From 5c80a3e1ef09d1c205cb4514f7feb3b2db560d5d Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Thu, 23 Jul 2026 03:28:02 +0000 Subject: [PATCH 01/28] Optimize agentic Gemini prompt caching (#22627) Stainless-Generated-From: 988a9af6987c084b8e54ff50848b5507d5c1a113 --- .../configurations/ParseV2Parameters.kt | 32 ++++++++--------- .../models/parsing/ParsingCreateParams.kt | 36 +++++++++---------- 2 files changed, 34 insertions(+), 34 deletions(-) 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 36d56c5..0e8c790 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 @@ -143,7 +143,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-06-26` - * - `agentic`: `2026-07-15` + * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -481,7 +481,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-06-26` - * - `agentic`: `2026-07-15` + * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -1012,7 +1012,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-06-26` - * - `agentic`: `2026-07-15` + * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -1033,7 +1033,7 @@ private constructor( @JvmField val LATEST = of("latest") - @JvmField val _2026_07_15 = of("2026-07-15") + @JvmField val _2026_07_23 = of("2026-07-23") @JvmField val _2026_07_08 = of("2026-07-08") @@ -1047,7 +1047,7 @@ private constructor( /** An enum containing [Version]'s known values. */ enum class Known { LATEST, - _2026_07_15, + _2026_07_23, _2026_07_08, _2026_06_26, _2026_06_15, @@ -1064,7 +1064,7 @@ private constructor( */ enum class Value { LATEST, - _2026_07_15, + _2026_07_23, _2026_07_08, _2026_06_26, _2026_06_15, @@ -1082,7 +1082,7 @@ private constructor( fun value(): Value = when (this) { LATEST -> Value.LATEST - _2026_07_15 -> Value._2026_07_15 + _2026_07_23 -> Value._2026_07_23 _2026_07_08 -> Value._2026_07_08 _2026_06_26 -> Value._2026_06_26 _2026_06_15 -> Value._2026_06_15 @@ -1101,7 +1101,7 @@ private constructor( fun known(): Known = when (this) { LATEST -> Known.LATEST - _2026_07_15 -> Known._2026_07_15 + _2026_07_23 -> Known._2026_07_23 _2026_07_08 -> Known._2026_07_08 _2026_06_26 -> Known._2026_06_26 _2026_06_15 -> Known._2026_06_15 @@ -9558,7 +9558,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-06-26` - * - `agentic`: `2026-07-15` + * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -10062,7 +10062,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-06-26` - * - `agentic`: `2026-07-15` + * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -11676,7 +11676,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-06-26` - * - `agentic`: `2026-07-15` + * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -11700,7 +11700,7 @@ private constructor( @JvmField val LATEST = of("latest") - @JvmField val _2026_07_15 = of("2026-07-15") + @JvmField val _2026_07_23 = of("2026-07-23") @JvmField val _2026_07_08 = of("2026-07-08") @@ -11714,7 +11714,7 @@ private constructor( /** An enum containing [Version]'s known values. */ enum class Known { LATEST, - _2026_07_15, + _2026_07_23, _2026_07_08, _2026_06_26, _2026_06_15, @@ -11731,7 +11731,7 @@ private constructor( */ enum class Value { LATEST, - _2026_07_15, + _2026_07_23, _2026_07_08, _2026_06_26, _2026_06_15, @@ -11752,7 +11752,7 @@ private constructor( fun value(): Value = when (this) { LATEST -> Value.LATEST - _2026_07_15 -> Value._2026_07_15 + _2026_07_23 -> Value._2026_07_23 _2026_07_08 -> Value._2026_07_08 _2026_06_26 -> Value._2026_06_26 _2026_06_15 -> Value._2026_06_15 @@ -11771,7 +11771,7 @@ private constructor( fun known(): Known = when (this) { LATEST -> Known.LATEST - _2026_07_15 -> Known._2026_07_15 + _2026_07_23 -> Known._2026_07_23 _2026_07_08 -> Known._2026_07_08 _2026_06_26 -> Known._2026_06_26 _2026_06_15 -> Known._2026_06_15 diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt index 8ec286a..4c91f50 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt @@ -77,7 +77,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-06-26` - * - `agentic`: `2026-07-15` + * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -465,7 +465,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-06-26` - * - `agentic`: `2026-07-15` + * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -1082,7 +1082,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-06-26` - * - `agentic`: `2026-07-15` + * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -1516,7 +1516,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-06-26` - * - `agentic`: `2026-07-15` + * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -2217,7 +2217,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-06-26` - * - `agentic`: `2026-07-15` + * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -2238,7 +2238,7 @@ private constructor( @JvmField val LATEST = of("latest") - @JvmField val _2026_07_15 = of("2026-07-15") + @JvmField val _2026_07_23 = of("2026-07-23") @JvmField val _2026_07_08 = of("2026-07-08") @@ -2252,7 +2252,7 @@ private constructor( /** An enum containing [Version]'s known values. */ enum class Known { LATEST, - _2026_07_15, + _2026_07_23, _2026_07_08, _2026_06_26, _2026_06_15, @@ -2269,7 +2269,7 @@ private constructor( */ enum class Value { LATEST, - _2026_07_15, + _2026_07_23, _2026_07_08, _2026_06_26, _2026_06_15, @@ -2287,7 +2287,7 @@ private constructor( fun value(): Value = when (this) { LATEST -> Value.LATEST - _2026_07_15 -> Value._2026_07_15 + _2026_07_23 -> Value._2026_07_23 _2026_07_08 -> Value._2026_07_08 _2026_06_26 -> Value._2026_06_26 _2026_06_15 -> Value._2026_06_15 @@ -2306,7 +2306,7 @@ private constructor( fun known(): Known = when (this) { LATEST -> Known.LATEST - _2026_07_15 -> Known._2026_07_15 + _2026_07_23 -> Known._2026_07_23 _2026_07_08 -> Known._2026_07_08 _2026_06_26 -> Known._2026_06_26 _2026_06_15 -> Known._2026_06_15 @@ -10763,7 +10763,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-06-26` - * - `agentic`: `2026-07-15` + * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -11267,7 +11267,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-06-26` - * - `agentic`: `2026-07-15` + * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -12881,7 +12881,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-06-26` - * - `agentic`: `2026-07-15` + * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -12905,7 +12905,7 @@ private constructor( @JvmField val LATEST = of("latest") - @JvmField val _2026_07_15 = of("2026-07-15") + @JvmField val _2026_07_23 = of("2026-07-23") @JvmField val _2026_07_08 = of("2026-07-08") @@ -12919,7 +12919,7 @@ private constructor( /** An enum containing [Version]'s known values. */ enum class Known { LATEST, - _2026_07_15, + _2026_07_23, _2026_07_08, _2026_06_26, _2026_06_15, @@ -12936,7 +12936,7 @@ private constructor( */ enum class Value { LATEST, - _2026_07_15, + _2026_07_23, _2026_07_08, _2026_06_26, _2026_06_15, @@ -12957,7 +12957,7 @@ private constructor( fun value(): Value = when (this) { LATEST -> Value.LATEST - _2026_07_15 -> Value._2026_07_15 + _2026_07_23 -> Value._2026_07_23 _2026_07_08 -> Value._2026_07_08 _2026_06_26 -> Value._2026_06_26 _2026_06_15 -> Value._2026_06_15 @@ -12976,7 +12976,7 @@ private constructor( fun known(): Known = when (this) { LATEST -> Known.LATEST - _2026_07_15 -> Known._2026_07_15 + _2026_07_23 -> Known._2026_07_23 _2026_07_08 -> Known._2026_07_08 _2026_06_26 -> Known._2026_06_26 _2026_06_15 -> Known._2026_06_15 From 6e3c3c924abb3e6700e042a95a66684913db61f4 Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Thu, 23 Jul 2026 06:48:45 +0000 Subject: [PATCH 02/28] refactor: remove Depends(get_db) from permissions endpoints (#22635) Stainless-Generated-From: 2ac5a6321a821c16afb361b8e313f1c84e55f0b9 --- .../configurations/ParseV2Parameters.kt | 24 ++++------------ .../models/parsing/ParsingCreateParams.kt | 28 ++++++------------- 2 files changed, 14 insertions(+), 38 deletions(-) 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 0e8c790..05729d7 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,7 +142,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-06-26` + * - `cost_effective`: `2026-07-23` * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * @@ -480,7 +480,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-06-26` + * - `cost_effective`: `2026-07-23` * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * @@ -1011,7 +1011,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-06-26` + * - `cost_effective`: `2026-07-23` * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * @@ -1037,8 +1037,6 @@ private constructor( @JvmField val _2026_07_08 = of("2026-07-08") - @JvmField val _2026_06_26 = of("2026-06-26") - @JvmField val _2026_06_15 = of("2026-06-15") @JvmStatic fun of(value: String) = Version(JsonField.of(value)) @@ -1049,7 +1047,6 @@ private constructor( LATEST, _2026_07_23, _2026_07_08, - _2026_06_26, _2026_06_15, } @@ -1066,7 +1063,6 @@ private constructor( LATEST, _2026_07_23, _2026_07_08, - _2026_06_26, _2026_06_15, /** An enum member indicating that [Version] was instantiated with an unknown value. */ _UNKNOWN, @@ -1084,7 +1080,6 @@ private constructor( LATEST -> Value.LATEST _2026_07_23 -> Value._2026_07_23 _2026_07_08 -> Value._2026_07_08 - _2026_06_26 -> Value._2026_06_26 _2026_06_15 -> Value._2026_06_15 else -> Value._UNKNOWN } @@ -1103,7 +1098,6 @@ private constructor( LATEST -> Known.LATEST _2026_07_23 -> Known._2026_07_23 _2026_07_08 -> Known._2026_07_08 - _2026_06_26 -> Known._2026_06_26 _2026_06_15 -> Known._2026_06_15 else -> throw LlamaCloudInvalidDataException("Unknown Version: $value") } @@ -9557,7 +9551,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-06-26` + * - `cost_effective`: `2026-07-23` * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * @@ -10061,7 +10055,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-06-26` + * - `cost_effective`: `2026-07-23` * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * @@ -11675,7 +11669,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-06-26` + * - `cost_effective`: `2026-07-23` * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * @@ -11704,8 +11698,6 @@ private constructor( @JvmField val _2026_07_08 = of("2026-07-08") - @JvmField val _2026_06_26 = of("2026-06-26") - @JvmField val _2026_06_15 = of("2026-06-15") @JvmStatic fun of(value: String) = Version(JsonField.of(value)) @@ -11716,7 +11708,6 @@ private constructor( LATEST, _2026_07_23, _2026_07_08, - _2026_06_26, _2026_06_15, } @@ -11733,7 +11724,6 @@ private constructor( LATEST, _2026_07_23, _2026_07_08, - _2026_06_26, _2026_06_15, /** * An enum member indicating that [Version] was instantiated with an unknown @@ -11754,7 +11744,6 @@ private constructor( LATEST -> Value.LATEST _2026_07_23 -> Value._2026_07_23 _2026_07_08 -> Value._2026_07_08 - _2026_06_26 -> Value._2026_06_26 _2026_06_15 -> Value._2026_06_15 else -> Value._UNKNOWN } @@ -11773,7 +11762,6 @@ private constructor( LATEST -> Known.LATEST _2026_07_23 -> Known._2026_07_23 _2026_07_08 -> Known._2026_07_08 - _2026_06_26 -> Known._2026_06_26 _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/parsing/ParsingCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt index 4c91f50..3a0d454 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt @@ -76,7 +76,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-06-26` + * - `cost_effective`: `2026-07-23` * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * @@ -464,7 +464,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-06-26` + * - `cost_effective`: `2026-07-23` * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * @@ -1081,7 +1081,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-06-26` + * - `cost_effective`: `2026-07-23` * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * @@ -1515,7 +1515,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-06-26` + * - `cost_effective`: `2026-07-23` * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * @@ -2216,7 +2216,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-06-26` + * - `cost_effective`: `2026-07-23` * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * @@ -2242,8 +2242,6 @@ private constructor( @JvmField val _2026_07_08 = of("2026-07-08") - @JvmField val _2026_06_26 = of("2026-06-26") - @JvmField val _2026_06_15 = of("2026-06-15") @JvmStatic fun of(value: String) = Version(JsonField.of(value)) @@ -2254,7 +2252,6 @@ private constructor( LATEST, _2026_07_23, _2026_07_08, - _2026_06_26, _2026_06_15, } @@ -2271,7 +2268,6 @@ private constructor( LATEST, _2026_07_23, _2026_07_08, - _2026_06_26, _2026_06_15, /** An enum member indicating that [Version] was instantiated with an unknown value. */ _UNKNOWN, @@ -2289,7 +2285,6 @@ private constructor( LATEST -> Value.LATEST _2026_07_23 -> Value._2026_07_23 _2026_07_08 -> Value._2026_07_08 - _2026_06_26 -> Value._2026_06_26 _2026_06_15 -> Value._2026_06_15 else -> Value._UNKNOWN } @@ -2308,7 +2303,6 @@ private constructor( LATEST -> Known.LATEST _2026_07_23 -> Known._2026_07_23 _2026_07_08 -> Known._2026_07_08 - _2026_06_26 -> Known._2026_06_26 _2026_06_15 -> Known._2026_06_15 else -> throw LlamaCloudInvalidDataException("Unknown Version: $value") } @@ -10762,7 +10756,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-06-26` + * - `cost_effective`: `2026-07-23` * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * @@ -11266,7 +11260,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-06-26` + * - `cost_effective`: `2026-07-23` * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * @@ -12880,7 +12874,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-06-26` + * - `cost_effective`: `2026-07-23` * - `agentic`: `2026-07-23` * - `agentic_plus`: `2026-07-08` * @@ -12909,8 +12903,6 @@ private constructor( @JvmField val _2026_07_08 = of("2026-07-08") - @JvmField val _2026_06_26 = of("2026-06-26") - @JvmField val _2026_06_15 = of("2026-06-15") @JvmStatic fun of(value: String) = Version(JsonField.of(value)) @@ -12921,7 +12913,6 @@ private constructor( LATEST, _2026_07_23, _2026_07_08, - _2026_06_26, _2026_06_15, } @@ -12938,7 +12929,6 @@ private constructor( LATEST, _2026_07_23, _2026_07_08, - _2026_06_26, _2026_06_15, /** * An enum member indicating that [Version] was instantiated with an unknown @@ -12959,7 +12949,6 @@ private constructor( LATEST -> Value.LATEST _2026_07_23 -> Value._2026_07_23 _2026_07_08 -> Value._2026_07_08 - _2026_06_26 -> Value._2026_06_26 _2026_06_15 -> Value._2026_06_15 else -> Value._UNKNOWN } @@ -12978,7 +12967,6 @@ private constructor( LATEST -> Known.LATEST _2026_07_23 -> Known._2026_07_23 _2026_07_08 -> Known._2026_07_08 - _2026_06_26 -> Known._2026_06_26 _2026_06_15 -> Known._2026_06_15 else -> throw LlamaCloudInvalidDataException("Unknown Version: $value") } From dd836b04becb5ed034975bbcd63712aa6cf5fc28 Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Fri, 24 Jul 2026 06:52:45 +0000 Subject: [PATCH 03/28] chore(api): regenerate OpenAPI specs for new agentic parse version (#22763) Stainless-Generated-From: 409d95c309f0ee982becfe0647f8e50c97d2dc6d --- .../configurations/ParseV2Parameters.kt | 24 ++++++++++++---- .../models/parsing/ParsingCreateParams.kt | 28 +++++++++++++------ 2 files changed, 38 insertions(+), 14 deletions(-) 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 05729d7..36c573f 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 @@ -143,7 +143,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-07-23` - * - `agentic`: `2026-07-23` + * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -481,7 +481,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-07-23` - * - `agentic`: `2026-07-23` + * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -1012,7 +1012,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-07-23` - * - `agentic`: `2026-07-23` + * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -1033,6 +1033,8 @@ private constructor( @JvmField val LATEST = of("latest") + @JvmField val _2026_07_24 = of("2026-07-24") + @JvmField val _2026_07_23 = of("2026-07-23") @JvmField val _2026_07_08 = of("2026-07-08") @@ -1045,6 +1047,7 @@ private constructor( /** An enum containing [Version]'s known values. */ enum class Known { LATEST, + _2026_07_24, _2026_07_23, _2026_07_08, _2026_06_15, @@ -1061,6 +1064,7 @@ private constructor( */ enum class Value { LATEST, + _2026_07_24, _2026_07_23, _2026_07_08, _2026_06_15, @@ -1078,6 +1082,7 @@ private constructor( fun value(): Value = when (this) { LATEST -> Value.LATEST + _2026_07_24 -> Value._2026_07_24 _2026_07_23 -> Value._2026_07_23 _2026_07_08 -> Value._2026_07_08 _2026_06_15 -> Value._2026_06_15 @@ -1096,6 +1101,7 @@ private constructor( fun known(): Known = when (this) { LATEST -> Known.LATEST + _2026_07_24 -> Known._2026_07_24 _2026_07_23 -> Known._2026_07_23 _2026_07_08 -> Known._2026_07_08 _2026_06_15 -> Known._2026_06_15 @@ -9552,7 +9558,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-07-23` - * - `agentic`: `2026-07-23` + * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -10056,7 +10062,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-07-23` - * - `agentic`: `2026-07-23` + * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -11670,7 +11676,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-07-23` - * - `agentic`: `2026-07-23` + * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -11694,6 +11700,8 @@ private constructor( @JvmField val LATEST = of("latest") + @JvmField val _2026_07_24 = of("2026-07-24") + @JvmField val _2026_07_23 = of("2026-07-23") @JvmField val _2026_07_08 = of("2026-07-08") @@ -11706,6 +11714,7 @@ private constructor( /** An enum containing [Version]'s known values. */ enum class Known { LATEST, + _2026_07_24, _2026_07_23, _2026_07_08, _2026_06_15, @@ -11722,6 +11731,7 @@ private constructor( */ enum class Value { LATEST, + _2026_07_24, _2026_07_23, _2026_07_08, _2026_06_15, @@ -11742,6 +11752,7 @@ private constructor( fun value(): Value = when (this) { LATEST -> Value.LATEST + _2026_07_24 -> Value._2026_07_24 _2026_07_23 -> Value._2026_07_23 _2026_07_08 -> Value._2026_07_08 _2026_06_15 -> Value._2026_06_15 @@ -11760,6 +11771,7 @@ private constructor( fun known(): Known = when (this) { LATEST -> Known.LATEST + _2026_07_24 -> Known._2026_07_24 _2026_07_23 -> Known._2026_07_23 _2026_07_08 -> Known._2026_07_08 _2026_06_15 -> Known._2026_06_15 diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt index 3a0d454..ce471d5 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt @@ -77,7 +77,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-07-23` - * - `agentic`: `2026-07-23` + * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -465,7 +465,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-07-23` - * - `agentic`: `2026-07-23` + * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -1082,7 +1082,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-07-23` - * - `agentic`: `2026-07-23` + * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -1516,7 +1516,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-07-23` - * - `agentic`: `2026-07-23` + * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -2217,7 +2217,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-07-23` - * - `agentic`: `2026-07-23` + * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -2238,6 +2238,8 @@ private constructor( @JvmField val LATEST = of("latest") + @JvmField val _2026_07_24 = of("2026-07-24") + @JvmField val _2026_07_23 = of("2026-07-23") @JvmField val _2026_07_08 = of("2026-07-08") @@ -2250,6 +2252,7 @@ private constructor( /** An enum containing [Version]'s known values. */ enum class Known { LATEST, + _2026_07_24, _2026_07_23, _2026_07_08, _2026_06_15, @@ -2266,6 +2269,7 @@ private constructor( */ enum class Value { LATEST, + _2026_07_24, _2026_07_23, _2026_07_08, _2026_06_15, @@ -2283,6 +2287,7 @@ private constructor( fun value(): Value = when (this) { LATEST -> Value.LATEST + _2026_07_24 -> Value._2026_07_24 _2026_07_23 -> Value._2026_07_23 _2026_07_08 -> Value._2026_07_08 _2026_06_15 -> Value._2026_06_15 @@ -2301,6 +2306,7 @@ private constructor( fun known(): Known = when (this) { LATEST -> Known.LATEST + _2026_07_24 -> Known._2026_07_24 _2026_07_23 -> Known._2026_07_23 _2026_07_08 -> Known._2026_07_08 _2026_06_15 -> Known._2026_06_15 @@ -10757,7 +10763,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-07-23` - * - `agentic`: `2026-07-23` + * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -11261,7 +11267,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-07-23` - * - `agentic`: `2026-07-23` + * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -12875,7 +12881,7 @@ private constructor( * Current `latest` by tier: * - `fast`: `2026-06-15` * - `cost_effective`: `2026-07-23` - * - `agentic`: `2026-07-23` + * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * * Full list: `GET /api/v2/parse/versions`. @@ -12899,6 +12905,8 @@ private constructor( @JvmField val LATEST = of("latest") + @JvmField val _2026_07_24 = of("2026-07-24") + @JvmField val _2026_07_23 = of("2026-07-23") @JvmField val _2026_07_08 = of("2026-07-08") @@ -12911,6 +12919,7 @@ private constructor( /** An enum containing [Version]'s known values. */ enum class Known { LATEST, + _2026_07_24, _2026_07_23, _2026_07_08, _2026_06_15, @@ -12927,6 +12936,7 @@ private constructor( */ enum class Value { LATEST, + _2026_07_24, _2026_07_23, _2026_07_08, _2026_06_15, @@ -12947,6 +12957,7 @@ private constructor( fun value(): Value = when (this) { LATEST -> Value.LATEST + _2026_07_24 -> Value._2026_07_24 _2026_07_23 -> Value._2026_07_23 _2026_07_08 -> Value._2026_07_08 _2026_06_15 -> Value._2026_06_15 @@ -12965,6 +12976,7 @@ private constructor( fun known(): Known = when (this) { LATEST -> Known.LATEST + _2026_07_24 -> Known._2026_07_24 _2026_07_23 -> Known._2026_07_23 _2026_07_08 -> Known._2026_07_08 _2026_06_15 -> Known._2026_06_15 From a12e081912c5d911970a2b8933748371833770b7 Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Mon, 27 Jul 2026 19:28:58 +0000 Subject: [PATCH 04/28] feat(extract): accept webhook_configuration_ids on extract job create (LI-8138) (#22907) Stainless-Generated-From: 1af8b974eca84a227e66486394a5ec994de82e2c --- .../models/extract/ExtractV2JobCreate.kt | 76 ++++++++++++++++++- .../models/extract/ExtractCreateParamsTest.kt | 8 ++ .../models/extract/ExtractV2JobCreateTest.kt | 6 ++ .../services/async/ExtractServiceAsyncTest.kt | 2 + .../services/blocking/ExtractServiceTest.kt | 2 + 5 files changed, 92 insertions(+), 2 deletions(-) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobCreate.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobCreate.kt index 06a1bfd..eba4889 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobCreate.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobCreate.kt @@ -27,6 +27,7 @@ private constructor( private val fileInput: JsonField, private val configuration: JsonField, private val configurationId: JsonField, + private val webhookConfigurationIds: JsonField>, private val webhookConfigurations: JsonField>, private val additionalProperties: MutableMap, ) { @@ -40,10 +41,20 @@ private constructor( @JsonProperty("configuration_id") @ExcludeMissing configurationId: JsonField = JsonMissing.of(), + @JsonProperty("webhook_configuration_ids") + @ExcludeMissing + webhookConfigurationIds: JsonField> = JsonMissing.of(), @JsonProperty("webhook_configurations") @ExcludeMissing webhookConfigurations: JsonField> = JsonMissing.of(), - ) : this(fileInput, configuration, configurationId, webhookConfigurations, mutableMapOf()) + ) : this( + fileInput, + configuration, + configurationId, + webhookConfigurationIds, + webhookConfigurations, + mutableMapOf(), + ) /** * File ID or parse job ID to extract from @@ -69,6 +80,15 @@ private constructor( */ fun configurationId(): Optional = configurationId.getOptional("configuration_id") + /** + * IDs of saved webhook configurations to notify for this job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookConfigurationIds(): Optional> = + webhookConfigurationIds.getOptional("webhook_configuration_ids") + /** * Outbound webhook endpoints to notify on job status changes * @@ -103,6 +123,16 @@ private constructor( @ExcludeMissing fun _configurationId(): JsonField = configurationId + /** + * Returns the raw JSON value of [webhookConfigurationIds]. + * + * Unlike [webhookConfigurationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("webhook_configuration_ids") + @ExcludeMissing + fun _webhookConfigurationIds(): JsonField> = webhookConfigurationIds + /** * Returns the raw JSON value of [webhookConfigurations]. * @@ -144,6 +174,7 @@ private constructor( private var fileInput: JsonField? = null private var configuration: JsonField = JsonMissing.of() private var configurationId: JsonField = JsonMissing.of() + private var webhookConfigurationIds: JsonField>? = null private var webhookConfigurations: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -152,6 +183,8 @@ private constructor( fileInput = extractV2JobCreate.fileInput configuration = extractV2JobCreate.configuration configurationId = extractV2JobCreate.configurationId + webhookConfigurationIds = + extractV2JobCreate.webhookConfigurationIds.map { it.toMutableList() } webhookConfigurations = extractV2JobCreate.webhookConfigurations.map { it.toMutableList() } additionalProperties = extractV2JobCreate.additionalProperties.toMutableMap() @@ -207,6 +240,40 @@ private constructor( this.configurationId = configurationId } + /** IDs of saved webhook configurations to notify for this job. */ + fun webhookConfigurationIds(webhookConfigurationIds: List?) = + webhookConfigurationIds(JsonField.ofNullable(webhookConfigurationIds)) + + /** + * Alias for calling [Builder.webhookConfigurationIds] with + * `webhookConfigurationIds.orElse(null)`. + */ + fun webhookConfigurationIds(webhookConfigurationIds: Optional>) = + webhookConfigurationIds(webhookConfigurationIds.getOrNull()) + + /** + * Sets [Builder.webhookConfigurationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookConfigurationIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun webhookConfigurationIds(webhookConfigurationIds: JsonField>) = apply { + this.webhookConfigurationIds = webhookConfigurationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [webhookConfigurationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookConfigurationId(webhookConfigurationId: String) = apply { + webhookConfigurationIds = + (webhookConfigurationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("webhookConfigurationIds", it).add(webhookConfigurationId) + } + } + /** Outbound webhook endpoints to notify on job status changes */ fun webhookConfigurations(webhookConfigurations: List?) = webhookConfigurations(JsonField.ofNullable(webhookConfigurations)) @@ -278,6 +345,7 @@ private constructor( checkRequired("fileInput", fileInput), configuration, configurationId, + (webhookConfigurationIds ?: JsonMissing.of()).map { it.toImmutable() }, (webhookConfigurations ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -301,6 +369,7 @@ private constructor( fileInput() configuration().ifPresent { it.validate() } configurationId() + webhookConfigurationIds() webhookConfigurations().ifPresent { it.forEach { it.validate() } } validated = true } @@ -323,6 +392,7 @@ private constructor( (if (fileInput.asKnown().isPresent) 1 else 0) + (configuration.asKnown().getOrNull()?.validity() ?: 0) + (if (configurationId.asKnown().isPresent) 1 else 0) + + (webhookConfigurationIds.asKnown().getOrNull()?.size ?: 0) + (webhookConfigurations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) /** Configuration for a single outbound webhook endpoint. */ @@ -1146,6 +1216,7 @@ private constructor( fileInput == other.fileInput && configuration == other.configuration && configurationId == other.configurationId && + webhookConfigurationIds == other.webhookConfigurationIds && webhookConfigurations == other.webhookConfigurations && additionalProperties == other.additionalProperties } @@ -1155,6 +1226,7 @@ private constructor( fileInput, configuration, configurationId, + webhookConfigurationIds, webhookConfigurations, additionalProperties, ) @@ -1163,5 +1235,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ExtractV2JobCreate{fileInput=$fileInput, configuration=$configuration, configurationId=$configurationId, webhookConfigurations=$webhookConfigurations, additionalProperties=$additionalProperties}" + "ExtractV2JobCreate{fileInput=$fileInput, configuration=$configuration, configurationId=$configurationId, webhookConfigurationIds=$webhookConfigurationIds, webhookConfigurations=$webhookConfigurations, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractCreateParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractCreateParamsTest.kt index 5d3b95c..1ca8d14 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractCreateParamsTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractCreateParamsTest.kt @@ -49,6 +49,8 @@ internal class ExtractCreateParamsTest { .build() ) .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( ExtractV2JobCreate.WebhookConfiguration.builder() .addWebhookEvent( @@ -119,6 +121,8 @@ internal class ExtractCreateParamsTest { .build() ) .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( ExtractV2JobCreate.WebhookConfiguration.builder() .addWebhookEvent( @@ -216,6 +220,8 @@ internal class ExtractCreateParamsTest { .build() ) .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( ExtractV2JobCreate.WebhookConfiguration.builder() .addWebhookEvent( @@ -280,6 +286,8 @@ internal class ExtractCreateParamsTest { .build() ) .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( ExtractV2JobCreate.WebhookConfiguration.builder() .addWebhookEvent( diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobCreateTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobCreateTest.kt index c58383c..7a08d6f 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobCreateTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobCreateTest.kt @@ -48,6 +48,8 @@ internal class ExtractV2JobCreateTest { .build() ) .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( ExtractV2JobCreate.WebhookConfiguration.builder() .addWebhookEvent( @@ -107,6 +109,8 @@ internal class ExtractV2JobCreateTest { ) assertThat(extractV2JobCreate.configurationId()) .contains("cfg-11111111-2222-3333-4444-555555555555") + assertThat(extractV2JobCreate.webhookConfigurationIds().getOrNull()) + .containsExactly("whc-...", "whc-...") assertThat(extractV2JobCreate.webhookConfigurations().getOrNull()) .containsExactly( ExtractV2JobCreate.WebhookConfiguration.builder() @@ -166,6 +170,8 @@ internal class ExtractV2JobCreateTest { .build() ) .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( ExtractV2JobCreate.WebhookConfiguration.builder() .addWebhookEvent( diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsyncTest.kt index 7449c48..a485ea7 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsyncTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsyncTest.kt @@ -68,6 +68,8 @@ internal class ExtractServiceAsyncTest { .build() ) .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( ExtractV2JobCreate.WebhookConfiguration.builder() .addWebhookEvent( diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractServiceTest.kt index 1eb793f..c9c1eb2 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractServiceTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractServiceTest.kt @@ -68,6 +68,8 @@ internal class ExtractServiceTest { .build() ) .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( ExtractV2JobCreate.WebhookConfiguration.builder() .addWebhookEvent( From f16916fa19b3dee150c7499d13bc7142446fa1a2 Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Mon, 27 Jul 2026 22:36:30 +0000 Subject: [PATCH 05/28] feat(split): accept webhook_configuration_ids on split job create (LI-8138) (#22940) Stainless-Generated-From: e2a31be67afe0e78f2d15843f5f0e873d0a51e62 --- .../models/beta/sheets/SheetCreateParams.kt | 117 +++++++++++++++++- .../models/sheets/SheetCreateParams.kt | 117 +++++++++++++++++- .../beta/sheets/SheetCreateParamsTest.kt | 7 ++ .../models/sheets/SheetCreateParamsTest.kt | 7 ++ .../services/async/SheetServiceAsyncTest.kt | 2 + .../async/beta/SheetServiceAsyncTest.kt | 2 + .../services/blocking/SheetServiceTest.kt | 2 + .../blocking/beta/SheetServiceTest.kt | 2 + 8 files changed, 252 insertions(+), 4 deletions(-) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/sheets/SheetCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/sheets/SheetCreateParams.kt index f0cf70a..11c86b3 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/sheets/SheetCreateParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/sheets/SheetCreateParams.kt @@ -76,6 +76,14 @@ private constructor( */ fun configurationId(): Optional = body.configurationId() + /** + * IDs of saved webhook configurations to notify for this job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookConfigurationIds(): Optional> = body.webhookConfigurationIds() + /** * Outbound webhook endpoints to notify on job status changes * @@ -112,6 +120,14 @@ private constructor( */ fun _configurationId(): JsonField = body._configurationId() + /** + * Returns the raw JSON value of [webhookConfigurationIds]. + * + * Unlike [webhookConfigurationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _webhookConfigurationIds(): JsonField> = body._webhookConfigurationIds() + /** * Returns the raw JSON value of [webhookConfigurations]. * @@ -182,7 +198,7 @@ private constructor( * - [config] * - [configuration] * - [configurationId] - * - [webhookConfigurations] + * - [webhookConfigurationIds] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -256,6 +272,38 @@ private constructor( body.configurationId(configurationId) } + /** IDs of saved webhook configurations to notify for this job. */ + fun webhookConfigurationIds(webhookConfigurationIds: List?) = apply { + body.webhookConfigurationIds(webhookConfigurationIds) + } + + /** + * Alias for calling [Builder.webhookConfigurationIds] with + * `webhookConfigurationIds.orElse(null)`. + */ + fun webhookConfigurationIds(webhookConfigurationIds: Optional>) = + webhookConfigurationIds(webhookConfigurationIds.getOrNull()) + + /** + * Sets [Builder.webhookConfigurationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookConfigurationIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun webhookConfigurationIds(webhookConfigurationIds: JsonField>) = apply { + body.webhookConfigurationIds(webhookConfigurationIds) + } + + /** + * Adds a single [String] to [webhookConfigurationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookConfigurationId(webhookConfigurationId: String) = apply { + body.addWebhookConfigurationId(webhookConfigurationId) + } + /** Outbound webhook endpoints to notify on job status changes */ fun webhookConfigurations(webhookConfigurations: List?) = apply { body.webhookConfigurations(webhookConfigurations) @@ -454,6 +502,7 @@ private constructor( private val config: JsonField, private val configuration: JsonField, private val configurationId: JsonField, + private val webhookConfigurationIds: JsonField>, private val webhookConfigurations: JsonField>, private val additionalProperties: MutableMap, ) { @@ -470,6 +519,9 @@ private constructor( @JsonProperty("configuration_id") @ExcludeMissing configurationId: JsonField = JsonMissing.of(), + @JsonProperty("webhook_configuration_ids") + @ExcludeMissing + webhookConfigurationIds: JsonField> = JsonMissing.of(), @JsonProperty("webhook_configurations") @ExcludeMissing webhookConfigurations: JsonField> = JsonMissing.of(), @@ -478,6 +530,7 @@ private constructor( config, configuration, configurationId, + webhookConfigurationIds, webhookConfigurations, mutableMapOf(), ) @@ -516,6 +569,15 @@ private constructor( */ fun configurationId(): Optional = configurationId.getOptional("configuration_id") + /** + * IDs of saved webhook configurations to notify for this job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookConfigurationIds(): Optional> = + webhookConfigurationIds.getOptional("webhook_configuration_ids") + /** * Outbound webhook endpoints to notify on job status changes * @@ -562,6 +624,16 @@ private constructor( @ExcludeMissing fun _configurationId(): JsonField = configurationId + /** + * Returns the raw JSON value of [webhookConfigurationIds]. + * + * Unlike [webhookConfigurationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("webhook_configuration_ids") + @ExcludeMissing + fun _webhookConfigurationIds(): JsonField> = webhookConfigurationIds + /** * Returns the raw JSON value of [webhookConfigurations]. * @@ -604,6 +676,7 @@ private constructor( private var config: JsonField = JsonMissing.of() private var configuration: JsonField = JsonMissing.of() private var configurationId: JsonField = JsonMissing.of() + private var webhookConfigurationIds: JsonField>? = null private var webhookConfigurations: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -613,6 +686,7 @@ private constructor( config = body.config configuration = body.configuration configurationId = body.configurationId + webhookConfigurationIds = body.webhookConfigurationIds.map { it.toMutableList() } webhookConfigurations = body.webhookConfigurations.map { it.toMutableList() } additionalProperties = body.additionalProperties.toMutableMap() } @@ -685,6 +759,40 @@ private constructor( this.configurationId = configurationId } + /** IDs of saved webhook configurations to notify for this job. */ + fun webhookConfigurationIds(webhookConfigurationIds: List?) = + webhookConfigurationIds(JsonField.ofNullable(webhookConfigurationIds)) + + /** + * Alias for calling [Builder.webhookConfigurationIds] with + * `webhookConfigurationIds.orElse(null)`. + */ + fun webhookConfigurationIds(webhookConfigurationIds: Optional>) = + webhookConfigurationIds(webhookConfigurationIds.getOrNull()) + + /** + * Sets [Builder.webhookConfigurationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookConfigurationIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun webhookConfigurationIds(webhookConfigurationIds: JsonField>) = apply { + this.webhookConfigurationIds = webhookConfigurationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [webhookConfigurationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookConfigurationId(webhookConfigurationId: String) = apply { + webhookConfigurationIds = + (webhookConfigurationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("webhookConfigurationIds", it).add(webhookConfigurationId) + } + } + /** Outbound webhook endpoints to notify on job status changes */ fun webhookConfigurations(webhookConfigurations: List?) = webhookConfigurations(JsonField.ofNullable(webhookConfigurations)) @@ -758,6 +866,7 @@ private constructor( config, configuration, configurationId, + (webhookConfigurationIds ?: JsonMissing.of()).map { it.toImmutable() }, (webhookConfigurations ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -783,6 +892,7 @@ private constructor( config().ifPresent { it.validate() } configuration().ifPresent { it.validate() } configurationId() + webhookConfigurationIds() webhookConfigurations().ifPresent { it.forEach { it.validate() } } validated = true } @@ -807,6 +917,7 @@ private constructor( (config.asKnown().getOrNull()?.validity() ?: 0) + (configuration.asKnown().getOrNull()?.validity() ?: 0) + (if (configurationId.asKnown().isPresent) 1 else 0) + + (webhookConfigurationIds.asKnown().getOrNull()?.size ?: 0) + (webhookConfigurations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) override fun equals(other: Any?): Boolean { @@ -819,6 +930,7 @@ private constructor( config == other.config && configuration == other.configuration && configurationId == other.configurationId && + webhookConfigurationIds == other.webhookConfigurationIds && webhookConfigurations == other.webhookConfigurations && additionalProperties == other.additionalProperties } @@ -829,6 +941,7 @@ private constructor( config, configuration, configurationId, + webhookConfigurationIds, webhookConfigurations, additionalProperties, ) @@ -837,7 +950,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{fileId=$fileId, config=$config, configuration=$configuration, configurationId=$configurationId, webhookConfigurations=$webhookConfigurations, additionalProperties=$additionalProperties}" + "Body{fileId=$fileId, config=$config, configuration=$configuration, configurationId=$configurationId, webhookConfigurationIds=$webhookConfigurationIds, webhookConfigurations=$webhookConfigurations, additionalProperties=$additionalProperties}" } /** Configuration for a single outbound webhook endpoint. */ diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/sheets/SheetCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/sheets/SheetCreateParams.kt index b78815c..4dbf20b 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/sheets/SheetCreateParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/sheets/SheetCreateParams.kt @@ -76,6 +76,14 @@ private constructor( */ fun configurationId(): Optional = body.configurationId() + /** + * IDs of saved webhook configurations to notify for this job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookConfigurationIds(): Optional> = body.webhookConfigurationIds() + /** * Outbound webhook endpoints to notify on job status changes * @@ -112,6 +120,14 @@ private constructor( */ fun _configurationId(): JsonField = body._configurationId() + /** + * Returns the raw JSON value of [webhookConfigurationIds]. + * + * Unlike [webhookConfigurationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _webhookConfigurationIds(): JsonField> = body._webhookConfigurationIds() + /** * Returns the raw JSON value of [webhookConfigurations]. * @@ -182,7 +198,7 @@ private constructor( * - [config] * - [configuration] * - [configurationId] - * - [webhookConfigurations] + * - [webhookConfigurationIds] * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -256,6 +272,38 @@ private constructor( body.configurationId(configurationId) } + /** IDs of saved webhook configurations to notify for this job. */ + fun webhookConfigurationIds(webhookConfigurationIds: List?) = apply { + body.webhookConfigurationIds(webhookConfigurationIds) + } + + /** + * Alias for calling [Builder.webhookConfigurationIds] with + * `webhookConfigurationIds.orElse(null)`. + */ + fun webhookConfigurationIds(webhookConfigurationIds: Optional>) = + webhookConfigurationIds(webhookConfigurationIds.getOrNull()) + + /** + * Sets [Builder.webhookConfigurationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookConfigurationIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun webhookConfigurationIds(webhookConfigurationIds: JsonField>) = apply { + body.webhookConfigurationIds(webhookConfigurationIds) + } + + /** + * Adds a single [String] to [webhookConfigurationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookConfigurationId(webhookConfigurationId: String) = apply { + body.addWebhookConfigurationId(webhookConfigurationId) + } + /** Outbound webhook endpoints to notify on job status changes */ fun webhookConfigurations(webhookConfigurations: List?) = apply { body.webhookConfigurations(webhookConfigurations) @@ -454,6 +502,7 @@ private constructor( private val config: JsonField, private val configuration: JsonField, private val configurationId: JsonField, + private val webhookConfigurationIds: JsonField>, private val webhookConfigurations: JsonField>, private val additionalProperties: MutableMap, ) { @@ -470,6 +519,9 @@ private constructor( @JsonProperty("configuration_id") @ExcludeMissing configurationId: JsonField = JsonMissing.of(), + @JsonProperty("webhook_configuration_ids") + @ExcludeMissing + webhookConfigurationIds: JsonField> = JsonMissing.of(), @JsonProperty("webhook_configurations") @ExcludeMissing webhookConfigurations: JsonField> = JsonMissing.of(), @@ -478,6 +530,7 @@ private constructor( config, configuration, configurationId, + webhookConfigurationIds, webhookConfigurations, mutableMapOf(), ) @@ -516,6 +569,15 @@ private constructor( */ fun configurationId(): Optional = configurationId.getOptional("configuration_id") + /** + * IDs of saved webhook configurations to notify for this job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookConfigurationIds(): Optional> = + webhookConfigurationIds.getOptional("webhook_configuration_ids") + /** * Outbound webhook endpoints to notify on job status changes * @@ -562,6 +624,16 @@ private constructor( @ExcludeMissing fun _configurationId(): JsonField = configurationId + /** + * Returns the raw JSON value of [webhookConfigurationIds]. + * + * Unlike [webhookConfigurationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("webhook_configuration_ids") + @ExcludeMissing + fun _webhookConfigurationIds(): JsonField> = webhookConfigurationIds + /** * Returns the raw JSON value of [webhookConfigurations]. * @@ -604,6 +676,7 @@ private constructor( private var config: JsonField = JsonMissing.of() private var configuration: JsonField = JsonMissing.of() private var configurationId: JsonField = JsonMissing.of() + private var webhookConfigurationIds: JsonField>? = null private var webhookConfigurations: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -613,6 +686,7 @@ private constructor( config = body.config configuration = body.configuration configurationId = body.configurationId + webhookConfigurationIds = body.webhookConfigurationIds.map { it.toMutableList() } webhookConfigurations = body.webhookConfigurations.map { it.toMutableList() } additionalProperties = body.additionalProperties.toMutableMap() } @@ -685,6 +759,40 @@ private constructor( this.configurationId = configurationId } + /** IDs of saved webhook configurations to notify for this job. */ + fun webhookConfigurationIds(webhookConfigurationIds: List?) = + webhookConfigurationIds(JsonField.ofNullable(webhookConfigurationIds)) + + /** + * Alias for calling [Builder.webhookConfigurationIds] with + * `webhookConfigurationIds.orElse(null)`. + */ + fun webhookConfigurationIds(webhookConfigurationIds: Optional>) = + webhookConfigurationIds(webhookConfigurationIds.getOrNull()) + + /** + * Sets [Builder.webhookConfigurationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookConfigurationIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun webhookConfigurationIds(webhookConfigurationIds: JsonField>) = apply { + this.webhookConfigurationIds = webhookConfigurationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [webhookConfigurationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookConfigurationId(webhookConfigurationId: String) = apply { + webhookConfigurationIds = + (webhookConfigurationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("webhookConfigurationIds", it).add(webhookConfigurationId) + } + } + /** Outbound webhook endpoints to notify on job status changes */ fun webhookConfigurations(webhookConfigurations: List?) = webhookConfigurations(JsonField.ofNullable(webhookConfigurations)) @@ -758,6 +866,7 @@ private constructor( config, configuration, configurationId, + (webhookConfigurationIds ?: JsonMissing.of()).map { it.toImmutable() }, (webhookConfigurations ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -783,6 +892,7 @@ private constructor( config().ifPresent { it.validate() } configuration().ifPresent { it.validate() } configurationId() + webhookConfigurationIds() webhookConfigurations().ifPresent { it.forEach { it.validate() } } validated = true } @@ -807,6 +917,7 @@ private constructor( (config.asKnown().getOrNull()?.validity() ?: 0) + (configuration.asKnown().getOrNull()?.validity() ?: 0) + (if (configurationId.asKnown().isPresent) 1 else 0) + + (webhookConfigurationIds.asKnown().getOrNull()?.size ?: 0) + (webhookConfigurations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) override fun equals(other: Any?): Boolean { @@ -819,6 +930,7 @@ private constructor( config == other.config && configuration == other.configuration && configurationId == other.configurationId && + webhookConfigurationIds == other.webhookConfigurationIds && webhookConfigurations == other.webhookConfigurations && additionalProperties == other.additionalProperties } @@ -829,6 +941,7 @@ private constructor( config, configuration, configurationId, + webhookConfigurationIds, webhookConfigurations, additionalProperties, ) @@ -837,7 +950,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{fileId=$fileId, config=$config, configuration=$configuration, configurationId=$configurationId, webhookConfigurations=$webhookConfigurations, additionalProperties=$additionalProperties}" + "Body{fileId=$fileId, config=$config, configuration=$configuration, configurationId=$configurationId, webhookConfigurationIds=$webhookConfigurationIds, webhookConfigurations=$webhookConfigurations, additionalProperties=$additionalProperties}" } /** Configuration for a single outbound webhook endpoint. */ diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/sheets/SheetCreateParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/sheets/SheetCreateParamsTest.kt index cc06e00..772ae91 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/sheets/SheetCreateParamsTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/sheets/SheetCreateParamsTest.kt @@ -43,6 +43,8 @@ internal class SheetCreateParamsTest { .build() ) .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( SheetCreateParams.WebhookConfiguration.builder() .addWebhookEvent( @@ -98,6 +100,8 @@ internal class SheetCreateParamsTest { .build() ) .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( SheetCreateParams.WebhookConfiguration.builder() .addWebhookEvent( @@ -176,6 +180,8 @@ internal class SheetCreateParamsTest { .build() ) .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( SheetCreateParams.WebhookConfiguration.builder() .addWebhookEvent( @@ -231,6 +237,7 @@ internal class SheetCreateParamsTest { .build() ) assertThat(body.configurationId()).contains("cfg-11111111-2222-3333-4444-555555555555") + assertThat(body.webhookConfigurationIds().getOrNull()).containsExactly("whc-...", "whc-...") assertThat(body.webhookConfigurations().getOrNull()) .containsExactly( SheetCreateParams.WebhookConfiguration.builder() diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/sheets/SheetCreateParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/sheets/SheetCreateParamsTest.kt index aa25ebb..6255d7a 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/sheets/SheetCreateParamsTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/sheets/SheetCreateParamsTest.kt @@ -44,6 +44,8 @@ internal class SheetCreateParamsTest { .build() ) .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( SheetCreateParams.WebhookConfiguration.builder() .addWebhookEvent( @@ -99,6 +101,8 @@ internal class SheetCreateParamsTest { .build() ) .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( SheetCreateParams.WebhookConfiguration.builder() .addWebhookEvent( @@ -177,6 +181,8 @@ internal class SheetCreateParamsTest { .build() ) .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( SheetCreateParams.WebhookConfiguration.builder() .addWebhookEvent( @@ -232,6 +238,7 @@ internal class SheetCreateParamsTest { .build() ) assertThat(body.configurationId()).contains("cfg-11111111-2222-3333-4444-555555555555") + assertThat(body.webhookConfigurationIds().getOrNull()).containsExactly("whc-...", "whc-...") assertThat(body.webhookConfigurations().getOrNull()) .containsExactly( SheetCreateParams.WebhookConfiguration.builder() diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/SheetServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/SheetServiceAsyncTest.kt index c7dea39..031df70 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/SheetServiceAsyncTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/SheetServiceAsyncTest.kt @@ -53,6 +53,8 @@ internal class SheetServiceAsyncTest { .build() ) .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( SheetCreateParams.WebhookConfiguration.builder() .addWebhookEvent( diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/beta/SheetServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/beta/SheetServiceAsyncTest.kt index 728ccde..71a1c4d 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/beta/SheetServiceAsyncTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/beta/SheetServiceAsyncTest.kt @@ -53,6 +53,8 @@ internal class SheetServiceAsyncTest { .build() ) .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( SheetCreateParams.WebhookConfiguration.builder() .addWebhookEvent( diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/SheetServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/SheetServiceTest.kt index b9a3201..ea0b2c5 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/SheetServiceTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/SheetServiceTest.kt @@ -53,6 +53,8 @@ internal class SheetServiceTest { .build() ) .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( SheetCreateParams.WebhookConfiguration.builder() .addWebhookEvent( diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/SheetServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/SheetServiceTest.kt index 42cbc4f..c8f8a6d 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/SheetServiceTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/SheetServiceTest.kt @@ -53,6 +53,8 @@ internal class SheetServiceTest { .build() ) .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( SheetCreateParams.WebhookConfiguration.builder() .addWebhookEvent( From 120db95cf47f98a3c4715b43b6a4a935aefdf752 Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Tue, 28 Jul 2026 00:30:39 +0000 Subject: [PATCH 06/28] feat(extract): reject parse_tier for parse-free tiers + pin turbo fallback to fast (#22919) Stainless-Generated-From: 24c77712f103352985dd73efc0372b4546d58ef6 --- .../configurations/ExtractV2Parameters.kt | 20 +++++++++++++++---- .../models/extract/ExtractConfiguration.kt | 20 +++++++++++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) 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 b3bfadb..42c519d 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 @@ -139,7 +139,9 @@ private constructor( fun maxPages(): Optional = maxPages.getOptional("max_pages") /** - * Saved parse configuration ID to control how the document is parsed before extraction + * Saved parse configuration ID to control how the document is parsed before extraction. Turbo + * extract does not support parse configuration or produce a parse output; use another tier if + * your workflow requires parsed text. * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -147,7 +149,9 @@ private constructor( fun parseConfigId(): Optional = parseConfigId.getOptional("parse_config_id") /** - * Parse tier to use before extraction. Defaults to the extract tier if not specified. + * Parse tier to use before extraction. Defaults to the extract tier if not specified. Turbo + * extract does not support parse configuration or produce a parse output; use another tier if + * your workflow requires parsed text. * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -437,7 +441,11 @@ private constructor( */ fun maxPages(maxPages: JsonField) = apply { this.maxPages = maxPages } - /** Saved parse configuration ID to control how the document is parsed before extraction */ + /** + * Saved parse configuration ID to control how the document is parsed before extraction. + * Turbo extract does not support parse configuration or produce a parse output; use another + * tier if your workflow requires parsed text. + */ fun parseConfigId(parseConfigId: String?) = parseConfigId(JsonField.ofNullable(parseConfigId)) @@ -456,7 +464,11 @@ private constructor( this.parseConfigId = parseConfigId } - /** Parse tier to use before extraction. Defaults to the extract tier if not specified. */ + /** + * Parse tier to use before extraction. Defaults to the extract tier if not specified. Turbo + * extract does not support parse configuration or produce a parse output; use another tier + * if your workflow requires parsed text. + */ fun parseTier(parseTier: String?) = parseTier(JsonField.ofNullable(parseTier)) /** Alias for calling [Builder.parseTier] with `parseTier.orElse(null)`. */ 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 16bdda5..f3dd4fd 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 @@ -123,7 +123,9 @@ private constructor( fun maxPages(): Optional = maxPages.getOptional("max_pages") /** - * Saved parse configuration ID to control how the document is parsed before extraction + * Saved parse configuration ID to control how the document is parsed before extraction. Turbo + * extract does not support parse configuration or produce a parse output; use another tier if + * your workflow requires parsed text. * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -131,7 +133,9 @@ private constructor( fun parseConfigId(): Optional = parseConfigId.getOptional("parse_config_id") /** - * Parse tier to use before extraction. Defaults to the extract tier if not specified. + * Parse tier to use before extraction. Defaults to the extract tier if not specified. Turbo + * extract does not support parse configuration or produce a parse output; use another tier if + * your workflow requires parsed text. * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -405,7 +409,11 @@ private constructor( */ fun maxPages(maxPages: JsonField) = apply { this.maxPages = maxPages } - /** Saved parse configuration ID to control how the document is parsed before extraction */ + /** + * Saved parse configuration ID to control how the document is parsed before extraction. + * Turbo extract does not support parse configuration or produce a parse output; use another + * tier if your workflow requires parsed text. + */ fun parseConfigId(parseConfigId: String?) = parseConfigId(JsonField.ofNullable(parseConfigId)) @@ -424,7 +432,11 @@ private constructor( this.parseConfigId = parseConfigId } - /** Parse tier to use before extraction. Defaults to the extract tier if not specified. */ + /** + * Parse tier to use before extraction. Defaults to the extract tier if not specified. Turbo + * extract does not support parse configuration or produce a parse output; use another tier + * if your workflow requires parsed text. + */ fun parseTier(parseTier: String?) = parseTier(JsonField.ofNullable(parseTier)) /** Alias for calling [Builder.parseTier] with `parseTier.orElse(null)`. */ From 9a6212f96f3a9f8e5a26538494d3f4a6bf429aa1 Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Tue, 28 Jul 2026 05:52:28 +0000 Subject: [PATCH 07/28] feat(extract): pin turbo to a stable dated version; accept citations+confidence, reject only granular bboxes (#22965) Stainless-Generated-From: 376260c625433736f87c10e08bd2cb52560eb226 --- .../models/configurations/ExtractV2Parameters.kt | 16 ++++++++++++---- .../models/extract/ExtractConfiguration.kt | 16 ++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) 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 42c519d..2823d16 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 @@ -105,7 +105,8 @@ private constructor( @JsonProperty("product_type") @ExcludeMissing fun _productType(): JsonValue = productType /** - * Include citations in results + * Include citations in results. Returned under `extract_metadata` (auto-included when set). + * Text-level on `turbo` (no bounding boxes). * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -113,7 +114,8 @@ private constructor( fun citeSources(): Optional = citeSources.getOptional("cite_sources") /** - * Include confidence scores in results + * Include confidence scores in results. Returned under `extract_metadata` (auto-included when + * set). * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -375,7 +377,10 @@ private constructor( */ fun productType(productType: JsonValue) = apply { this.productType = productType } - /** Include citations in results */ + /** + * Include citations in results. Returned under `extract_metadata` (auto-included when set). + * Text-level on `turbo` (no bounding boxes). + */ fun citeSources(citeSources: Boolean) = citeSources(JsonField.of(citeSources)) /** @@ -387,7 +392,10 @@ private constructor( */ fun citeSources(citeSources: JsonField) = apply { this.citeSources = citeSources } - /** Include confidence scores in results */ + /** + * Include confidence scores in results. Returned under `extract_metadata` (auto-included + * when set). + */ fun confidenceScores(confidenceScores: Boolean) = confidenceScores(JsonField.of(confidenceScores)) 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 f3dd4fd..e0e4361 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 @@ -89,7 +89,8 @@ private constructor( fun dataSchema(): DataSchema = dataSchema.getRequired("data_schema") /** - * Include citations in results + * Include citations in results. Returned under `extract_metadata` (auto-included when set). + * Text-level on `turbo` (no bounding boxes). * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -97,7 +98,8 @@ private constructor( fun citeSources(): Optional = citeSources.getOptional("cite_sources") /** - * Include confidence scores in results + * Include confidence scores in results. Returned under `extract_metadata` (auto-included when + * set). * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -343,7 +345,10 @@ private constructor( */ fun dataSchema(dataSchema: JsonField) = apply { this.dataSchema = dataSchema } - /** Include citations in results */ + /** + * Include citations in results. Returned under `extract_metadata` (auto-included when set). + * Text-level on `turbo` (no bounding boxes). + */ fun citeSources(citeSources: Boolean) = citeSources(JsonField.of(citeSources)) /** @@ -355,7 +360,10 @@ private constructor( */ fun citeSources(citeSources: JsonField) = apply { this.citeSources = citeSources } - /** Include confidence scores in results */ + /** + * Include confidence scores in results. Returned under `extract_metadata` (auto-included + * when set). + */ fun confidenceScores(confidenceScores: Boolean) = confidenceScores(JsonField.of(confidenceScores)) From b8dbc0091561ae8bb036d81fbe1b142902ea0368 Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Tue, 28 Jul 2026 21:11:09 +0000 Subject: [PATCH 08/28] feat(classify): accept webhook_configuration_ids on classify job create (LI-8138) (#22943) Stainless-Generated-From: 0edfe9d9aff853ab6a2d8514422f8aa39a31d0cd --- .../models/classify/ClassifyCreateRequest.kt | 68 ++++++++++++++++++- .../classify/ClassifyCreateParamsTest.kt | 8 +++ .../classify/ClassifyCreateRequestTest.kt | 6 ++ .../async/ClassifyServiceAsyncTest.kt | 2 + .../services/blocking/ClassifyServiceTest.kt | 2 + 5 files changed, 85 insertions(+), 1 deletion(-) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCreateRequest.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCreateRequest.kt index 2d6f592..d575ede 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCreateRequest.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCreateRequest.kt @@ -29,6 +29,7 @@ private constructor( private val fileInput: JsonField, private val parseJobId: JsonField, private val transactionId: JsonField, + private val webhookConfigurationIds: JsonField>, private val webhookConfigurations: JsonField>, private val additionalProperties: MutableMap, ) { @@ -49,6 +50,9 @@ private constructor( @JsonProperty("transaction_id") @ExcludeMissing transactionId: JsonField = JsonMissing.of(), + @JsonProperty("webhook_configuration_ids") + @ExcludeMissing + webhookConfigurationIds: JsonField> = JsonMissing.of(), @JsonProperty("webhook_configurations") @ExcludeMissing webhookConfigurations: JsonField> = JsonMissing.of(), @@ -59,6 +63,7 @@ private constructor( fileInput, parseJobId, transactionId, + webhookConfigurationIds, webhookConfigurations, mutableMapOf(), ) @@ -114,6 +119,15 @@ private constructor( */ fun transactionId(): Optional = transactionId.getOptional("transaction_id") + /** + * IDs of saved webhook configurations to notify for this job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookConfigurationIds(): Optional> = + webhookConfigurationIds.getOptional("webhook_configuration_ids") + /** * Outbound webhook endpoints to notify on job status changes * @@ -177,6 +191,16 @@ private constructor( @ExcludeMissing fun _transactionId(): JsonField = transactionId + /** + * Returns the raw JSON value of [webhookConfigurationIds]. + * + * Unlike [webhookConfigurationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("webhook_configuration_ids") + @ExcludeMissing + fun _webhookConfigurationIds(): JsonField> = webhookConfigurationIds + /** * Returns the raw JSON value of [webhookConfigurations]. * @@ -214,6 +238,7 @@ private constructor( private var fileInput: JsonField = JsonMissing.of() private var parseJobId: JsonField = JsonMissing.of() private var transactionId: JsonField = JsonMissing.of() + private var webhookConfigurationIds: JsonField>? = null private var webhookConfigurations: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -225,6 +250,8 @@ private constructor( fileInput = classifyCreateRequest.fileInput parseJobId = classifyCreateRequest.parseJobId transactionId = classifyCreateRequest.transactionId + webhookConfigurationIds = + classifyCreateRequest.webhookConfigurationIds.map { it.toMutableList() } webhookConfigurations = classifyCreateRequest.webhookConfigurations.map { it.toMutableList() } additionalProperties = classifyCreateRequest.additionalProperties.toMutableMap() @@ -338,6 +365,40 @@ private constructor( this.transactionId = transactionId } + /** IDs of saved webhook configurations to notify for this job. */ + fun webhookConfigurationIds(webhookConfigurationIds: List?) = + webhookConfigurationIds(JsonField.ofNullable(webhookConfigurationIds)) + + /** + * Alias for calling [Builder.webhookConfigurationIds] with + * `webhookConfigurationIds.orElse(null)`. + */ + fun webhookConfigurationIds(webhookConfigurationIds: Optional>) = + webhookConfigurationIds(webhookConfigurationIds.getOrNull()) + + /** + * Sets [Builder.webhookConfigurationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookConfigurationIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun webhookConfigurationIds(webhookConfigurationIds: JsonField>) = apply { + this.webhookConfigurationIds = webhookConfigurationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [webhookConfigurationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookConfigurationId(webhookConfigurationId: String) = apply { + webhookConfigurationIds = + (webhookConfigurationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("webhookConfigurationIds", it).add(webhookConfigurationId) + } + } + /** Outbound webhook endpoints to notify on job status changes */ fun webhookConfigurations(webhookConfigurations: List?) = webhookConfigurations(JsonField.ofNullable(webhookConfigurations)) @@ -405,6 +466,7 @@ private constructor( fileInput, parseJobId, transactionId, + (webhookConfigurationIds ?: JsonMissing.of()).map { it.toImmutable() }, (webhookConfigurations ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) @@ -431,6 +493,7 @@ private constructor( fileInput() parseJobId() transactionId() + webhookConfigurationIds() webhookConfigurations().ifPresent { it.forEach { it.validate() } } validated = true } @@ -456,6 +519,7 @@ private constructor( (if (fileInput.asKnown().isPresent) 1 else 0) + (if (parseJobId.asKnown().isPresent) 1 else 0) + (if (transactionId.asKnown().isPresent) 1 else 0) + + (webhookConfigurationIds.asKnown().getOrNull()?.size ?: 0) + (webhookConfigurations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) /** Configuration for a single outbound webhook endpoint. */ @@ -1282,6 +1346,7 @@ private constructor( fileInput == other.fileInput && parseJobId == other.parseJobId && transactionId == other.transactionId && + webhookConfigurationIds == other.webhookConfigurationIds && webhookConfigurations == other.webhookConfigurations && additionalProperties == other.additionalProperties } @@ -1294,6 +1359,7 @@ private constructor( fileInput, parseJobId, transactionId, + webhookConfigurationIds, webhookConfigurations, additionalProperties, ) @@ -1302,5 +1368,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ClassifyCreateRequest{configuration=$configuration, configurationId=$configurationId, fileId=$fileId, fileInput=$fileInput, parseJobId=$parseJobId, transactionId=$transactionId, webhookConfigurations=$webhookConfigurations, additionalProperties=$additionalProperties}" + "ClassifyCreateRequest{configuration=$configuration, configurationId=$configurationId, fileId=$fileId, fileInput=$fileInput, parseJobId=$parseJobId, transactionId=$transactionId, webhookConfigurationIds=$webhookConfigurationIds, webhookConfigurations=$webhookConfigurations, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCreateParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCreateParamsTest.kt index 54a3a28..225135b 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCreateParamsTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCreateParamsTest.kt @@ -41,6 +41,8 @@ internal class ClassifyCreateParamsTest { .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") .parseJobId("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") .transactionId("tx-unique-idempotency-key") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( ClassifyCreateRequest.WebhookConfiguration.builder() .addWebhookEvent( @@ -101,6 +103,8 @@ internal class ClassifyCreateParamsTest { .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") .parseJobId("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") .transactionId("tx-unique-idempotency-key") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( ClassifyCreateRequest.WebhookConfiguration.builder() .addWebhookEvent( @@ -185,6 +189,8 @@ internal class ClassifyCreateParamsTest { .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") .parseJobId("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") .transactionId("tx-unique-idempotency-key") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( ClassifyCreateRequest.WebhookConfiguration.builder() .addWebhookEvent( @@ -243,6 +249,8 @@ internal class ClassifyCreateParamsTest { .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") .parseJobId("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") .transactionId("tx-unique-idempotency-key") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( ClassifyCreateRequest.WebhookConfiguration.builder() .addWebhookEvent( diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCreateRequestTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCreateRequestTest.kt index 6dfad6b..c9a0ef6 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCreateRequestTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCreateRequestTest.kt @@ -40,6 +40,8 @@ internal class ClassifyCreateRequestTest { .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") .parseJobId("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") .transactionId("tx-unique-idempotency-key") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( ClassifyCreateRequest.WebhookConfiguration.builder() .addWebhookEvent( @@ -91,6 +93,8 @@ internal class ClassifyCreateRequestTest { assertThat(classifyCreateRequest.parseJobId()) .contains("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") assertThat(classifyCreateRequest.transactionId()).contains("tx-unique-idempotency-key") + assertThat(classifyCreateRequest.webhookConfigurationIds().getOrNull()) + .containsExactly("whc-...", "whc-...") assertThat(classifyCreateRequest.webhookConfigurations().getOrNull()) .containsExactly( ClassifyCreateRequest.WebhookConfiguration.builder() @@ -142,6 +146,8 @@ internal class ClassifyCreateRequestTest { .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") .parseJobId("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") .transactionId("tx-unique-idempotency-key") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( ClassifyCreateRequest.WebhookConfiguration.builder() .addWebhookEvent( diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ClassifyServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ClassifyServiceAsyncTest.kt index 7952439..cf5490c 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ClassifyServiceAsyncTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ClassifyServiceAsyncTest.kt @@ -51,6 +51,8 @@ internal class ClassifyServiceAsyncTest { .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") .parseJobId("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") .transactionId("tx-unique-idempotency-key") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( ClassifyCreateRequest.WebhookConfiguration.builder() .addWebhookEvent( diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ClassifyServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ClassifyServiceTest.kt index 572651c..53d2676 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ClassifyServiceTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ClassifyServiceTest.kt @@ -51,6 +51,8 @@ internal class ClassifyServiceTest { .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") .parseJobId("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") .transactionId("tx-unique-idempotency-key") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") .addWebhookConfiguration( ClassifyCreateRequest.WebhookConfiguration.builder() .addWebhookEvent( From 4650496db554c19d17355add4955d353c35d7e20 Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Thu, 30 Jul 2026 03:48:04 +0000 Subject: [PATCH 09/28] feat(extract): opt-in spreadsheet mode for agentic_plus (#22958) Stainless-Generated-From: 278d954adc10ae61b21739e6be46e46fe978a805 --- .../configurations/ExtractV2Parameters.kt | 122 +++++++++++++++++- .../models/extract/ExtractConfiguration.kt | 122 +++++++++++++++++- .../configurations/ExtractV2ParametersTest.kt | 10 ++ .../extract/ExtractConfigurationTest.kt | 10 ++ .../models/extract/ExtractCreateParamsTest.kt | 12 ++ .../models/extract/ExtractV2JobCreateTest.kt | 9 ++ .../extract/ExtractV2JobQueryResponseTest.kt | 9 ++ .../models/extract/ExtractV2JobTest.kt | 9 ++ .../services/async/ExtractServiceAsyncTest.kt | 3 + .../services/blocking/ExtractServiceTest.kt | 3 + 10 files changed, 307 insertions(+), 2 deletions(-) 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 2823d16..8e1c67e 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 @@ -7,6 +7,7 @@ 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 @@ -31,6 +32,8 @@ private constructor( private val maxPages: JsonField, private val parseConfigId: JsonField, private val parseTier: JsonField, + private val sheetNames: JsonField>, + private val spreadsheetMode: JsonField, private val systemPrompt: JsonField, private val targetPages: JsonField, private val tier: JsonField, @@ -58,6 +61,12 @@ private constructor( @ExcludeMissing parseConfigId: JsonField = JsonMissing.of(), @JsonProperty("parse_tier") @ExcludeMissing parseTier: JsonField = JsonMissing.of(), + @JsonProperty("sheet_names") + @ExcludeMissing + sheetNames: JsonField> = JsonMissing.of(), + @JsonProperty("spreadsheet_mode") + @ExcludeMissing + spreadsheetMode: JsonField = JsonMissing.of(), @JsonProperty("system_prompt") @ExcludeMissing systemPrompt: JsonField = JsonMissing.of(), @@ -75,6 +84,8 @@ private constructor( maxPages, parseConfigId, parseTier, + sheetNames, + spreadsheetMode, systemPrompt, targetPages, tier, @@ -160,6 +171,28 @@ private constructor( */ fun parseTier(): Optional = parseTier.getOptional("parse_tier") + /** + * Optional worksheet names to extract when spreadsheet_mode is on. Overrides target_pages for + * spreadsheets; omit to extract every sheet. Names are matched exactly (case-sensitive) — pass + * them as a list, e.g. ["Sheet 1", "My Sheet"]. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sheetNames(): Optional> = sheetNames.getOptional("sheet_names") + + /** + * Beta. When true, extract structured data directly from a spreadsheet workbook + * (.xlsx/.xls/.csv) — the agent reads cells straight from the workbook instead of the standard + * document path. Off by default (spreadsheets keep the standard path). Requires the + * agentic_plus tier. Billed on the standard per-page extract rate, against a page count derived + * from workbook size. Citations and confidence scores are not available in this mode. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun spreadsheetMode(): Optional = spreadsheetMode.getOptional("spreadsheet_mode") + /** * Custom system prompt to guide extraction behavior * @@ -257,6 +290,24 @@ private constructor( */ @JsonProperty("parse_tier") @ExcludeMissing fun _parseTier(): JsonField = parseTier + /** + * Returns the raw JSON value of [sheetNames]. + * + * Unlike [sheetNames], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sheet_names") + @ExcludeMissing + fun _sheetNames(): JsonField> = sheetNames + + /** + * Returns the raw JSON value of [spreadsheetMode]. + * + * Unlike [spreadsheetMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("spreadsheet_mode") + @ExcludeMissing + fun _spreadsheetMode(): JsonField = spreadsheetMode + /** * Returns the raw JSON value of [systemPrompt]. * @@ -325,6 +376,8 @@ private constructor( private var maxPages: JsonField = JsonMissing.of() private var parseConfigId: JsonField = JsonMissing.of() private var parseTier: JsonField = JsonMissing.of() + private var sheetNames: JsonField>? = null + private var spreadsheetMode: JsonField = JsonMissing.of() private var systemPrompt: JsonField = JsonMissing.of() private var targetPages: JsonField = JsonMissing.of() private var tier: JsonField = JsonMissing.of() @@ -341,6 +394,8 @@ private constructor( maxPages = extractV2Parameters.maxPages parseConfigId = extractV2Parameters.parseConfigId parseTier = extractV2Parameters.parseTier + sheetNames = extractV2Parameters.sheetNames.map { it.toMutableList() } + spreadsheetMode = extractV2Parameters.spreadsheetMode systemPrompt = extractV2Parameters.systemPrompt targetPages = extractV2Parameters.targetPages tier = extractV2Parameters.tier @@ -491,6 +546,61 @@ private constructor( */ fun parseTier(parseTier: JsonField) = apply { this.parseTier = parseTier } + /** + * Optional worksheet names to extract when spreadsheet_mode is on. Overrides target_pages + * for spreadsheets; omit to extract every sheet. Names are matched exactly (case-sensitive) + * — pass them as a list, e.g. ["Sheet 1", "My Sheet"]. + */ + fun sheetNames(sheetNames: List?) = sheetNames(JsonField.ofNullable(sheetNames)) + + /** Alias for calling [Builder.sheetNames] with `sheetNames.orElse(null)`. */ + fun sheetNames(sheetNames: Optional>) = sheetNames(sheetNames.getOrNull()) + + /** + * Sets [Builder.sheetNames] to an arbitrary JSON value. + * + * You should usually call [Builder.sheetNames] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sheetNames(sheetNames: JsonField>) = apply { + this.sheetNames = sheetNames.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [sheetNames]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSheetName(sheetName: String) = apply { + sheetNames = + (sheetNames ?: JsonField.of(mutableListOf())).also { + checkKnown("sheetNames", it).add(sheetName) + } + } + + /** + * Beta. When true, extract structured data directly from a spreadsheet workbook + * (.xlsx/.xls/.csv) — the agent reads cells straight from the workbook instead of the + * standard document path. Off by default (spreadsheets keep the standard path). Requires + * the agentic_plus tier. Billed on the standard per-page extract rate, against a page count + * derived from workbook size. Citations and confidence scores are not available in this + * mode. + */ + fun spreadsheetMode(spreadsheetMode: Boolean) = + spreadsheetMode(JsonField.of(spreadsheetMode)) + + /** + * Sets [Builder.spreadsheetMode] to an arbitrary JSON value. + * + * You should usually call [Builder.spreadsheetMode] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun spreadsheetMode(spreadsheetMode: JsonField) = apply { + this.spreadsheetMode = spreadsheetMode + } + /** Custom system prompt to guide extraction behavior */ fun systemPrompt(systemPrompt: String?) = systemPrompt(JsonField.ofNullable(systemPrompt)) @@ -596,6 +706,8 @@ private constructor( maxPages, parseConfigId, parseTier, + (sheetNames ?: JsonMissing.of()).map { it.toImmutable() }, + spreadsheetMode, systemPrompt, targetPages, tier, @@ -631,6 +743,8 @@ private constructor( maxPages() parseConfigId() parseTier() + sheetNames() + spreadsheetMode() systemPrompt() targetPages() tier().ifPresent { it.validate() } @@ -661,6 +775,8 @@ private constructor( (if (maxPages.asKnown().isPresent) 1 else 0) + (if (parseConfigId.asKnown().isPresent) 1 else 0) + (if (parseTier.asKnown().isPresent) 1 else 0) + + (sheetNames.asKnown().getOrNull()?.size ?: 0) + + (if (spreadsheetMode.asKnown().isPresent) 1 else 0) + (if (systemPrompt.asKnown().isPresent) 1 else 0) + (if (targetPages.asKnown().isPresent) 1 else 0) + (tier.asKnown().getOrNull()?.validity() ?: 0) + @@ -1088,6 +1204,8 @@ private constructor( maxPages == other.maxPages && parseConfigId == other.parseConfigId && parseTier == other.parseTier && + sheetNames == other.sheetNames && + spreadsheetMode == other.spreadsheetMode && systemPrompt == other.systemPrompt && targetPages == other.targetPages && tier == other.tier && @@ -1105,6 +1223,8 @@ private constructor( maxPages, parseConfigId, parseTier, + sheetNames, + spreadsheetMode, systemPrompt, targetPages, tier, @@ -1116,5 +1236,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ExtractV2Parameters{dataSchema=$dataSchema, productType=$productType, citeSources=$citeSources, confidenceScores=$confidenceScores, extractionTarget=$extractionTarget, maxPages=$maxPages, parseConfigId=$parseConfigId, parseTier=$parseTier, systemPrompt=$systemPrompt, targetPages=$targetPages, tier=$tier, version=$version, additionalProperties=$additionalProperties}" + "ExtractV2Parameters{dataSchema=$dataSchema, productType=$productType, citeSources=$citeSources, confidenceScores=$confidenceScores, extractionTarget=$extractionTarget, maxPages=$maxPages, parseConfigId=$parseConfigId, parseTier=$parseTier, sheetNames=$sheetNames, spreadsheetMode=$spreadsheetMode, systemPrompt=$systemPrompt, targetPages=$targetPages, tier=$tier, version=$version, additionalProperties=$additionalProperties}" } 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 e0e4361..0cf7005 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 @@ -7,6 +7,7 @@ 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 @@ -30,6 +31,8 @@ private constructor( private val maxPages: JsonField, private val parseConfigId: JsonField, private val parseTier: JsonField, + private val sheetNames: JsonField>, + private val spreadsheetMode: JsonField, private val systemPrompt: JsonField, private val targetPages: JsonField, private val tier: JsonField, @@ -56,6 +59,12 @@ private constructor( @ExcludeMissing parseConfigId: JsonField = JsonMissing.of(), @JsonProperty("parse_tier") @ExcludeMissing parseTier: JsonField = JsonMissing.of(), + @JsonProperty("sheet_names") + @ExcludeMissing + sheetNames: JsonField> = JsonMissing.of(), + @JsonProperty("spreadsheet_mode") + @ExcludeMissing + spreadsheetMode: JsonField = JsonMissing.of(), @JsonProperty("system_prompt") @ExcludeMissing systemPrompt: JsonField = JsonMissing.of(), @@ -72,6 +81,8 @@ private constructor( maxPages, parseConfigId, parseTier, + sheetNames, + spreadsheetMode, systemPrompt, targetPages, tier, @@ -144,6 +155,28 @@ private constructor( */ fun parseTier(): Optional = parseTier.getOptional("parse_tier") + /** + * Optional worksheet names to extract when spreadsheet_mode is on. Overrides target_pages for + * spreadsheets; omit to extract every sheet. Names are matched exactly (case-sensitive) — pass + * them as a list, e.g. ["Sheet 1", "My Sheet"]. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun sheetNames(): Optional> = sheetNames.getOptional("sheet_names") + + /** + * Beta. When true, extract structured data directly from a spreadsheet workbook + * (.xlsx/.xls/.csv) — the agent reads cells straight from the workbook instead of the standard + * document path. Off by default (spreadsheets keep the standard path). Requires the + * agentic_plus tier. Billed on the standard per-page extract rate, against a page count derived + * from workbook size. Citations and confidence scores are not available in this mode. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun spreadsheetMode(): Optional = spreadsheetMode.getOptional("spreadsheet_mode") + /** * Custom system prompt to guide extraction behavior * @@ -241,6 +274,24 @@ private constructor( */ @JsonProperty("parse_tier") @ExcludeMissing fun _parseTier(): JsonField = parseTier + /** + * Returns the raw JSON value of [sheetNames]. + * + * Unlike [sheetNames], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("sheet_names") + @ExcludeMissing + fun _sheetNames(): JsonField> = sheetNames + + /** + * Returns the raw JSON value of [spreadsheetMode]. + * + * Unlike [spreadsheetMode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("spreadsheet_mode") + @ExcludeMissing + fun _spreadsheetMode(): JsonField = spreadsheetMode + /** * Returns the raw JSON value of [systemPrompt]. * @@ -308,6 +359,8 @@ private constructor( private var maxPages: JsonField = JsonMissing.of() private var parseConfigId: JsonField = JsonMissing.of() private var parseTier: JsonField = JsonMissing.of() + private var sheetNames: JsonField>? = null + private var spreadsheetMode: JsonField = JsonMissing.of() private var systemPrompt: JsonField = JsonMissing.of() private var targetPages: JsonField = JsonMissing.of() private var tier: JsonField = JsonMissing.of() @@ -323,6 +376,8 @@ private constructor( maxPages = extractConfiguration.maxPages parseConfigId = extractConfiguration.parseConfigId parseTier = extractConfiguration.parseTier + sheetNames = extractConfiguration.sheetNames.map { it.toMutableList() } + spreadsheetMode = extractConfiguration.spreadsheetMode systemPrompt = extractConfiguration.systemPrompt targetPages = extractConfiguration.targetPages tier = extractConfiguration.tier @@ -459,6 +514,61 @@ private constructor( */ fun parseTier(parseTier: JsonField) = apply { this.parseTier = parseTier } + /** + * Optional worksheet names to extract when spreadsheet_mode is on. Overrides target_pages + * for spreadsheets; omit to extract every sheet. Names are matched exactly (case-sensitive) + * — pass them as a list, e.g. ["Sheet 1", "My Sheet"]. + */ + fun sheetNames(sheetNames: List?) = sheetNames(JsonField.ofNullable(sheetNames)) + + /** Alias for calling [Builder.sheetNames] with `sheetNames.orElse(null)`. */ + fun sheetNames(sheetNames: Optional>) = sheetNames(sheetNames.getOrNull()) + + /** + * Sets [Builder.sheetNames] to an arbitrary JSON value. + * + * You should usually call [Builder.sheetNames] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sheetNames(sheetNames: JsonField>) = apply { + this.sheetNames = sheetNames.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [sheetNames]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addSheetName(sheetName: String) = apply { + sheetNames = + (sheetNames ?: JsonField.of(mutableListOf())).also { + checkKnown("sheetNames", it).add(sheetName) + } + } + + /** + * Beta. When true, extract structured data directly from a spreadsheet workbook + * (.xlsx/.xls/.csv) — the agent reads cells straight from the workbook instead of the + * standard document path. Off by default (spreadsheets keep the standard path). Requires + * the agentic_plus tier. Billed on the standard per-page extract rate, against a page count + * derived from workbook size. Citations and confidence scores are not available in this + * mode. + */ + fun spreadsheetMode(spreadsheetMode: Boolean) = + spreadsheetMode(JsonField.of(spreadsheetMode)) + + /** + * Sets [Builder.spreadsheetMode] to an arbitrary JSON value. + * + * You should usually call [Builder.spreadsheetMode] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun spreadsheetMode(spreadsheetMode: JsonField) = apply { + this.spreadsheetMode = spreadsheetMode + } + /** Custom system prompt to guide extraction behavior */ fun systemPrompt(systemPrompt: String?) = systemPrompt(JsonField.ofNullable(systemPrompt)) @@ -563,6 +673,8 @@ private constructor( maxPages, parseConfigId, parseTier, + (sheetNames ?: JsonMissing.of()).map { it.toImmutable() }, + spreadsheetMode, systemPrompt, targetPages, tier, @@ -593,6 +705,8 @@ private constructor( maxPages() parseConfigId() parseTier() + sheetNames() + spreadsheetMode() systemPrompt() targetPages() tier().ifPresent { it.validate() } @@ -622,6 +736,8 @@ private constructor( (if (maxPages.asKnown().isPresent) 1 else 0) + (if (parseConfigId.asKnown().isPresent) 1 else 0) + (if (parseTier.asKnown().isPresent) 1 else 0) + + (sheetNames.asKnown().getOrNull()?.size ?: 0) + + (if (spreadsheetMode.asKnown().isPresent) 1 else 0) + (if (systemPrompt.asKnown().isPresent) 1 else 0) + (if (targetPages.asKnown().isPresent) 1 else 0) + (tier.asKnown().getOrNull()?.validity() ?: 0) + @@ -1048,6 +1164,8 @@ private constructor( maxPages == other.maxPages && parseConfigId == other.parseConfigId && parseTier == other.parseTier && + sheetNames == other.sheetNames && + spreadsheetMode == other.spreadsheetMode && systemPrompt == other.systemPrompt && targetPages == other.targetPages && tier == other.tier && @@ -1064,6 +1182,8 @@ private constructor( maxPages, parseConfigId, parseTier, + sheetNames, + spreadsheetMode, systemPrompt, targetPages, tier, @@ -1075,5 +1195,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ExtractConfiguration{dataSchema=$dataSchema, citeSources=$citeSources, confidenceScores=$confidenceScores, extractionTarget=$extractionTarget, maxPages=$maxPages, parseConfigId=$parseConfigId, parseTier=$parseTier, systemPrompt=$systemPrompt, targetPages=$targetPages, tier=$tier, version=$version, additionalProperties=$additionalProperties}" + "ExtractConfiguration{dataSchema=$dataSchema, citeSources=$citeSources, confidenceScores=$confidenceScores, extractionTarget=$extractionTarget, maxPages=$maxPages, parseConfigId=$parseConfigId, parseTier=$parseTier, sheetNames=$sheetNames, spreadsheetMode=$spreadsheetMode, systemPrompt=$systemPrompt, targetPages=$targetPages, tier=$tier, version=$version, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/configurations/ExtractV2ParametersTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/configurations/ExtractV2ParametersTest.kt index 1e4d74a..8ce176d 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/configurations/ExtractV2ParametersTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/configurations/ExtractV2ParametersTest.kt @@ -5,6 +5,7 @@ package ai.llamaindex.llamacloud.models.configurations import ai.llamaindex.llamacloud.core.JsonValue import ai.llamaindex.llamacloud.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -25,6 +26,9 @@ internal class ExtractV2ParametersTest { .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") .parseTier("fast") + .addSheetName("Sheet 1") + .addSheetName("Q4 Summary") + .spreadsheetMode(true) .systemPrompt( "Extract all monetary values in USD. If a currency is not specified, assume USD." ) @@ -47,6 +51,9 @@ internal class ExtractV2ParametersTest { assertThat(extractV2Parameters.parseConfigId()) .contains("cfg-11111111-2222-3333-4444-555555555555") assertThat(extractV2Parameters.parseTier()).contains("fast") + assertThat(extractV2Parameters.sheetNames().getOrNull()) + .containsExactly("Sheet 1", "Q4 Summary") + assertThat(extractV2Parameters.spreadsheetMode()).contains(true) assertThat(extractV2Parameters.systemPrompt()) .contains( "Extract all monetary values in USD. If a currency is not specified, assume USD." @@ -72,6 +79,9 @@ internal class ExtractV2ParametersTest { .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") .parseTier("fast") + .addSheetName("Sheet 1") + .addSheetName("Q4 Summary") + .spreadsheetMode(true) .systemPrompt( "Extract all monetary values in USD. If a currency is not specified, assume USD." ) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractConfigurationTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractConfigurationTest.kt index 5c81a3f..4b70942 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractConfigurationTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractConfigurationTest.kt @@ -5,6 +5,7 @@ package ai.llamaindex.llamacloud.models.extract import ai.llamaindex.llamacloud.core.JsonValue import ai.llamaindex.llamacloud.core.jsonMapper import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -25,6 +26,9 @@ internal class ExtractConfigurationTest { .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") .parseTier("fast") + .addSheetName("Sheet 1") + .addSheetName("Q4 Summary") + .spreadsheetMode(true) .systemPrompt( "Extract all monetary values in USD. If a currency is not specified, assume USD." ) @@ -47,6 +51,9 @@ internal class ExtractConfigurationTest { assertThat(extractConfiguration.parseConfigId()) .contains("cfg-11111111-2222-3333-4444-555555555555") assertThat(extractConfiguration.parseTier()).contains("fast") + assertThat(extractConfiguration.sheetNames().getOrNull()) + .containsExactly("Sheet 1", "Q4 Summary") + assertThat(extractConfiguration.spreadsheetMode()).contains(true) assertThat(extractConfiguration.systemPrompt()) .contains( "Extract all monetary values in USD. If a currency is not specified, assume USD." @@ -72,6 +79,9 @@ internal class ExtractConfigurationTest { .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") .parseTier("fast") + .addSheetName("Sheet 1") + .addSheetName("Q4 Summary") + .spreadsheetMode(true) .systemPrompt( "Extract all monetary values in USD. If a currency is not specified, assume USD." ) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractCreateParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractCreateParamsTest.kt index 1ca8d14..0d7375e 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractCreateParamsTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractCreateParamsTest.kt @@ -40,6 +40,9 @@ internal class ExtractCreateParamsTest { .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") .parseTier("fast") + .addSheetName("Sheet 1") + .addSheetName("Q4 Summary") + .spreadsheetMode(true) .systemPrompt( "Extract all monetary values in USD. If a currency is not specified, assume USD." ) @@ -112,6 +115,9 @@ internal class ExtractCreateParamsTest { .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") .parseTier("fast") + .addSheetName("Sheet 1") + .addSheetName("Q4 Summary") + .spreadsheetMode(true) .systemPrompt( "Extract all monetary values in USD. If a currency is not specified, assume USD." ) @@ -211,6 +217,9 @@ internal class ExtractCreateParamsTest { .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") .parseTier("fast") + .addSheetName("Sheet 1") + .addSheetName("Q4 Summary") + .spreadsheetMode(true) .systemPrompt( "Extract all monetary values in USD. If a currency is not specified, assume USD." ) @@ -277,6 +286,9 @@ internal class ExtractCreateParamsTest { .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") .parseTier("fast") + .addSheetName("Sheet 1") + .addSheetName("Q4 Summary") + .spreadsheetMode(true) .systemPrompt( "Extract all monetary values in USD. If a currency is not specified, assume USD." ) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobCreateTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobCreateTest.kt index 7a08d6f..00b914b 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobCreateTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobCreateTest.kt @@ -39,6 +39,9 @@ internal class ExtractV2JobCreateTest { .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") .parseTier("fast") + .addSheetName("Sheet 1") + .addSheetName("Q4 Summary") + .spreadsheetMode(true) .systemPrompt( "Extract all monetary values in USD. If a currency is not specified, assume USD." ) @@ -99,6 +102,9 @@ internal class ExtractV2JobCreateTest { .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") .parseTier("fast") + .addSheetName("Sheet 1") + .addSheetName("Q4 Summary") + .spreadsheetMode(true) .systemPrompt( "Extract all monetary values in USD. If a currency is not specified, assume USD." ) @@ -161,6 +167,9 @@ internal class ExtractV2JobCreateTest { .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") .parseTier("fast") + .addSheetName("Sheet 1") + .addSheetName("Q4 Summary") + .spreadsheetMode(true) .systemPrompt( "Extract all monetary values in USD. If a currency is not specified, assume USD." ) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobQueryResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobQueryResponseTest.kt index f173e80..c550275 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobQueryResponseTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobQueryResponseTest.kt @@ -39,6 +39,9 @@ internal class ExtractV2JobQueryResponseTest { .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") .parseTier("fast") + .addSheetName("Sheet 1") + .addSheetName("Q4 Summary") + .spreadsheetMode(true) .systemPrompt( "Extract all monetary values in USD. If a currency is not specified, assume USD." ) @@ -178,6 +181,9 @@ internal class ExtractV2JobQueryResponseTest { .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") .parseTier("fast") + .addSheetName("Sheet 1") + .addSheetName("Q4 Summary") + .spreadsheetMode(true) .systemPrompt( "Extract all monetary values in USD. If a currency is not specified, assume USD." ) @@ -321,6 +327,9 @@ internal class ExtractV2JobQueryResponseTest { .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") .parseTier("fast") + .addSheetName("Sheet 1") + .addSheetName("Q4 Summary") + .spreadsheetMode(true) .systemPrompt( "Extract all monetary values in USD. If a currency is not specified, assume USD." ) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobTest.kt index 56010f2..5648f0a 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobTest.kt @@ -34,6 +34,9 @@ internal class ExtractV2JobTest { .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") .parseTier("fast") + .addSheetName("Sheet 1") + .addSheetName("Q4 Summary") + .spreadsheetMode(true) .systemPrompt( "Extract all monetary values in USD. If a currency is not specified, assume USD." ) @@ -163,6 +166,9 @@ internal class ExtractV2JobTest { .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") .parseTier("fast") + .addSheetName("Sheet 1") + .addSheetName("Q4 Summary") + .spreadsheetMode(true) .systemPrompt( "Extract all monetary values in USD. If a currency is not specified, assume USD." ) @@ -297,6 +303,9 @@ internal class ExtractV2JobTest { .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") .parseTier("fast") + .addSheetName("Sheet 1") + .addSheetName("Q4 Summary") + .spreadsheetMode(true) .systemPrompt( "Extract all monetary values in USD. If a currency is not specified, assume USD." ) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsyncTest.kt index a485ea7..96c1014 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsyncTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsyncTest.kt @@ -59,6 +59,9 @@ internal class ExtractServiceAsyncTest { .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") .parseTier("fast") + .addSheetName("Sheet 1") + .addSheetName("Q4 Summary") + .spreadsheetMode(true) .systemPrompt( "Extract all monetary values in USD. If a currency is not specified, assume USD." ) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractServiceTest.kt index c9c1eb2..5061d11 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractServiceTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractServiceTest.kt @@ -59,6 +59,9 @@ internal class ExtractServiceTest { .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") .parseTier("fast") + .addSheetName("Sheet 1") + .addSheetName("Q4 Summary") + .spreadsheetMode(true) .systemPrompt( "Extract all monetary values in USD. If a currency is not specified, assume USD." ) From 2d48eeae701d159b52193094ab98c261347fa4bc Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Thu, 30 Jul 2026 06:44:27 +0000 Subject: [PATCH 10/28] fix(api): name paginated + filter schemas instead of leaking generic parametrizations (#23120) Stainless-Generated-From: 7c029bf8b7c8ee1c0e85864e690b063f4aaa1b08 --- .../models/beta/agentdata/AgentDataAggregatePageResponse.kt | 1 + .../models/beta/agentdata/AgentDataSearchPageResponse.kt | 1 + .../models/beta/retrieval/RetrievalRetrieveParams.kt | 4 ++++ .../llamacloud/models/beta/sheets/SheetListPageResponse.kt | 1 + .../llamacloud/models/classifier/jobs/JobListPageResponse.kt | 1 + .../llamacloud/models/sheets/SheetListPageResponse.kt | 1 + 6 files changed, 9 insertions(+) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/agentdata/AgentDataAggregatePageResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/agentdata/AgentDataAggregatePageResponse.kt index 206ac06..a9ba0a9 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/agentdata/AgentDataAggregatePageResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/agentdata/AgentDataAggregatePageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Paginated agent data aggregation groups. */ class AgentDataAggregatePageResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/agentdata/AgentDataSearchPageResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/agentdata/AgentDataSearchPageResponse.kt index 6f05192..a6b0040 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/agentdata/AgentDataSearchPageResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/agentdata/AgentDataSearchPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Paginated agent data search results. */ class AgentDataSearchPageResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/retrieval/RetrievalRetrieveParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/retrieval/RetrievalRetrieveParams.kt index 161fc22..e7cb8bb 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/retrieval/RetrievalRetrieveParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/retrieval/RetrievalRetrieveParams.kt @@ -1582,6 +1582,8 @@ private constructor( ) : this(parsedDirectoryFileId, mutableMapOf()) /** + * Filter on a string field. + * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ @@ -1628,6 +1630,7 @@ private constructor( additionalProperties = staticFilters.additionalProperties.toMutableMap() } + /** Filter on a string field. */ fun parsedDirectoryFileId(parsedDirectoryFileId: ParsedDirectoryFileId?) = parsedDirectoryFileId(JsonField.ofNullable(parsedDirectoryFileId)) @@ -1716,6 +1719,7 @@ private constructor( internal fun validity(): Int = (parsedDirectoryFileId.asKnown().getOrNull()?.validity() ?: 0) + /** Filter on a string field. */ class ParsedDirectoryFileId @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/sheets/SheetListPageResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/sheets/SheetListPageResponse.kt index 6c2d3be..8d60ff4 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/sheets/SheetListPageResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/sheets/SheetListPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Response schema for paginated spreadsheet job queries. */ class SheetListPageResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classifier/jobs/JobListPageResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classifier/jobs/JobListPageResponse.kt index d232721..abfc4f1 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classifier/jobs/JobListPageResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classifier/jobs/JobListPageResponse.kt @@ -19,6 +19,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Paginated list of classify jobs. */ class JobListPageResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/sheets/SheetListPageResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/sheets/SheetListPageResponse.kt index 4cc8fbe..faf7e40 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/sheets/SheetListPageResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/sheets/SheetListPageResponse.kt @@ -20,6 +20,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** Response schema for paginated spreadsheet job queries. */ class SheetListPageResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( From c3e7456a11ca7ce2d14c9b25abed0117fe01f949 Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Thu, 30 Jul 2026 20:53:43 +0000 Subject: [PATCH 11/28] feat(batches): webhooks for /api/v2/batches (#23148) Stainless-Generated-From: c85a8db2a944d2def5d78149433e7e550eb1503a --- .../models/batches/BatchCreateParams.kt | 1107 ++++++++++++++++- .../models/beta/batch/BatchCreateParams.kt | 30 + .../JobItemGetProcessingResultsResponse.kt | 30 + .../models/beta/sheets/SheetCreateParams.kt | 30 + .../models/beta/sheets/SheetsJob.kt | 30 + .../models/classify/ClassifyCreateRequest.kt | 30 + .../models/extract/ExtractV2JobCreate.kt | 30 + .../models/pipelines/LlamaParseParameters.kt | 30 + .../models/sheets/SheetCreateParams.kt | 30 + .../services/async/BatchServiceAsync.kt | 15 +- .../services/blocking/BatchService.kt | 15 +- .../models/batches/BatchCreateParamsTest.kt | 88 ++ .../services/async/BatchServiceAsyncTest.kt | 24 + .../services/blocking/BatchServiceTest.kt | 24 + 14 files changed, 1506 insertions(+), 7 deletions(-) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParams.kt index f505b67..e88e1bd 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParams.kt @@ -8,9 +8,11 @@ import ai.llamaindex.llamacloud.core.JsonField import ai.llamaindex.llamacloud.core.JsonMissing import ai.llamaindex.llamacloud.core.JsonValue import ai.llamaindex.llamacloud.core.Params +import ai.llamaindex.llamacloud.core.checkKnown 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.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter @@ -21,7 +23,20 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** Create a batch over a source directory and start processing asynchronously. */ +/** + * Create a batch over a source directory and start processing asynchronously. + * + * To be notified as the batch progresses, pass `webhook_configurations` with inline endpoints + * and/or `webhook_configuration_ids` referencing saved configurations. Batches emit `batch.pending` + * on create, `batch.running` once processing starts, and a terminal `batch.success` or + * `batch.error`. + * + * `batch.success` means the batch finished mapping every source file to a job — individual files + * may still have failed, so read `results` (with `expand=results`) for per-file outcomes. + * + * Delivery order across events is not guaranteed; key on the `status` field in the payload rather + * than arrival order. + */ class BatchCreateParams private constructor( private val organizationId: String?, @@ -51,6 +66,22 @@ private constructor( */ fun sourceDirectoryId(): String = body.sourceDirectoryId() + /** + * IDs of saved webhook configurations to notify for this job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookConfigurationIds(): Optional> = body.webhookConfigurationIds() + + /** + * Outbound webhook endpoints to notify on job status changes + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookConfigurations(): Optional> = body.webhookConfigurations() + /** * Returns the raw JSON value of [config]. * @@ -66,6 +97,23 @@ private constructor( */ fun _sourceDirectoryId(): JsonField = body._sourceDirectoryId() + /** + * Returns the raw JSON value of [webhookConfigurationIds]. + * + * Unlike [webhookConfigurationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _webhookConfigurationIds(): JsonField> = body._webhookConfigurationIds() + + /** + * Returns the raw JSON value of [webhookConfigurations]. + * + * Unlike [webhookConfigurations], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _webhookConfigurations(): JsonField> = + body._webhookConfigurations() + fun _additionalBodyProperties(): Map = body._additionalProperties() /** Additional headers to send with the request. */ @@ -126,6 +174,8 @@ private constructor( * Otherwise, it's more convenient to use the top-level setters instead: * - [config] * - [sourceDirectoryId] + * - [webhookConfigurationIds] + * - [webhookConfigurations] */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -156,6 +206,71 @@ private constructor( body.sourceDirectoryId(sourceDirectoryId) } + /** IDs of saved webhook configurations to notify for this job. */ + fun webhookConfigurationIds(webhookConfigurationIds: List?) = apply { + body.webhookConfigurationIds(webhookConfigurationIds) + } + + /** + * Alias for calling [Builder.webhookConfigurationIds] with + * `webhookConfigurationIds.orElse(null)`. + */ + fun webhookConfigurationIds(webhookConfigurationIds: Optional>) = + webhookConfigurationIds(webhookConfigurationIds.getOrNull()) + + /** + * Sets [Builder.webhookConfigurationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookConfigurationIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun webhookConfigurationIds(webhookConfigurationIds: JsonField>) = apply { + body.webhookConfigurationIds(webhookConfigurationIds) + } + + /** + * Adds a single [String] to [webhookConfigurationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookConfigurationId(webhookConfigurationId: String) = apply { + body.addWebhookConfigurationId(webhookConfigurationId) + } + + /** Outbound webhook endpoints to notify on job status changes */ + fun webhookConfigurations(webhookConfigurations: List?) = apply { + body.webhookConfigurations(webhookConfigurations) + } + + /** + * Alias for calling [Builder.webhookConfigurations] with + * `webhookConfigurations.orElse(null)`. + */ + fun webhookConfigurations(webhookConfigurations: Optional>) = + webhookConfigurations(webhookConfigurations.getOrNull()) + + /** + * Sets [Builder.webhookConfigurations] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookConfigurations] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun webhookConfigurations(webhookConfigurations: JsonField>) = + apply { + body.webhookConfigurations(webhookConfigurations) + } + + /** + * Adds a single [WebhookConfiguration] to [webhookConfigurations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookConfiguration(webhookConfiguration: WebhookConfiguration) = apply { + body.addWebhookConfiguration(webhookConfiguration) + } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) } @@ -323,6 +438,8 @@ private constructor( private constructor( private val config: JsonField, private val sourceDirectoryId: JsonField, + private val webhookConfigurationIds: JsonField>, + private val webhookConfigurations: JsonField>, private val additionalProperties: MutableMap, ) { @@ -332,7 +449,19 @@ private constructor( @JsonProperty("source_directory_id") @ExcludeMissing sourceDirectoryId: JsonField = JsonMissing.of(), - ) : this(config, sourceDirectoryId, mutableMapOf()) + @JsonProperty("webhook_configuration_ids") + @ExcludeMissing + webhookConfigurationIds: JsonField> = JsonMissing.of(), + @JsonProperty("webhook_configurations") + @ExcludeMissing + webhookConfigurations: JsonField> = JsonMissing.of(), + ) : this( + config, + sourceDirectoryId, + webhookConfigurationIds, + webhookConfigurations, + mutableMapOf(), + ) /** * Batch configuration snapshot to apply to this source directory. @@ -350,6 +479,24 @@ private constructor( */ fun sourceDirectoryId(): String = sourceDirectoryId.getRequired("source_directory_id") + /** + * IDs of saved webhook configurations to notify for this job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookConfigurationIds(): Optional> = + webhookConfigurationIds.getOptional("webhook_configuration_ids") + + /** + * Outbound webhook endpoints to notify on job status changes + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookConfigurations(): Optional> = + webhookConfigurations.getOptional("webhook_configurations") + /** * Returns the raw JSON value of [config]. * @@ -367,6 +514,26 @@ private constructor( @ExcludeMissing fun _sourceDirectoryId(): JsonField = sourceDirectoryId + /** + * Returns the raw JSON value of [webhookConfigurationIds]. + * + * Unlike [webhookConfigurationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("webhook_configuration_ids") + @ExcludeMissing + fun _webhookConfigurationIds(): JsonField> = webhookConfigurationIds + + /** + * Returns the raw JSON value of [webhookConfigurations]. + * + * Unlike [webhookConfigurations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("webhook_configurations") + @ExcludeMissing + fun _webhookConfigurations(): JsonField> = webhookConfigurations + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -398,12 +565,16 @@ private constructor( private var config: JsonField? = null private var sourceDirectoryId: JsonField? = null + private var webhookConfigurationIds: JsonField>? = null + private var webhookConfigurations: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(body: Body) = apply { config = body.config sourceDirectoryId = body.sourceDirectoryId + webhookConfigurationIds = body.webhookConfigurationIds.map { it.toMutableList() } + webhookConfigurations = body.webhookConfigurations.map { it.toMutableList() } additionalProperties = body.additionalProperties.toMutableMap() } @@ -434,6 +605,76 @@ private constructor( this.sourceDirectoryId = sourceDirectoryId } + /** IDs of saved webhook configurations to notify for this job. */ + fun webhookConfigurationIds(webhookConfigurationIds: List?) = + webhookConfigurationIds(JsonField.ofNullable(webhookConfigurationIds)) + + /** + * Alias for calling [Builder.webhookConfigurationIds] with + * `webhookConfigurationIds.orElse(null)`. + */ + fun webhookConfigurationIds(webhookConfigurationIds: Optional>) = + webhookConfigurationIds(webhookConfigurationIds.getOrNull()) + + /** + * Sets [Builder.webhookConfigurationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookConfigurationIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun webhookConfigurationIds(webhookConfigurationIds: JsonField>) = apply { + this.webhookConfigurationIds = webhookConfigurationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [webhookConfigurationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookConfigurationId(webhookConfigurationId: String) = apply { + webhookConfigurationIds = + (webhookConfigurationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("webhookConfigurationIds", it).add(webhookConfigurationId) + } + } + + /** Outbound webhook endpoints to notify on job status changes */ + fun webhookConfigurations(webhookConfigurations: List?) = + webhookConfigurations(JsonField.ofNullable(webhookConfigurations)) + + /** + * Alias for calling [Builder.webhookConfigurations] with + * `webhookConfigurations.orElse(null)`. + */ + fun webhookConfigurations(webhookConfigurations: Optional>) = + webhookConfigurations(webhookConfigurations.getOrNull()) + + /** + * Sets [Builder.webhookConfigurations] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookConfigurations] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun webhookConfigurations( + webhookConfigurations: JsonField> + ) = apply { + this.webhookConfigurations = webhookConfigurations.map { it.toMutableList() } + } + + /** + * Adds a single [WebhookConfiguration] to [webhookConfigurations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookConfiguration(webhookConfiguration: WebhookConfiguration) = apply { + webhookConfigurations = + (webhookConfigurations ?: JsonField.of(mutableListOf())).also { + checkKnown("webhookConfigurations", it).add(webhookConfiguration) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -470,6 +711,8 @@ private constructor( Body( checkRequired("config", config), checkRequired("sourceDirectoryId", sourceDirectoryId), + (webhookConfigurationIds ?: JsonMissing.of()).map { it.toImmutable() }, + (webhookConfigurations ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } @@ -492,6 +735,8 @@ private constructor( config().validate() sourceDirectoryId() + webhookConfigurationIds() + webhookConfigurations().ifPresent { it.forEach { it.validate() } } validated = true } @@ -512,7 +757,9 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (config.asKnown().getOrNull()?.validity() ?: 0) + - (if (sourceDirectoryId.asKnown().isPresent) 1 else 0) + (if (sourceDirectoryId.asKnown().isPresent) 1 else 0) + + (webhookConfigurationIds.asKnown().getOrNull()?.size ?: 0) + + (webhookConfigurations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -522,17 +769,25 @@ private constructor( return other is Body && config == other.config && sourceDirectoryId == other.sourceDirectoryId && + webhookConfigurationIds == other.webhookConfigurationIds && + webhookConfigurations == other.webhookConfigurations && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(config, sourceDirectoryId, additionalProperties) + Objects.hash( + config, + sourceDirectoryId, + webhookConfigurationIds, + webhookConfigurations, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{config=$config, sourceDirectoryId=$sourceDirectoryId, additionalProperties=$additionalProperties}" + "Body{config=$config, sourceDirectoryId=$sourceDirectoryId, webhookConfigurationIds=$webhookConfigurationIds, webhookConfigurations=$webhookConfigurations, additionalProperties=$additionalProperties}" } /** Batch configuration snapshot to apply to this source directory. */ @@ -1065,6 +1320,848 @@ private constructor( override fun toString() = "Config{job=$job, additionalProperties=$additionalProperties}" } + /** Configuration for a single outbound webhook endpoint. */ + class WebhookConfiguration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val webhookEvents: JsonField>, + private val webhookHeaders: JsonField, + private val webhookOutputFormat: JsonField, + private val webhookSigningSecret: JsonField, + private val webhookUrl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("webhook_events") + @ExcludeMissing + webhookEvents: JsonField> = JsonMissing.of(), + @JsonProperty("webhook_headers") + @ExcludeMissing + webhookHeaders: JsonField = JsonMissing.of(), + @JsonProperty("webhook_output_format") + @ExcludeMissing + webhookOutputFormat: JsonField = JsonMissing.of(), + @JsonProperty("webhook_signing_secret") + @ExcludeMissing + webhookSigningSecret: JsonField = JsonMissing.of(), + @JsonProperty("webhook_url") + @ExcludeMissing + webhookUrl: JsonField = JsonMissing.of(), + ) : this( + webhookEvents, + webhookHeaders, + webhookOutputFormat, + webhookSigningSecret, + webhookUrl, + mutableMapOf(), + ) + + /** + * Events to subscribe to (e.g. 'parse.success', 'extract.error'). If null, all events are + * delivered. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookEvents(): Optional> = + webhookEvents.getOptional("webhook_events") + + /** + * Custom HTTP headers sent with each webhook request (e.g. auth tokens) + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookHeaders(): Optional = + webhookHeaders.getOptional("webhook_headers") + + /** + * Response format sent to the webhook: 'string' (default) or 'json' + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookOutputFormat(): Optional = + webhookOutputFormat.getOptional("webhook_output_format") + + /** + * Shared signing secret used to sign webhook deliveries. When set, each request includes an + * HMAC-SHA256 signature of the request body in the 'LC-Signature' header (value + * 'sha256='). Recompute the HMAC over the raw request body with this secret to verify + * the delivery is authentic. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookSigningSecret(): Optional = + webhookSigningSecret.getOptional("webhook_signing_secret") + + /** + * URL to receive webhook POST notifications + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookUrl(): Optional = webhookUrl.getOptional("webhook_url") + + /** + * Returns the raw JSON value of [webhookEvents]. + * + * Unlike [webhookEvents], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("webhook_events") + @ExcludeMissing + fun _webhookEvents(): JsonField> = webhookEvents + + /** + * Returns the raw JSON value of [webhookHeaders]. + * + * Unlike [webhookHeaders], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("webhook_headers") + @ExcludeMissing + fun _webhookHeaders(): JsonField = webhookHeaders + + /** + * Returns the raw JSON value of [webhookOutputFormat]. + * + * Unlike [webhookOutputFormat], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("webhook_output_format") + @ExcludeMissing + fun _webhookOutputFormat(): JsonField = webhookOutputFormat + + /** + * Returns the raw JSON value of [webhookSigningSecret]. + * + * Unlike [webhookSigningSecret], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("webhook_signing_secret") + @ExcludeMissing + fun _webhookSigningSecret(): JsonField = webhookSigningSecret + + /** + * Returns the raw JSON value of [webhookUrl]. + * + * Unlike [webhookUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("webhook_url") + @ExcludeMissing + fun _webhookUrl(): JsonField = webhookUrl + + @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 [WebhookConfiguration]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebhookConfiguration]. */ + class Builder internal constructor() { + + private var webhookEvents: JsonField>? = null + private var webhookHeaders: JsonField = JsonMissing.of() + private var webhookOutputFormat: JsonField = JsonMissing.of() + private var webhookSigningSecret: JsonField = JsonMissing.of() + private var webhookUrl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webhookConfiguration: WebhookConfiguration) = apply { + webhookEvents = webhookConfiguration.webhookEvents.map { it.toMutableList() } + webhookHeaders = webhookConfiguration.webhookHeaders + webhookOutputFormat = webhookConfiguration.webhookOutputFormat + webhookSigningSecret = webhookConfiguration.webhookSigningSecret + webhookUrl = webhookConfiguration.webhookUrl + additionalProperties = webhookConfiguration.additionalProperties.toMutableMap() + } + + /** + * Events to subscribe to (e.g. 'parse.success', 'extract.error'). If null, all events + * are delivered. + */ + fun webhookEvents(webhookEvents: List?) = + webhookEvents(JsonField.ofNullable(webhookEvents)) + + /** Alias for calling [Builder.webhookEvents] with `webhookEvents.orElse(null)`. */ + fun webhookEvents(webhookEvents: Optional>) = + webhookEvents(webhookEvents.getOrNull()) + + /** + * Sets [Builder.webhookEvents] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookEvents] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun webhookEvents(webhookEvents: JsonField>) = apply { + this.webhookEvents = webhookEvents.map { it.toMutableList() } + } + + /** + * Adds a single [WebhookEvent] to [webhookEvents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookEvent(webhookEvent: WebhookEvent) = apply { + webhookEvents = + (webhookEvents ?: JsonField.of(mutableListOf())).also { + checkKnown("webhookEvents", it).add(webhookEvent) + } + } + + /** Custom HTTP headers sent with each webhook request (e.g. auth tokens) */ + fun webhookHeaders(webhookHeaders: WebhookHeaders?) = + webhookHeaders(JsonField.ofNullable(webhookHeaders)) + + /** Alias for calling [Builder.webhookHeaders] with `webhookHeaders.orElse(null)`. */ + fun webhookHeaders(webhookHeaders: Optional) = + webhookHeaders(webhookHeaders.getOrNull()) + + /** + * Sets [Builder.webhookHeaders] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookHeaders] with a well-typed [WebhookHeaders] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun webhookHeaders(webhookHeaders: JsonField) = apply { + this.webhookHeaders = webhookHeaders + } + + /** Response format sent to the webhook: 'string' (default) or 'json' */ + fun webhookOutputFormat(webhookOutputFormat: String?) = + webhookOutputFormat(JsonField.ofNullable(webhookOutputFormat)) + + /** + * Alias for calling [Builder.webhookOutputFormat] with + * `webhookOutputFormat.orElse(null)`. + */ + fun webhookOutputFormat(webhookOutputFormat: Optional) = + webhookOutputFormat(webhookOutputFormat.getOrNull()) + + /** + * Sets [Builder.webhookOutputFormat] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookOutputFormat] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun webhookOutputFormat(webhookOutputFormat: JsonField) = apply { + this.webhookOutputFormat = webhookOutputFormat + } + + /** + * Shared signing secret used to sign webhook deliveries. When set, each request + * includes an HMAC-SHA256 signature of the request body in the 'LC-Signature' header + * (value 'sha256='). Recompute the HMAC over the raw request body with this secret + * to verify the delivery is authentic. + */ + fun webhookSigningSecret(webhookSigningSecret: String?) = + webhookSigningSecret(JsonField.ofNullable(webhookSigningSecret)) + + /** + * Alias for calling [Builder.webhookSigningSecret] with + * `webhookSigningSecret.orElse(null)`. + */ + fun webhookSigningSecret(webhookSigningSecret: Optional) = + webhookSigningSecret(webhookSigningSecret.getOrNull()) + + /** + * Sets [Builder.webhookSigningSecret] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookSigningSecret] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun webhookSigningSecret(webhookSigningSecret: JsonField) = apply { + this.webhookSigningSecret = webhookSigningSecret + } + + /** URL to receive webhook POST notifications */ + fun webhookUrl(webhookUrl: String?) = webhookUrl(JsonField.ofNullable(webhookUrl)) + + /** Alias for calling [Builder.webhookUrl] with `webhookUrl.orElse(null)`. */ + fun webhookUrl(webhookUrl: Optional) = webhookUrl(webhookUrl.getOrNull()) + + /** + * Sets [Builder.webhookUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun webhookUrl(webhookUrl: JsonField) = apply { this.webhookUrl = webhookUrl } + + 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 [WebhookConfiguration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WebhookConfiguration = + WebhookConfiguration( + (webhookEvents ?: JsonMissing.of()).map { it.toImmutable() }, + webhookHeaders, + webhookOutputFormat, + webhookSigningSecret, + webhookUrl, + 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(): WebhookConfiguration = apply { + if (validated) { + return@apply + } + + webhookEvents().ifPresent { it.forEach { it.validate() } } + webhookHeaders().ifPresent { it.validate() } + webhookOutputFormat() + webhookSigningSecret() + webhookUrl() + 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 = + (webhookEvents.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (webhookHeaders.asKnown().getOrNull()?.validity() ?: 0) + + (if (webhookOutputFormat.asKnown().isPresent) 1 else 0) + + (if (webhookSigningSecret.asKnown().isPresent) 1 else 0) + + (if (webhookUrl.asKnown().isPresent) 1 else 0) + + class WebhookEvent @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 BATCH_CANCELLED = of("batch.cancelled") + + @JvmField val BATCH_ERROR = of("batch.error") + + @JvmField val BATCH_PENDING = of("batch.pending") + + @JvmField val BATCH_RUNNING = of("batch.running") + + @JvmField val BATCH_SUCCESS = of("batch.success") + + @JvmField val CLASSIFY_CANCELLED = of("classify.cancelled") + + @JvmField val CLASSIFY_ERROR = of("classify.error") + + @JvmField val CLASSIFY_PARTIAL_SUCCESS = of("classify.partial_success") + + @JvmField val CLASSIFY_PENDING = of("classify.pending") + + @JvmField val CLASSIFY_RUNNING = of("classify.running") + + @JvmField val CLASSIFY_SUCCESS = of("classify.success") + + @JvmField val EXTRACT_CANCELLED = of("extract.cancelled") + + @JvmField val EXTRACT_ERROR = of("extract.error") + + @JvmField val EXTRACT_PARTIAL_SUCCESS = of("extract.partial_success") + + @JvmField val EXTRACT_PENDING = of("extract.pending") + + @JvmField val EXTRACT_SUCCESS = of("extract.success") + + @JvmField val PARSE_CANCELLED = of("parse.cancelled") + + @JvmField val PARSE_ERROR = of("parse.error") + + @JvmField val PARSE_PARTIAL_SUCCESS = of("parse.partial_success") + + @JvmField val PARSE_PENDING = of("parse.pending") + + @JvmField val PARSE_RUNNING = of("parse.running") + + @JvmField val PARSE_SUCCESS = of("parse.success") + + @JvmField val SHEETS_CANCELLED = of("sheets.cancelled") + + @JvmField val SHEETS_ERROR = of("sheets.error") + + @JvmField val SHEETS_PARTIAL_SUCCESS = of("sheets.partial_success") + + @JvmField val SHEETS_PENDING = of("sheets.pending") + + @JvmField val SHEETS_SUCCESS = of("sheets.success") + + @JvmField val SPLIT_CANCELLED = of("split.cancelled") + + @JvmField val SPLIT_ERROR = of("split.error") + + @JvmField val SPLIT_PENDING = of("split.pending") + + @JvmField val SPLIT_PROCESSING = of("split.processing") + + @JvmField val SPLIT_SUCCESS = of("split.success") + + @JvmField val UNMAPPED_EVENT = of("unmapped_event") + + @JvmStatic fun of(value: String) = WebhookEvent(JsonField.of(value)) + } + + /** An enum containing [WebhookEvent]'s known values. */ + enum class Known { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, + CLASSIFY_CANCELLED, + CLASSIFY_ERROR, + CLASSIFY_PARTIAL_SUCCESS, + CLASSIFY_PENDING, + CLASSIFY_RUNNING, + CLASSIFY_SUCCESS, + EXTRACT_CANCELLED, + EXTRACT_ERROR, + EXTRACT_PARTIAL_SUCCESS, + EXTRACT_PENDING, + EXTRACT_SUCCESS, + PARSE_CANCELLED, + PARSE_ERROR, + PARSE_PARTIAL_SUCCESS, + PARSE_PENDING, + PARSE_RUNNING, + PARSE_SUCCESS, + SHEETS_CANCELLED, + SHEETS_ERROR, + SHEETS_PARTIAL_SUCCESS, + SHEETS_PENDING, + SHEETS_SUCCESS, + SPLIT_CANCELLED, + SPLIT_ERROR, + SPLIT_PENDING, + SPLIT_PROCESSING, + SPLIT_SUCCESS, + UNMAPPED_EVENT, + } + + /** + * An enum containing [WebhookEvent]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [WebhookEvent] 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 { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, + CLASSIFY_CANCELLED, + CLASSIFY_ERROR, + CLASSIFY_PARTIAL_SUCCESS, + CLASSIFY_PENDING, + CLASSIFY_RUNNING, + CLASSIFY_SUCCESS, + EXTRACT_CANCELLED, + EXTRACT_ERROR, + EXTRACT_PARTIAL_SUCCESS, + EXTRACT_PENDING, + EXTRACT_SUCCESS, + PARSE_CANCELLED, + PARSE_ERROR, + PARSE_PARTIAL_SUCCESS, + PARSE_PENDING, + PARSE_RUNNING, + PARSE_SUCCESS, + SHEETS_CANCELLED, + SHEETS_ERROR, + SHEETS_PARTIAL_SUCCESS, + SHEETS_PENDING, + SHEETS_SUCCESS, + SPLIT_CANCELLED, + SPLIT_ERROR, + SPLIT_PENDING, + SPLIT_PROCESSING, + SPLIT_SUCCESS, + UNMAPPED_EVENT, + /** + * An enum member indicating that [WebhookEvent] 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) { + BATCH_CANCELLED -> Value.BATCH_CANCELLED + BATCH_ERROR -> Value.BATCH_ERROR + BATCH_PENDING -> Value.BATCH_PENDING + BATCH_RUNNING -> Value.BATCH_RUNNING + BATCH_SUCCESS -> Value.BATCH_SUCCESS + CLASSIFY_CANCELLED -> Value.CLASSIFY_CANCELLED + CLASSIFY_ERROR -> Value.CLASSIFY_ERROR + CLASSIFY_PARTIAL_SUCCESS -> Value.CLASSIFY_PARTIAL_SUCCESS + CLASSIFY_PENDING -> Value.CLASSIFY_PENDING + CLASSIFY_RUNNING -> Value.CLASSIFY_RUNNING + CLASSIFY_SUCCESS -> Value.CLASSIFY_SUCCESS + EXTRACT_CANCELLED -> Value.EXTRACT_CANCELLED + EXTRACT_ERROR -> Value.EXTRACT_ERROR + EXTRACT_PARTIAL_SUCCESS -> Value.EXTRACT_PARTIAL_SUCCESS + EXTRACT_PENDING -> Value.EXTRACT_PENDING + EXTRACT_SUCCESS -> Value.EXTRACT_SUCCESS + PARSE_CANCELLED -> Value.PARSE_CANCELLED + PARSE_ERROR -> Value.PARSE_ERROR + PARSE_PARTIAL_SUCCESS -> Value.PARSE_PARTIAL_SUCCESS + PARSE_PENDING -> Value.PARSE_PENDING + PARSE_RUNNING -> Value.PARSE_RUNNING + PARSE_SUCCESS -> Value.PARSE_SUCCESS + SHEETS_CANCELLED -> Value.SHEETS_CANCELLED + SHEETS_ERROR -> Value.SHEETS_ERROR + SHEETS_PARTIAL_SUCCESS -> Value.SHEETS_PARTIAL_SUCCESS + SHEETS_PENDING -> Value.SHEETS_PENDING + SHEETS_SUCCESS -> Value.SHEETS_SUCCESS + SPLIT_CANCELLED -> Value.SPLIT_CANCELLED + SPLIT_ERROR -> Value.SPLIT_ERROR + SPLIT_PENDING -> Value.SPLIT_PENDING + SPLIT_PROCESSING -> Value.SPLIT_PROCESSING + SPLIT_SUCCESS -> Value.SPLIT_SUCCESS + UNMAPPED_EVENT -> Value.UNMAPPED_EVENT + 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) { + BATCH_CANCELLED -> Known.BATCH_CANCELLED + BATCH_ERROR -> Known.BATCH_ERROR + BATCH_PENDING -> Known.BATCH_PENDING + BATCH_RUNNING -> Known.BATCH_RUNNING + BATCH_SUCCESS -> Known.BATCH_SUCCESS + CLASSIFY_CANCELLED -> Known.CLASSIFY_CANCELLED + CLASSIFY_ERROR -> Known.CLASSIFY_ERROR + CLASSIFY_PARTIAL_SUCCESS -> Known.CLASSIFY_PARTIAL_SUCCESS + CLASSIFY_PENDING -> Known.CLASSIFY_PENDING + CLASSIFY_RUNNING -> Known.CLASSIFY_RUNNING + CLASSIFY_SUCCESS -> Known.CLASSIFY_SUCCESS + EXTRACT_CANCELLED -> Known.EXTRACT_CANCELLED + EXTRACT_ERROR -> Known.EXTRACT_ERROR + EXTRACT_PARTIAL_SUCCESS -> Known.EXTRACT_PARTIAL_SUCCESS + EXTRACT_PENDING -> Known.EXTRACT_PENDING + EXTRACT_SUCCESS -> Known.EXTRACT_SUCCESS + PARSE_CANCELLED -> Known.PARSE_CANCELLED + PARSE_ERROR -> Known.PARSE_ERROR + PARSE_PARTIAL_SUCCESS -> Known.PARSE_PARTIAL_SUCCESS + PARSE_PENDING -> Known.PARSE_PENDING + PARSE_RUNNING -> Known.PARSE_RUNNING + PARSE_SUCCESS -> Known.PARSE_SUCCESS + SHEETS_CANCELLED -> Known.SHEETS_CANCELLED + SHEETS_ERROR -> Known.SHEETS_ERROR + SHEETS_PARTIAL_SUCCESS -> Known.SHEETS_PARTIAL_SUCCESS + SHEETS_PENDING -> Known.SHEETS_PENDING + SHEETS_SUCCESS -> Known.SHEETS_SUCCESS + SPLIT_CANCELLED -> Known.SPLIT_CANCELLED + SPLIT_ERROR -> Known.SPLIT_ERROR + SPLIT_PENDING -> Known.SPLIT_PENDING + SPLIT_PROCESSING -> Known.SPLIT_PROCESSING + SPLIT_SUCCESS -> Known.SPLIT_SUCCESS + UNMAPPED_EVENT -> Known.UNMAPPED_EVENT + else -> throw LlamaCloudInvalidDataException("Unknown WebhookEvent: $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(): WebhookEvent = 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 WebhookEvent && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Custom HTTP headers sent with each webhook request (e.g. auth tokens) */ + class WebhookHeaders + @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 [WebhookHeaders]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebhookHeaders]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webhookHeaders: WebhookHeaders) = apply { + additionalProperties = webhookHeaders.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 [WebhookHeaders]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WebhookHeaders = WebhookHeaders(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(): WebhookHeaders = 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 WebhookHeaders && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "WebhookHeaders{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WebhookConfiguration && + webhookEvents == other.webhookEvents && + webhookHeaders == other.webhookHeaders && + webhookOutputFormat == other.webhookOutputFormat && + webhookSigningSecret == other.webhookSigningSecret && + webhookUrl == other.webhookUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + webhookEvents, + webhookHeaders, + webhookOutputFormat, + webhookSigningSecret, + webhookUrl, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "WebhookConfiguration{webhookEvents=$webhookEvents, webhookHeaders=$webhookHeaders, webhookOutputFormat=$webhookOutputFormat, webhookSigningSecret=$webhookSigningSecret, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateParams.kt index 3d6951b..ef6f429 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateParams.kt @@ -9789,6 +9789,16 @@ private constructor( companion object { + @JvmField val BATCH_CANCELLED = of("batch.cancelled") + + @JvmField val BATCH_ERROR = of("batch.error") + + @JvmField val BATCH_PENDING = of("batch.pending") + + @JvmField val BATCH_RUNNING = of("batch.running") + + @JvmField val BATCH_SUCCESS = of("batch.success") + @JvmField val CLASSIFY_CANCELLED = of("classify.cancelled") @JvmField val CLASSIFY_ERROR = of("classify.error") @@ -9850,6 +9860,11 @@ private constructor( /** An enum containing [WebhookEvent]'s known values. */ enum class Known { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, CLASSIFY_CANCELLED, CLASSIFY_ERROR, CLASSIFY_PARTIAL_SUCCESS, @@ -9892,6 +9907,11 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, CLASSIFY_CANCELLED, CLASSIFY_ERROR, CLASSIFY_PARTIAL_SUCCESS, @@ -9936,6 +9956,11 @@ private constructor( */ fun value(): Value = when (this) { + BATCH_CANCELLED -> Value.BATCH_CANCELLED + BATCH_ERROR -> Value.BATCH_ERROR + BATCH_PENDING -> Value.BATCH_PENDING + BATCH_RUNNING -> Value.BATCH_RUNNING + BATCH_SUCCESS -> Value.BATCH_SUCCESS CLASSIFY_CANCELLED -> Value.CLASSIFY_CANCELLED CLASSIFY_ERROR -> Value.CLASSIFY_ERROR CLASSIFY_PARTIAL_SUCCESS -> Value.CLASSIFY_PARTIAL_SUCCESS @@ -9978,6 +10003,11 @@ private constructor( */ fun known(): Known = when (this) { + BATCH_CANCELLED -> Known.BATCH_CANCELLED + BATCH_ERROR -> Known.BATCH_ERROR + BATCH_PENDING -> Known.BATCH_PENDING + BATCH_RUNNING -> Known.BATCH_RUNNING + BATCH_SUCCESS -> Known.BATCH_SUCCESS CLASSIFY_CANCELLED -> Known.CLASSIFY_CANCELLED CLASSIFY_ERROR -> Known.CLASSIFY_ERROR CLASSIFY_PARTIAL_SUCCESS -> Known.CLASSIFY_PARTIAL_SUCCESS diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsResponse.kt index 835ab40..7c6e58f 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsResponse.kt @@ -9898,6 +9898,16 @@ private constructor( companion object { + @JvmField val BATCH_CANCELLED = of("batch.cancelled") + + @JvmField val BATCH_ERROR = of("batch.error") + + @JvmField val BATCH_PENDING = of("batch.pending") + + @JvmField val BATCH_RUNNING = of("batch.running") + + @JvmField val BATCH_SUCCESS = of("batch.success") + @JvmField val CLASSIFY_CANCELLED = of("classify.cancelled") @JvmField val CLASSIFY_ERROR = of("classify.error") @@ -9961,6 +9971,11 @@ private constructor( /** An enum containing [WebhookEvent]'s known values. */ enum class Known { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, CLASSIFY_CANCELLED, CLASSIFY_ERROR, CLASSIFY_PARTIAL_SUCCESS, @@ -10003,6 +10018,11 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, CLASSIFY_CANCELLED, CLASSIFY_ERROR, CLASSIFY_PARTIAL_SUCCESS, @@ -10048,6 +10068,11 @@ private constructor( */ fun value(): Value = when (this) { + BATCH_CANCELLED -> Value.BATCH_CANCELLED + BATCH_ERROR -> Value.BATCH_ERROR + BATCH_PENDING -> Value.BATCH_PENDING + BATCH_RUNNING -> Value.BATCH_RUNNING + BATCH_SUCCESS -> Value.BATCH_SUCCESS CLASSIFY_CANCELLED -> Value.CLASSIFY_CANCELLED CLASSIFY_ERROR -> Value.CLASSIFY_ERROR CLASSIFY_PARTIAL_SUCCESS -> Value.CLASSIFY_PARTIAL_SUCCESS @@ -10090,6 +10115,11 @@ private constructor( */ fun known(): Known = when (this) { + BATCH_CANCELLED -> Known.BATCH_CANCELLED + BATCH_ERROR -> Known.BATCH_ERROR + BATCH_PENDING -> Known.BATCH_PENDING + BATCH_RUNNING -> Known.BATCH_RUNNING + BATCH_SUCCESS -> Known.BATCH_SUCCESS CLASSIFY_CANCELLED -> Known.CLASSIFY_CANCELLED CLASSIFY_ERROR -> Known.CLASSIFY_ERROR CLASSIFY_PARTIAL_SUCCESS -> Known.CLASSIFY_PARTIAL_SUCCESS diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/sheets/SheetCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/sheets/SheetCreateParams.kt index 11c86b3..d12a465 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/sheets/SheetCreateParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/sheets/SheetCreateParams.kt @@ -1339,6 +1339,16 @@ private constructor( companion object { + @JvmField val BATCH_CANCELLED = of("batch.cancelled") + + @JvmField val BATCH_ERROR = of("batch.error") + + @JvmField val BATCH_PENDING = of("batch.pending") + + @JvmField val BATCH_RUNNING = of("batch.running") + + @JvmField val BATCH_SUCCESS = of("batch.success") + @JvmField val CLASSIFY_CANCELLED = of("classify.cancelled") @JvmField val CLASSIFY_ERROR = of("classify.error") @@ -1400,6 +1410,11 @@ private constructor( /** An enum containing [WebhookEvent]'s known values. */ enum class Known { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, CLASSIFY_CANCELLED, CLASSIFY_ERROR, CLASSIFY_PARTIAL_SUCCESS, @@ -1440,6 +1455,11 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, CLASSIFY_CANCELLED, CLASSIFY_ERROR, CLASSIFY_PARTIAL_SUCCESS, @@ -1484,6 +1504,11 @@ private constructor( */ fun value(): Value = when (this) { + BATCH_CANCELLED -> Value.BATCH_CANCELLED + BATCH_ERROR -> Value.BATCH_ERROR + BATCH_PENDING -> Value.BATCH_PENDING + BATCH_RUNNING -> Value.BATCH_RUNNING + BATCH_SUCCESS -> Value.BATCH_SUCCESS CLASSIFY_CANCELLED -> Value.CLASSIFY_CANCELLED CLASSIFY_ERROR -> Value.CLASSIFY_ERROR CLASSIFY_PARTIAL_SUCCESS -> Value.CLASSIFY_PARTIAL_SUCCESS @@ -1526,6 +1551,11 @@ private constructor( */ fun known(): Known = when (this) { + BATCH_CANCELLED -> Known.BATCH_CANCELLED + BATCH_ERROR -> Known.BATCH_ERROR + BATCH_PENDING -> Known.BATCH_PENDING + BATCH_RUNNING -> Known.BATCH_RUNNING + BATCH_SUCCESS -> Known.BATCH_SUCCESS CLASSIFY_CANCELLED -> Known.CLASSIFY_CANCELLED CLASSIFY_ERROR -> Known.CLASSIFY_ERROR CLASSIFY_PARTIAL_SUCCESS -> Known.CLASSIFY_PARTIAL_SUCCESS diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/sheets/SheetsJob.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/sheets/SheetsJob.kt index 47692ca..c902811 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/sheets/SheetsJob.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/sheets/SheetsJob.kt @@ -1706,6 +1706,16 @@ private constructor( companion object { + @JvmField val BATCH_CANCELLED = of("batch.cancelled") + + @JvmField val BATCH_ERROR = of("batch.error") + + @JvmField val BATCH_PENDING = of("batch.pending") + + @JvmField val BATCH_RUNNING = of("batch.running") + + @JvmField val BATCH_SUCCESS = of("batch.success") + @JvmField val CLASSIFY_CANCELLED = of("classify.cancelled") @JvmField val CLASSIFY_ERROR = of("classify.error") @@ -1767,6 +1777,11 @@ private constructor( /** An enum containing [WebhookEvent]'s known values. */ enum class Known { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, CLASSIFY_CANCELLED, CLASSIFY_ERROR, CLASSIFY_PARTIAL_SUCCESS, @@ -1808,6 +1823,11 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, CLASSIFY_CANCELLED, CLASSIFY_ERROR, CLASSIFY_PARTIAL_SUCCESS, @@ -1852,6 +1872,11 @@ private constructor( */ fun value(): Value = when (this) { + BATCH_CANCELLED -> Value.BATCH_CANCELLED + BATCH_ERROR -> Value.BATCH_ERROR + BATCH_PENDING -> Value.BATCH_PENDING + BATCH_RUNNING -> Value.BATCH_RUNNING + BATCH_SUCCESS -> Value.BATCH_SUCCESS CLASSIFY_CANCELLED -> Value.CLASSIFY_CANCELLED CLASSIFY_ERROR -> Value.CLASSIFY_ERROR CLASSIFY_PARTIAL_SUCCESS -> Value.CLASSIFY_PARTIAL_SUCCESS @@ -1894,6 +1919,11 @@ private constructor( */ fun known(): Known = when (this) { + BATCH_CANCELLED -> Known.BATCH_CANCELLED + BATCH_ERROR -> Known.BATCH_ERROR + BATCH_PENDING -> Known.BATCH_PENDING + BATCH_RUNNING -> Known.BATCH_RUNNING + BATCH_SUCCESS -> Known.BATCH_SUCCESS CLASSIFY_CANCELLED -> Known.CLASSIFY_CANCELLED CLASSIFY_ERROR -> Known.CLASSIFY_ERROR CLASSIFY_PARTIAL_SUCCESS -> Known.CLASSIFY_PARTIAL_SUCCESS diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCreateRequest.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCreateRequest.kt index d575ede..9c90604 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCreateRequest.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCreateRequest.kt @@ -908,6 +908,16 @@ private constructor( companion object { + @JvmField val BATCH_CANCELLED = of("batch.cancelled") + + @JvmField val BATCH_ERROR = of("batch.error") + + @JvmField val BATCH_PENDING = of("batch.pending") + + @JvmField val BATCH_RUNNING = of("batch.running") + + @JvmField val BATCH_SUCCESS = of("batch.success") + @JvmField val CLASSIFY_CANCELLED = of("classify.cancelled") @JvmField val CLASSIFY_ERROR = of("classify.error") @@ -969,6 +979,11 @@ private constructor( /** An enum containing [WebhookEvent]'s known values. */ enum class Known { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, CLASSIFY_CANCELLED, CLASSIFY_ERROR, CLASSIFY_PARTIAL_SUCCESS, @@ -1009,6 +1024,11 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, CLASSIFY_CANCELLED, CLASSIFY_ERROR, CLASSIFY_PARTIAL_SUCCESS, @@ -1053,6 +1073,11 @@ private constructor( */ fun value(): Value = when (this) { + BATCH_CANCELLED -> Value.BATCH_CANCELLED + BATCH_ERROR -> Value.BATCH_ERROR + BATCH_PENDING -> Value.BATCH_PENDING + BATCH_RUNNING -> Value.BATCH_RUNNING + BATCH_SUCCESS -> Value.BATCH_SUCCESS CLASSIFY_CANCELLED -> Value.CLASSIFY_CANCELLED CLASSIFY_ERROR -> Value.CLASSIFY_ERROR CLASSIFY_PARTIAL_SUCCESS -> Value.CLASSIFY_PARTIAL_SUCCESS @@ -1095,6 +1120,11 @@ private constructor( */ fun known(): Known = when (this) { + BATCH_CANCELLED -> Known.BATCH_CANCELLED + BATCH_ERROR -> Known.BATCH_ERROR + BATCH_PENDING -> Known.BATCH_PENDING + BATCH_RUNNING -> Known.BATCH_RUNNING + BATCH_SUCCESS -> Known.BATCH_SUCCESS CLASSIFY_CANCELLED -> Known.CLASSIFY_CANCELLED CLASSIFY_ERROR -> Known.CLASSIFY_ERROR CLASSIFY_PARTIAL_SUCCESS -> Known.CLASSIFY_PARTIAL_SUCCESS diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobCreate.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobCreate.kt index eba4889..e589149 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobCreate.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobCreate.kt @@ -781,6 +781,16 @@ private constructor( companion object { + @JvmField val BATCH_CANCELLED = of("batch.cancelled") + + @JvmField val BATCH_ERROR = of("batch.error") + + @JvmField val BATCH_PENDING = of("batch.pending") + + @JvmField val BATCH_RUNNING = of("batch.running") + + @JvmField val BATCH_SUCCESS = of("batch.success") + @JvmField val CLASSIFY_CANCELLED = of("classify.cancelled") @JvmField val CLASSIFY_ERROR = of("classify.error") @@ -842,6 +852,11 @@ private constructor( /** An enum containing [WebhookEvent]'s known values. */ enum class Known { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, CLASSIFY_CANCELLED, CLASSIFY_ERROR, CLASSIFY_PARTIAL_SUCCESS, @@ -882,6 +897,11 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, CLASSIFY_CANCELLED, CLASSIFY_ERROR, CLASSIFY_PARTIAL_SUCCESS, @@ -926,6 +946,11 @@ private constructor( */ fun value(): Value = when (this) { + BATCH_CANCELLED -> Value.BATCH_CANCELLED + BATCH_ERROR -> Value.BATCH_ERROR + BATCH_PENDING -> Value.BATCH_PENDING + BATCH_RUNNING -> Value.BATCH_RUNNING + BATCH_SUCCESS -> Value.BATCH_SUCCESS CLASSIFY_CANCELLED -> Value.CLASSIFY_CANCELLED CLASSIFY_ERROR -> Value.CLASSIFY_ERROR CLASSIFY_PARTIAL_SUCCESS -> Value.CLASSIFY_PARTIAL_SUCCESS @@ -968,6 +993,11 @@ private constructor( */ fun known(): Known = when (this) { + BATCH_CANCELLED -> Known.BATCH_CANCELLED + BATCH_ERROR -> Known.BATCH_ERROR + BATCH_PENDING -> Known.BATCH_PENDING + BATCH_RUNNING -> Known.BATCH_RUNNING + BATCH_SUCCESS -> Known.BATCH_SUCCESS CLASSIFY_CANCELLED -> Known.CLASSIFY_CANCELLED CLASSIFY_ERROR -> Known.CLASSIFY_ERROR CLASSIFY_PARTIAL_SUCCESS -> Known.CLASSIFY_PARTIAL_SUCCESS diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/pipelines/LlamaParseParameters.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/pipelines/LlamaParseParameters.kt index 017999a..93f65cd 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/pipelines/LlamaParseParameters.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/pipelines/LlamaParseParameters.kt @@ -6743,6 +6743,16 @@ private constructor( companion object { + @JvmField val BATCH_CANCELLED = of("batch.cancelled") + + @JvmField val BATCH_ERROR = of("batch.error") + + @JvmField val BATCH_PENDING = of("batch.pending") + + @JvmField val BATCH_RUNNING = of("batch.running") + + @JvmField val BATCH_SUCCESS = of("batch.success") + @JvmField val CLASSIFY_CANCELLED = of("classify.cancelled") @JvmField val CLASSIFY_ERROR = of("classify.error") @@ -6804,6 +6814,11 @@ private constructor( /** An enum containing [WebhookEvent]'s known values. */ enum class Known { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, CLASSIFY_CANCELLED, CLASSIFY_ERROR, CLASSIFY_PARTIAL_SUCCESS, @@ -6844,6 +6859,11 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, CLASSIFY_CANCELLED, CLASSIFY_ERROR, CLASSIFY_PARTIAL_SUCCESS, @@ -6888,6 +6908,11 @@ private constructor( */ fun value(): Value = when (this) { + BATCH_CANCELLED -> Value.BATCH_CANCELLED + BATCH_ERROR -> Value.BATCH_ERROR + BATCH_PENDING -> Value.BATCH_PENDING + BATCH_RUNNING -> Value.BATCH_RUNNING + BATCH_SUCCESS -> Value.BATCH_SUCCESS CLASSIFY_CANCELLED -> Value.CLASSIFY_CANCELLED CLASSIFY_ERROR -> Value.CLASSIFY_ERROR CLASSIFY_PARTIAL_SUCCESS -> Value.CLASSIFY_PARTIAL_SUCCESS @@ -6930,6 +6955,11 @@ private constructor( */ fun known(): Known = when (this) { + BATCH_CANCELLED -> Known.BATCH_CANCELLED + BATCH_ERROR -> Known.BATCH_ERROR + BATCH_PENDING -> Known.BATCH_PENDING + BATCH_RUNNING -> Known.BATCH_RUNNING + BATCH_SUCCESS -> Known.BATCH_SUCCESS CLASSIFY_CANCELLED -> Known.CLASSIFY_CANCELLED CLASSIFY_ERROR -> Known.CLASSIFY_ERROR CLASSIFY_PARTIAL_SUCCESS -> Known.CLASSIFY_PARTIAL_SUCCESS diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/sheets/SheetCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/sheets/SheetCreateParams.kt index 4dbf20b..59a1cf5 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/sheets/SheetCreateParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/sheets/SheetCreateParams.kt @@ -1339,6 +1339,16 @@ private constructor( companion object { + @JvmField val BATCH_CANCELLED = of("batch.cancelled") + + @JvmField val BATCH_ERROR = of("batch.error") + + @JvmField val BATCH_PENDING = of("batch.pending") + + @JvmField val BATCH_RUNNING = of("batch.running") + + @JvmField val BATCH_SUCCESS = of("batch.success") + @JvmField val CLASSIFY_CANCELLED = of("classify.cancelled") @JvmField val CLASSIFY_ERROR = of("classify.error") @@ -1400,6 +1410,11 @@ private constructor( /** An enum containing [WebhookEvent]'s known values. */ enum class Known { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, CLASSIFY_CANCELLED, CLASSIFY_ERROR, CLASSIFY_PARTIAL_SUCCESS, @@ -1440,6 +1455,11 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, CLASSIFY_CANCELLED, CLASSIFY_ERROR, CLASSIFY_PARTIAL_SUCCESS, @@ -1484,6 +1504,11 @@ private constructor( */ fun value(): Value = when (this) { + BATCH_CANCELLED -> Value.BATCH_CANCELLED + BATCH_ERROR -> Value.BATCH_ERROR + BATCH_PENDING -> Value.BATCH_PENDING + BATCH_RUNNING -> Value.BATCH_RUNNING + BATCH_SUCCESS -> Value.BATCH_SUCCESS CLASSIFY_CANCELLED -> Value.CLASSIFY_CANCELLED CLASSIFY_ERROR -> Value.CLASSIFY_ERROR CLASSIFY_PARTIAL_SUCCESS -> Value.CLASSIFY_PARTIAL_SUCCESS @@ -1526,6 +1551,11 @@ private constructor( */ fun known(): Known = when (this) { + BATCH_CANCELLED -> Known.BATCH_CANCELLED + BATCH_ERROR -> Known.BATCH_ERROR + BATCH_PENDING -> Known.BATCH_PENDING + BATCH_RUNNING -> Known.BATCH_RUNNING + BATCH_SUCCESS -> Known.BATCH_SUCCESS CLASSIFY_CANCELLED -> Known.CLASSIFY_CANCELLED CLASSIFY_ERROR -> Known.CLASSIFY_ERROR CLASSIFY_PARTIAL_SUCCESS -> Known.CLASSIFY_PARTIAL_SUCCESS diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsync.kt index a52c380..d26f2fe 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsync.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsync.kt @@ -28,7 +28,20 @@ interface BatchServiceAsync { */ fun withOptions(modifier: Consumer): BatchServiceAsync - /** Create a batch over a source directory and start processing asynchronously. */ + /** + * Create a batch over a source directory and start processing asynchronously. + * + * To be notified as the batch progresses, pass `webhook_configurations` with inline endpoints + * and/or `webhook_configuration_ids` referencing saved configurations. Batches emit + * `batch.pending` on create, `batch.running` once processing starts, and a terminal + * `batch.success` or `batch.error`. + * + * `batch.success` means the batch finished mapping every source file to a job — individual + * files may still have failed, so read `results` (with `expand=results`) for per-file outcomes. + * + * Delivery order across events is not guaranteed; key on the `status` field in the payload + * rather than arrival order. + */ fun create(params: BatchCreateParams): CompletableFuture = create(params, RequestOptions.none()) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchService.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchService.kt index f5e892c..24634ab 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchService.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchService.kt @@ -28,7 +28,20 @@ interface BatchService { */ fun withOptions(modifier: Consumer): BatchService - /** Create a batch over a source directory and start processing asynchronously. */ + /** + * Create a batch over a source directory and start processing asynchronously. + * + * To be notified as the batch progresses, pass `webhook_configurations` with inline endpoints + * and/or `webhook_configuration_ids` referencing saved configurations. Batches emit + * `batch.pending` on create, `batch.running` once processing starts, and a terminal + * `batch.success` or `batch.error`. + * + * `batch.success` means the batch finished mapping every source file to a job — individual + * files may still have failed, so read `results` (with `expand=results`) for per-file outcomes. + * + * Delivery order across events is not guaranteed; key on the `status` field in the payload + * rather than arrival order. + */ fun create(params: BatchCreateParams): BatchCreateResponse = create(params, RequestOptions.none()) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParamsTest.kt index 25711b3..56f4860 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParamsTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParamsTest.kt @@ -2,7 +2,9 @@ package ai.llamaindex.llamacloud.models.batches +import ai.llamaindex.llamacloud.core.JsonValue import ai.llamaindex.llamacloud.core.http.QueryParams +import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -24,6 +26,26 @@ internal class BatchCreateParamsTest { .build() ) .sourceDirectoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") + .addWebhookConfiguration( + BatchCreateParams.WebhookConfiguration.builder() + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS + ) + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR + ) + .webhookHeaders( + BatchCreateParams.WebhookConfiguration.WebhookHeaders.builder() + .putAdditionalProperty("Authorization", JsonValue.from("Bearer sk-...")) + .build() + ) + .webhookOutputFormat("json") + .webhookSigningSecret("whsec_...") + .webhookUrl("https://example.com/webhooks/llamacloud") + .build() + ) .build() } @@ -44,6 +66,29 @@ internal class BatchCreateParamsTest { .build() ) .sourceDirectoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") + .addWebhookConfiguration( + BatchCreateParams.WebhookConfiguration.builder() + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS + ) + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR + ) + .webhookHeaders( + BatchCreateParams.WebhookConfiguration.WebhookHeaders.builder() + .putAdditionalProperty( + "Authorization", + JsonValue.from("Bearer sk-..."), + ) + .build() + ) + .webhookOutputFormat("json") + .webhookSigningSecret("whsec_...") + .webhookUrl("https://example.com/webhooks/llamacloud") + .build() + ) .build() val queryParams = params._queryParams() @@ -96,6 +141,29 @@ internal class BatchCreateParamsTest { .build() ) .sourceDirectoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") + .addWebhookConfiguration( + BatchCreateParams.WebhookConfiguration.builder() + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS + ) + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR + ) + .webhookHeaders( + BatchCreateParams.WebhookConfiguration.WebhookHeaders.builder() + .putAdditionalProperty( + "Authorization", + JsonValue.from("Bearer sk-..."), + ) + .build() + ) + .webhookOutputFormat("json") + .webhookSigningSecret("whsec_...") + .webhookUrl("https://example.com/webhooks/llamacloud") + .build() + ) .build() val body = params._body() @@ -112,6 +180,26 @@ internal class BatchCreateParamsTest { .build() ) assertThat(body.sourceDirectoryId()).isEqualTo("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + assertThat(body.webhookConfigurationIds().getOrNull()).containsExactly("whc-...", "whc-...") + assertThat(body.webhookConfigurations().getOrNull()) + .containsExactly( + BatchCreateParams.WebhookConfiguration.builder() + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS + ) + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR + ) + .webhookHeaders( + BatchCreateParams.WebhookConfiguration.WebhookHeaders.builder() + .putAdditionalProperty("Authorization", JsonValue.from("Bearer sk-...")) + .build() + ) + .webhookOutputFormat("json") + .webhookSigningSecret("whsec_...") + .webhookUrl("https://example.com/webhooks/llamacloud") + .build() + ) } @Test diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncTest.kt index 07acb3a..4bcdfe2 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncTest.kt @@ -3,6 +3,7 @@ package ai.llamaindex.llamacloud.services.async import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClientAsync +import ai.llamaindex.llamacloud.core.JsonValue import ai.llamaindex.llamacloud.models.batches.BatchCreateParams import ai.llamaindex.llamacloud.models.batches.BatchGetParams import org.junit.jupiter.api.Disabled @@ -32,6 +33,29 @@ internal class BatchServiceAsyncTest { .build() ) .sourceDirectoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") + .addWebhookConfiguration( + BatchCreateParams.WebhookConfiguration.builder() + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS + ) + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR + ) + .webhookHeaders( + BatchCreateParams.WebhookConfiguration.WebhookHeaders.builder() + .putAdditionalProperty( + "Authorization", + JsonValue.from("Bearer sk-..."), + ) + .build() + ) + .webhookOutputFormat("json") + .webhookSigningSecret("whsec_...") + .webhookUrl("https://example.com/webhooks/llamacloud") + .build() + ) .build() ) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceTest.kt index 2a331af..a0da2cb 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceTest.kt @@ -3,6 +3,7 @@ package ai.llamaindex.llamacloud.services.blocking import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClient +import ai.llamaindex.llamacloud.core.JsonValue import ai.llamaindex.llamacloud.models.batches.BatchCreateParams import ai.llamaindex.llamacloud.models.batches.BatchGetParams import org.junit.jupiter.api.Disabled @@ -32,6 +33,29 @@ internal class BatchServiceTest { .build() ) .sourceDirectoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") + .addWebhookConfiguration( + BatchCreateParams.WebhookConfiguration.builder() + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS + ) + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR + ) + .webhookHeaders( + BatchCreateParams.WebhookConfiguration.WebhookHeaders.builder() + .putAdditionalProperty( + "Authorization", + JsonValue.from("Bearer sk-..."), + ) + .build() + ) + .webhookOutputFormat("json") + .webhookSigningSecret("whsec_...") + .webhookUrl("https://example.com/webhooks/llamacloud") + .build() + ) .build() ) From 03e853469760520255741a2529ad98b8695e2b1c Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Fri, 31 Jul 2026 06:42:36 +0000 Subject: [PATCH 12/28] feat(parse): extract Word revision annotations (#23152) Stainless-Generated-From: 2f04fe178d85dfffccaffbc8cdf071ca973b9acf --- .../models/beta/batch/BatchCreateParams.kt | 60 +- .../JobItemGetProcessingResultsResponse.kt | 60 +- .../configurations/ParseV2Parameters.kt | 71 +- .../models/parsing/ParsingCreateParams.kt | 71 +- .../models/parsing/ParsingGetResponse.kt | 2122 ++++++++++++++++- .../models/pipelines/LlamaParseParameters.kt | 56 +- .../beta/batch/BatchCreateParamsTest.kt | 5 + ...JobItemGetProcessingResultsResponseTest.kt | 3 + .../configurations/ParseV2ParametersTest.kt | 3 + .../models/parsing/ParsingCreateParamsTest.kt | 4 + .../models/parsing/ParsingGetResponseTest.kt | 178 ++ .../pipelines/LlamaParseParametersTest.kt | 3 + .../pipelines/PipelineCreateParamsTest.kt | 4 + .../models/pipelines/PipelineCreateTest.kt | 3 + .../models/pipelines/PipelineTest.kt | 3 + .../pipelines/PipelineUpdateParamsTest.kt | 3 + .../pipelines/PipelineUpsertParamsTest.kt | 4 + .../llamacloud/services/ServiceParamsTest.kt | 1 + .../services/async/ParsingServiceAsyncTest.kt | 1 + .../async/PipelineServiceAsyncTest.kt | 3 + .../async/beta/BatchServiceAsyncTest.kt | 1 + .../services/blocking/ParsingServiceTest.kt | 1 + .../services/blocking/PipelineServiceTest.kt | 3 + .../blocking/beta/BatchServiceTest.kt | 1 + 24 files changed, 2652 insertions(+), 12 deletions(-) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateParams.kt index ef6f429..69334ca 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateParams.kt @@ -1862,6 +1862,7 @@ private constructor( private val adaptiveLongTable: JsonField, private val aggressiveTableExtraction: JsonField, private val annotateLinks: JsonField, + private val annotateRevisions: JsonField, private val autoMode: JsonField, private val autoModeConfigurationJson: JsonField, private val autoModeTriggerOnImageInPage: JsonField, @@ -1999,6 +2000,9 @@ private constructor( @JsonProperty("annotate_links") @ExcludeMissing annotateLinks: JsonField = JsonMissing.of(), + @JsonProperty("annotate_revisions") + @ExcludeMissing + annotateRevisions: JsonField = JsonMissing.of(), @JsonProperty("auto_mode") @ExcludeMissing autoMode: JsonField = JsonMissing.of(), @@ -2370,6 +2374,7 @@ private constructor( adaptiveLongTable, aggressiveTableExtraction, annotateLinks, + annotateRevisions, autoMode, autoModeConfigurationJson, autoModeTriggerOnImageInPage, @@ -2516,6 +2521,13 @@ private constructor( */ fun annotateLinks(): Optional = annotateLinks.getOptional("annotate_links") + /** + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun annotateRevisions(): Optional = + annotateRevisions.getOptional("annotate_revisions") + /** * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type * (e.g. if the server responded with an unexpected value). @@ -3413,6 +3425,16 @@ private constructor( @ExcludeMissing fun _annotateLinks(): JsonField = annotateLinks + /** + * Returns the raw JSON value of [annotateRevisions]. + * + * Unlike [annotateRevisions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("annotate_revisions") + @ExcludeMissing + fun _annotateRevisions(): JsonField = annotateRevisions + /** * Returns the raw JSON value of [autoMode]. * @@ -4676,6 +4698,7 @@ private constructor( private var adaptiveLongTable: JsonField = JsonMissing.of() private var aggressiveTableExtraction: JsonField = JsonMissing.of() private var annotateLinks: JsonField = JsonMissing.of() + private var annotateRevisions: JsonField = JsonMissing.of() private var autoMode: JsonField = JsonMissing.of() private var autoModeConfigurationJson: JsonField = JsonMissing.of() private var autoModeTriggerOnImageInPage: JsonField = JsonMissing.of() @@ -4822,6 +4845,7 @@ private constructor( adaptiveLongTable = parameters.adaptiveLongTable aggressiveTableExtraction = parameters.aggressiveTableExtraction annotateLinks = parameters.annotateLinks + annotateRevisions = parameters.annotateRevisions autoMode = parameters.autoMode autoModeConfigurationJson = parameters.autoModeConfigurationJson autoModeTriggerOnImageInPage = parameters.autoModeTriggerOnImageInPage @@ -5047,6 +5071,35 @@ private constructor( this.annotateLinks = annotateLinks } + fun annotateRevisions(annotateRevisions: Boolean?) = + annotateRevisions(JsonField.ofNullable(annotateRevisions)) + + /** + * Alias for [Builder.annotateRevisions]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun annotateRevisions(annotateRevisions: Boolean) = + annotateRevisions(annotateRevisions as Boolean?) + + /** + * Alias for calling [Builder.annotateRevisions] with + * `annotateRevisions.orElse(null)`. + */ + fun annotateRevisions(annotateRevisions: Optional) = + annotateRevisions(annotateRevisions.getOrNull()) + + /** + * Sets [Builder.annotateRevisions] to an arbitrary JSON value. + * + * You should usually call [Builder.annotateRevisions] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun annotateRevisions(annotateRevisions: JsonField) = apply { + this.annotateRevisions = annotateRevisions + } + fun autoMode(autoMode: Boolean?) = autoMode(JsonField.ofNullable(autoMode)) /** @@ -8261,6 +8314,7 @@ private constructor( adaptiveLongTable, aggressiveTableExtraction, annotateLinks, + annotateRevisions, autoMode, autoModeConfigurationJson, autoModeTriggerOnImageInPage, @@ -8408,6 +8462,7 @@ private constructor( adaptiveLongTable() aggressiveTableExtraction() annotateLinks() + annotateRevisions() autoMode() autoModeConfigurationJson() autoModeTriggerOnImageInPage() @@ -8553,6 +8608,7 @@ private constructor( (if (adaptiveLongTable.asKnown().isPresent) 1 else 0) + (if (aggressiveTableExtraction.asKnown().isPresent) 1 else 0) + (if (annotateLinks.asKnown().isPresent) 1 else 0) + + (if (annotateRevisions.asKnown().isPresent) 1 else 0) + (if (autoMode.asKnown().isPresent) 1 else 0) + (if (autoModeConfigurationJson.asKnown().isPresent) 1 else 0) + (if (autoModeTriggerOnImageInPage.asKnown().isPresent) 1 else 0) + @@ -10271,6 +10327,7 @@ private constructor( adaptiveLongTable == other.adaptiveLongTable && aggressiveTableExtraction == other.aggressiveTableExtraction && annotateLinks == other.annotateLinks && + annotateRevisions == other.annotateRevisions && autoMode == other.autoMode && autoModeConfigurationJson == other.autoModeConfigurationJson && autoModeTriggerOnImageInPage == other.autoModeTriggerOnImageInPage && @@ -10413,6 +10470,7 @@ private constructor( adaptiveLongTable, aggressiveTableExtraction, annotateLinks, + annotateRevisions, autoMode, autoModeConfigurationJson, autoModeTriggerOnImageInPage, @@ -10543,7 +10601,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Parameters{adaptiveLongTable=$adaptiveLongTable, aggressiveTableExtraction=$aggressiveTableExtraction, annotateLinks=$annotateLinks, autoMode=$autoMode, autoModeConfigurationJson=$autoModeConfigurationJson, autoModeTriggerOnImageInPage=$autoModeTriggerOnImageInPage, autoModeTriggerOnRegexpInPage=$autoModeTriggerOnRegexpInPage, autoModeTriggerOnTableInPage=$autoModeTriggerOnTableInPage, autoModeTriggerOnTextInPage=$autoModeTriggerOnTextInPage, azureOpenAIApiVersion=$azureOpenAIApiVersion, azureOpenAIDeploymentName=$azureOpenAIDeploymentName, azureOpenAIEndpoint=$azureOpenAIEndpoint, azureOpenAIKey=$azureOpenAIKey, bboxBottom=$bboxBottom, bboxLeft=$bboxLeft, bboxRight=$bboxRight, bboxTop=$bboxTop, boundingBox=$boundingBox, compactMarkdownTable=$compactMarkdownTable, complementalFormattingInstruction=$complementalFormattingInstruction, confidenceScoreEffort=$confidenceScoreEffort, contentGuidelineInstruction=$contentGuidelineInstruction, continuousMode=$continuousMode, customMetadata=$customMetadata, disableImageExtraction=$disableImageExtraction, disableOcr=$disableOcr, disableReconstruction=$disableReconstruction, doNotCache=$doNotCache, doNotUnrollColumns=$doNotUnrollColumns, enableCostOptimizer=$enableCostOptimizer, extractCharts=$extractCharts, extractLayout=$extractLayout, extractPrintedPageNumber=$extractPrintedPageNumber, fastMode=$fastMode, formattingInstruction=$formattingInstruction, gpt4oApiKey=$gpt4oApiKey, gpt4oMode=$gpt4oMode, guessXlsxSheetName=$guessXlsxSheetName, hideFooters=$hideFooters, hideHeaders=$hideHeaders, highResOcr=$highResOcr, htmlMakeAllElementsVisible=$htmlMakeAllElementsVisible, htmlRemoveFixedElements=$htmlRemoveFixedElements, htmlRemoveNavigationElements=$htmlRemoveNavigationElements, httpProxy=$httpProxy, ignoreDocumentElementsForLayoutDetection=$ignoreDocumentElementsForLayoutDetection, imagesToSave=$imagesToSave, inlineImagesInMarkdown=$inlineImagesInMarkdown, inputS3Path=$inputS3Path, inputS3Region=$inputS3Region, inputUrl=$inputUrl, internalIsScreenshotJob=$internalIsScreenshotJob, invalidateCache=$invalidateCache, isFormattingInstruction=$isFormattingInstruction, jobTimeoutExtraTimePerPageInSeconds=$jobTimeoutExtraTimePerPageInSeconds, jobTimeoutInSeconds=$jobTimeoutInSeconds, keepPageSeparatorWhenMergingTables=$keepPageSeparatorWhenMergingTables, lang=$lang, languages=$languages, layoutAware=$layoutAware, lineLevelBoundingBox=$lineLevelBoundingBox, markdownTableMultilineHeaderSeparator=$markdownTableMultilineHeaderSeparator, maxPages=$maxPages, maxPagesEnforced=$maxPagesEnforced, mergeTablesAcrossPagesInMarkdown=$mergeTablesAcrossPagesInMarkdown, model=$model, outlinedTableExtraction=$outlinedTableExtraction, outputPdfOfDocument=$outputPdfOfDocument, outputS3PathPrefix=$outputS3PathPrefix, outputS3Region=$outputS3Region, outputTablesAsHtml=$outputTablesAsHtml, outputBucket=$outputBucket, pageErrorTolerance=$pageErrorTolerance, pageFooterPrefix=$pageFooterPrefix, pageFooterSuffix=$pageFooterSuffix, pageHeaderPrefix=$pageHeaderPrefix, pageHeaderSuffix=$pageHeaderSuffix, pagePrefix=$pagePrefix, pageSeparator=$pageSeparator, pageSuffix=$pageSuffix, parseMode=$parseMode, parsingInstruction=$parsingInstruction, pipelineId=$pipelineId, preciseBoundingBox=$preciseBoundingBox, premiumMode=$premiumMode, presentationOutOfBoundsContent=$presentationOutOfBoundsContent, presentationSkipEmbeddedData=$presentationSkipEmbeddedData, preserveLayoutAlignmentAcrossPages=$preserveLayoutAlignmentAcrossPages, preserveVerySmallText=$preserveVerySmallText, preset=$preset, priority=$priority, projectId=$projectId, removeHiddenText=$removeHiddenText, replaceFailedPageMode=$replaceFailedPageMode, replaceFailedPageWithErrorMessagePrefix=$replaceFailedPageWithErrorMessagePrefix, replaceFailedPageWithErrorMessageSuffix=$replaceFailedPageWithErrorMessageSuffix, resourceInfo=$resourceInfo, saveImages=$saveImages, skipDiagonalText=$skipDiagonalText, specializedChartParsingAgentic=$specializedChartParsingAgentic, specializedChartParsingEfficient=$specializedChartParsingEfficient, specializedChartParsingPlus=$specializedChartParsingPlus, specializedImageParsing=$specializedImageParsing, spreadsheetExtractSubTables=$spreadsheetExtractSubTables, spreadsheetForceFormulaComputation=$spreadsheetForceFormulaComputation, spreadsheetIncludeHiddenSheets=$spreadsheetIncludeHiddenSheets, strictModeBuggyFont=$strictModeBuggyFont, strictModeImageExtraction=$strictModeImageExtraction, strictModeImageOcr=$strictModeImageOcr, strictModeReconstruction=$strictModeReconstruction, structuredOutput=$structuredOutput, structuredOutputJsonSchema=$structuredOutputJsonSchema, structuredOutputJsonSchemaName=$structuredOutputJsonSchemaName, systemPrompt=$systemPrompt, systemPromptAppend=$systemPromptAppend, takeScreenshot=$takeScreenshot, targetPages=$targetPages, tier=$tier, type=$type, useVendorMultimodalModel=$useVendorMultimodalModel, userPrompt=$userPrompt, vendorMultimodalApiKey=$vendorMultimodalApiKey, vendorMultimodalModelName=$vendorMultimodalModelName, version=$version, webhookConfigurations=$webhookConfigurations, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + "Parameters{adaptiveLongTable=$adaptiveLongTable, aggressiveTableExtraction=$aggressiveTableExtraction, annotateLinks=$annotateLinks, annotateRevisions=$annotateRevisions, autoMode=$autoMode, autoModeConfigurationJson=$autoModeConfigurationJson, autoModeTriggerOnImageInPage=$autoModeTriggerOnImageInPage, autoModeTriggerOnRegexpInPage=$autoModeTriggerOnRegexpInPage, autoModeTriggerOnTableInPage=$autoModeTriggerOnTableInPage, autoModeTriggerOnTextInPage=$autoModeTriggerOnTextInPage, azureOpenAIApiVersion=$azureOpenAIApiVersion, azureOpenAIDeploymentName=$azureOpenAIDeploymentName, azureOpenAIEndpoint=$azureOpenAIEndpoint, azureOpenAIKey=$azureOpenAIKey, bboxBottom=$bboxBottom, bboxLeft=$bboxLeft, bboxRight=$bboxRight, bboxTop=$bboxTop, boundingBox=$boundingBox, compactMarkdownTable=$compactMarkdownTable, complementalFormattingInstruction=$complementalFormattingInstruction, confidenceScoreEffort=$confidenceScoreEffort, contentGuidelineInstruction=$contentGuidelineInstruction, continuousMode=$continuousMode, customMetadata=$customMetadata, disableImageExtraction=$disableImageExtraction, disableOcr=$disableOcr, disableReconstruction=$disableReconstruction, doNotCache=$doNotCache, doNotUnrollColumns=$doNotUnrollColumns, enableCostOptimizer=$enableCostOptimizer, extractCharts=$extractCharts, extractLayout=$extractLayout, extractPrintedPageNumber=$extractPrintedPageNumber, fastMode=$fastMode, formattingInstruction=$formattingInstruction, gpt4oApiKey=$gpt4oApiKey, gpt4oMode=$gpt4oMode, guessXlsxSheetName=$guessXlsxSheetName, hideFooters=$hideFooters, hideHeaders=$hideHeaders, highResOcr=$highResOcr, htmlMakeAllElementsVisible=$htmlMakeAllElementsVisible, htmlRemoveFixedElements=$htmlRemoveFixedElements, htmlRemoveNavigationElements=$htmlRemoveNavigationElements, httpProxy=$httpProxy, ignoreDocumentElementsForLayoutDetection=$ignoreDocumentElementsForLayoutDetection, imagesToSave=$imagesToSave, inlineImagesInMarkdown=$inlineImagesInMarkdown, inputS3Path=$inputS3Path, inputS3Region=$inputS3Region, inputUrl=$inputUrl, internalIsScreenshotJob=$internalIsScreenshotJob, invalidateCache=$invalidateCache, isFormattingInstruction=$isFormattingInstruction, jobTimeoutExtraTimePerPageInSeconds=$jobTimeoutExtraTimePerPageInSeconds, jobTimeoutInSeconds=$jobTimeoutInSeconds, keepPageSeparatorWhenMergingTables=$keepPageSeparatorWhenMergingTables, lang=$lang, languages=$languages, layoutAware=$layoutAware, lineLevelBoundingBox=$lineLevelBoundingBox, markdownTableMultilineHeaderSeparator=$markdownTableMultilineHeaderSeparator, maxPages=$maxPages, maxPagesEnforced=$maxPagesEnforced, mergeTablesAcrossPagesInMarkdown=$mergeTablesAcrossPagesInMarkdown, model=$model, outlinedTableExtraction=$outlinedTableExtraction, outputPdfOfDocument=$outputPdfOfDocument, outputS3PathPrefix=$outputS3PathPrefix, outputS3Region=$outputS3Region, outputTablesAsHtml=$outputTablesAsHtml, outputBucket=$outputBucket, pageErrorTolerance=$pageErrorTolerance, pageFooterPrefix=$pageFooterPrefix, pageFooterSuffix=$pageFooterSuffix, pageHeaderPrefix=$pageHeaderPrefix, pageHeaderSuffix=$pageHeaderSuffix, pagePrefix=$pagePrefix, pageSeparator=$pageSeparator, pageSuffix=$pageSuffix, parseMode=$parseMode, parsingInstruction=$parsingInstruction, pipelineId=$pipelineId, preciseBoundingBox=$preciseBoundingBox, premiumMode=$premiumMode, presentationOutOfBoundsContent=$presentationOutOfBoundsContent, presentationSkipEmbeddedData=$presentationSkipEmbeddedData, preserveLayoutAlignmentAcrossPages=$preserveLayoutAlignmentAcrossPages, preserveVerySmallText=$preserveVerySmallText, preset=$preset, priority=$priority, projectId=$projectId, removeHiddenText=$removeHiddenText, replaceFailedPageMode=$replaceFailedPageMode, replaceFailedPageWithErrorMessagePrefix=$replaceFailedPageWithErrorMessagePrefix, replaceFailedPageWithErrorMessageSuffix=$replaceFailedPageWithErrorMessageSuffix, resourceInfo=$resourceInfo, saveImages=$saveImages, skipDiagonalText=$skipDiagonalText, specializedChartParsingAgentic=$specializedChartParsingAgentic, specializedChartParsingEfficient=$specializedChartParsingEfficient, specializedChartParsingPlus=$specializedChartParsingPlus, specializedImageParsing=$specializedImageParsing, spreadsheetExtractSubTables=$spreadsheetExtractSubTables, spreadsheetForceFormulaComputation=$spreadsheetForceFormulaComputation, spreadsheetIncludeHiddenSheets=$spreadsheetIncludeHiddenSheets, strictModeBuggyFont=$strictModeBuggyFont, strictModeImageExtraction=$strictModeImageExtraction, strictModeImageOcr=$strictModeImageOcr, strictModeReconstruction=$strictModeReconstruction, structuredOutput=$structuredOutput, structuredOutputJsonSchema=$structuredOutputJsonSchema, structuredOutputJsonSchemaName=$structuredOutputJsonSchemaName, systemPrompt=$systemPrompt, systemPromptAppend=$systemPromptAppend, takeScreenshot=$takeScreenshot, targetPages=$targetPages, tier=$tier, type=$type, useVendorMultimodalModel=$useVendorMultimodalModel, userPrompt=$userPrompt, vendorMultimodalApiKey=$vendorMultimodalApiKey, vendorMultimodalModelName=$vendorMultimodalModelName, version=$version, webhookConfigurations=$webhookConfigurations, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" } /** The partitions for this execution. Used for determining where to save job output. */ diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsResponse.kt index 7c6e58f..47f98f9 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsResponse.kt @@ -1744,6 +1744,7 @@ private constructor( private val adaptiveLongTable: JsonField, private val aggressiveTableExtraction: JsonField, private val annotateLinks: JsonField, + private val annotateRevisions: JsonField, private val autoMode: JsonField, private val autoModeConfigurationJson: JsonField, private val autoModeTriggerOnImageInPage: JsonField, @@ -1881,6 +1882,9 @@ private constructor( @JsonProperty("annotate_links") @ExcludeMissing annotateLinks: JsonField = JsonMissing.of(), + @JsonProperty("annotate_revisions") + @ExcludeMissing + annotateRevisions: JsonField = JsonMissing.of(), @JsonProperty("auto_mode") @ExcludeMissing autoMode: JsonField = JsonMissing.of(), @@ -2258,6 +2262,7 @@ private constructor( adaptiveLongTable, aggressiveTableExtraction, annotateLinks, + annotateRevisions, autoMode, autoModeConfigurationJson, autoModeTriggerOnImageInPage, @@ -2405,6 +2410,13 @@ private constructor( fun annotateLinks(): Optional = annotateLinks.getOptional("annotate_links") + /** + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun annotateRevisions(): Optional = + annotateRevisions.getOptional("annotate_revisions") + /** * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected * type (e.g. if the server responded with an unexpected value). @@ -3320,6 +3332,16 @@ private constructor( @ExcludeMissing fun _annotateLinks(): JsonField = annotateLinks + /** + * Returns the raw JSON value of [annotateRevisions]. + * + * Unlike [annotateRevisions], this method doesn't throw if the JSON field has + * an unexpected type. + */ + @JsonProperty("annotate_revisions") + @ExcludeMissing + fun _annotateRevisions(): JsonField = annotateRevisions + /** * Returns the raw JSON value of [autoMode]. * @@ -4595,6 +4617,7 @@ private constructor( private var adaptiveLongTable: JsonField = JsonMissing.of() private var aggressiveTableExtraction: JsonField = JsonMissing.of() private var annotateLinks: JsonField = JsonMissing.of() + private var annotateRevisions: JsonField = JsonMissing.of() private var autoMode: JsonField = JsonMissing.of() private var autoModeConfigurationJson: JsonField = JsonMissing.of() private var autoModeTriggerOnImageInPage: JsonField = @@ -4754,6 +4777,7 @@ private constructor( adaptiveLongTable = parameters.adaptiveLongTable aggressiveTableExtraction = parameters.aggressiveTableExtraction annotateLinks = parameters.annotateLinks + annotateRevisions = parameters.annotateRevisions autoMode = parameters.autoMode autoModeConfigurationJson = parameters.autoModeConfigurationJson autoModeTriggerOnImageInPage = parameters.autoModeTriggerOnImageInPage @@ -4986,6 +5010,35 @@ private constructor( this.annotateLinks = annotateLinks } + fun annotateRevisions(annotateRevisions: Boolean?) = + annotateRevisions(JsonField.ofNullable(annotateRevisions)) + + /** + * Alias for [Builder.annotateRevisions]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun annotateRevisions(annotateRevisions: Boolean) = + annotateRevisions(annotateRevisions as Boolean?) + + /** + * Alias for calling [Builder.annotateRevisions] with + * `annotateRevisions.orElse(null)`. + */ + fun annotateRevisions(annotateRevisions: Optional) = + annotateRevisions(annotateRevisions.getOrNull()) + + /** + * Sets [Builder.annotateRevisions] to an arbitrary JSON value. + * + * You should usually call [Builder.annotateRevisions] with a well-typed + * [Boolean] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun annotateRevisions(annotateRevisions: JsonField) = apply { + this.annotateRevisions = annotateRevisions + } + fun autoMode(autoMode: Boolean?) = autoMode(JsonField.ofNullable(autoMode)) /** @@ -8340,6 +8393,7 @@ private constructor( adaptiveLongTable, aggressiveTableExtraction, annotateLinks, + annotateRevisions, autoMode, autoModeConfigurationJson, autoModeTriggerOnImageInPage, @@ -8489,6 +8543,7 @@ private constructor( adaptiveLongTable() aggressiveTableExtraction() annotateLinks() + annotateRevisions() autoMode() autoModeConfigurationJson() autoModeTriggerOnImageInPage() @@ -8634,6 +8689,7 @@ private constructor( (if (adaptiveLongTable.asKnown().isPresent) 1 else 0) + (if (aggressiveTableExtraction.asKnown().isPresent) 1 else 0) + (if (annotateLinks.asKnown().isPresent) 1 else 0) + + (if (annotateRevisions.asKnown().isPresent) 1 else 0) + (if (autoMode.asKnown().isPresent) 1 else 0) + (if (autoModeConfigurationJson.asKnown().isPresent) 1 else 0) + (if (autoModeTriggerOnImageInPage.asKnown().isPresent) 1 else 0) + @@ -10385,6 +10441,7 @@ private constructor( adaptiveLongTable == other.adaptiveLongTable && aggressiveTableExtraction == other.aggressiveTableExtraction && annotateLinks == other.annotateLinks && + annotateRevisions == other.annotateRevisions && autoMode == other.autoMode && autoModeConfigurationJson == other.autoModeConfigurationJson && autoModeTriggerOnImageInPage == other.autoModeTriggerOnImageInPage && @@ -10531,6 +10588,7 @@ private constructor( adaptiveLongTable, aggressiveTableExtraction, annotateLinks, + annotateRevisions, autoMode, autoModeConfigurationJson, autoModeTriggerOnImageInPage, @@ -10661,7 +10719,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Parameters{adaptiveLongTable=$adaptiveLongTable, aggressiveTableExtraction=$aggressiveTableExtraction, annotateLinks=$annotateLinks, autoMode=$autoMode, autoModeConfigurationJson=$autoModeConfigurationJson, autoModeTriggerOnImageInPage=$autoModeTriggerOnImageInPage, autoModeTriggerOnRegexpInPage=$autoModeTriggerOnRegexpInPage, autoModeTriggerOnTableInPage=$autoModeTriggerOnTableInPage, autoModeTriggerOnTextInPage=$autoModeTriggerOnTextInPage, azureOpenAIApiVersion=$azureOpenAIApiVersion, azureOpenAIDeploymentName=$azureOpenAIDeploymentName, azureOpenAIEndpoint=$azureOpenAIEndpoint, azureOpenAIKey=$azureOpenAIKey, bboxBottom=$bboxBottom, bboxLeft=$bboxLeft, bboxRight=$bboxRight, bboxTop=$bboxTop, boundingBox=$boundingBox, compactMarkdownTable=$compactMarkdownTable, complementalFormattingInstruction=$complementalFormattingInstruction, confidenceScoreEffort=$confidenceScoreEffort, contentGuidelineInstruction=$contentGuidelineInstruction, continuousMode=$continuousMode, customMetadata=$customMetadata, disableImageExtraction=$disableImageExtraction, disableOcr=$disableOcr, disableReconstruction=$disableReconstruction, doNotCache=$doNotCache, doNotUnrollColumns=$doNotUnrollColumns, enableCostOptimizer=$enableCostOptimizer, extractCharts=$extractCharts, extractLayout=$extractLayout, extractPrintedPageNumber=$extractPrintedPageNumber, fastMode=$fastMode, formattingInstruction=$formattingInstruction, gpt4oApiKey=$gpt4oApiKey, gpt4oMode=$gpt4oMode, guessXlsxSheetName=$guessXlsxSheetName, hideFooters=$hideFooters, hideHeaders=$hideHeaders, highResOcr=$highResOcr, htmlMakeAllElementsVisible=$htmlMakeAllElementsVisible, htmlRemoveFixedElements=$htmlRemoveFixedElements, htmlRemoveNavigationElements=$htmlRemoveNavigationElements, httpProxy=$httpProxy, ignoreDocumentElementsForLayoutDetection=$ignoreDocumentElementsForLayoutDetection, imagesToSave=$imagesToSave, inlineImagesInMarkdown=$inlineImagesInMarkdown, inputS3Path=$inputS3Path, inputS3Region=$inputS3Region, inputUrl=$inputUrl, internalIsScreenshotJob=$internalIsScreenshotJob, invalidateCache=$invalidateCache, isFormattingInstruction=$isFormattingInstruction, jobTimeoutExtraTimePerPageInSeconds=$jobTimeoutExtraTimePerPageInSeconds, jobTimeoutInSeconds=$jobTimeoutInSeconds, keepPageSeparatorWhenMergingTables=$keepPageSeparatorWhenMergingTables, lang=$lang, languages=$languages, layoutAware=$layoutAware, lineLevelBoundingBox=$lineLevelBoundingBox, markdownTableMultilineHeaderSeparator=$markdownTableMultilineHeaderSeparator, maxPages=$maxPages, maxPagesEnforced=$maxPagesEnforced, mergeTablesAcrossPagesInMarkdown=$mergeTablesAcrossPagesInMarkdown, model=$model, outlinedTableExtraction=$outlinedTableExtraction, outputPdfOfDocument=$outputPdfOfDocument, outputS3PathPrefix=$outputS3PathPrefix, outputS3Region=$outputS3Region, outputTablesAsHtml=$outputTablesAsHtml, outputBucket=$outputBucket, pageErrorTolerance=$pageErrorTolerance, pageFooterPrefix=$pageFooterPrefix, pageFooterSuffix=$pageFooterSuffix, pageHeaderPrefix=$pageHeaderPrefix, pageHeaderSuffix=$pageHeaderSuffix, pagePrefix=$pagePrefix, pageSeparator=$pageSeparator, pageSuffix=$pageSuffix, parseMode=$parseMode, parsingInstruction=$parsingInstruction, pipelineId=$pipelineId, preciseBoundingBox=$preciseBoundingBox, premiumMode=$premiumMode, presentationOutOfBoundsContent=$presentationOutOfBoundsContent, presentationSkipEmbeddedData=$presentationSkipEmbeddedData, preserveLayoutAlignmentAcrossPages=$preserveLayoutAlignmentAcrossPages, preserveVerySmallText=$preserveVerySmallText, preset=$preset, priority=$priority, projectId=$projectId, removeHiddenText=$removeHiddenText, replaceFailedPageMode=$replaceFailedPageMode, replaceFailedPageWithErrorMessagePrefix=$replaceFailedPageWithErrorMessagePrefix, replaceFailedPageWithErrorMessageSuffix=$replaceFailedPageWithErrorMessageSuffix, resourceInfo=$resourceInfo, saveImages=$saveImages, skipDiagonalText=$skipDiagonalText, specializedChartParsingAgentic=$specializedChartParsingAgentic, specializedChartParsingEfficient=$specializedChartParsingEfficient, specializedChartParsingPlus=$specializedChartParsingPlus, specializedImageParsing=$specializedImageParsing, spreadsheetExtractSubTables=$spreadsheetExtractSubTables, spreadsheetForceFormulaComputation=$spreadsheetForceFormulaComputation, spreadsheetIncludeHiddenSheets=$spreadsheetIncludeHiddenSheets, strictModeBuggyFont=$strictModeBuggyFont, strictModeImageExtraction=$strictModeImageExtraction, strictModeImageOcr=$strictModeImageOcr, strictModeReconstruction=$strictModeReconstruction, structuredOutput=$structuredOutput, structuredOutputJsonSchema=$structuredOutputJsonSchema, structuredOutputJsonSchemaName=$structuredOutputJsonSchemaName, systemPrompt=$systemPrompt, systemPromptAppend=$systemPromptAppend, takeScreenshot=$takeScreenshot, targetPages=$targetPages, tier=$tier, type=$type, useVendorMultimodalModel=$useVendorMultimodalModel, userPrompt=$userPrompt, vendorMultimodalApiKey=$vendorMultimodalApiKey, vendorMultimodalModelName=$vendorMultimodalModelName, version=$version, webhookConfigurations=$webhookConfigurations, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + "Parameters{adaptiveLongTable=$adaptiveLongTable, aggressiveTableExtraction=$aggressiveTableExtraction, annotateLinks=$annotateLinks, annotateRevisions=$annotateRevisions, autoMode=$autoMode, autoModeConfigurationJson=$autoModeConfigurationJson, autoModeTriggerOnImageInPage=$autoModeTriggerOnImageInPage, autoModeTriggerOnRegexpInPage=$autoModeTriggerOnRegexpInPage, autoModeTriggerOnTableInPage=$autoModeTriggerOnTableInPage, autoModeTriggerOnTextInPage=$autoModeTriggerOnTextInPage, azureOpenAIApiVersion=$azureOpenAIApiVersion, azureOpenAIDeploymentName=$azureOpenAIDeploymentName, azureOpenAIEndpoint=$azureOpenAIEndpoint, azureOpenAIKey=$azureOpenAIKey, bboxBottom=$bboxBottom, bboxLeft=$bboxLeft, bboxRight=$bboxRight, bboxTop=$bboxTop, boundingBox=$boundingBox, compactMarkdownTable=$compactMarkdownTable, complementalFormattingInstruction=$complementalFormattingInstruction, confidenceScoreEffort=$confidenceScoreEffort, contentGuidelineInstruction=$contentGuidelineInstruction, continuousMode=$continuousMode, customMetadata=$customMetadata, disableImageExtraction=$disableImageExtraction, disableOcr=$disableOcr, disableReconstruction=$disableReconstruction, doNotCache=$doNotCache, doNotUnrollColumns=$doNotUnrollColumns, enableCostOptimizer=$enableCostOptimizer, extractCharts=$extractCharts, extractLayout=$extractLayout, extractPrintedPageNumber=$extractPrintedPageNumber, fastMode=$fastMode, formattingInstruction=$formattingInstruction, gpt4oApiKey=$gpt4oApiKey, gpt4oMode=$gpt4oMode, guessXlsxSheetName=$guessXlsxSheetName, hideFooters=$hideFooters, hideHeaders=$hideHeaders, highResOcr=$highResOcr, htmlMakeAllElementsVisible=$htmlMakeAllElementsVisible, htmlRemoveFixedElements=$htmlRemoveFixedElements, htmlRemoveNavigationElements=$htmlRemoveNavigationElements, httpProxy=$httpProxy, ignoreDocumentElementsForLayoutDetection=$ignoreDocumentElementsForLayoutDetection, imagesToSave=$imagesToSave, inlineImagesInMarkdown=$inlineImagesInMarkdown, inputS3Path=$inputS3Path, inputS3Region=$inputS3Region, inputUrl=$inputUrl, internalIsScreenshotJob=$internalIsScreenshotJob, invalidateCache=$invalidateCache, isFormattingInstruction=$isFormattingInstruction, jobTimeoutExtraTimePerPageInSeconds=$jobTimeoutExtraTimePerPageInSeconds, jobTimeoutInSeconds=$jobTimeoutInSeconds, keepPageSeparatorWhenMergingTables=$keepPageSeparatorWhenMergingTables, lang=$lang, languages=$languages, layoutAware=$layoutAware, lineLevelBoundingBox=$lineLevelBoundingBox, markdownTableMultilineHeaderSeparator=$markdownTableMultilineHeaderSeparator, maxPages=$maxPages, maxPagesEnforced=$maxPagesEnforced, mergeTablesAcrossPagesInMarkdown=$mergeTablesAcrossPagesInMarkdown, model=$model, outlinedTableExtraction=$outlinedTableExtraction, outputPdfOfDocument=$outputPdfOfDocument, outputS3PathPrefix=$outputS3PathPrefix, outputS3Region=$outputS3Region, outputTablesAsHtml=$outputTablesAsHtml, outputBucket=$outputBucket, pageErrorTolerance=$pageErrorTolerance, pageFooterPrefix=$pageFooterPrefix, pageFooterSuffix=$pageFooterSuffix, pageHeaderPrefix=$pageHeaderPrefix, pageHeaderSuffix=$pageHeaderSuffix, pagePrefix=$pagePrefix, pageSeparator=$pageSeparator, pageSuffix=$pageSuffix, parseMode=$parseMode, parsingInstruction=$parsingInstruction, pipelineId=$pipelineId, preciseBoundingBox=$preciseBoundingBox, premiumMode=$premiumMode, presentationOutOfBoundsContent=$presentationOutOfBoundsContent, presentationSkipEmbeddedData=$presentationSkipEmbeddedData, preserveLayoutAlignmentAcrossPages=$preserveLayoutAlignmentAcrossPages, preserveVerySmallText=$preserveVerySmallText, preset=$preset, priority=$priority, projectId=$projectId, removeHiddenText=$removeHiddenText, replaceFailedPageMode=$replaceFailedPageMode, replaceFailedPageWithErrorMessagePrefix=$replaceFailedPageWithErrorMessagePrefix, replaceFailedPageWithErrorMessageSuffix=$replaceFailedPageWithErrorMessageSuffix, resourceInfo=$resourceInfo, saveImages=$saveImages, skipDiagonalText=$skipDiagonalText, specializedChartParsingAgentic=$specializedChartParsingAgentic, specializedChartParsingEfficient=$specializedChartParsingEfficient, specializedChartParsingPlus=$specializedChartParsingPlus, specializedImageParsing=$specializedImageParsing, spreadsheetExtractSubTables=$spreadsheetExtractSubTables, spreadsheetForceFormulaComputation=$spreadsheetForceFormulaComputation, spreadsheetIncludeHiddenSheets=$spreadsheetIncludeHiddenSheets, strictModeBuggyFont=$strictModeBuggyFont, strictModeImageExtraction=$strictModeImageExtraction, strictModeImageOcr=$strictModeImageOcr, strictModeReconstruction=$strictModeReconstruction, structuredOutput=$structuredOutput, structuredOutputJsonSchema=$structuredOutputJsonSchema, structuredOutputJsonSchemaName=$structuredOutputJsonSchemaName, systemPrompt=$systemPrompt, systemPromptAppend=$systemPromptAppend, takeScreenshot=$takeScreenshot, targetPages=$targetPages, tier=$tier, type=$type, useVendorMultimodalModel=$useVendorMultimodalModel, userPrompt=$userPrompt, vendorMultimodalApiKey=$vendorMultimodalApiKey, vendorMultimodalModelName=$vendorMultimodalModelName, version=$version, webhookConfigurations=$webhookConfigurations, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" } /** 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 36c573f..86801f4 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 @@ -3870,6 +3870,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val annotateLinks: JsonField, + private val annotateRevisions: JsonField, private val inlineImages: JsonField, private val tables: JsonField, private val additionalProperties: MutableMap, @@ -3880,11 +3881,14 @@ private constructor( @JsonProperty("annotate_links") @ExcludeMissing annotateLinks: JsonField = JsonMissing.of(), + @JsonProperty("annotate_revisions") + @ExcludeMissing + annotateRevisions: JsonField = JsonMissing.of(), @JsonProperty("inline_images") @ExcludeMissing inlineImages: JsonField = JsonMissing.of(), @JsonProperty("tables") @ExcludeMissing tables: JsonField = JsonMissing.of(), - ) : this(annotateLinks, inlineImages, tables, mutableMapOf()) + ) : this(annotateLinks, annotateRevisions, inlineImages, tables, mutableMapOf()) /** * Add link annotations to markdown output in the format [text](url). When false, only @@ -3895,6 +3899,15 @@ private constructor( */ fun annotateLinks(): Optional = annotateLinks.getOptional("annotate_links") + /** + * Extract Word-style revisions and comments into structured page output + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun annotateRevisions(): Optional = + annotateRevisions.getOptional("annotate_revisions") + /** * Embed images directly in markdown as base64 data URIs instead of extracting them as * separate files. Useful for self-contained markdown output @@ -3922,6 +3935,16 @@ private constructor( @ExcludeMissing fun _annotateLinks(): JsonField = annotateLinks + /** + * Returns the raw JSON value of [annotateRevisions]. + * + * Unlike [annotateRevisions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("annotate_revisions") + @ExcludeMissing + fun _annotateRevisions(): JsonField = annotateRevisions + /** * Returns the raw JSON value of [inlineImages]. * @@ -3961,6 +3984,7 @@ private constructor( class Builder internal constructor() { private var annotateLinks: JsonField = JsonMissing.of() + private var annotateRevisions: JsonField = JsonMissing.of() private var inlineImages: JsonField = JsonMissing.of() private var tables: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3968,6 +3992,7 @@ private constructor( @JvmSynthetic internal fun from(markdown: Markdown) = apply { annotateLinks = markdown.annotateLinks + annotateRevisions = markdown.annotateRevisions inlineImages = markdown.inlineImages tables = markdown.tables additionalProperties = markdown.additionalProperties.toMutableMap() @@ -4002,6 +4027,36 @@ private constructor( this.annotateLinks = annotateLinks } + /** Extract Word-style revisions and comments into structured page output */ + fun annotateRevisions(annotateRevisions: Boolean?) = + annotateRevisions(JsonField.ofNullable(annotateRevisions)) + + /** + * Alias for [Builder.annotateRevisions]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun annotateRevisions(annotateRevisions: Boolean) = + annotateRevisions(annotateRevisions as Boolean?) + + /** + * Alias for calling [Builder.annotateRevisions] with + * `annotateRevisions.orElse(null)`. + */ + fun annotateRevisions(annotateRevisions: Optional) = + annotateRevisions(annotateRevisions.getOrNull()) + + /** + * Sets [Builder.annotateRevisions] to an arbitrary JSON value. + * + * You should usually call [Builder.annotateRevisions] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun annotateRevisions(annotateRevisions: JsonField) = apply { + this.annotateRevisions = annotateRevisions + } + /** * Embed images directly in markdown as base64 data URIs instead of extracting them * as separate files. Useful for self-contained markdown output @@ -4075,6 +4130,7 @@ private constructor( fun build(): Markdown = Markdown( annotateLinks, + annotateRevisions, inlineImages, tables, additionalProperties.toMutableMap(), @@ -4099,6 +4155,7 @@ private constructor( } annotateLinks() + annotateRevisions() inlineImages() tables().ifPresent { it.validate() } validated = true @@ -4121,6 +4178,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (annotateLinks.asKnown().isPresent) 1 else 0) + + (if (annotateRevisions.asKnown().isPresent) 1 else 0) + (if (inlineImages.asKnown().isPresent) 1 else 0) + (tables.asKnown().getOrNull()?.validity() ?: 0) @@ -4525,19 +4583,26 @@ private constructor( return other is Markdown && annotateLinks == other.annotateLinks && + annotateRevisions == other.annotateRevisions && inlineImages == other.inlineImages && tables == other.tables && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(annotateLinks, inlineImages, tables, additionalProperties) + Objects.hash( + annotateLinks, + annotateRevisions, + inlineImages, + tables, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Markdown{annotateLinks=$annotateLinks, inlineImages=$inlineImages, tables=$tables, additionalProperties=$additionalProperties}" + "Markdown{annotateLinks=$annotateLinks, annotateRevisions=$annotateRevisions, inlineImages=$inlineImages, tables=$tables, additionalProperties=$additionalProperties}" } /** Spatial text output options for preserving document layout structure */ diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt index ce471d5..80f4e79 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt @@ -5075,6 +5075,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val annotateLinks: JsonField, + private val annotateRevisions: JsonField, private val inlineImages: JsonField, private val tables: JsonField, private val additionalProperties: MutableMap, @@ -5085,11 +5086,14 @@ private constructor( @JsonProperty("annotate_links") @ExcludeMissing annotateLinks: JsonField = JsonMissing.of(), + @JsonProperty("annotate_revisions") + @ExcludeMissing + annotateRevisions: JsonField = JsonMissing.of(), @JsonProperty("inline_images") @ExcludeMissing inlineImages: JsonField = JsonMissing.of(), @JsonProperty("tables") @ExcludeMissing tables: JsonField = JsonMissing.of(), - ) : this(annotateLinks, inlineImages, tables, mutableMapOf()) + ) : this(annotateLinks, annotateRevisions, inlineImages, tables, mutableMapOf()) /** * Add link annotations to markdown output in the format [text](url). When false, only @@ -5100,6 +5104,15 @@ private constructor( */ fun annotateLinks(): Optional = annotateLinks.getOptional("annotate_links") + /** + * Extract Word-style revisions and comments into structured page output + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun annotateRevisions(): Optional = + annotateRevisions.getOptional("annotate_revisions") + /** * Embed images directly in markdown as base64 data URIs instead of extracting them as * separate files. Useful for self-contained markdown output @@ -5127,6 +5140,16 @@ private constructor( @ExcludeMissing fun _annotateLinks(): JsonField = annotateLinks + /** + * Returns the raw JSON value of [annotateRevisions]. + * + * Unlike [annotateRevisions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("annotate_revisions") + @ExcludeMissing + fun _annotateRevisions(): JsonField = annotateRevisions + /** * Returns the raw JSON value of [inlineImages]. * @@ -5166,6 +5189,7 @@ private constructor( class Builder internal constructor() { private var annotateLinks: JsonField = JsonMissing.of() + private var annotateRevisions: JsonField = JsonMissing.of() private var inlineImages: JsonField = JsonMissing.of() private var tables: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -5173,6 +5197,7 @@ private constructor( @JvmSynthetic internal fun from(markdown: Markdown) = apply { annotateLinks = markdown.annotateLinks + annotateRevisions = markdown.annotateRevisions inlineImages = markdown.inlineImages tables = markdown.tables additionalProperties = markdown.additionalProperties.toMutableMap() @@ -5207,6 +5232,36 @@ private constructor( this.annotateLinks = annotateLinks } + /** Extract Word-style revisions and comments into structured page output */ + fun annotateRevisions(annotateRevisions: Boolean?) = + annotateRevisions(JsonField.ofNullable(annotateRevisions)) + + /** + * Alias for [Builder.annotateRevisions]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun annotateRevisions(annotateRevisions: Boolean) = + annotateRevisions(annotateRevisions as Boolean?) + + /** + * Alias for calling [Builder.annotateRevisions] with + * `annotateRevisions.orElse(null)`. + */ + fun annotateRevisions(annotateRevisions: Optional) = + annotateRevisions(annotateRevisions.getOrNull()) + + /** + * Sets [Builder.annotateRevisions] to an arbitrary JSON value. + * + * You should usually call [Builder.annotateRevisions] with a well-typed [Boolean] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun annotateRevisions(annotateRevisions: JsonField) = apply { + this.annotateRevisions = annotateRevisions + } + /** * Embed images directly in markdown as base64 data URIs instead of extracting them * as separate files. Useful for self-contained markdown output @@ -5280,6 +5335,7 @@ private constructor( fun build(): Markdown = Markdown( annotateLinks, + annotateRevisions, inlineImages, tables, additionalProperties.toMutableMap(), @@ -5304,6 +5360,7 @@ private constructor( } annotateLinks() + annotateRevisions() inlineImages() tables().ifPresent { it.validate() } validated = true @@ -5326,6 +5383,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (annotateLinks.asKnown().isPresent) 1 else 0) + + (if (annotateRevisions.asKnown().isPresent) 1 else 0) + (if (inlineImages.asKnown().isPresent) 1 else 0) + (tables.asKnown().getOrNull()?.validity() ?: 0) @@ -5730,19 +5788,26 @@ private constructor( return other is Markdown && annotateLinks == other.annotateLinks && + annotateRevisions == other.annotateRevisions && inlineImages == other.inlineImages && tables == other.tables && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(annotateLinks, inlineImages, tables, additionalProperties) + Objects.hash( + annotateLinks, + annotateRevisions, + inlineImages, + tables, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Markdown{annotateLinks=$annotateLinks, inlineImages=$inlineImages, tables=$tables, additionalProperties=$additionalProperties}" + "Markdown{annotateLinks=$annotateLinks, annotateRevisions=$annotateRevisions, inlineImages=$inlineImages, tables=$tables, additionalProperties=$additionalProperties}" } /** Spatial text output options for preserving document layout structure */ diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponse.kt index b78911a..cfc2dcf 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponse.kt @@ -3728,6 +3728,7 @@ private constructor( internal fun validity(): Int = (pages.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + /** Successfully parsed page in structured items output. */ @JsonDeserialize(using = Page.Deserializer::class) @JsonSerialize(using = Page.Serializer::class) class Page @@ -3737,6 +3738,7 @@ private constructor( private val _json: JsonValue? = null, ) { + /** Successfully parsed page in structured items output. */ fun structuredResult(): Optional = Optional.ofNullable(structuredResult) @@ -3747,6 +3749,7 @@ private constructor( fun isFailedStructured(): Boolean = failedStructured != null + /** Successfully parsed page in structured items output. */ fun asStructuredResult(): StructuredResultPage = structuredResult.getOrThrow("structuredResult") @@ -3873,6 +3876,7 @@ private constructor( companion object { + /** Successfully parsed page in structured items output. */ @JvmStatic fun ofStructuredResult(structuredResult: StructuredResultPage) = Page(structuredResult = structuredResult) @@ -3887,6 +3891,7 @@ private constructor( */ interface Visitor { + /** Successfully parsed page in structured items output. */ fun visitStructuredResult(structuredResult: StructuredResultPage): T fun visitFailedStructured(failedStructured: FailedStructuredPage): T @@ -3954,6 +3959,7 @@ private constructor( } } + /** Successfully parsed page in structured items output. */ class StructuredResultPage @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( @@ -3962,6 +3968,7 @@ private constructor( private val pageNumber: JsonField, private val pageWidth: JsonField, private val success: JsonValue, + private val revisions: JsonField>, private val additionalProperties: MutableMap, ) { @@ -3980,7 +3987,18 @@ private constructor( @ExcludeMissing pageWidth: JsonField = JsonMissing.of(), @JsonProperty("success") @ExcludeMissing success: JsonValue = JsonMissing.of(), - ) : this(items, pageHeight, pageNumber, pageWidth, success, mutableMapOf()) + @JsonProperty("revisions") + @ExcludeMissing + revisions: JsonField> = JsonMissing.of(), + ) : this( + items, + pageHeight, + pageNumber, + pageWidth, + success, + revisions, + mutableMapOf(), + ) /** * List of structured items on the page @@ -4031,6 +4049,14 @@ private constructor( */ @JsonProperty("success") @ExcludeMissing fun _success(): JsonValue = success + /** + * Extracted revisions and comments on the page + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun revisions(): Optional> = revisions.getOptional("revisions") + /** * Returns the raw JSON value of [items]. * @@ -4069,6 +4095,16 @@ private constructor( @ExcludeMissing fun _pageWidth(): JsonField = pageWidth + /** + * Returns the raw JSON value of [revisions]. + * + * Unlike [revisions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("revisions") + @ExcludeMissing + fun _revisions(): JsonField> = revisions + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -4106,6 +4142,7 @@ private constructor( private var pageNumber: JsonField? = null private var pageWidth: JsonField? = null private var success: JsonValue = JsonValue.from(true) + private var revisions: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4115,6 +4152,7 @@ private constructor( pageNumber = structuredResultPage.pageNumber pageWidth = structuredResultPage.pageWidth success = structuredResultPage.success + revisions = structuredResultPage.revisions.map { it.toMutableList() } additionalProperties = structuredResultPage.additionalProperties.toMutableMap() } @@ -4228,6 +4266,37 @@ private constructor( */ fun success(success: JsonValue) = apply { this.success = success } + /** Extracted revisions and comments on the page */ + fun revisions(revisions: List?) = + revisions(JsonField.ofNullable(revisions)) + + /** Alias for calling [Builder.revisions] with `revisions.orElse(null)`. */ + fun revisions(revisions: Optional>) = + revisions(revisions.getOrNull()) + + /** + * Sets [Builder.revisions] to an arbitrary JSON value. + * + * You should usually call [Builder.revisions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun revisions(revisions: JsonField>) = apply { + this.revisions = revisions.map { it.toMutableList() } + } + + /** + * Adds a single [Revision] to [revisions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addRevision(revision: Revision) = apply { + revisions = + (revisions ?: JsonField.of(mutableListOf())).also { + checkKnown("revisions", it).add(revision) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -4272,6 +4341,7 @@ private constructor( checkRequired("pageNumber", pageNumber), checkRequired("pageWidth", pageWidth), success, + (revisions ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } @@ -4304,6 +4374,7 @@ private constructor( ) } } + revisions().ifPresent { it.forEach { it.validate() } } validated = true } @@ -4327,7 +4398,8 @@ private constructor( (if (pageHeight.asKnown().isPresent) 1 else 0) + (if (pageNumber.asKnown().isPresent) 1 else 0) + (if (pageWidth.asKnown().isPresent) 1 else 0) + - success.let { if (it == JsonValue.from(true)) 1 else 0 } + success.let { if (it == JsonValue.from(true)) 1 else 0 } + + (revisions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) @JsonDeserialize(using = Item.Deserializer::class) @JsonSerialize(using = Item.Serializer::class) @@ -4723,6 +4795,2048 @@ private constructor( } } + /** One extracted document revision linked to page content. */ + class Revision + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val content: JsonField, + private val revisionBbox: JsonField, + private val target: JsonField, + private val targetBbox: JsonField, + private val type: JsonField, + private val author: JsonField, + private val endIndex: JsonField, + private val startIndex: JsonField, + private val targetSpans: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("content") + @ExcludeMissing + content: JsonField = JsonMissing.of(), + @JsonProperty("revision_bbox") + @ExcludeMissing + revisionBbox: JsonField = JsonMissing.of(), + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("target_bbox") + @ExcludeMissing + targetBbox: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), + @JsonProperty("author") + @ExcludeMissing + author: JsonField = JsonMissing.of(), + @JsonProperty("end_index") + @ExcludeMissing + endIndex: JsonField = JsonMissing.of(), + @JsonProperty("start_index") + @ExcludeMissing + startIndex: JsonField = JsonMissing.of(), + @JsonProperty("target_spans") + @ExcludeMissing + targetSpans: JsonField> = JsonMissing.of(), + ) : this( + content, + revisionBbox, + target, + targetBbox, + type, + author, + endIndex, + startIndex, + targetSpans, + mutableMapOf(), + ) + + /** + * Revision or comment content + * + * @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 content(): String = content.getRequired("content") + + /** + * Bounding box of the printed revision balloon + * + * @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 revisionBbox(): RevisionBbox = revisionBbox.getRequired("revision_bbox") + + /** + * Best available target text in the page content + * + * @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 target(): String = target.getRequired("target") + + /** + * Union bounding box of the target spans + * + * @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 targetBbox(): TargetBbox = targetBbox.getRequired("target_bbox") + + /** + * Type of revision + * + * @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 type(): Type = type.getRequired("type") + + /** + * Revision author, when available + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun author(): Optional = author.getOptional("author") + + /** + * Exclusive end offset in final page markdown + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun endIndex(): Optional = endIndex.getOptional("end_index") + + /** + * Inclusive start offset in final page markdown + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun startIndex(): Optional = startIndex.getOptional("start_index") + + /** + * Disconnected target spans, when present + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected + * type (e.g. if the server responded with an unexpected value). + */ + fun targetSpans(): Optional> = + targetSpans.getOptional("target_spans") + + /** + * Returns the raw JSON value of [content]. + * + * Unlike [content], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("content") + @ExcludeMissing + fun _content(): JsonField = content + + /** + * Returns the raw JSON value of [revisionBbox]. + * + * Unlike [revisionBbox], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("revision_bbox") + @ExcludeMissing + fun _revisionBbox(): JsonField = revisionBbox + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("target") + @ExcludeMissing + fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [targetBbox]. + * + * Unlike [targetBbox], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("target_bbox") + @ExcludeMissing + fun _targetBbox(): JsonField = targetBbox + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [author]. + * + * Unlike [author], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("author") + @ExcludeMissing + fun _author(): JsonField = author + + /** + * Returns the raw JSON value of [endIndex]. + * + * Unlike [endIndex], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("end_index") + @ExcludeMissing + fun _endIndex(): JsonField = endIndex + + /** + * Returns the raw JSON value of [startIndex]. + * + * Unlike [startIndex], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("start_index") + @ExcludeMissing + fun _startIndex(): JsonField = startIndex + + /** + * Returns the raw JSON value of [targetSpans]. + * + * Unlike [targetSpans], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("target_spans") + @ExcludeMissing + fun _targetSpans(): JsonField> = targetSpans + + @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 [Revision]. + * + * The following fields are required: + * ```java + * .content() + * .revisionBbox() + * .target() + * .targetBbox() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Revision]. */ + class Builder internal constructor() { + + private var content: JsonField? = null + private var revisionBbox: JsonField? = null + private var target: JsonField? = null + private var targetBbox: JsonField? = null + private var type: JsonField? = null + private var author: JsonField = JsonMissing.of() + private var endIndex: JsonField = JsonMissing.of() + private var startIndex: JsonField = JsonMissing.of() + private var targetSpans: JsonField>? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(revision: Revision) = apply { + content = revision.content + revisionBbox = revision.revisionBbox + target = revision.target + targetBbox = revision.targetBbox + type = revision.type + author = revision.author + endIndex = revision.endIndex + startIndex = revision.startIndex + targetSpans = revision.targetSpans.map { it.toMutableList() } + additionalProperties = revision.additionalProperties.toMutableMap() + } + + /** Revision or comment content */ + fun content(content: String) = content(JsonField.of(content)) + + /** + * Sets [Builder.content] to an arbitrary JSON value. + * + * You should usually call [Builder.content] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun content(content: JsonField) = apply { this.content = content } + + /** Bounding box of the printed revision balloon */ + fun revisionBbox(revisionBbox: RevisionBbox) = + revisionBbox(JsonField.of(revisionBbox)) + + /** + * Sets [Builder.revisionBbox] to an arbitrary JSON value. + * + * You should usually call [Builder.revisionBbox] with a well-typed + * [RevisionBbox] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun revisionBbox(revisionBbox: JsonField) = apply { + this.revisionBbox = revisionBbox + } + + /** Best available target text in the page content */ + fun target(target: String) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Union bounding box of the target spans */ + fun targetBbox(targetBbox: TargetBbox) = + targetBbox(JsonField.of(targetBbox)) + + /** + * Sets [Builder.targetBbox] to an arbitrary JSON value. + * + * You should usually call [Builder.targetBbox] with a well-typed + * [TargetBbox] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun targetBbox(targetBbox: JsonField) = apply { + this.targetBbox = targetBbox + } + + /** Type of revision */ + 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 } + + /** Revision author, when available */ + fun author(author: String?) = author(JsonField.ofNullable(author)) + + /** Alias for calling [Builder.author] with `author.orElse(null)`. */ + fun author(author: Optional) = author(author.getOrNull()) + + /** + * Sets [Builder.author] to an arbitrary JSON value. + * + * You should usually call [Builder.author] with a well-typed [String] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun author(author: JsonField) = apply { this.author = author } + + /** Exclusive end offset in final page markdown */ + fun endIndex(endIndex: Long?) = endIndex(JsonField.ofNullable(endIndex)) + + /** + * Alias for [Builder.endIndex]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun endIndex(endIndex: Long) = endIndex(endIndex as Long?) + + /** Alias for calling [Builder.endIndex] with `endIndex.orElse(null)`. */ + fun endIndex(endIndex: Optional) = endIndex(endIndex.getOrNull()) + + /** + * Sets [Builder.endIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.endIndex] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun endIndex(endIndex: JsonField) = apply { this.endIndex = endIndex } + + /** Inclusive start offset in final page markdown */ + fun startIndex(startIndex: Long?) = + startIndex(JsonField.ofNullable(startIndex)) + + /** + * Alias for [Builder.startIndex]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun startIndex(startIndex: Long) = startIndex(startIndex as Long?) + + /** + * Alias for calling [Builder.startIndex] with `startIndex.orElse(null)`. + */ + fun startIndex(startIndex: Optional) = + startIndex(startIndex.getOrNull()) + + /** + * Sets [Builder.startIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.startIndex] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun startIndex(startIndex: JsonField) = apply { + this.startIndex = startIndex + } + + /** Disconnected target spans, when present */ + fun targetSpans(targetSpans: List?) = + targetSpans(JsonField.ofNullable(targetSpans)) + + /** + * Alias for calling [Builder.targetSpans] with `targetSpans.orElse(null)`. + */ + fun targetSpans(targetSpans: Optional>) = + targetSpans(targetSpans.getOrNull()) + + /** + * Sets [Builder.targetSpans] to an arbitrary JSON value. + * + * You should usually call [Builder.targetSpans] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun targetSpans(targetSpans: JsonField>) = apply { + this.targetSpans = targetSpans.map { it.toMutableList() } + } + + /** + * Adds a single [TargetSpan] to [targetSpans]. + * + * @throws IllegalStateException if the field was previously set to a + * non-list. + */ + fun addTargetSpan(targetSpan: TargetSpan) = apply { + targetSpans = + (targetSpans ?: JsonField.of(mutableListOf())).also { + checkKnown("targetSpans", it).add(targetSpan) + } + } + + 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 [Revision]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .content() + * .revisionBbox() + * .target() + * .targetBbox() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Revision = + Revision( + checkRequired("content", content), + checkRequired("revisionBbox", revisionBbox), + checkRequired("target", target), + checkRequired("targetBbox", targetBbox), + checkRequired("type", type), + author, + endIndex, + startIndex, + (targetSpans ?: JsonMissing.of()).map { it.toImmutable() }, + 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(): Revision = apply { + if (validated) { + return@apply + } + + content() + revisionBbox().validate() + target() + targetBbox().validate() + type().validate() + author() + endIndex() + startIndex() + targetSpans().ifPresent { it.forEach { 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 (content.asKnown().isPresent) 1 else 0) + + (revisionBbox.asKnown().getOrNull()?.validity() ?: 0) + + (if (target.asKnown().isPresent) 1 else 0) + + (targetBbox.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (author.asKnown().isPresent) 1 else 0) + + (if (endIndex.asKnown().isPresent) 1 else 0) + + (if (startIndex.asKnown().isPresent) 1 else 0) + + (targetSpans.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + /** Bounding box of the printed revision balloon */ + class RevisionBbox + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val h: JsonField, + private val w: JsonField, + private val x: JsonField, + private val y: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("h") + @ExcludeMissing + h: JsonField = JsonMissing.of(), + @JsonProperty("w") + @ExcludeMissing + w: JsonField = JsonMissing.of(), + @JsonProperty("x") + @ExcludeMissing + x: JsonField = JsonMissing.of(), + @JsonProperty("y") + @ExcludeMissing + y: JsonField = JsonMissing.of(), + ) : this(h, w, x, y, mutableMapOf()) + + /** + * Height of the bounding box + * + * @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 h(): Double = h.getRequired("h") + + /** + * Width of the bounding box + * + * @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 w(): Double = w.getRequired("w") + + /** + * X coordinate of the bounding box + * + * @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 x(): Double = x.getRequired("x") + + /** + * Y coordinate of the bounding box + * + * @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 y(): Double = y.getRequired("y") + + /** + * Returns the raw JSON value of [h]. + * + * Unlike [h], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("h") @ExcludeMissing fun _h(): JsonField = h + + /** + * Returns the raw JSON value of [w]. + * + * Unlike [w], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("w") @ExcludeMissing fun _w(): JsonField = w + + /** + * Returns the raw JSON value of [x]. + * + * Unlike [x], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("x") @ExcludeMissing fun _x(): JsonField = x + + /** + * Returns the raw JSON value of [y]. + * + * Unlike [y], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("y") @ExcludeMissing fun _y(): JsonField = y + + @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 + * [RevisionBbox]. + * + * The following fields are required: + * ```java + * .h() + * .w() + * .x() + * .y() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [RevisionBbox]. */ + class Builder internal constructor() { + + private var h: JsonField? = null + private var w: JsonField? = null + private var x: JsonField? = null + private var y: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(revisionBbox: RevisionBbox) = apply { + h = revisionBbox.h + w = revisionBbox.w + x = revisionBbox.x + y = revisionBbox.y + additionalProperties = + revisionBbox.additionalProperties.toMutableMap() + } + + /** Height of the bounding box */ + fun h(h: Double) = h(JsonField.of(h)) + + /** + * Sets [Builder.h] to an arbitrary JSON value. + * + * You should usually call [Builder.h] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun h(h: JsonField) = apply { this.h = h } + + /** Width of the bounding box */ + fun w(w: Double) = w(JsonField.of(w)) + + /** + * Sets [Builder.w] to an arbitrary JSON value. + * + * You should usually call [Builder.w] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun w(w: JsonField) = apply { this.w = w } + + /** X coordinate of the bounding box */ + fun x(x: Double) = x(JsonField.of(x)) + + /** + * Sets [Builder.x] to an arbitrary JSON value. + * + * You should usually call [Builder.x] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun x(x: JsonField) = apply { this.x = x } + + /** Y coordinate of the bounding box */ + fun y(y: Double) = y(JsonField.of(y)) + + /** + * Sets [Builder.y] to an arbitrary JSON value. + * + * You should usually call [Builder.y] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun y(y: JsonField) = apply { this.y = y } + + 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 [RevisionBbox]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .h() + * .w() + * .x() + * .y() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): RevisionBbox = + RevisionBbox( + checkRequired("h", h), + checkRequired("w", w), + checkRequired("x", x), + checkRequired("y", y), + 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(): RevisionBbox = apply { + if (validated) { + return@apply + } + + h() + w() + x() + y() + 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 (h.asKnown().isPresent) 1 else 0) + + (if (w.asKnown().isPresent) 1 else 0) + + (if (x.asKnown().isPresent) 1 else 0) + + (if (y.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is RevisionBbox && + h == other.h && + w == other.w && + x == other.x && + y == other.y && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(h, w, x, y, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "RevisionBbox{h=$h, w=$w, x=$x, y=$y, additionalProperties=$additionalProperties}" + } + + /** Union bounding box of the target spans */ + class TargetBbox + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val h: JsonField, + private val w: JsonField, + private val x: JsonField, + private val y: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("h") + @ExcludeMissing + h: JsonField = JsonMissing.of(), + @JsonProperty("w") + @ExcludeMissing + w: JsonField = JsonMissing.of(), + @JsonProperty("x") + @ExcludeMissing + x: JsonField = JsonMissing.of(), + @JsonProperty("y") + @ExcludeMissing + y: JsonField = JsonMissing.of(), + ) : this(h, w, x, y, mutableMapOf()) + + /** + * Height of the bounding box + * + * @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 h(): Double = h.getRequired("h") + + /** + * Width of the bounding box + * + * @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 w(): Double = w.getRequired("w") + + /** + * X coordinate of the bounding box + * + * @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 x(): Double = x.getRequired("x") + + /** + * Y coordinate of the bounding box + * + * @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 y(): Double = y.getRequired("y") + + /** + * Returns the raw JSON value of [h]. + * + * Unlike [h], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("h") @ExcludeMissing fun _h(): JsonField = h + + /** + * Returns the raw JSON value of [w]. + * + * Unlike [w], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("w") @ExcludeMissing fun _w(): JsonField = w + + /** + * Returns the raw JSON value of [x]. + * + * Unlike [x], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("x") @ExcludeMissing fun _x(): JsonField = x + + /** + * Returns the raw JSON value of [y]. + * + * Unlike [y], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("y") @ExcludeMissing fun _y(): JsonField = y + + @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 + * [TargetBbox]. + * + * The following fields are required: + * ```java + * .h() + * .w() + * .x() + * .y() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TargetBbox]. */ + class Builder internal constructor() { + + private var h: JsonField? = null + private var w: JsonField? = null + private var x: JsonField? = null + private var y: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(targetBbox: TargetBbox) = apply { + h = targetBbox.h + w = targetBbox.w + x = targetBbox.x + y = targetBbox.y + additionalProperties = + targetBbox.additionalProperties.toMutableMap() + } + + /** Height of the bounding box */ + fun h(h: Double) = h(JsonField.of(h)) + + /** + * Sets [Builder.h] to an arbitrary JSON value. + * + * You should usually call [Builder.h] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun h(h: JsonField) = apply { this.h = h } + + /** Width of the bounding box */ + fun w(w: Double) = w(JsonField.of(w)) + + /** + * Sets [Builder.w] to an arbitrary JSON value. + * + * You should usually call [Builder.w] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun w(w: JsonField) = apply { this.w = w } + + /** X coordinate of the bounding box */ + fun x(x: Double) = x(JsonField.of(x)) + + /** + * Sets [Builder.x] to an arbitrary JSON value. + * + * You should usually call [Builder.x] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun x(x: JsonField) = apply { this.x = x } + + /** Y coordinate of the bounding box */ + fun y(y: Double) = y(JsonField.of(y)) + + /** + * Sets [Builder.y] to an arbitrary JSON value. + * + * You should usually call [Builder.y] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun y(y: JsonField) = apply { this.y = y } + + 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 [TargetBbox]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .h() + * .w() + * .x() + * .y() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TargetBbox = + TargetBbox( + checkRequired("h", h), + checkRequired("w", w), + checkRequired("x", x), + checkRequired("y", y), + 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(): TargetBbox = apply { + if (validated) { + return@apply + } + + h() + w() + x() + y() + 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 (h.asKnown().isPresent) 1 else 0) + + (if (w.asKnown().isPresent) 1 else 0) + + (if (x.asKnown().isPresent) 1 else 0) + + (if (y.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TargetBbox && + h == other.h && + w == other.w && + x == other.x && + y == other.y && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(h, w, x, y, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TargetBbox{h=$h, w=$w, x=$x, y=$y, additionalProperties=$additionalProperties}" + } + + /** Type of revision */ + class Type + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data + * that doesn't match any known member, and you want to know that value. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val COMMENT = of("comment") + + @JvmField val DELETED = of("deleted") + + @JvmField val FORMATTED = of("formatted") + + @JvmField val INSERTED = of("inserted") + + @JvmField val MOVED_FROM = of("moved_from") + + @JvmField val MOVED_TO = of("moved_to") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + COMMENT, + DELETED, + FORMATTED, + INSERTED, + MOVED_FROM, + MOVED_TO, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API + * may respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COMMENT, + DELETED, + FORMATTED, + INSERTED, + MOVED_FROM, + MOVED_TO, + /** + * An enum member indicating that [Type] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always + * known or if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMMENT -> Value.COMMENT + DELETED -> Value.DELETED + FORMATTED -> Value.FORMATTED + INSERTED -> Value.INSERTED + MOVED_FROM -> Value.MOVED_FROM + MOVED_TO -> Value.MOVED_TO + 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) { + COMMENT -> Known.COMMENT + DELETED -> Known.DELETED + FORMATTED -> Known.FORMATTED + INSERTED -> Known.INSERTED + MOVED_FROM -> Known.MOVED_FROM + MOVED_TO -> Known.MOVED_TO + else -> throw LlamaCloudInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily + * for debugging and generally doesn't throw. + * + * @throws 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(): Type = 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 Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** One contiguous target span linked to a document revision. */ + class TargetSpan + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val target: JsonField, + private val targetBbox: JsonField, + private val endIndex: JsonField, + private val startIndex: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("target") + @ExcludeMissing + target: JsonField = JsonMissing.of(), + @JsonProperty("target_bbox") + @ExcludeMissing + targetBbox: JsonField = JsonMissing.of(), + @JsonProperty("end_index") + @ExcludeMissing + endIndex: JsonField = JsonMissing.of(), + @JsonProperty("start_index") + @ExcludeMissing + startIndex: JsonField = JsonMissing.of(), + ) : this(target, targetBbox, endIndex, startIndex, mutableMapOf()) + + /** + * Text covered by this target span + * + * @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 target(): String = target.getRequired("target") + + /** + * Bounding box of this target span + * + * @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 targetBbox(): TargetBbox = targetBbox.getRequired("target_bbox") + + /** + * Exclusive end offset in final page markdown + * + * @throws LlamaCloudInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun endIndex(): Optional = endIndex.getOptional("end_index") + + /** + * Inclusive start offset in final page markdown + * + * @throws LlamaCloudInvalidDataException if the JSON field has an + * unexpected type (e.g. if the server responded with an unexpected + * value). + */ + fun startIndex(): Optional = startIndex.getOptional("start_index") + + /** + * Returns the raw JSON value of [target]. + * + * Unlike [target], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("target") + @ExcludeMissing + fun _target(): JsonField = target + + /** + * Returns the raw JSON value of [targetBbox]. + * + * Unlike [targetBbox], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("target_bbox") + @ExcludeMissing + fun _targetBbox(): JsonField = targetBbox + + /** + * Returns the raw JSON value of [endIndex]. + * + * Unlike [endIndex], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("end_index") + @ExcludeMissing + fun _endIndex(): JsonField = endIndex + + /** + * Returns the raw JSON value of [startIndex]. + * + * Unlike [startIndex], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("start_index") + @ExcludeMissing + fun _startIndex(): JsonField = startIndex + + @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 + * [TargetSpan]. + * + * The following fields are required: + * ```java + * .target() + * .targetBbox() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TargetSpan]. */ + class Builder internal constructor() { + + private var target: JsonField? = null + private var targetBbox: JsonField? = null + private var endIndex: JsonField = JsonMissing.of() + private var startIndex: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(targetSpan: TargetSpan) = apply { + target = targetSpan.target + targetBbox = targetSpan.targetBbox + endIndex = targetSpan.endIndex + startIndex = targetSpan.startIndex + additionalProperties = + targetSpan.additionalProperties.toMutableMap() + } + + /** Text covered by this target span */ + fun target(target: String) = target(JsonField.of(target)) + + /** + * Sets [Builder.target] to an arbitrary JSON value. + * + * You should usually call [Builder.target] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun target(target: JsonField) = apply { this.target = target } + + /** Bounding box of this target span */ + fun targetBbox(targetBbox: TargetBbox) = + targetBbox(JsonField.of(targetBbox)) + + /** + * Sets [Builder.targetBbox] to an arbitrary JSON value. + * + * You should usually call [Builder.targetBbox] with a well-typed + * [TargetBbox] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun targetBbox(targetBbox: JsonField) = apply { + this.targetBbox = targetBbox + } + + /** Exclusive end offset in final page markdown */ + fun endIndex(endIndex: Long?) = endIndex(JsonField.ofNullable(endIndex)) + + /** + * Alias for [Builder.endIndex]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun endIndex(endIndex: Long) = endIndex(endIndex as Long?) + + /** + * Alias for calling [Builder.endIndex] with `endIndex.orElse(null)`. + */ + fun endIndex(endIndex: Optional) = endIndex(endIndex.getOrNull()) + + /** + * Sets [Builder.endIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.endIndex] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun endIndex(endIndex: JsonField) = apply { + this.endIndex = endIndex + } + + /** Inclusive start offset in final page markdown */ + fun startIndex(startIndex: Long?) = + startIndex(JsonField.ofNullable(startIndex)) + + /** + * Alias for [Builder.startIndex]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun startIndex(startIndex: Long) = startIndex(startIndex as Long?) + + /** + * Alias for calling [Builder.startIndex] with + * `startIndex.orElse(null)`. + */ + fun startIndex(startIndex: Optional) = + startIndex(startIndex.getOrNull()) + + /** + * Sets [Builder.startIndex] to an arbitrary JSON value. + * + * You should usually call [Builder.startIndex] with a well-typed [Long] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun startIndex(startIndex: JsonField) = apply { + this.startIndex = startIndex + } + + 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 [TargetSpan]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .target() + * .targetBbox() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TargetSpan = + TargetSpan( + checkRequired("target", target), + checkRequired("targetBbox", targetBbox), + endIndex, + startIndex, + 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(): TargetSpan = apply { + if (validated) { + return@apply + } + + target() + targetBbox().validate() + endIndex() + startIndex() + 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 (target.asKnown().isPresent) 1 else 0) + + (targetBbox.asKnown().getOrNull()?.validity() ?: 0) + + (if (endIndex.asKnown().isPresent) 1 else 0) + + (if (startIndex.asKnown().isPresent) 1 else 0) + + /** Bounding box of this target span */ + class TargetBbox + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val h: JsonField, + private val w: JsonField, + private val x: JsonField, + private val y: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("h") + @ExcludeMissing + h: JsonField = JsonMissing.of(), + @JsonProperty("w") + @ExcludeMissing + w: JsonField = JsonMissing.of(), + @JsonProperty("x") + @ExcludeMissing + x: JsonField = JsonMissing.of(), + @JsonProperty("y") + @ExcludeMissing + y: JsonField = JsonMissing.of(), + ) : this(h, w, x, y, mutableMapOf()) + + /** + * Height of the bounding box + * + * @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 h(): Double = h.getRequired("h") + + /** + * Width of the bounding box + * + * @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 w(): Double = w.getRequired("w") + + /** + * X coordinate of the bounding box + * + * @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 x(): Double = x.getRequired("x") + + /** + * Y coordinate of the bounding box + * + * @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 y(): Double = y.getRequired("y") + + /** + * Returns the raw JSON value of [h]. + * + * Unlike [h], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("h") @ExcludeMissing fun _h(): JsonField = h + + /** + * Returns the raw JSON value of [w]. + * + * Unlike [w], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("w") @ExcludeMissing fun _w(): JsonField = w + + /** + * Returns the raw JSON value of [x]. + * + * Unlike [x], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("x") @ExcludeMissing fun _x(): JsonField = x + + /** + * Returns the raw JSON value of [y]. + * + * Unlike [y], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("y") @ExcludeMissing fun _y(): JsonField = y + + @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 + * [TargetBbox]. + * + * The following fields are required: + * ```java + * .h() + * .w() + * .x() + * .y() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TargetBbox]. */ + class Builder internal constructor() { + + private var h: JsonField? = null + private var w: JsonField? = null + private var x: JsonField? = null + private var y: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(targetBbox: TargetBbox) = apply { + h = targetBbox.h + w = targetBbox.w + x = targetBbox.x + y = targetBbox.y + additionalProperties = + targetBbox.additionalProperties.toMutableMap() + } + + /** Height of the bounding box */ + fun h(h: Double) = h(JsonField.of(h)) + + /** + * Sets [Builder.h] to an arbitrary JSON value. + * + * You should usually call [Builder.h] with a well-typed [Double] + * value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun h(h: JsonField) = apply { this.h = h } + + /** Width of the bounding box */ + fun w(w: Double) = w(JsonField.of(w)) + + /** + * Sets [Builder.w] to an arbitrary JSON value. + * + * You should usually call [Builder.w] with a well-typed [Double] + * value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun w(w: JsonField) = apply { this.w = w } + + /** X coordinate of the bounding box */ + fun x(x: Double) = x(JsonField.of(x)) + + /** + * Sets [Builder.x] to an arbitrary JSON value. + * + * You should usually call [Builder.x] with a well-typed [Double] + * value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun x(x: JsonField) = apply { this.x = x } + + /** Y coordinate of the bounding box */ + fun y(y: Double) = y(JsonField.of(y)) + + /** + * Sets [Builder.y] to an arbitrary JSON value. + * + * You should usually call [Builder.y] with a well-typed [Double] + * value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun y(y: JsonField) = apply { this.y = y } + + 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 [TargetBbox]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .h() + * .w() + * .x() + * .y() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TargetBbox = + TargetBbox( + checkRequired("h", h), + checkRequired("w", w), + checkRequired("x", x), + checkRequired("y", y), + 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(): TargetBbox = apply { + if (validated) { + return@apply + } + + h() + w() + x() + y() + 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 (h.asKnown().isPresent) 1 else 0) + + (if (w.asKnown().isPresent) 1 else 0) + + (if (x.asKnown().isPresent) 1 else 0) + + (if (y.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TargetBbox && + h == other.h && + w == other.w && + x == other.x && + y == other.y && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(h, w, x, y, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TargetBbox{h=$h, w=$w, x=$x, y=$y, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TargetSpan && + target == other.target && + targetBbox == other.targetBbox && + endIndex == other.endIndex && + startIndex == other.startIndex && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + target, + targetBbox, + endIndex, + startIndex, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TargetSpan{target=$target, targetBbox=$targetBbox, endIndex=$endIndex, startIndex=$startIndex, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Revision && + content == other.content && + revisionBbox == other.revisionBbox && + target == other.target && + targetBbox == other.targetBbox && + type == other.type && + author == other.author && + endIndex == other.endIndex && + startIndex == other.startIndex && + targetSpans == other.targetSpans && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + content, + revisionBbox, + target, + targetBbox, + type, + author, + endIndex, + startIndex, + targetSpans, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Revision{content=$content, revisionBbox=$revisionBbox, target=$target, targetBbox=$targetBbox, type=$type, author=$author, endIndex=$endIndex, startIndex=$startIndex, targetSpans=$targetSpans, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4734,6 +6848,7 @@ private constructor( pageNumber == other.pageNumber && pageWidth == other.pageWidth && success == other.success && + revisions == other.revisions && additionalProperties == other.additionalProperties } @@ -4744,6 +6859,7 @@ private constructor( pageNumber, pageWidth, success, + revisions, additionalProperties, ) } @@ -4751,7 +6867,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "StructuredResultPage{items=$items, pageHeight=$pageHeight, pageNumber=$pageNumber, pageWidth=$pageWidth, success=$success, additionalProperties=$additionalProperties}" + "StructuredResultPage{items=$items, pageHeight=$pageHeight, pageNumber=$pageNumber, pageWidth=$pageWidth, success=$success, revisions=$revisions, additionalProperties=$additionalProperties}" } class FailedStructuredPage diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/pipelines/LlamaParseParameters.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/pipelines/LlamaParseParameters.kt index 93f65cd..61f3601 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/pipelines/LlamaParseParameters.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/pipelines/LlamaParseParameters.kt @@ -28,6 +28,7 @@ private constructor( private val adaptiveLongTable: JsonField, private val aggressiveTableExtraction: JsonField, private val annotateLinks: JsonField, + private val annotateRevisions: JsonField, private val autoMode: JsonField, private val autoModeConfigurationJson: JsonField, private val autoModeTriggerOnImageInPage: JsonField, @@ -159,6 +160,9 @@ private constructor( @JsonProperty("annotate_links") @ExcludeMissing annotateLinks: JsonField = JsonMissing.of(), + @JsonProperty("annotate_revisions") + @ExcludeMissing + annotateRevisions: JsonField = JsonMissing.of(), @JsonProperty("auto_mode") @ExcludeMissing autoMode: JsonField = JsonMissing.of(), @JsonProperty("auto_mode_configuration_json") @ExcludeMissing @@ -486,6 +490,7 @@ private constructor( adaptiveLongTable, aggressiveTableExtraction, annotateLinks, + annotateRevisions, autoMode, autoModeConfigurationJson, autoModeTriggerOnImageInPage, @@ -626,6 +631,12 @@ private constructor( */ fun annotateLinks(): Optional = annotateLinks.getOptional("annotate_links") + /** + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun annotateRevisions(): Optional = annotateRevisions.getOptional("annotate_revisions") + /** * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -1440,6 +1451,16 @@ private constructor( @ExcludeMissing fun _annotateLinks(): JsonField = annotateLinks + /** + * Returns the raw JSON value of [annotateRevisions]. + * + * Unlike [annotateRevisions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("annotate_revisions") + @ExcludeMissing + fun _annotateRevisions(): JsonField = annotateRevisions + /** * Returns the raw JSON value of [autoMode]. * @@ -2547,6 +2568,7 @@ private constructor( private var adaptiveLongTable: JsonField = JsonMissing.of() private var aggressiveTableExtraction: JsonField = JsonMissing.of() private var annotateLinks: JsonField = JsonMissing.of() + private var annotateRevisions: JsonField = JsonMissing.of() private var autoMode: JsonField = JsonMissing.of() private var autoModeConfigurationJson: JsonField = JsonMissing.of() private var autoModeTriggerOnImageInPage: JsonField = JsonMissing.of() @@ -2671,6 +2693,7 @@ private constructor( adaptiveLongTable = llamaParseParameters.adaptiveLongTable aggressiveTableExtraction = llamaParseParameters.aggressiveTableExtraction annotateLinks = llamaParseParameters.annotateLinks + annotateRevisions = llamaParseParameters.annotateRevisions autoMode = llamaParseParameters.autoMode autoModeConfigurationJson = llamaParseParameters.autoModeConfigurationJson autoModeTriggerOnImageInPage = llamaParseParameters.autoModeTriggerOnImageInPage @@ -2881,6 +2904,32 @@ private constructor( this.annotateLinks = annotateLinks } + fun annotateRevisions(annotateRevisions: Boolean?) = + annotateRevisions(JsonField.ofNullable(annotateRevisions)) + + /** + * Alias for [Builder.annotateRevisions]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun annotateRevisions(annotateRevisions: Boolean) = + annotateRevisions(annotateRevisions as Boolean?) + + /** Alias for calling [Builder.annotateRevisions] with `annotateRevisions.orElse(null)`. */ + fun annotateRevisions(annotateRevisions: Optional) = + annotateRevisions(annotateRevisions.getOrNull()) + + /** + * Sets [Builder.annotateRevisions] to an arbitrary JSON value. + * + * You should usually call [Builder.annotateRevisions] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun annotateRevisions(annotateRevisions: JsonField) = apply { + this.annotateRevisions = annotateRevisions + } + fun autoMode(autoMode: Boolean?) = autoMode(JsonField.ofNullable(autoMode)) /** @@ -5665,6 +5714,7 @@ private constructor( adaptiveLongTable, aggressiveTableExtraction, annotateLinks, + annotateRevisions, autoMode, autoModeConfigurationJson, autoModeTriggerOnImageInPage, @@ -5804,6 +5854,7 @@ private constructor( adaptiveLongTable() aggressiveTableExtraction() annotateLinks() + annotateRevisions() autoMode() autoModeConfigurationJson() autoModeTriggerOnImageInPage() @@ -5942,6 +5993,7 @@ private constructor( (if (adaptiveLongTable.asKnown().isPresent) 1 else 0) + (if (aggressiveTableExtraction.asKnown().isPresent) 1 else 0) + (if (annotateLinks.asKnown().isPresent) 1 else 0) + + (if (annotateRevisions.asKnown().isPresent) 1 else 0) + (if (autoMode.asKnown().isPresent) 1 else 0) + (if (autoModeConfigurationJson.asKnown().isPresent) 1 else 0) + (if (autoModeTriggerOnImageInPage.asKnown().isPresent) 1 else 0) + @@ -7208,6 +7260,7 @@ private constructor( adaptiveLongTable == other.adaptiveLongTable && aggressiveTableExtraction == other.aggressiveTableExtraction && annotateLinks == other.annotateLinks && + annotateRevisions == other.annotateRevisions && autoMode == other.autoMode && autoModeConfigurationJson == other.autoModeConfigurationJson && autoModeTriggerOnImageInPage == other.autoModeTriggerOnImageInPage && @@ -7336,6 +7389,7 @@ private constructor( adaptiveLongTable, aggressiveTableExtraction, annotateLinks, + annotateRevisions, autoMode, autoModeConfigurationJson, autoModeTriggerOnImageInPage, @@ -7460,5 +7514,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "LlamaParseParameters{adaptiveLongTable=$adaptiveLongTable, aggressiveTableExtraction=$aggressiveTableExtraction, annotateLinks=$annotateLinks, autoMode=$autoMode, autoModeConfigurationJson=$autoModeConfigurationJson, autoModeTriggerOnImageInPage=$autoModeTriggerOnImageInPage, autoModeTriggerOnRegexpInPage=$autoModeTriggerOnRegexpInPage, autoModeTriggerOnTableInPage=$autoModeTriggerOnTableInPage, autoModeTriggerOnTextInPage=$autoModeTriggerOnTextInPage, azureOpenAIApiVersion=$azureOpenAIApiVersion, azureOpenAIDeploymentName=$azureOpenAIDeploymentName, azureOpenAIEndpoint=$azureOpenAIEndpoint, azureOpenAIKey=$azureOpenAIKey, bboxBottom=$bboxBottom, bboxLeft=$bboxLeft, bboxRight=$bboxRight, bboxTop=$bboxTop, boundingBox=$boundingBox, compactMarkdownTable=$compactMarkdownTable, complementalFormattingInstruction=$complementalFormattingInstruction, confidenceScoreEffort=$confidenceScoreEffort, contentGuidelineInstruction=$contentGuidelineInstruction, continuousMode=$continuousMode, disableImageExtraction=$disableImageExtraction, disableOcr=$disableOcr, disableReconstruction=$disableReconstruction, doNotCache=$doNotCache, doNotUnrollColumns=$doNotUnrollColumns, enableCostOptimizer=$enableCostOptimizer, extractCharts=$extractCharts, extractLayout=$extractLayout, extractPrintedPageNumber=$extractPrintedPageNumber, fastMode=$fastMode, formattingInstruction=$formattingInstruction, gpt4oApiKey=$gpt4oApiKey, gpt4oMode=$gpt4oMode, guessXlsxSheetName=$guessXlsxSheetName, hideFooters=$hideFooters, hideHeaders=$hideHeaders, highResOcr=$highResOcr, htmlMakeAllElementsVisible=$htmlMakeAllElementsVisible, htmlRemoveFixedElements=$htmlRemoveFixedElements, htmlRemoveNavigationElements=$htmlRemoveNavigationElements, httpProxy=$httpProxy, ignoreDocumentElementsForLayoutDetection=$ignoreDocumentElementsForLayoutDetection, imagesToSave=$imagesToSave, inlineImagesInMarkdown=$inlineImagesInMarkdown, inputS3Path=$inputS3Path, inputS3Region=$inputS3Region, inputUrl=$inputUrl, internalIsScreenshotJob=$internalIsScreenshotJob, invalidateCache=$invalidateCache, isFormattingInstruction=$isFormattingInstruction, jobTimeoutExtraTimePerPageInSeconds=$jobTimeoutExtraTimePerPageInSeconds, jobTimeoutInSeconds=$jobTimeoutInSeconds, keepPageSeparatorWhenMergingTables=$keepPageSeparatorWhenMergingTables, languages=$languages, layoutAware=$layoutAware, lineLevelBoundingBox=$lineLevelBoundingBox, markdownTableMultilineHeaderSeparator=$markdownTableMultilineHeaderSeparator, maxPages=$maxPages, maxPagesEnforced=$maxPagesEnforced, mergeTablesAcrossPagesInMarkdown=$mergeTablesAcrossPagesInMarkdown, model=$model, outlinedTableExtraction=$outlinedTableExtraction, outputPdfOfDocument=$outputPdfOfDocument, outputS3PathPrefix=$outputS3PathPrefix, outputS3Region=$outputS3Region, outputTablesAsHtml=$outputTablesAsHtml, pageErrorTolerance=$pageErrorTolerance, pageFooterPrefix=$pageFooterPrefix, pageFooterSuffix=$pageFooterSuffix, pageHeaderPrefix=$pageHeaderPrefix, pageHeaderSuffix=$pageHeaderSuffix, pagePrefix=$pagePrefix, pageSeparator=$pageSeparator, pageSuffix=$pageSuffix, parseMode=$parseMode, parsingInstruction=$parsingInstruction, preciseBoundingBox=$preciseBoundingBox, premiumMode=$premiumMode, presentationOutOfBoundsContent=$presentationOutOfBoundsContent, presentationSkipEmbeddedData=$presentationSkipEmbeddedData, preserveLayoutAlignmentAcrossPages=$preserveLayoutAlignmentAcrossPages, preserveVerySmallText=$preserveVerySmallText, preset=$preset, priority=$priority, projectId=$projectId, removeHiddenText=$removeHiddenText, replaceFailedPageMode=$replaceFailedPageMode, replaceFailedPageWithErrorMessagePrefix=$replaceFailedPageWithErrorMessagePrefix, replaceFailedPageWithErrorMessageSuffix=$replaceFailedPageWithErrorMessageSuffix, saveImages=$saveImages, skipDiagonalText=$skipDiagonalText, specializedChartParsingAgentic=$specializedChartParsingAgentic, specializedChartParsingEfficient=$specializedChartParsingEfficient, specializedChartParsingPlus=$specializedChartParsingPlus, specializedImageParsing=$specializedImageParsing, spreadsheetExtractSubTables=$spreadsheetExtractSubTables, spreadsheetForceFormulaComputation=$spreadsheetForceFormulaComputation, spreadsheetIncludeHiddenSheets=$spreadsheetIncludeHiddenSheets, strictModeBuggyFont=$strictModeBuggyFont, strictModeImageExtraction=$strictModeImageExtraction, strictModeImageOcr=$strictModeImageOcr, strictModeReconstruction=$strictModeReconstruction, structuredOutput=$structuredOutput, structuredOutputJsonSchema=$structuredOutputJsonSchema, structuredOutputJsonSchemaName=$structuredOutputJsonSchemaName, systemPrompt=$systemPrompt, systemPromptAppend=$systemPromptAppend, takeScreenshot=$takeScreenshot, targetPages=$targetPages, tier=$tier, useVendorMultimodalModel=$useVendorMultimodalModel, userPrompt=$userPrompt, vendorMultimodalApiKey=$vendorMultimodalApiKey, vendorMultimodalModelName=$vendorMultimodalModelName, version=$version, webhookConfigurations=$webhookConfigurations, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + "LlamaParseParameters{adaptiveLongTable=$adaptiveLongTable, aggressiveTableExtraction=$aggressiveTableExtraction, annotateLinks=$annotateLinks, annotateRevisions=$annotateRevisions, autoMode=$autoMode, autoModeConfigurationJson=$autoModeConfigurationJson, autoModeTriggerOnImageInPage=$autoModeTriggerOnImageInPage, autoModeTriggerOnRegexpInPage=$autoModeTriggerOnRegexpInPage, autoModeTriggerOnTableInPage=$autoModeTriggerOnTableInPage, autoModeTriggerOnTextInPage=$autoModeTriggerOnTextInPage, azureOpenAIApiVersion=$azureOpenAIApiVersion, azureOpenAIDeploymentName=$azureOpenAIDeploymentName, azureOpenAIEndpoint=$azureOpenAIEndpoint, azureOpenAIKey=$azureOpenAIKey, bboxBottom=$bboxBottom, bboxLeft=$bboxLeft, bboxRight=$bboxRight, bboxTop=$bboxTop, boundingBox=$boundingBox, compactMarkdownTable=$compactMarkdownTable, complementalFormattingInstruction=$complementalFormattingInstruction, confidenceScoreEffort=$confidenceScoreEffort, contentGuidelineInstruction=$contentGuidelineInstruction, continuousMode=$continuousMode, disableImageExtraction=$disableImageExtraction, disableOcr=$disableOcr, disableReconstruction=$disableReconstruction, doNotCache=$doNotCache, doNotUnrollColumns=$doNotUnrollColumns, enableCostOptimizer=$enableCostOptimizer, extractCharts=$extractCharts, extractLayout=$extractLayout, extractPrintedPageNumber=$extractPrintedPageNumber, fastMode=$fastMode, formattingInstruction=$formattingInstruction, gpt4oApiKey=$gpt4oApiKey, gpt4oMode=$gpt4oMode, guessXlsxSheetName=$guessXlsxSheetName, hideFooters=$hideFooters, hideHeaders=$hideHeaders, highResOcr=$highResOcr, htmlMakeAllElementsVisible=$htmlMakeAllElementsVisible, htmlRemoveFixedElements=$htmlRemoveFixedElements, htmlRemoveNavigationElements=$htmlRemoveNavigationElements, httpProxy=$httpProxy, ignoreDocumentElementsForLayoutDetection=$ignoreDocumentElementsForLayoutDetection, imagesToSave=$imagesToSave, inlineImagesInMarkdown=$inlineImagesInMarkdown, inputS3Path=$inputS3Path, inputS3Region=$inputS3Region, inputUrl=$inputUrl, internalIsScreenshotJob=$internalIsScreenshotJob, invalidateCache=$invalidateCache, isFormattingInstruction=$isFormattingInstruction, jobTimeoutExtraTimePerPageInSeconds=$jobTimeoutExtraTimePerPageInSeconds, jobTimeoutInSeconds=$jobTimeoutInSeconds, keepPageSeparatorWhenMergingTables=$keepPageSeparatorWhenMergingTables, languages=$languages, layoutAware=$layoutAware, lineLevelBoundingBox=$lineLevelBoundingBox, markdownTableMultilineHeaderSeparator=$markdownTableMultilineHeaderSeparator, maxPages=$maxPages, maxPagesEnforced=$maxPagesEnforced, mergeTablesAcrossPagesInMarkdown=$mergeTablesAcrossPagesInMarkdown, model=$model, outlinedTableExtraction=$outlinedTableExtraction, outputPdfOfDocument=$outputPdfOfDocument, outputS3PathPrefix=$outputS3PathPrefix, outputS3Region=$outputS3Region, outputTablesAsHtml=$outputTablesAsHtml, pageErrorTolerance=$pageErrorTolerance, pageFooterPrefix=$pageFooterPrefix, pageFooterSuffix=$pageFooterSuffix, pageHeaderPrefix=$pageHeaderPrefix, pageHeaderSuffix=$pageHeaderSuffix, pagePrefix=$pagePrefix, pageSeparator=$pageSeparator, pageSuffix=$pageSuffix, parseMode=$parseMode, parsingInstruction=$parsingInstruction, preciseBoundingBox=$preciseBoundingBox, premiumMode=$premiumMode, presentationOutOfBoundsContent=$presentationOutOfBoundsContent, presentationSkipEmbeddedData=$presentationSkipEmbeddedData, preserveLayoutAlignmentAcrossPages=$preserveLayoutAlignmentAcrossPages, preserveVerySmallText=$preserveVerySmallText, preset=$preset, priority=$priority, projectId=$projectId, removeHiddenText=$removeHiddenText, replaceFailedPageMode=$replaceFailedPageMode, replaceFailedPageWithErrorMessagePrefix=$replaceFailedPageWithErrorMessagePrefix, replaceFailedPageWithErrorMessageSuffix=$replaceFailedPageWithErrorMessageSuffix, saveImages=$saveImages, skipDiagonalText=$skipDiagonalText, specializedChartParsingAgentic=$specializedChartParsingAgentic, specializedChartParsingEfficient=$specializedChartParsingEfficient, specializedChartParsingPlus=$specializedChartParsingPlus, specializedImageParsing=$specializedImageParsing, spreadsheetExtractSubTables=$spreadsheetExtractSubTables, spreadsheetForceFormulaComputation=$spreadsheetForceFormulaComputation, spreadsheetIncludeHiddenSheets=$spreadsheetIncludeHiddenSheets, strictModeBuggyFont=$strictModeBuggyFont, strictModeImageExtraction=$strictModeImageExtraction, strictModeImageOcr=$strictModeImageOcr, strictModeReconstruction=$strictModeReconstruction, structuredOutput=$structuredOutput, structuredOutputJsonSchema=$structuredOutputJsonSchema, structuredOutputJsonSchemaName=$structuredOutputJsonSchemaName, systemPrompt=$systemPrompt, systemPromptAppend=$systemPromptAppend, takeScreenshot=$takeScreenshot, targetPages=$targetPages, tier=$tier, useVendorMultimodalModel=$useVendorMultimodalModel, userPrompt=$userPrompt, vendorMultimodalApiKey=$vendorMultimodalApiKey, vendorMultimodalModelName=$vendorMultimodalModelName, version=$version, webhookConfigurations=$webhookConfigurations, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateParamsTest.kt index ed68521..2b3cdd5 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateParamsTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateParamsTest.kt @@ -32,6 +32,7 @@ internal class BatchCreateParamsTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -266,6 +267,7 @@ internal class BatchCreateParamsTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -522,6 +524,7 @@ internal class BatchCreateParamsTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -783,6 +786,7 @@ internal class BatchCreateParamsTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -1018,6 +1022,7 @@ internal class BatchCreateParamsTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsResponseTest.kt index e34c324..592f9bf 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsResponseTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsResponseTest.kt @@ -43,6 +43,7 @@ internal class JobItemGetProcessingResultsResponseTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -326,6 +327,7 @@ internal class JobItemGetProcessingResultsResponseTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -604,6 +606,7 @@ internal class JobItemGetProcessingResultsResponseTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/configurations/ParseV2ParametersTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/configurations/ParseV2ParametersTest.kt index 747dd04..94f15c7 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/configurations/ParseV2ParametersTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/configurations/ParseV2ParametersTest.kt @@ -79,6 +79,7 @@ internal class ParseV2ParametersTest { .markdown( ParseV2Parameters.OutputOptions.Markdown.builder() .annotateLinks(true) + .annotateRevisions(true) .inlineImages(true) .tables( ParseV2Parameters.OutputOptions.Markdown.Tables.builder() @@ -365,6 +366,7 @@ internal class ParseV2ParametersTest { .markdown( ParseV2Parameters.OutputOptions.Markdown.builder() .annotateLinks(true) + .annotateRevisions(true) .inlineImages(true) .tables( ParseV2Parameters.OutputOptions.Markdown.Tables.builder() @@ -649,6 +651,7 @@ internal class ParseV2ParametersTest { .markdown( ParseV2Parameters.OutputOptions.Markdown.builder() .annotateLinks(true) + .annotateRevisions(true) .inlineImages(true) .tables( ParseV2Parameters.OutputOptions.Markdown.Tables.builder() diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParamsTest.kt index 077554a..6245f16 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParamsTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParamsTest.kt @@ -81,6 +81,7 @@ internal class ParsingCreateParamsTest { .markdown( ParsingCreateParams.OutputOptions.Markdown.builder() .annotateLinks(true) + .annotateRevisions(true) .inlineImages(true) .tables( ParsingCreateParams.OutputOptions.Markdown.Tables.builder() @@ -375,6 +376,7 @@ internal class ParsingCreateParamsTest { .markdown( ParsingCreateParams.OutputOptions.Markdown.builder() .annotateLinks(true) + .annotateRevisions(true) .inlineImages(true) .tables( ParsingCreateParams.OutputOptions.Markdown.Tables.builder() @@ -699,6 +701,7 @@ internal class ParsingCreateParamsTest { .markdown( ParsingCreateParams.OutputOptions.Markdown.builder() .annotateLinks(true) + .annotateRevisions(true) .inlineImages(true) .tables( ParsingCreateParams.OutputOptions.Markdown.Tables.builder() @@ -997,6 +1000,7 @@ internal class ParsingCreateParamsTest { .markdown( ParsingCreateParams.OutputOptions.Markdown.builder() .annotateLinks(true) + .annotateRevisions(true) .inlineImages(true) .tables( ParsingCreateParams.OutputOptions.Markdown.Tables.builder() diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponseTest.kt index 462a70f..df75633 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponseTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponseTest.kt @@ -145,6 +145,67 @@ internal class ParsingGetResponseTest { .pageHeight(0.0) .pageNumber(0L) .pageWidth(0.0) + .addRevision( + ParsingGetResponse.Items.Page.StructuredResultPage.Revision + .builder() + .content("content") + .revisionBbox( + ParsingGetResponse.Items.Page.StructuredResultPage + .Revision + .RevisionBbox + .builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .build() + ) + .target("target") + .targetBbox( + ParsingGetResponse.Items.Page.StructuredResultPage + .Revision + .TargetBbox + .builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .build() + ) + .type( + ParsingGetResponse.Items.Page.StructuredResultPage + .Revision + .Type + .COMMENT + ) + .author("author") + .endIndex(0L) + .startIndex(0L) + .addTargetSpan( + ParsingGetResponse.Items.Page.StructuredResultPage + .Revision + .TargetSpan + .builder() + .target("target") + .targetBbox( + ParsingGetResponse.Items.Page + .StructuredResultPage + .Revision + .TargetSpan + .TargetBbox + .builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .build() + ) + .endIndex(0L) + .startIndex(0L) + .build() + ) + .build() + ) .build() ) .build() @@ -347,6 +408,62 @@ internal class ParsingGetResponseTest { .pageHeight(0.0) .pageNumber(0L) .pageWidth(0.0) + .addRevision( + ParsingGetResponse.Items.Page.StructuredResultPage.Revision + .builder() + .content("content") + .revisionBbox( + ParsingGetResponse.Items.Page.StructuredResultPage.Revision + .RevisionBbox + .builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .build() + ) + .target("target") + .targetBbox( + ParsingGetResponse.Items.Page.StructuredResultPage.Revision + .TargetBbox + .builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .build() + ) + .type( + ParsingGetResponse.Items.Page.StructuredResultPage.Revision + .Type + .COMMENT + ) + .author("author") + .endIndex(0L) + .startIndex(0L) + .addTargetSpan( + ParsingGetResponse.Items.Page.StructuredResultPage.Revision + .TargetSpan + .builder() + .target("target") + .targetBbox( + ParsingGetResponse.Items.Page.StructuredResultPage + .Revision + .TargetSpan + .TargetBbox + .builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .build() + ) + .endIndex(0L) + .startIndex(0L) + .build() + ) + .build() + ) .build() ) .build() @@ -555,6 +672,67 @@ internal class ParsingGetResponseTest { .pageHeight(0.0) .pageNumber(0L) .pageWidth(0.0) + .addRevision( + ParsingGetResponse.Items.Page.StructuredResultPage.Revision + .builder() + .content("content") + .revisionBbox( + ParsingGetResponse.Items.Page.StructuredResultPage + .Revision + .RevisionBbox + .builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .build() + ) + .target("target") + .targetBbox( + ParsingGetResponse.Items.Page.StructuredResultPage + .Revision + .TargetBbox + .builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .build() + ) + .type( + ParsingGetResponse.Items.Page.StructuredResultPage + .Revision + .Type + .COMMENT + ) + .author("author") + .endIndex(0L) + .startIndex(0L) + .addTargetSpan( + ParsingGetResponse.Items.Page.StructuredResultPage + .Revision + .TargetSpan + .builder() + .target("target") + .targetBbox( + ParsingGetResponse.Items.Page + .StructuredResultPage + .Revision + .TargetSpan + .TargetBbox + .builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .build() + ) + .endIndex(0L) + .startIndex(0L) + .build() + ) + .build() + ) .build() ) .build() diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/LlamaParseParametersTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/LlamaParseParametersTest.kt index 3becdef..e695f4b 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/LlamaParseParametersTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/LlamaParseParametersTest.kt @@ -21,6 +21,7 @@ internal class LlamaParseParametersTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -167,6 +168,7 @@ internal class LlamaParseParametersTest { assertThat(llamaParseParameters.adaptiveLongTable()).contains(true) assertThat(llamaParseParameters.aggressiveTableExtraction()).contains(true) assertThat(llamaParseParameters.annotateLinks()).contains(true) + assertThat(llamaParseParameters.annotateRevisions()).contains(true) assertThat(llamaParseParameters.autoMode()).contains(true) assertThat(llamaParseParameters.autoModeConfigurationJson()) .contains("auto_mode_configuration_json") @@ -328,6 +330,7 @@ internal class LlamaParseParametersTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/PipelineCreateParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/PipelineCreateParamsTest.kt index 053de42..3b92f4c 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/PipelineCreateParamsTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/PipelineCreateParamsTest.kt @@ -70,6 +70,7 @@ internal class PipelineCreateParamsTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -348,6 +349,7 @@ internal class PipelineCreateParamsTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -652,6 +654,7 @@ internal class PipelineCreateParamsTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -927,6 +930,7 @@ internal class PipelineCreateParamsTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/PipelineCreateTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/PipelineCreateTest.kt index 356b738..9a1e16c 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/PipelineCreateTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/PipelineCreateTest.kt @@ -68,6 +68,7 @@ internal class PipelineCreateTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -333,6 +334,7 @@ internal class PipelineCreateTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -600,6 +602,7 @@ internal class PipelineCreateTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/PipelineTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/PipelineTest.kt index 4d08b8e..e083de2 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/PipelineTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/PipelineTest.kt @@ -127,6 +127,7 @@ internal class PipelineTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -449,6 +450,7 @@ internal class PipelineTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -773,6 +775,7 @@ internal class PipelineTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/PipelineUpdateParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/PipelineUpdateParamsTest.kt index ceb6078..3ce70d1 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/PipelineUpdateParamsTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/PipelineUpdateParamsTest.kt @@ -65,6 +65,7 @@ internal class PipelineUpdateParamsTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -337,6 +338,7 @@ internal class PipelineUpdateParamsTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -602,6 +604,7 @@ internal class PipelineUpdateParamsTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/PipelineUpsertParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/PipelineUpsertParamsTest.kt index 83442b0..52743a8 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/PipelineUpsertParamsTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/PipelineUpsertParamsTest.kt @@ -70,6 +70,7 @@ internal class PipelineUpsertParamsTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -348,6 +349,7 @@ internal class PipelineUpsertParamsTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -652,6 +654,7 @@ internal class PipelineUpsertParamsTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -927,6 +930,7 @@ internal class PipelineUpsertParamsTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/ServiceParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/ServiceParamsTest.kt index 73198d7..63ddc8f 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/ServiceParamsTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/ServiceParamsTest.kt @@ -138,6 +138,7 @@ internal class ServiceParamsTest { .markdown( ParsingCreateParams.OutputOptions.Markdown.builder() .annotateLinks(true) + .annotateRevisions(true) .inlineImages(true) .tables( ParsingCreateParams.OutputOptions.Markdown.Tables.builder() diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncTest.kt index c846035..0ff7cd3 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncTest.kt @@ -93,6 +93,7 @@ internal class ParsingServiceAsyncTest { .markdown( ParsingCreateParams.OutputOptions.Markdown.builder() .annotateLinks(true) + .annotateRevisions(true) .inlineImages(true) .tables( ParsingCreateParams.OutputOptions.Markdown.Tables.builder() diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/PipelineServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/PipelineServiceAsyncTest.kt index 0e4a865..d6407de 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/PipelineServiceAsyncTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/PipelineServiceAsyncTest.kt @@ -100,6 +100,7 @@ internal class PipelineServiceAsyncTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -441,6 +442,7 @@ internal class PipelineServiceAsyncTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -791,6 +793,7 @@ internal class PipelineServiceAsyncTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/beta/BatchServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/beta/BatchServiceAsyncTest.kt index 2a83b9e..c941a7c 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/beta/BatchServiceAsyncTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/beta/BatchServiceAsyncTest.kt @@ -40,6 +40,7 @@ internal class BatchServiceAsyncTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceTest.kt index 156f0f4..f82cf17 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceTest.kt @@ -93,6 +93,7 @@ internal class ParsingServiceTest { .markdown( ParsingCreateParams.OutputOptions.Markdown.builder() .annotateLinks(true) + .annotateRevisions(true) .inlineImages(true) .tables( ParsingCreateParams.OutputOptions.Markdown.Tables.builder() diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/PipelineServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/PipelineServiceTest.kt index 6d57683..828eae7 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/PipelineServiceTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/PipelineServiceTest.kt @@ -100,6 +100,7 @@ internal class PipelineServiceTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -439,6 +440,7 @@ internal class PipelineServiceTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) @@ -783,6 +785,7 @@ internal class PipelineServiceTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/BatchServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/BatchServiceTest.kt index ed01a31..f21fc58 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/BatchServiceTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/BatchServiceTest.kt @@ -40,6 +40,7 @@ internal class BatchServiceTest { .adaptiveLongTable(true) .aggressiveTableExtraction(true) .annotateLinks(true) + .annotateRevisions(true) .autoMode(true) .autoModeConfigurationJson("auto_mode_configuration_json") .autoModeTriggerOnImageInPage(true) From 9f6718aa55e83c0ae5dab1c6592b17913b8534a6 Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Mon, 3 Aug 2026 21:54:13 +0000 Subject: [PATCH 13/28] LI-8489: surface Parse V2 cancel; withhold Batches from the SDK Stainless-Generated-From: 29dc7c5acf32a915e4065b7c7c1242655511364b --- .stats.yml | 2 +- .../llamacloud/client/LlamaCloudClient.kt | 5 - .../client/LlamaCloudClientAsync.kt | 5 - .../client/LlamaCloudClientAsyncImpl.kt | 14 - .../llamacloud/client/LlamaCloudClientImpl.kt | 12 - .../models/batches/BatchCreateParams.kt | 2183 --- .../models/batches/BatchCreateResponse.kt | 1867 --- .../models/batches/BatchGetParams.kt | 258 - .../models/batches/BatchGetResponse.kt | 1867 --- .../models/batches/BatchListPage.kt | 130 - .../models/batches/BatchListPageAsync.kt | 145 - .../models/batches/BatchListPageResponse.kt | 303 - .../models/batches/BatchListParams.kt | 490 - .../models/batches/BatchListResponse.kt | 1867 --- .../models/beta/batch/BatchCancelParams.kt | 489 - .../models/beta/batch/BatchCancelResponse.kt | 464 - .../models/beta/batch/BatchCreateParams.kt | 10788 --------------- .../models/beta/batch/BatchCreateResponse.kt | 1172 -- .../beta/batch/BatchGetStatusResponse.kt | 1427 -- .../models/beta/batch/BatchListPage.kt | 137 - .../models/beta/batch/BatchListPageAsync.kt | 152 - .../beta/batch/BatchListPageResponse.kt | 303 - .../models/beta/batch/BatchListParams.kt | 620 - .../models/beta/batch/BatchListResponse.kt | 1172 -- .../JobItemGetProcessingResultsParams.kt | 405 - .../JobItemGetProcessingResultsResponse.kt | 11091 ---------------- .../beta/batch/jobitems/JobItemListPage.kt | 138 - .../batch/jobitems/JobItemListPageAsync.kt | 153 - .../batch/jobitems/JobItemListPageResponse.kt | 290 - .../beta/batch/jobitems/JobItemListParams.kt | 463 - .../ParsingCancelParams.kt} | 84 +- .../ParsingCancelResponse.kt} | 556 +- .../services/async/BatchServiceAsync.kt | 195 - .../services/async/BatchServiceAsyncImpl.kt | 178 - .../services/async/BetaServiceAsync.kt | 5 - .../services/async/BetaServiceAsyncImpl.kt | 12 - .../services/async/ParsingServiceAsync.kt | 83 + .../services/async/ParsingServiceAsyncImpl.kt | 43 + .../services/async/beta/BatchServiceAsync.kt | 293 - .../async/beta/BatchServiceAsyncImpl.kt | 240 - .../async/beta/batch/JobItemServiceAsync.kt | 212 - .../beta/batch/JobItemServiceAsyncImpl.kt | 155 - .../services/blocking/BatchService.kt | 189 - .../services/blocking/BatchServiceImpl.kt | 161 - .../services/blocking/BetaService.kt | 5 - .../services/blocking/BetaServiceImpl.kt | 12 - .../services/blocking/ParsingService.kt | 81 + .../services/blocking/ParsingServiceImpl.kt | 40 + .../services/blocking/beta/BatchService.kt | 285 - .../blocking/beta/BatchServiceImpl.kt | 223 - .../blocking/beta/batch/JobItemService.kt | 203 - .../blocking/beta/batch/JobItemServiceImpl.kt | 144 - .../models/batches/BatchCreateParamsTest.kt | 237 - .../models/batches/BatchCreateResponseTest.kt | 125 - .../models/batches/BatchGetParamsTest.kt | 63 - .../models/batches/BatchGetResponseTest.kt | 125 - .../batches/BatchListPageResponseTest.kt | 139 - .../models/batches/BatchListParamsTest.kt | 65 - .../models/batches/BatchListResponseTest.kt | 125 - .../beta/batch/BatchCancelParamsTest.kt | 111 - .../beta/batch/BatchCancelResponseTest.kt | 47 - .../beta/batch/BatchCreateParamsTest.kt | 1264 -- .../beta/batch/BatchCreateResponseTest.kt | 94 - .../beta/batch/BatchGetStatusResponseTest.kt | 103 - .../beta/batch/BatchListPageResponseTest.kt | 106 - .../models/beta/batch/BatchListParamsTest.kt | 61 - .../beta/batch/BatchListResponseTest.kt | 94 - .../JobItemGetProcessingResultsParamsTest.kt | 60 - ...JobItemGetProcessingResultsResponseTest.kt | 877 -- .../jobitems/JobItemListPageResponseTest.kt | 86 - .../batch/jobitems/JobItemListParamsTest.kt | 66 - .../batch/jobitems/JobItemListResponseTest.kt | 69 - .../ParsingCancelParamsTest.kt} | 12 +- .../parsing/ParsingCancelResponseTest.kt | 83 + .../services/async/BatchServiceAsyncTest.kt | 98 - .../services/async/ParsingServiceAsyncTest.kt | 20 + .../async/beta/BatchServiceAsyncTest.kt | 329 - .../beta/batch/JobItemServiceAsyncTest.kt | 43 - .../services/blocking/BatchServiceTest.kt | 95 - .../services/blocking/ParsingServiceTest.kt | 19 + .../blocking/beta/BatchServiceTest.kt | 325 - .../blocking/beta/batch/JobItemServiceTest.kt | 41 - .../proguard/ProGuardCompatibilityTest.kt | 1 - 83 files changed, 748 insertions(+), 46046 deletions(-) delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParams.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateResponse.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetParams.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetResponse.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPage.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageAsync.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageResponse.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListParams.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListResponse.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCancelParams.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCancelResponse.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateParams.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateResponse.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchGetStatusResponse.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListPage.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListPageAsync.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListPageResponse.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListParams.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListResponse.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsParams.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsResponse.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListPage.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListPageAsync.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListPageResponse.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListParams.kt rename llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/{beta/batch/BatchGetStatusParams.kt => parsing/ParsingCancelParams.kt} (70%) rename llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/{beta/batch/jobitems/JobItemListResponse.kt => parsing/ParsingCancelResponse.kt} (51%) delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsync.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncImpl.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/beta/BatchServiceAsync.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/beta/BatchServiceAsyncImpl.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/beta/batch/JobItemServiceAsync.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/beta/batch/JobItemServiceAsyncImpl.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchService.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceImpl.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/BatchService.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/BatchServiceImpl.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/batch/JobItemService.kt delete mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/batch/JobItemServiceImpl.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParamsTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateResponseTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetParamsTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetResponseTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageResponseTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListParamsTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListResponseTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCancelParamsTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCancelResponseTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateParamsTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateResponseTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchGetStatusResponseTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListPageResponseTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListParamsTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListResponseTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsParamsTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsResponseTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListPageResponseTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListParamsTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListResponseTest.kt rename llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/{beta/batch/BatchGetStatusParamsTest.kt => parsing/ParsingCancelParamsTest.kt} (81%) create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCancelResponseTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/beta/BatchServiceAsyncTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/beta/batch/JobItemServiceAsyncTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/BatchServiceTest.kt delete mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/batch/JobItemServiceTest.kt diff --git a/.stats.yml b/.stats.yml index a77bc26..dcc1db9 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 136 +configured_endpoints: 128 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 3e7677a..0ee14b3 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 @@ -3,7 +3,6 @@ package ai.llamaindex.llamacloud.client import ai.llamaindex.llamacloud.core.ClientOptions -import ai.llamaindex.llamacloud.services.blocking.BatchService import ai.llamaindex.llamacloud.services.blocking.BetaService import ai.llamaindex.llamacloud.services.blocking.ClassifierService import ai.llamaindex.llamacloud.services.blocking.ClassifyService @@ -65,8 +64,6 @@ interface LlamaCloudClient { fun classifier(): ClassifierService - fun batches(): BatchService - fun classify(): ClassifyService fun configurations(): ConfigurationService @@ -116,8 +113,6 @@ interface LlamaCloudClient { fun classifier(): ClassifierService.WithRawResponse - fun batches(): BatchService.WithRawResponse - fun classify(): ClassifyService.WithRawResponse fun configurations(): ConfigurationService.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 32487c4..cbb2ea6 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 @@ -3,7 +3,6 @@ package ai.llamaindex.llamacloud.client import ai.llamaindex.llamacloud.core.ClientOptions -import ai.llamaindex.llamacloud.services.async.BatchServiceAsync import ai.llamaindex.llamacloud.services.async.BetaServiceAsync import ai.llamaindex.llamacloud.services.async.ClassifierServiceAsync import ai.llamaindex.llamacloud.services.async.ClassifyServiceAsync @@ -65,8 +64,6 @@ interface LlamaCloudClientAsync { fun classifier(): ClassifierServiceAsync - fun batches(): BatchServiceAsync - fun classify(): ClassifyServiceAsync fun configurations(): ConfigurationServiceAsync @@ -120,8 +117,6 @@ interface LlamaCloudClientAsync { fun classifier(): ClassifierServiceAsync.WithRawResponse - fun batches(): BatchServiceAsync.WithRawResponse - fun classify(): ClassifyServiceAsync.WithRawResponse fun configurations(): ConfigurationServiceAsync.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 84dfcbc..d0a4aeb 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 @@ -4,8 +4,6 @@ package ai.llamaindex.llamacloud.client import ai.llamaindex.llamacloud.core.ClientOptions import ai.llamaindex.llamacloud.core.getPackageVersion -import ai.llamaindex.llamacloud.services.async.BatchServiceAsync -import ai.llamaindex.llamacloud.services.async.BatchServiceAsyncImpl import ai.llamaindex.llamacloud.services.async.BetaServiceAsync import ai.llamaindex.llamacloud.services.async.BetaServiceAsyncImpl import ai.llamaindex.llamacloud.services.async.ClassifierServiceAsync @@ -69,10 +67,6 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam ClassifierServiceAsyncImpl(clientOptionsWithUserAgent) } - private val batches: BatchServiceAsync by lazy { - BatchServiceAsyncImpl(clientOptionsWithUserAgent) - } - private val classify: ClassifyServiceAsync by lazy { ClassifyServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -120,8 +114,6 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam override fun classifier(): ClassifierServiceAsync = classifier - override fun batches(): BatchServiceAsync = batches - override fun classify(): ClassifyServiceAsync = classify override fun configurations(): ConfigurationServiceAsync = configurations @@ -163,10 +155,6 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam ClassifierServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val batches: BatchServiceAsync.WithRawResponse by lazy { - BatchServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - private val classify: ClassifyServiceAsync.WithRawResponse by lazy { ClassifyServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -216,8 +204,6 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam override fun classifier(): ClassifierServiceAsync.WithRawResponse = classifier - override fun batches(): BatchServiceAsync.WithRawResponse = batches - override fun classify(): ClassifyServiceAsync.WithRawResponse = classify override fun configurations(): ConfigurationServiceAsync.WithRawResponse = configurations 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 df8f4db..6b8dd07 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 @@ -4,8 +4,6 @@ package ai.llamaindex.llamacloud.client import ai.llamaindex.llamacloud.core.ClientOptions import ai.llamaindex.llamacloud.core.getPackageVersion -import ai.llamaindex.llamacloud.services.blocking.BatchService -import ai.llamaindex.llamacloud.services.blocking.BatchServiceImpl import ai.llamaindex.llamacloud.services.blocking.BetaService import ai.llamaindex.llamacloud.services.blocking.BetaServiceImpl import ai.llamaindex.llamacloud.services.blocking.ClassifierService @@ -63,8 +61,6 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou ClassifierServiceImpl(clientOptionsWithUserAgent) } - private val batches: BatchService by lazy { BatchServiceImpl(clientOptionsWithUserAgent) } - private val classify: ClassifyService by lazy { ClassifyServiceImpl(clientOptionsWithUserAgent) } @@ -110,8 +106,6 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou override fun classifier(): ClassifierService = classifier - override fun batches(): BatchService = batches - override fun classify(): ClassifyService = classify override fun configurations(): ConfigurationService = configurations @@ -153,10 +147,6 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou ClassifierServiceImpl.WithRawResponseImpl(clientOptions) } - private val batches: BatchService.WithRawResponse by lazy { - BatchServiceImpl.WithRawResponseImpl(clientOptions) - } - private val classify: ClassifyService.WithRawResponse by lazy { ClassifyServiceImpl.WithRawResponseImpl(clientOptions) } @@ -206,8 +196,6 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou override fun classifier(): ClassifierService.WithRawResponse = classifier - override fun batches(): BatchService.WithRawResponse = batches - override fun classify(): ClassifyService.WithRawResponse = classify override fun configurations(): ConfigurationService.WithRawResponse = configurations diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParams.kt deleted file mode 100644 index e88e1bd..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParams.kt +++ /dev/null @@ -1,2183 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.batches - -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.Params -import ai.llamaindex.llamacloud.core.checkKnown -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.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 - -/** - * Create a batch over a source directory and start processing asynchronously. - * - * To be notified as the batch progresses, pass `webhook_configurations` with inline endpoints - * and/or `webhook_configuration_ids` referencing saved configurations. Batches emit `batch.pending` - * on create, `batch.running` once processing starts, and a terminal `batch.success` or - * `batch.error`. - * - * `batch.success` means the batch finished mapping every source file to a job — individual files - * may still have failed, so read `results` (with `expand=results`) for per-file outcomes. - * - * Delivery order across events is not guaranteed; key on the `status` field in the payload rather - * than arrival order. - */ -class BatchCreateParams -private constructor( - private val organizationId: String?, - private val projectId: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun organizationId(): Optional = Optional.ofNullable(organizationId) - - fun projectId(): Optional = Optional.ofNullable(projectId) - - /** - * Batch configuration snapshot to apply to this source directory. - * - * @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 = body.config() - - /** - * Directory whose files should be processed. - * - * @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 sourceDirectoryId(): String = body.sourceDirectoryId() - - /** - * IDs of saved webhook configurations to notify for this job. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun webhookConfigurationIds(): Optional> = body.webhookConfigurationIds() - - /** - * Outbound webhook endpoints to notify on job status changes - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun webhookConfigurations(): Optional> = body.webhookConfigurations() - - /** - * Returns the raw JSON value of [config]. - * - * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _config(): JsonField = body._config() - - /** - * Returns the raw JSON value of [sourceDirectoryId]. - * - * Unlike [sourceDirectoryId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - fun _sourceDirectoryId(): JsonField = body._sourceDirectoryId() - - /** - * Returns the raw JSON value of [webhookConfigurationIds]. - * - * Unlike [webhookConfigurationIds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - fun _webhookConfigurationIds(): JsonField> = body._webhookConfigurationIds() - - /** - * Returns the raw JSON value of [webhookConfigurations]. - * - * Unlike [webhookConfigurations], this method doesn't throw if the JSON field has an unexpected - * type. - */ - fun _webhookConfigurations(): JsonField> = - body._webhookConfigurations() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BatchCreateParams]. - * - * The following fields are required: - * ```java - * .config() - * .sourceDirectoryId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchCreateParams]. */ - class Builder internal constructor() { - - private var organizationId: String? = null - private var projectId: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(batchCreateParams: BatchCreateParams) = apply { - organizationId = batchCreateParams.organizationId - projectId = batchCreateParams.projectId - body = batchCreateParams.body.toBuilder() - additionalHeaders = batchCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = batchCreateParams.additionalQueryParams.toBuilder() - } - - 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()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [config] - * - [sourceDirectoryId] - * - [webhookConfigurationIds] - * - [webhookConfigurations] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** Batch configuration snapshot to apply to this source directory. */ - fun config(config: Config) = apply { body.config(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 { body.config(config) } - - /** Directory whose files should be processed. */ - fun sourceDirectoryId(sourceDirectoryId: String) = apply { - body.sourceDirectoryId(sourceDirectoryId) - } - - /** - * Sets [Builder.sourceDirectoryId] to an arbitrary JSON value. - * - * You should usually call [Builder.sourceDirectoryId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun sourceDirectoryId(sourceDirectoryId: JsonField) = apply { - body.sourceDirectoryId(sourceDirectoryId) - } - - /** IDs of saved webhook configurations to notify for this job. */ - fun webhookConfigurationIds(webhookConfigurationIds: List?) = apply { - body.webhookConfigurationIds(webhookConfigurationIds) - } - - /** - * Alias for calling [Builder.webhookConfigurationIds] with - * `webhookConfigurationIds.orElse(null)`. - */ - fun webhookConfigurationIds(webhookConfigurationIds: Optional>) = - webhookConfigurationIds(webhookConfigurationIds.getOrNull()) - - /** - * Sets [Builder.webhookConfigurationIds] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookConfigurationIds] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun webhookConfigurationIds(webhookConfigurationIds: JsonField>) = apply { - body.webhookConfigurationIds(webhookConfigurationIds) - } - - /** - * Adds a single [String] to [webhookConfigurationIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addWebhookConfigurationId(webhookConfigurationId: String) = apply { - body.addWebhookConfigurationId(webhookConfigurationId) - } - - /** Outbound webhook endpoints to notify on job status changes */ - fun webhookConfigurations(webhookConfigurations: List?) = apply { - body.webhookConfigurations(webhookConfigurations) - } - - /** - * Alias for calling [Builder.webhookConfigurations] with - * `webhookConfigurations.orElse(null)`. - */ - fun webhookConfigurations(webhookConfigurations: Optional>) = - webhookConfigurations(webhookConfigurations.getOrNull()) - - /** - * Sets [Builder.webhookConfigurations] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookConfigurations] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun webhookConfigurations(webhookConfigurations: JsonField>) = - apply { - body.webhookConfigurations(webhookConfigurations) - } - - /** - * Adds a single [WebhookConfiguration] to [webhookConfigurations]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addWebhookConfiguration(webhookConfiguration: WebhookConfiguration) = apply { - body.addWebhookConfiguration(webhookConfiguration) - } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [BatchCreateParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .config() - * .sourceDirectoryId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BatchCreateParams = - BatchCreateParams( - organizationId, - projectId, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - 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() - - /** - * Create a batch over a directory. - * - * Example: { "source_directory_id": "dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "config": { - * "job": { "type": "parse_v2", "configuration_id": "cfg-PARSE_AGENTIC" } }, } - * - * The source is always a directory. Callers upload or attach files to the directory first, then - * this API maps each source directory file to an output job such as a parse job ID. - */ - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val config: JsonField, - private val sourceDirectoryId: JsonField, - private val webhookConfigurationIds: JsonField>, - private val webhookConfigurations: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("config") @ExcludeMissing config: JsonField = JsonMissing.of(), - @JsonProperty("source_directory_id") - @ExcludeMissing - sourceDirectoryId: JsonField = JsonMissing.of(), - @JsonProperty("webhook_configuration_ids") - @ExcludeMissing - webhookConfigurationIds: JsonField> = JsonMissing.of(), - @JsonProperty("webhook_configurations") - @ExcludeMissing - webhookConfigurations: JsonField> = JsonMissing.of(), - ) : this( - config, - sourceDirectoryId, - webhookConfigurationIds, - webhookConfigurations, - mutableMapOf(), - ) - - /** - * Batch configuration snapshot to apply to this source directory. - * - * @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") - - /** - * Directory whose files should be processed. - * - * @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 sourceDirectoryId(): String = sourceDirectoryId.getRequired("source_directory_id") - - /** - * IDs of saved webhook configurations to notify for this job. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun webhookConfigurationIds(): Optional> = - webhookConfigurationIds.getOptional("webhook_configuration_ids") - - /** - * Outbound webhook endpoints to notify on job status changes - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun webhookConfigurations(): Optional> = - webhookConfigurations.getOptional("webhook_configurations") - - /** - * 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 [sourceDirectoryId]. - * - * Unlike [sourceDirectoryId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("source_directory_id") - @ExcludeMissing - fun _sourceDirectoryId(): JsonField = sourceDirectoryId - - /** - * Returns the raw JSON value of [webhookConfigurationIds]. - * - * Unlike [webhookConfigurationIds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("webhook_configuration_ids") - @ExcludeMissing - fun _webhookConfigurationIds(): JsonField> = webhookConfigurationIds - - /** - * Returns the raw JSON value of [webhookConfigurations]. - * - * Unlike [webhookConfigurations], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("webhook_configurations") - @ExcludeMissing - fun _webhookConfigurations(): JsonField> = webhookConfigurations - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .config() - * .sourceDirectoryId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var config: JsonField? = null - private var sourceDirectoryId: JsonField? = null - private var webhookConfigurationIds: JsonField>? = null - private var webhookConfigurations: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - config = body.config - sourceDirectoryId = body.sourceDirectoryId - webhookConfigurationIds = body.webhookConfigurationIds.map { it.toMutableList() } - webhookConfigurations = body.webhookConfigurations.map { it.toMutableList() } - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** Batch configuration snapshot to apply to this source directory. */ - 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 } - - /** Directory whose files should be processed. */ - fun sourceDirectoryId(sourceDirectoryId: String) = - sourceDirectoryId(JsonField.of(sourceDirectoryId)) - - /** - * Sets [Builder.sourceDirectoryId] to an arbitrary JSON value. - * - * You should usually call [Builder.sourceDirectoryId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun sourceDirectoryId(sourceDirectoryId: JsonField) = apply { - this.sourceDirectoryId = sourceDirectoryId - } - - /** IDs of saved webhook configurations to notify for this job. */ - fun webhookConfigurationIds(webhookConfigurationIds: List?) = - webhookConfigurationIds(JsonField.ofNullable(webhookConfigurationIds)) - - /** - * Alias for calling [Builder.webhookConfigurationIds] with - * `webhookConfigurationIds.orElse(null)`. - */ - fun webhookConfigurationIds(webhookConfigurationIds: Optional>) = - webhookConfigurationIds(webhookConfigurationIds.getOrNull()) - - /** - * Sets [Builder.webhookConfigurationIds] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookConfigurationIds] with a well-typed - * `List` value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun webhookConfigurationIds(webhookConfigurationIds: JsonField>) = apply { - this.webhookConfigurationIds = webhookConfigurationIds.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [webhookConfigurationIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addWebhookConfigurationId(webhookConfigurationId: String) = apply { - webhookConfigurationIds = - (webhookConfigurationIds ?: JsonField.of(mutableListOf())).also { - checkKnown("webhookConfigurationIds", it).add(webhookConfigurationId) - } - } - - /** Outbound webhook endpoints to notify on job status changes */ - fun webhookConfigurations(webhookConfigurations: List?) = - webhookConfigurations(JsonField.ofNullable(webhookConfigurations)) - - /** - * Alias for calling [Builder.webhookConfigurations] with - * `webhookConfigurations.orElse(null)`. - */ - fun webhookConfigurations(webhookConfigurations: Optional>) = - webhookConfigurations(webhookConfigurations.getOrNull()) - - /** - * Sets [Builder.webhookConfigurations] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookConfigurations] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun webhookConfigurations( - webhookConfigurations: JsonField> - ) = apply { - this.webhookConfigurations = webhookConfigurations.map { it.toMutableList() } - } - - /** - * Adds a single [WebhookConfiguration] to [webhookConfigurations]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addWebhookConfiguration(webhookConfiguration: WebhookConfiguration) = apply { - webhookConfigurations = - (webhookConfigurations ?: JsonField.of(mutableListOf())).also { - checkKnown("webhookConfigurations", it).add(webhookConfiguration) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .config() - * .sourceDirectoryId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body( - checkRequired("config", config), - checkRequired("sourceDirectoryId", sourceDirectoryId), - (webhookConfigurationIds ?: JsonMissing.of()).map { it.toImmutable() }, - (webhookConfigurations ?: JsonMissing.of()).map { it.toImmutable() }, - 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(): Body = apply { - if (validated) { - return@apply - } - - config().validate() - sourceDirectoryId() - webhookConfigurationIds() - webhookConfigurations().ifPresent { it.forEach { 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 = - (config.asKnown().getOrNull()?.validity() ?: 0) + - (if (sourceDirectoryId.asKnown().isPresent) 1 else 0) + - (webhookConfigurationIds.asKnown().getOrNull()?.size ?: 0) + - (webhookConfigurations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - config == other.config && - sourceDirectoryId == other.sourceDirectoryId && - webhookConfigurationIds == other.webhookConfigurationIds && - webhookConfigurations == other.webhookConfigurations && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - config, - sourceDirectoryId, - webhookConfigurationIds, - webhookConfigurations, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{config=$config, sourceDirectoryId=$sourceDirectoryId, webhookConfigurationIds=$webhookConfigurationIds, webhookConfigurations=$webhookConfigurations, additionalProperties=$additionalProperties}" - } - - /** Batch configuration snapshot to apply to this source directory. */ - class Config - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val job: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("job") @ExcludeMissing job: JsonField = JsonMissing.of() - ) : this(job, mutableMapOf()) - - /** - * Job to create for each file in the source directory. - * - * @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 job(): Job = job.getRequired("job") - - /** - * Returns the raw JSON value of [job]. - * - * Unlike [job], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("job") @ExcludeMissing fun _job(): JsonField = job - - @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]. - * - * The following fields are required: - * ```java - * .job() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Config]. */ - class Builder internal constructor() { - - private var job: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(config: Config) = apply { - job = config.job - additionalProperties = config.additionalProperties.toMutableMap() - } - - /** Job to create for each file in the source directory. */ - fun job(job: Job) = job(JsonField.of(job)) - - /** - * Sets [Builder.job] to an arbitrary JSON value. - * - * You should usually call [Builder.job] with a well-typed [Job] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun job(job: JsonField) = apply { this.job = job } - - 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. - * - * The following fields are required: - * ```java - * .job() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Config = - Config(checkRequired("job", job), 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 - } - - job().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 = (job.asKnown().getOrNull()?.validity() ?: 0) - - /** Job to create for each file in the source directory. */ - class Job - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val configurationId: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("configuration_id") - @ExcludeMissing - configurationId: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(configurationId, type, mutableMapOf()) - - /** - * Product configuration ID or built-in preset ID matching the job type. - * - * @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 configurationId(): String = configurationId.getRequired("configuration_id") - - /** - * Product job type to run for each source directory file. - * - * @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 type(): Type = type.getRequired("type") - - /** - * Returns the raw JSON value of [configurationId]. - * - * Unlike [configurationId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("configuration_id") - @ExcludeMissing - fun _configurationId(): JsonField = configurationId - - /** - * 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 [Job]. - * - * The following fields are required: - * ```java - * .configurationId() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Job]. */ - class Builder internal constructor() { - - private var configurationId: JsonField? = null - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(job: Job) = apply { - configurationId = job.configurationId - type = job.type - additionalProperties = job.additionalProperties.toMutableMap() - } - - /** Product configuration ID or built-in preset ID matching the job type. */ - fun configurationId(configurationId: String) = - configurationId(JsonField.of(configurationId)) - - /** - * Sets [Builder.configurationId] to an arbitrary JSON value. - * - * You should usually call [Builder.configurationId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun configurationId(configurationId: JsonField) = apply { - this.configurationId = configurationId - } - - /** Product job type to run for each source directory file. */ - 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 [Job]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .configurationId() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Job = - Job( - checkRequired("configurationId", configurationId), - checkRequired("type", 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(): Job = apply { - if (validated) { - return@apply - } - - configurationId() - type().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 (configurationId.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - /** Product job type to run for each source directory file. */ - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PARSE_V2 = of("parse_v2") - - @JvmField val EXTRACT_V2 = of("extract_v2") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - PARSE_V2, - EXTRACT_V2, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PARSE_V2, - EXTRACT_V2, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PARSE_V2 -> Value.PARSE_V2 - EXTRACT_V2 -> Value.EXTRACT_V2 - 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) { - PARSE_V2 -> Known.PARSE_V2 - EXTRACT_V2 -> Known.EXTRACT_V2 - else -> throw LlamaCloudInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws 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(): Type = 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 Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Job && - configurationId == other.configurationId && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(configurationId, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Job{configurationId=$configurationId, type=$type, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Config && - job == other.job && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(job, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Config{job=$job, additionalProperties=$additionalProperties}" - } - - /** Configuration for a single outbound webhook endpoint. */ - class WebhookConfiguration - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val webhookEvents: JsonField>, - private val webhookHeaders: JsonField, - private val webhookOutputFormat: JsonField, - private val webhookSigningSecret: JsonField, - private val webhookUrl: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("webhook_events") - @ExcludeMissing - webhookEvents: JsonField> = JsonMissing.of(), - @JsonProperty("webhook_headers") - @ExcludeMissing - webhookHeaders: JsonField = JsonMissing.of(), - @JsonProperty("webhook_output_format") - @ExcludeMissing - webhookOutputFormat: JsonField = JsonMissing.of(), - @JsonProperty("webhook_signing_secret") - @ExcludeMissing - webhookSigningSecret: JsonField = JsonMissing.of(), - @JsonProperty("webhook_url") - @ExcludeMissing - webhookUrl: JsonField = JsonMissing.of(), - ) : this( - webhookEvents, - webhookHeaders, - webhookOutputFormat, - webhookSigningSecret, - webhookUrl, - mutableMapOf(), - ) - - /** - * Events to subscribe to (e.g. 'parse.success', 'extract.error'). If null, all events are - * delivered. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun webhookEvents(): Optional> = - webhookEvents.getOptional("webhook_events") - - /** - * Custom HTTP headers sent with each webhook request (e.g. auth tokens) - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun webhookHeaders(): Optional = - webhookHeaders.getOptional("webhook_headers") - - /** - * Response format sent to the webhook: 'string' (default) or 'json' - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun webhookOutputFormat(): Optional = - webhookOutputFormat.getOptional("webhook_output_format") - - /** - * Shared signing secret used to sign webhook deliveries. When set, each request includes an - * HMAC-SHA256 signature of the request body in the 'LC-Signature' header (value - * 'sha256='). Recompute the HMAC over the raw request body with this secret to verify - * the delivery is authentic. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun webhookSigningSecret(): Optional = - webhookSigningSecret.getOptional("webhook_signing_secret") - - /** - * URL to receive webhook POST notifications - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun webhookUrl(): Optional = webhookUrl.getOptional("webhook_url") - - /** - * Returns the raw JSON value of [webhookEvents]. - * - * Unlike [webhookEvents], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("webhook_events") - @ExcludeMissing - fun _webhookEvents(): JsonField> = webhookEvents - - /** - * Returns the raw JSON value of [webhookHeaders]. - * - * Unlike [webhookHeaders], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("webhook_headers") - @ExcludeMissing - fun _webhookHeaders(): JsonField = webhookHeaders - - /** - * Returns the raw JSON value of [webhookOutputFormat]. - * - * Unlike [webhookOutputFormat], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("webhook_output_format") - @ExcludeMissing - fun _webhookOutputFormat(): JsonField = webhookOutputFormat - - /** - * Returns the raw JSON value of [webhookSigningSecret]. - * - * Unlike [webhookSigningSecret], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("webhook_signing_secret") - @ExcludeMissing - fun _webhookSigningSecret(): JsonField = webhookSigningSecret - - /** - * Returns the raw JSON value of [webhookUrl]. - * - * Unlike [webhookUrl], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("webhook_url") - @ExcludeMissing - fun _webhookUrl(): JsonField = webhookUrl - - @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 [WebhookConfiguration]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [WebhookConfiguration]. */ - class Builder internal constructor() { - - private var webhookEvents: JsonField>? = null - private var webhookHeaders: JsonField = JsonMissing.of() - private var webhookOutputFormat: JsonField = JsonMissing.of() - private var webhookSigningSecret: JsonField = JsonMissing.of() - private var webhookUrl: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(webhookConfiguration: WebhookConfiguration) = apply { - webhookEvents = webhookConfiguration.webhookEvents.map { it.toMutableList() } - webhookHeaders = webhookConfiguration.webhookHeaders - webhookOutputFormat = webhookConfiguration.webhookOutputFormat - webhookSigningSecret = webhookConfiguration.webhookSigningSecret - webhookUrl = webhookConfiguration.webhookUrl - additionalProperties = webhookConfiguration.additionalProperties.toMutableMap() - } - - /** - * Events to subscribe to (e.g. 'parse.success', 'extract.error'). If null, all events - * are delivered. - */ - fun webhookEvents(webhookEvents: List?) = - webhookEvents(JsonField.ofNullable(webhookEvents)) - - /** Alias for calling [Builder.webhookEvents] with `webhookEvents.orElse(null)`. */ - fun webhookEvents(webhookEvents: Optional>) = - webhookEvents(webhookEvents.getOrNull()) - - /** - * Sets [Builder.webhookEvents] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookEvents] with a well-typed - * `List` value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun webhookEvents(webhookEvents: JsonField>) = apply { - this.webhookEvents = webhookEvents.map { it.toMutableList() } - } - - /** - * Adds a single [WebhookEvent] to [webhookEvents]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addWebhookEvent(webhookEvent: WebhookEvent) = apply { - webhookEvents = - (webhookEvents ?: JsonField.of(mutableListOf())).also { - checkKnown("webhookEvents", it).add(webhookEvent) - } - } - - /** Custom HTTP headers sent with each webhook request (e.g. auth tokens) */ - fun webhookHeaders(webhookHeaders: WebhookHeaders?) = - webhookHeaders(JsonField.ofNullable(webhookHeaders)) - - /** Alias for calling [Builder.webhookHeaders] with `webhookHeaders.orElse(null)`. */ - fun webhookHeaders(webhookHeaders: Optional) = - webhookHeaders(webhookHeaders.getOrNull()) - - /** - * Sets [Builder.webhookHeaders] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookHeaders] with a well-typed [WebhookHeaders] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun webhookHeaders(webhookHeaders: JsonField) = apply { - this.webhookHeaders = webhookHeaders - } - - /** Response format sent to the webhook: 'string' (default) or 'json' */ - fun webhookOutputFormat(webhookOutputFormat: String?) = - webhookOutputFormat(JsonField.ofNullable(webhookOutputFormat)) - - /** - * Alias for calling [Builder.webhookOutputFormat] with - * `webhookOutputFormat.orElse(null)`. - */ - fun webhookOutputFormat(webhookOutputFormat: Optional) = - webhookOutputFormat(webhookOutputFormat.getOrNull()) - - /** - * Sets [Builder.webhookOutputFormat] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookOutputFormat] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun webhookOutputFormat(webhookOutputFormat: JsonField) = apply { - this.webhookOutputFormat = webhookOutputFormat - } - - /** - * Shared signing secret used to sign webhook deliveries. When set, each request - * includes an HMAC-SHA256 signature of the request body in the 'LC-Signature' header - * (value 'sha256='). Recompute the HMAC over the raw request body with this secret - * to verify the delivery is authentic. - */ - fun webhookSigningSecret(webhookSigningSecret: String?) = - webhookSigningSecret(JsonField.ofNullable(webhookSigningSecret)) - - /** - * Alias for calling [Builder.webhookSigningSecret] with - * `webhookSigningSecret.orElse(null)`. - */ - fun webhookSigningSecret(webhookSigningSecret: Optional) = - webhookSigningSecret(webhookSigningSecret.getOrNull()) - - /** - * Sets [Builder.webhookSigningSecret] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookSigningSecret] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun webhookSigningSecret(webhookSigningSecret: JsonField) = apply { - this.webhookSigningSecret = webhookSigningSecret - } - - /** URL to receive webhook POST notifications */ - fun webhookUrl(webhookUrl: String?) = webhookUrl(JsonField.ofNullable(webhookUrl)) - - /** Alias for calling [Builder.webhookUrl] with `webhookUrl.orElse(null)`. */ - fun webhookUrl(webhookUrl: Optional) = webhookUrl(webhookUrl.getOrNull()) - - /** - * Sets [Builder.webhookUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun webhookUrl(webhookUrl: JsonField) = apply { this.webhookUrl = webhookUrl } - - 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 [WebhookConfiguration]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): WebhookConfiguration = - WebhookConfiguration( - (webhookEvents ?: JsonMissing.of()).map { it.toImmutable() }, - webhookHeaders, - webhookOutputFormat, - webhookSigningSecret, - webhookUrl, - 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(): WebhookConfiguration = apply { - if (validated) { - return@apply - } - - webhookEvents().ifPresent { it.forEach { it.validate() } } - webhookHeaders().ifPresent { it.validate() } - webhookOutputFormat() - webhookSigningSecret() - webhookUrl() - 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 = - (webhookEvents.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (webhookHeaders.asKnown().getOrNull()?.validity() ?: 0) + - (if (webhookOutputFormat.asKnown().isPresent) 1 else 0) + - (if (webhookSigningSecret.asKnown().isPresent) 1 else 0) + - (if (webhookUrl.asKnown().isPresent) 1 else 0) - - class WebhookEvent @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 BATCH_CANCELLED = of("batch.cancelled") - - @JvmField val BATCH_ERROR = of("batch.error") - - @JvmField val BATCH_PENDING = of("batch.pending") - - @JvmField val BATCH_RUNNING = of("batch.running") - - @JvmField val BATCH_SUCCESS = of("batch.success") - - @JvmField val CLASSIFY_CANCELLED = of("classify.cancelled") - - @JvmField val CLASSIFY_ERROR = of("classify.error") - - @JvmField val CLASSIFY_PARTIAL_SUCCESS = of("classify.partial_success") - - @JvmField val CLASSIFY_PENDING = of("classify.pending") - - @JvmField val CLASSIFY_RUNNING = of("classify.running") - - @JvmField val CLASSIFY_SUCCESS = of("classify.success") - - @JvmField val EXTRACT_CANCELLED = of("extract.cancelled") - - @JvmField val EXTRACT_ERROR = of("extract.error") - - @JvmField val EXTRACT_PARTIAL_SUCCESS = of("extract.partial_success") - - @JvmField val EXTRACT_PENDING = of("extract.pending") - - @JvmField val EXTRACT_SUCCESS = of("extract.success") - - @JvmField val PARSE_CANCELLED = of("parse.cancelled") - - @JvmField val PARSE_ERROR = of("parse.error") - - @JvmField val PARSE_PARTIAL_SUCCESS = of("parse.partial_success") - - @JvmField val PARSE_PENDING = of("parse.pending") - - @JvmField val PARSE_RUNNING = of("parse.running") - - @JvmField val PARSE_SUCCESS = of("parse.success") - - @JvmField val SHEETS_CANCELLED = of("sheets.cancelled") - - @JvmField val SHEETS_ERROR = of("sheets.error") - - @JvmField val SHEETS_PARTIAL_SUCCESS = of("sheets.partial_success") - - @JvmField val SHEETS_PENDING = of("sheets.pending") - - @JvmField val SHEETS_SUCCESS = of("sheets.success") - - @JvmField val SPLIT_CANCELLED = of("split.cancelled") - - @JvmField val SPLIT_ERROR = of("split.error") - - @JvmField val SPLIT_PENDING = of("split.pending") - - @JvmField val SPLIT_PROCESSING = of("split.processing") - - @JvmField val SPLIT_SUCCESS = of("split.success") - - @JvmField val UNMAPPED_EVENT = of("unmapped_event") - - @JvmStatic fun of(value: String) = WebhookEvent(JsonField.of(value)) - } - - /** An enum containing [WebhookEvent]'s known values. */ - enum class Known { - BATCH_CANCELLED, - BATCH_ERROR, - BATCH_PENDING, - BATCH_RUNNING, - BATCH_SUCCESS, - CLASSIFY_CANCELLED, - CLASSIFY_ERROR, - CLASSIFY_PARTIAL_SUCCESS, - CLASSIFY_PENDING, - CLASSIFY_RUNNING, - CLASSIFY_SUCCESS, - EXTRACT_CANCELLED, - EXTRACT_ERROR, - EXTRACT_PARTIAL_SUCCESS, - EXTRACT_PENDING, - EXTRACT_SUCCESS, - PARSE_CANCELLED, - PARSE_ERROR, - PARSE_PARTIAL_SUCCESS, - PARSE_PENDING, - PARSE_RUNNING, - PARSE_SUCCESS, - SHEETS_CANCELLED, - SHEETS_ERROR, - SHEETS_PARTIAL_SUCCESS, - SHEETS_PENDING, - SHEETS_SUCCESS, - SPLIT_CANCELLED, - SPLIT_ERROR, - SPLIT_PENDING, - SPLIT_PROCESSING, - SPLIT_SUCCESS, - UNMAPPED_EVENT, - } - - /** - * An enum containing [WebhookEvent]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [WebhookEvent] 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 { - BATCH_CANCELLED, - BATCH_ERROR, - BATCH_PENDING, - BATCH_RUNNING, - BATCH_SUCCESS, - CLASSIFY_CANCELLED, - CLASSIFY_ERROR, - CLASSIFY_PARTIAL_SUCCESS, - CLASSIFY_PENDING, - CLASSIFY_RUNNING, - CLASSIFY_SUCCESS, - EXTRACT_CANCELLED, - EXTRACT_ERROR, - EXTRACT_PARTIAL_SUCCESS, - EXTRACT_PENDING, - EXTRACT_SUCCESS, - PARSE_CANCELLED, - PARSE_ERROR, - PARSE_PARTIAL_SUCCESS, - PARSE_PENDING, - PARSE_RUNNING, - PARSE_SUCCESS, - SHEETS_CANCELLED, - SHEETS_ERROR, - SHEETS_PARTIAL_SUCCESS, - SHEETS_PENDING, - SHEETS_SUCCESS, - SPLIT_CANCELLED, - SPLIT_ERROR, - SPLIT_PENDING, - SPLIT_PROCESSING, - SPLIT_SUCCESS, - UNMAPPED_EVENT, - /** - * An enum member indicating that [WebhookEvent] 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) { - BATCH_CANCELLED -> Value.BATCH_CANCELLED - BATCH_ERROR -> Value.BATCH_ERROR - BATCH_PENDING -> Value.BATCH_PENDING - BATCH_RUNNING -> Value.BATCH_RUNNING - BATCH_SUCCESS -> Value.BATCH_SUCCESS - CLASSIFY_CANCELLED -> Value.CLASSIFY_CANCELLED - CLASSIFY_ERROR -> Value.CLASSIFY_ERROR - CLASSIFY_PARTIAL_SUCCESS -> Value.CLASSIFY_PARTIAL_SUCCESS - CLASSIFY_PENDING -> Value.CLASSIFY_PENDING - CLASSIFY_RUNNING -> Value.CLASSIFY_RUNNING - CLASSIFY_SUCCESS -> Value.CLASSIFY_SUCCESS - EXTRACT_CANCELLED -> Value.EXTRACT_CANCELLED - EXTRACT_ERROR -> Value.EXTRACT_ERROR - EXTRACT_PARTIAL_SUCCESS -> Value.EXTRACT_PARTIAL_SUCCESS - EXTRACT_PENDING -> Value.EXTRACT_PENDING - EXTRACT_SUCCESS -> Value.EXTRACT_SUCCESS - PARSE_CANCELLED -> Value.PARSE_CANCELLED - PARSE_ERROR -> Value.PARSE_ERROR - PARSE_PARTIAL_SUCCESS -> Value.PARSE_PARTIAL_SUCCESS - PARSE_PENDING -> Value.PARSE_PENDING - PARSE_RUNNING -> Value.PARSE_RUNNING - PARSE_SUCCESS -> Value.PARSE_SUCCESS - SHEETS_CANCELLED -> Value.SHEETS_CANCELLED - SHEETS_ERROR -> Value.SHEETS_ERROR - SHEETS_PARTIAL_SUCCESS -> Value.SHEETS_PARTIAL_SUCCESS - SHEETS_PENDING -> Value.SHEETS_PENDING - SHEETS_SUCCESS -> Value.SHEETS_SUCCESS - SPLIT_CANCELLED -> Value.SPLIT_CANCELLED - SPLIT_ERROR -> Value.SPLIT_ERROR - SPLIT_PENDING -> Value.SPLIT_PENDING - SPLIT_PROCESSING -> Value.SPLIT_PROCESSING - SPLIT_SUCCESS -> Value.SPLIT_SUCCESS - UNMAPPED_EVENT -> Value.UNMAPPED_EVENT - 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) { - BATCH_CANCELLED -> Known.BATCH_CANCELLED - BATCH_ERROR -> Known.BATCH_ERROR - BATCH_PENDING -> Known.BATCH_PENDING - BATCH_RUNNING -> Known.BATCH_RUNNING - BATCH_SUCCESS -> Known.BATCH_SUCCESS - CLASSIFY_CANCELLED -> Known.CLASSIFY_CANCELLED - CLASSIFY_ERROR -> Known.CLASSIFY_ERROR - CLASSIFY_PARTIAL_SUCCESS -> Known.CLASSIFY_PARTIAL_SUCCESS - CLASSIFY_PENDING -> Known.CLASSIFY_PENDING - CLASSIFY_RUNNING -> Known.CLASSIFY_RUNNING - CLASSIFY_SUCCESS -> Known.CLASSIFY_SUCCESS - EXTRACT_CANCELLED -> Known.EXTRACT_CANCELLED - EXTRACT_ERROR -> Known.EXTRACT_ERROR - EXTRACT_PARTIAL_SUCCESS -> Known.EXTRACT_PARTIAL_SUCCESS - EXTRACT_PENDING -> Known.EXTRACT_PENDING - EXTRACT_SUCCESS -> Known.EXTRACT_SUCCESS - PARSE_CANCELLED -> Known.PARSE_CANCELLED - PARSE_ERROR -> Known.PARSE_ERROR - PARSE_PARTIAL_SUCCESS -> Known.PARSE_PARTIAL_SUCCESS - PARSE_PENDING -> Known.PARSE_PENDING - PARSE_RUNNING -> Known.PARSE_RUNNING - PARSE_SUCCESS -> Known.PARSE_SUCCESS - SHEETS_CANCELLED -> Known.SHEETS_CANCELLED - SHEETS_ERROR -> Known.SHEETS_ERROR - SHEETS_PARTIAL_SUCCESS -> Known.SHEETS_PARTIAL_SUCCESS - SHEETS_PENDING -> Known.SHEETS_PENDING - SHEETS_SUCCESS -> Known.SHEETS_SUCCESS - SPLIT_CANCELLED -> Known.SPLIT_CANCELLED - SPLIT_ERROR -> Known.SPLIT_ERROR - SPLIT_PENDING -> Known.SPLIT_PENDING - SPLIT_PROCESSING -> Known.SPLIT_PROCESSING - SPLIT_SUCCESS -> Known.SPLIT_SUCCESS - UNMAPPED_EVENT -> Known.UNMAPPED_EVENT - else -> throw LlamaCloudInvalidDataException("Unknown WebhookEvent: $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(): WebhookEvent = 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 WebhookEvent && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Custom HTTP headers sent with each webhook request (e.g. auth tokens) */ - class WebhookHeaders - @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 [WebhookHeaders]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [WebhookHeaders]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(webhookHeaders: WebhookHeaders) = apply { - additionalProperties = webhookHeaders.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 [WebhookHeaders]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): WebhookHeaders = WebhookHeaders(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(): WebhookHeaders = 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 WebhookHeaders && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "WebhookHeaders{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is WebhookConfiguration && - webhookEvents == other.webhookEvents && - webhookHeaders == other.webhookHeaders && - webhookOutputFormat == other.webhookOutputFormat && - webhookSigningSecret == other.webhookSigningSecret && - webhookUrl == other.webhookUrl && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - webhookEvents, - webhookHeaders, - webhookOutputFormat, - webhookSigningSecret, - webhookUrl, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "WebhookConfiguration{webhookEvents=$webhookEvents, webhookHeaders=$webhookHeaders, webhookOutputFormat=$webhookOutputFormat, webhookSigningSecret=$webhookSigningSecret, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BatchCreateParams && - organizationId == other.organizationId && - projectId == other.projectId && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash(organizationId, projectId, body, additionalHeaders, additionalQueryParams) - - override fun toString() = - "BatchCreateParams{organizationId=$organizationId, projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateResponse.kt deleted file mode 100644 index 6049883..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateResponse.kt +++ /dev/null @@ -1,1867 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.batches - -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.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.time.OffsetDateTime -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * A top-level batch. - * - * Example: { "id": "bat-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "project_id": - * "prj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "source_directory_id": - * "dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "config": { "job": { "type": "parse_v2", - * "configuration_id": "cfg-PARSE_AGENTIC" } }, "status": "COMPLETED", "results": - * [ { "source_directory_file_id": "dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "job_reference": { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" }, "error_message": null } ] - * } - * - * Batch-level ``FAILED`` means the orchestration failed and cannot provide a reliable per-file - * result set. ``results`` is only populated when explicitly requested with ``expand=results`` and - * may be ``null`` while a batch is still running. - */ -class BatchCreateResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val id: JsonField, - private val config: JsonField, - private val projectId: JsonField, - private val sourceDirectoryId: JsonField, - private val status: JsonField, - private val createdAt: JsonField, - private val results: 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("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), - @JsonProperty("source_directory_id") - @ExcludeMissing - sourceDirectoryId: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("results") - @ExcludeMissing - results: JsonField> = JsonMissing.of(), - @JsonProperty("updated_at") - @ExcludeMissing - updatedAt: JsonField = JsonMissing.of(), - ) : this( - id, - config, - projectId, - sourceDirectoryId, - status, - createdAt, - results, - updatedAt, - mutableMapOf(), - ) - - /** - * Unique identifier - * - * @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") - - /** - * Batch configuration snapshot. - * - * @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") - - /** - * Project this batch 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") - - /** - * Directory being processed. - * - * @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 sourceDirectoryId(): String = sourceDirectoryId.getRequired("source_directory_id") - - /** - * Current batch 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(): Status = status.getRequired("status") - - /** - * Creation datetime - * - * @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") - - /** - * Expanded per-file result mappings. Null unless requested with expand=results, or while the - * batch is still running. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun results(): Optional> = results.getOptional("results") - - /** - * Update datetime - * - * @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 [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 [sourceDirectoryId]. - * - * Unlike [sourceDirectoryId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("source_directory_id") - @ExcludeMissing - fun _sourceDirectoryId(): JsonField = sourceDirectoryId - - /** - * 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 [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 [results]. - * - * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("results") @ExcludeMissing fun _results(): JsonField> = results - - /** - * 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 [BatchCreateResponse]. - * - * The following fields are required: - * ```java - * .id() - * .config() - * .projectId() - * .sourceDirectoryId() - * .status() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchCreateResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var config: JsonField? = null - private var projectId: JsonField? = null - private var sourceDirectoryId: JsonField? = null - private var status: JsonField? = null - private var createdAt: JsonField = JsonMissing.of() - private var results: JsonField>? = null - private var updatedAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(batchCreateResponse: BatchCreateResponse) = apply { - id = batchCreateResponse.id - config = batchCreateResponse.config - projectId = batchCreateResponse.projectId - sourceDirectoryId = batchCreateResponse.sourceDirectoryId - status = batchCreateResponse.status - createdAt = batchCreateResponse.createdAt - results = batchCreateResponse.results.map { it.toMutableList() } - updatedAt = batchCreateResponse.updatedAt - additionalProperties = batchCreateResponse.additionalProperties.toMutableMap() - } - - /** Unique identifier */ - 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 } - - /** Batch configuration snapshot. */ - 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 } - - /** Project this batch 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 } - - /** Directory being processed. */ - fun sourceDirectoryId(sourceDirectoryId: String) = - sourceDirectoryId(JsonField.of(sourceDirectoryId)) - - /** - * Sets [Builder.sourceDirectoryId] to an arbitrary JSON value. - * - * You should usually call [Builder.sourceDirectoryId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun sourceDirectoryId(sourceDirectoryId: JsonField) = apply { - this.sourceDirectoryId = sourceDirectoryId - } - - /** Current batch status. */ - fun status(status: Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - /** Creation datetime */ - 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 } - - /** - * Expanded per-file result mappings. Null unless requested with expand=results, or while - * the batch is still running. - */ - fun results(results: List?) = results(JsonField.ofNullable(results)) - - /** Alias for calling [Builder.results] with `results.orElse(null)`. */ - fun results(results: Optional>) = results(results.getOrNull()) - - /** - * Sets [Builder.results] to an arbitrary JSON value. - * - * You should usually call [Builder.results] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun results(results: JsonField>) = apply { - this.results = results.map { it.toMutableList() } - } - - /** - * Adds a single [Result] to [results]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addResult(result: Result) = apply { - results = - (results ?: JsonField.of(mutableListOf())).also { - checkKnown("results", it).add(result) - } - } - - /** Update datetime */ - 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 [BatchCreateResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .config() - * .projectId() - * .sourceDirectoryId() - * .status() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BatchCreateResponse = - BatchCreateResponse( - checkRequired("id", id), - checkRequired("config", config), - checkRequired("projectId", projectId), - checkRequired("sourceDirectoryId", sourceDirectoryId), - checkRequired("status", status), - createdAt, - (results ?: JsonMissing.of()).map { it.toImmutable() }, - 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(): BatchCreateResponse = apply { - if (validated) { - return@apply - } - - id() - config().validate() - projectId() - sourceDirectoryId() - status().validate() - createdAt() - results().ifPresent { it.forEach { 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) + - (if (projectId.asKnown().isPresent) 1 else 0) + - (if (sourceDirectoryId.asKnown().isPresent) 1 else 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (updatedAt.asKnown().isPresent) 1 else 0) - - /** Batch configuration snapshot. */ - class Config - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val job: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("job") @ExcludeMissing job: JsonField = JsonMissing.of() - ) : this(job, mutableMapOf()) - - /** - * Job to create for each file in the source directory. - * - * @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 job(): Job = job.getRequired("job") - - /** - * Returns the raw JSON value of [job]. - * - * Unlike [job], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("job") @ExcludeMissing fun _job(): JsonField = job - - @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]. - * - * The following fields are required: - * ```java - * .job() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Config]. */ - class Builder internal constructor() { - - private var job: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(config: Config) = apply { - job = config.job - additionalProperties = config.additionalProperties.toMutableMap() - } - - /** Job to create for each file in the source directory. */ - fun job(job: Job) = job(JsonField.of(job)) - - /** - * Sets [Builder.job] to an arbitrary JSON value. - * - * You should usually call [Builder.job] with a well-typed [Job] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun job(job: JsonField) = apply { this.job = job } - - 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. - * - * The following fields are required: - * ```java - * .job() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Config = - Config(checkRequired("job", job), 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 - } - - job().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 = (job.asKnown().getOrNull()?.validity() ?: 0) - - /** Job to create for each file in the source directory. */ - class Job - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val configurationId: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("configuration_id") - @ExcludeMissing - configurationId: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(configurationId, type, mutableMapOf()) - - /** - * Product configuration ID or built-in preset ID matching the job type. - * - * @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 configurationId(): String = configurationId.getRequired("configuration_id") - - /** - * Product job type to run for each source directory file. - * - * @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 type(): Type = type.getRequired("type") - - /** - * Returns the raw JSON value of [configurationId]. - * - * Unlike [configurationId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("configuration_id") - @ExcludeMissing - fun _configurationId(): JsonField = configurationId - - /** - * 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 [Job]. - * - * The following fields are required: - * ```java - * .configurationId() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Job]. */ - class Builder internal constructor() { - - private var configurationId: JsonField? = null - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(job: Job) = apply { - configurationId = job.configurationId - type = job.type - additionalProperties = job.additionalProperties.toMutableMap() - } - - /** Product configuration ID or built-in preset ID matching the job type. */ - fun configurationId(configurationId: String) = - configurationId(JsonField.of(configurationId)) - - /** - * Sets [Builder.configurationId] to an arbitrary JSON value. - * - * You should usually call [Builder.configurationId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun configurationId(configurationId: JsonField) = apply { - this.configurationId = configurationId - } - - /** Product job type to run for each source directory file. */ - 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 [Job]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .configurationId() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Job = - Job( - checkRequired("configurationId", configurationId), - checkRequired("type", 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(): Job = apply { - if (validated) { - return@apply - } - - configurationId() - type().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 (configurationId.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - /** Product job type to run for each source directory file. */ - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PARSE_V2 = of("parse_v2") - - @JvmField val EXTRACT_V2 = of("extract_v2") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - PARSE_V2, - EXTRACT_V2, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PARSE_V2, - EXTRACT_V2, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PARSE_V2 -> Value.PARSE_V2 - EXTRACT_V2 -> Value.EXTRACT_V2 - 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) { - PARSE_V2 -> Known.PARSE_V2 - EXTRACT_V2 -> Known.EXTRACT_V2 - else -> throw LlamaCloudInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws 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(): Type = 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 Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Job && - configurationId == other.configurationId && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(configurationId, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Job{configurationId=$configurationId, type=$type, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Config && - job == other.job && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(job, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Config{job=$job, additionalProperties=$additionalProperties}" - } - - /** Current batch status. */ - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CANCELLED = of("CANCELLED") - - @JvmField val COMPLETED = of("COMPLETED") - - @JvmField val FAILED = of("FAILED") - - @JvmField val PENDING = of("PENDING") - - @JvmField val RUNNING = of("RUNNING") - - @JvmField val THROTTLED = of("THROTTLED") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - CANCELLED, - COMPLETED, - FAILED, - PENDING, - RUNNING, - THROTTLED, - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CANCELLED, - COMPLETED, - FAILED, - PENDING, - RUNNING, - THROTTLED, - /** An enum member indicating that [Status] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CANCELLED -> Value.CANCELLED - COMPLETED -> Value.COMPLETED - FAILED -> Value.FAILED - PENDING -> Value.PENDING - RUNNING -> Value.RUNNING - THROTTLED -> Value.THROTTLED - 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) { - CANCELLED -> Known.CANCELLED - COMPLETED -> Known.COMPLETED - FAILED -> Known.FAILED - PENDING -> Known.PENDING - RUNNING -> Known.RUNNING - THROTTLED -> Known.THROTTLED - else -> throw LlamaCloudInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws 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(): Status = 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 Status && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * Result projection for one source directory file in a batch. - * - * Example: { "source_directory_file_id": "dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", - * "job_reference": { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" }, - * "error_message": null } - * - * This is a projection of directory-sync state, not a separate child resource that callers need - * to create. The source directory file ID is the stable correlation key. Underlying job - * progress and failures should be resolved through the referenced product job endpoint. - */ - class Result - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val sourceDirectoryFileId: JsonField, - private val errorMessage: JsonField, - private val jobReference: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("source_directory_file_id") - @ExcludeMissing - sourceDirectoryFileId: JsonField = JsonMissing.of(), - @JsonProperty("error_message") - @ExcludeMissing - errorMessage: JsonField = JsonMissing.of(), - @JsonProperty("job_reference") - @ExcludeMissing - jobReference: JsonField = JsonMissing.of(), - ) : this(sourceDirectoryFileId, errorMessage, jobReference, mutableMapOf()) - - /** - * Source directory file processed by this batch. - * - * @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 sourceDirectoryFileId(): String = - sourceDirectoryFileId.getRequired("source_directory_file_id") - - /** - * Batch-level mapping error if the system could not create or associate a job for this - * source file. - * - * @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") - - /** - * Reference to a job produced by a batch. - * - * Example: { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun jobReference(): Optional = jobReference.getOptional("job_reference") - - /** - * Returns the raw JSON value of [sourceDirectoryFileId]. - * - * Unlike [sourceDirectoryFileId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("source_directory_file_id") - @ExcludeMissing - fun _sourceDirectoryFileId(): JsonField = sourceDirectoryFileId - - /** - * 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 [jobReference]. - * - * Unlike [jobReference], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("job_reference") - @ExcludeMissing - fun _jobReference(): JsonField = jobReference - - @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 [Result]. - * - * The following fields are required: - * ```java - * .sourceDirectoryFileId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Result]. */ - class Builder internal constructor() { - - private var sourceDirectoryFileId: JsonField? = null - private var errorMessage: JsonField = JsonMissing.of() - private var jobReference: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(result: Result) = apply { - sourceDirectoryFileId = result.sourceDirectoryFileId - errorMessage = result.errorMessage - jobReference = result.jobReference - additionalProperties = result.additionalProperties.toMutableMap() - } - - /** Source directory file processed by this batch. */ - fun sourceDirectoryFileId(sourceDirectoryFileId: String) = - sourceDirectoryFileId(JsonField.of(sourceDirectoryFileId)) - - /** - * Sets [Builder.sourceDirectoryFileId] to an arbitrary JSON value. - * - * You should usually call [Builder.sourceDirectoryFileId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun sourceDirectoryFileId(sourceDirectoryFileId: JsonField) = apply { - this.sourceDirectoryFileId = sourceDirectoryFileId - } - - /** - * Batch-level mapping error if the system could not create or associate a job for this - * source file. - */ - 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 - } - - /** - * Reference to a job produced by a batch. - * - * Example: { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } - */ - fun jobReference(jobReference: JobReference?) = - jobReference(JsonField.ofNullable(jobReference)) - - /** Alias for calling [Builder.jobReference] with `jobReference.orElse(null)`. */ - fun jobReference(jobReference: Optional) = - jobReference(jobReference.getOrNull()) - - /** - * Sets [Builder.jobReference] to an arbitrary JSON value. - * - * You should usually call [Builder.jobReference] with a well-typed [JobReference] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun jobReference(jobReference: JsonField) = apply { - this.jobReference = jobReference - } - - 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 [Result]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .sourceDirectoryFileId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Result = - Result( - checkRequired("sourceDirectoryFileId", sourceDirectoryFileId), - errorMessage, - jobReference, - 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(): Result = apply { - if (validated) { - return@apply - } - - sourceDirectoryFileId() - errorMessage() - jobReference().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 (sourceDirectoryFileId.asKnown().isPresent) 1 else 0) + - (if (errorMessage.asKnown().isPresent) 1 else 0) + - (jobReference.asKnown().getOrNull()?.validity() ?: 0) - - /** - * Reference to a job produced by a batch. - * - * Example: { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } - */ - class JobReference - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(id, type, mutableMapOf()) - - /** - * Job ID, such as a parse 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") - - /** - * Type of job produced for the file. - * - * @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 type(): Type = type.getRequired("type") - - /** - * 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 [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 [JobReference]. - * - * The following fields are required: - * ```java - * .id() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [JobReference]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(jobReference: JobReference) = apply { - id = jobReference.id - type = jobReference.type - additionalProperties = jobReference.additionalProperties.toMutableMap() - } - - /** Job ID, such as a parse 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 } - - /** Type of job produced for the file. */ - 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 [JobReference]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): JobReference = - JobReference( - checkRequired("id", id), - checkRequired("type", 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(): JobReference = apply { - if (validated) { - return@apply - } - - id() - type().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) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - /** Type of job produced for the file. */ - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PARSE_V2 = of("parse_v2") - - @JvmField val EXTRACT_V2 = of("extract_v2") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - PARSE_V2, - EXTRACT_V2, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PARSE_V2, - EXTRACT_V2, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PARSE_V2 -> Value.PARSE_V2 - EXTRACT_V2 -> Value.EXTRACT_V2 - 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) { - PARSE_V2 -> Known.PARSE_V2 - EXTRACT_V2 -> Known.EXTRACT_V2 - else -> throw LlamaCloudInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws 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(): Type = 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 Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is JobReference && - id == other.id && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, type, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "JobReference{id=$id, type=$type, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Result && - sourceDirectoryFileId == other.sourceDirectoryFileId && - errorMessage == other.errorMessage && - jobReference == other.jobReference && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(sourceDirectoryFileId, errorMessage, jobReference, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Result{sourceDirectoryFileId=$sourceDirectoryFileId, errorMessage=$errorMessage, jobReference=$jobReference, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BatchCreateResponse && - id == other.id && - config == other.config && - projectId == other.projectId && - sourceDirectoryId == other.sourceDirectoryId && - status == other.status && - createdAt == other.createdAt && - results == other.results && - updatedAt == other.updatedAt && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - config, - projectId, - sourceDirectoryId, - status, - createdAt, - results, - updatedAt, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BatchCreateResponse{id=$id, config=$config, projectId=$projectId, sourceDirectoryId=$sourceDirectoryId, status=$status, createdAt=$createdAt, results=$results, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetParams.kt deleted file mode 100644 index b9bbb6a..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetParams.kt +++ /dev/null @@ -1,258 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.batches - -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 - -/** Get a batch by ID. */ -class BatchGetParams -private constructor( - private val batchId: String?, - private val expand: List?, - private val organizationId: String?, - private val projectId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun batchId(): Optional = Optional.ofNullable(batchId) - - /** Fields to expand. Supported value: results. */ - fun expand(): Optional> = Optional.ofNullable(expand) - - 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 { - - @JvmStatic fun none(): BatchGetParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [BatchGetParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchGetParams]. */ - class Builder internal constructor() { - - private var batchId: String? = null - private var expand: MutableList? = 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(batchGetParams: BatchGetParams) = apply { - batchId = batchGetParams.batchId - expand = batchGetParams.expand?.toMutableList() - organizationId = batchGetParams.organizationId - projectId = batchGetParams.projectId - additionalHeaders = batchGetParams.additionalHeaders.toBuilder() - additionalQueryParams = batchGetParams.additionalQueryParams.toBuilder() - } - - fun batchId(batchId: String?) = apply { this.batchId = batchId } - - /** Alias for calling [Builder.batchId] with `batchId.orElse(null)`. */ - fun batchId(batchId: Optional) = batchId(batchId.getOrNull()) - - /** Fields to expand. Supported value: results. */ - fun expand(expand: List?) = apply { this.expand = expand?.toMutableList() } - - /** Alias for calling [Builder.expand] with `expand.orElse(null)`. */ - fun expand(expand: Optional>) = expand(expand.getOrNull()) - - /** - * Adds a single [String] to [Builder.expand]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addExpand(expand: String) = apply { - this.expand = (this.expand ?: mutableListOf()).apply { add(expand) } - } - - 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 [BatchGetParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BatchGetParams = - BatchGetParams( - batchId, - expand?.toImmutable(), - organizationId, - projectId, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> batchId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - expand?.forEach { put("expand", it) } - 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 BatchGetParams && - batchId == other.batchId && - expand == other.expand && - organizationId == other.organizationId && - projectId == other.projectId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash( - batchId, - expand, - organizationId, - projectId, - additionalHeaders, - additionalQueryParams, - ) - - override fun toString() = - "BatchGetParams{batchId=$batchId, expand=$expand, organizationId=$organizationId, projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetResponse.kt deleted file mode 100644 index be174a5..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetResponse.kt +++ /dev/null @@ -1,1867 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.batches - -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.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.time.OffsetDateTime -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * A top-level batch. - * - * Example: { "id": "bat-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "project_id": - * "prj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "source_directory_id": - * "dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "config": { "job": { "type": "parse_v2", - * "configuration_id": "cfg-PARSE_AGENTIC" } }, "status": "COMPLETED", "results": - * [ { "source_directory_file_id": "dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "job_reference": { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" }, "error_message": null } ] - * } - * - * Batch-level ``FAILED`` means the orchestration failed and cannot provide a reliable per-file - * result set. ``results`` is only populated when explicitly requested with ``expand=results`` and - * may be ``null`` while a batch is still running. - */ -class BatchGetResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val id: JsonField, - private val config: JsonField, - private val projectId: JsonField, - private val sourceDirectoryId: JsonField, - private val status: JsonField, - private val createdAt: JsonField, - private val results: 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("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), - @JsonProperty("source_directory_id") - @ExcludeMissing - sourceDirectoryId: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("results") - @ExcludeMissing - results: JsonField> = JsonMissing.of(), - @JsonProperty("updated_at") - @ExcludeMissing - updatedAt: JsonField = JsonMissing.of(), - ) : this( - id, - config, - projectId, - sourceDirectoryId, - status, - createdAt, - results, - updatedAt, - mutableMapOf(), - ) - - /** - * Unique identifier - * - * @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") - - /** - * Batch configuration snapshot. - * - * @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") - - /** - * Project this batch 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") - - /** - * Directory being processed. - * - * @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 sourceDirectoryId(): String = sourceDirectoryId.getRequired("source_directory_id") - - /** - * Current batch 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(): Status = status.getRequired("status") - - /** - * Creation datetime - * - * @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") - - /** - * Expanded per-file result mappings. Null unless requested with expand=results, or while the - * batch is still running. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun results(): Optional> = results.getOptional("results") - - /** - * Update datetime - * - * @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 [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 [sourceDirectoryId]. - * - * Unlike [sourceDirectoryId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("source_directory_id") - @ExcludeMissing - fun _sourceDirectoryId(): JsonField = sourceDirectoryId - - /** - * 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 [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 [results]. - * - * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("results") @ExcludeMissing fun _results(): JsonField> = results - - /** - * 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 [BatchGetResponse]. - * - * The following fields are required: - * ```java - * .id() - * .config() - * .projectId() - * .sourceDirectoryId() - * .status() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchGetResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var config: JsonField? = null - private var projectId: JsonField? = null - private var sourceDirectoryId: JsonField? = null - private var status: JsonField? = null - private var createdAt: JsonField = JsonMissing.of() - private var results: JsonField>? = null - private var updatedAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(batchGetResponse: BatchGetResponse) = apply { - id = batchGetResponse.id - config = batchGetResponse.config - projectId = batchGetResponse.projectId - sourceDirectoryId = batchGetResponse.sourceDirectoryId - status = batchGetResponse.status - createdAt = batchGetResponse.createdAt - results = batchGetResponse.results.map { it.toMutableList() } - updatedAt = batchGetResponse.updatedAt - additionalProperties = batchGetResponse.additionalProperties.toMutableMap() - } - - /** Unique identifier */ - 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 } - - /** Batch configuration snapshot. */ - 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 } - - /** Project this batch 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 } - - /** Directory being processed. */ - fun sourceDirectoryId(sourceDirectoryId: String) = - sourceDirectoryId(JsonField.of(sourceDirectoryId)) - - /** - * Sets [Builder.sourceDirectoryId] to an arbitrary JSON value. - * - * You should usually call [Builder.sourceDirectoryId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun sourceDirectoryId(sourceDirectoryId: JsonField) = apply { - this.sourceDirectoryId = sourceDirectoryId - } - - /** Current batch status. */ - fun status(status: Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - /** Creation datetime */ - 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 } - - /** - * Expanded per-file result mappings. Null unless requested with expand=results, or while - * the batch is still running. - */ - fun results(results: List?) = results(JsonField.ofNullable(results)) - - /** Alias for calling [Builder.results] with `results.orElse(null)`. */ - fun results(results: Optional>) = results(results.getOrNull()) - - /** - * Sets [Builder.results] to an arbitrary JSON value. - * - * You should usually call [Builder.results] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun results(results: JsonField>) = apply { - this.results = results.map { it.toMutableList() } - } - - /** - * Adds a single [Result] to [results]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addResult(result: Result) = apply { - results = - (results ?: JsonField.of(mutableListOf())).also { - checkKnown("results", it).add(result) - } - } - - /** Update datetime */ - 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 [BatchGetResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .config() - * .projectId() - * .sourceDirectoryId() - * .status() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BatchGetResponse = - BatchGetResponse( - checkRequired("id", id), - checkRequired("config", config), - checkRequired("projectId", projectId), - checkRequired("sourceDirectoryId", sourceDirectoryId), - checkRequired("status", status), - createdAt, - (results ?: JsonMissing.of()).map { it.toImmutable() }, - 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(): BatchGetResponse = apply { - if (validated) { - return@apply - } - - id() - config().validate() - projectId() - sourceDirectoryId() - status().validate() - createdAt() - results().ifPresent { it.forEach { 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) + - (if (projectId.asKnown().isPresent) 1 else 0) + - (if (sourceDirectoryId.asKnown().isPresent) 1 else 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (updatedAt.asKnown().isPresent) 1 else 0) - - /** Batch configuration snapshot. */ - class Config - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val job: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("job") @ExcludeMissing job: JsonField = JsonMissing.of() - ) : this(job, mutableMapOf()) - - /** - * Job to create for each file in the source directory. - * - * @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 job(): Job = job.getRequired("job") - - /** - * Returns the raw JSON value of [job]. - * - * Unlike [job], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("job") @ExcludeMissing fun _job(): JsonField = job - - @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]. - * - * The following fields are required: - * ```java - * .job() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Config]. */ - class Builder internal constructor() { - - private var job: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(config: Config) = apply { - job = config.job - additionalProperties = config.additionalProperties.toMutableMap() - } - - /** Job to create for each file in the source directory. */ - fun job(job: Job) = job(JsonField.of(job)) - - /** - * Sets [Builder.job] to an arbitrary JSON value. - * - * You should usually call [Builder.job] with a well-typed [Job] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun job(job: JsonField) = apply { this.job = job } - - 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. - * - * The following fields are required: - * ```java - * .job() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Config = - Config(checkRequired("job", job), 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 - } - - job().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 = (job.asKnown().getOrNull()?.validity() ?: 0) - - /** Job to create for each file in the source directory. */ - class Job - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val configurationId: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("configuration_id") - @ExcludeMissing - configurationId: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(configurationId, type, mutableMapOf()) - - /** - * Product configuration ID or built-in preset ID matching the job type. - * - * @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 configurationId(): String = configurationId.getRequired("configuration_id") - - /** - * Product job type to run for each source directory file. - * - * @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 type(): Type = type.getRequired("type") - - /** - * Returns the raw JSON value of [configurationId]. - * - * Unlike [configurationId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("configuration_id") - @ExcludeMissing - fun _configurationId(): JsonField = configurationId - - /** - * 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 [Job]. - * - * The following fields are required: - * ```java - * .configurationId() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Job]. */ - class Builder internal constructor() { - - private var configurationId: JsonField? = null - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(job: Job) = apply { - configurationId = job.configurationId - type = job.type - additionalProperties = job.additionalProperties.toMutableMap() - } - - /** Product configuration ID or built-in preset ID matching the job type. */ - fun configurationId(configurationId: String) = - configurationId(JsonField.of(configurationId)) - - /** - * Sets [Builder.configurationId] to an arbitrary JSON value. - * - * You should usually call [Builder.configurationId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun configurationId(configurationId: JsonField) = apply { - this.configurationId = configurationId - } - - /** Product job type to run for each source directory file. */ - 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 [Job]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .configurationId() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Job = - Job( - checkRequired("configurationId", configurationId), - checkRequired("type", 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(): Job = apply { - if (validated) { - return@apply - } - - configurationId() - type().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 (configurationId.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - /** Product job type to run for each source directory file. */ - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PARSE_V2 = of("parse_v2") - - @JvmField val EXTRACT_V2 = of("extract_v2") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - PARSE_V2, - EXTRACT_V2, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PARSE_V2, - EXTRACT_V2, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PARSE_V2 -> Value.PARSE_V2 - EXTRACT_V2 -> Value.EXTRACT_V2 - 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) { - PARSE_V2 -> Known.PARSE_V2 - EXTRACT_V2 -> Known.EXTRACT_V2 - else -> throw LlamaCloudInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws 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(): Type = 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 Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Job && - configurationId == other.configurationId && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(configurationId, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Job{configurationId=$configurationId, type=$type, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Config && - job == other.job && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(job, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Config{job=$job, additionalProperties=$additionalProperties}" - } - - /** Current batch status. */ - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CANCELLED = of("CANCELLED") - - @JvmField val COMPLETED = of("COMPLETED") - - @JvmField val FAILED = of("FAILED") - - @JvmField val PENDING = of("PENDING") - - @JvmField val RUNNING = of("RUNNING") - - @JvmField val THROTTLED = of("THROTTLED") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - CANCELLED, - COMPLETED, - FAILED, - PENDING, - RUNNING, - THROTTLED, - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CANCELLED, - COMPLETED, - FAILED, - PENDING, - RUNNING, - THROTTLED, - /** An enum member indicating that [Status] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CANCELLED -> Value.CANCELLED - COMPLETED -> Value.COMPLETED - FAILED -> Value.FAILED - PENDING -> Value.PENDING - RUNNING -> Value.RUNNING - THROTTLED -> Value.THROTTLED - 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) { - CANCELLED -> Known.CANCELLED - COMPLETED -> Known.COMPLETED - FAILED -> Known.FAILED - PENDING -> Known.PENDING - RUNNING -> Known.RUNNING - THROTTLED -> Known.THROTTLED - else -> throw LlamaCloudInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws 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(): Status = 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 Status && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * Result projection for one source directory file in a batch. - * - * Example: { "source_directory_file_id": "dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", - * "job_reference": { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" }, - * "error_message": null } - * - * This is a projection of directory-sync state, not a separate child resource that callers need - * to create. The source directory file ID is the stable correlation key. Underlying job - * progress and failures should be resolved through the referenced product job endpoint. - */ - class Result - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val sourceDirectoryFileId: JsonField, - private val errorMessage: JsonField, - private val jobReference: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("source_directory_file_id") - @ExcludeMissing - sourceDirectoryFileId: JsonField = JsonMissing.of(), - @JsonProperty("error_message") - @ExcludeMissing - errorMessage: JsonField = JsonMissing.of(), - @JsonProperty("job_reference") - @ExcludeMissing - jobReference: JsonField = JsonMissing.of(), - ) : this(sourceDirectoryFileId, errorMessage, jobReference, mutableMapOf()) - - /** - * Source directory file processed by this batch. - * - * @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 sourceDirectoryFileId(): String = - sourceDirectoryFileId.getRequired("source_directory_file_id") - - /** - * Batch-level mapping error if the system could not create or associate a job for this - * source file. - * - * @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") - - /** - * Reference to a job produced by a batch. - * - * Example: { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun jobReference(): Optional = jobReference.getOptional("job_reference") - - /** - * Returns the raw JSON value of [sourceDirectoryFileId]. - * - * Unlike [sourceDirectoryFileId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("source_directory_file_id") - @ExcludeMissing - fun _sourceDirectoryFileId(): JsonField = sourceDirectoryFileId - - /** - * 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 [jobReference]. - * - * Unlike [jobReference], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("job_reference") - @ExcludeMissing - fun _jobReference(): JsonField = jobReference - - @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 [Result]. - * - * The following fields are required: - * ```java - * .sourceDirectoryFileId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Result]. */ - class Builder internal constructor() { - - private var sourceDirectoryFileId: JsonField? = null - private var errorMessage: JsonField = JsonMissing.of() - private var jobReference: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(result: Result) = apply { - sourceDirectoryFileId = result.sourceDirectoryFileId - errorMessage = result.errorMessage - jobReference = result.jobReference - additionalProperties = result.additionalProperties.toMutableMap() - } - - /** Source directory file processed by this batch. */ - fun sourceDirectoryFileId(sourceDirectoryFileId: String) = - sourceDirectoryFileId(JsonField.of(sourceDirectoryFileId)) - - /** - * Sets [Builder.sourceDirectoryFileId] to an arbitrary JSON value. - * - * You should usually call [Builder.sourceDirectoryFileId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun sourceDirectoryFileId(sourceDirectoryFileId: JsonField) = apply { - this.sourceDirectoryFileId = sourceDirectoryFileId - } - - /** - * Batch-level mapping error if the system could not create or associate a job for this - * source file. - */ - 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 - } - - /** - * Reference to a job produced by a batch. - * - * Example: { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } - */ - fun jobReference(jobReference: JobReference?) = - jobReference(JsonField.ofNullable(jobReference)) - - /** Alias for calling [Builder.jobReference] with `jobReference.orElse(null)`. */ - fun jobReference(jobReference: Optional) = - jobReference(jobReference.getOrNull()) - - /** - * Sets [Builder.jobReference] to an arbitrary JSON value. - * - * You should usually call [Builder.jobReference] with a well-typed [JobReference] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun jobReference(jobReference: JsonField) = apply { - this.jobReference = jobReference - } - - 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 [Result]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .sourceDirectoryFileId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Result = - Result( - checkRequired("sourceDirectoryFileId", sourceDirectoryFileId), - errorMessage, - jobReference, - 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(): Result = apply { - if (validated) { - return@apply - } - - sourceDirectoryFileId() - errorMessage() - jobReference().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 (sourceDirectoryFileId.asKnown().isPresent) 1 else 0) + - (if (errorMessage.asKnown().isPresent) 1 else 0) + - (jobReference.asKnown().getOrNull()?.validity() ?: 0) - - /** - * Reference to a job produced by a batch. - * - * Example: { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } - */ - class JobReference - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(id, type, mutableMapOf()) - - /** - * Job ID, such as a parse 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") - - /** - * Type of job produced for the file. - * - * @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 type(): Type = type.getRequired("type") - - /** - * 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 [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 [JobReference]. - * - * The following fields are required: - * ```java - * .id() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [JobReference]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(jobReference: JobReference) = apply { - id = jobReference.id - type = jobReference.type - additionalProperties = jobReference.additionalProperties.toMutableMap() - } - - /** Job ID, such as a parse 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 } - - /** Type of job produced for the file. */ - 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 [JobReference]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): JobReference = - JobReference( - checkRequired("id", id), - checkRequired("type", 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(): JobReference = apply { - if (validated) { - return@apply - } - - id() - type().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) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - /** Type of job produced for the file. */ - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PARSE_V2 = of("parse_v2") - - @JvmField val EXTRACT_V2 = of("extract_v2") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - PARSE_V2, - EXTRACT_V2, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PARSE_V2, - EXTRACT_V2, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PARSE_V2 -> Value.PARSE_V2 - EXTRACT_V2 -> Value.EXTRACT_V2 - 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) { - PARSE_V2 -> Known.PARSE_V2 - EXTRACT_V2 -> Known.EXTRACT_V2 - else -> throw LlamaCloudInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws 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(): Type = 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 Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is JobReference && - id == other.id && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, type, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "JobReference{id=$id, type=$type, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Result && - sourceDirectoryFileId == other.sourceDirectoryFileId && - errorMessage == other.errorMessage && - jobReference == other.jobReference && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(sourceDirectoryFileId, errorMessage, jobReference, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Result{sourceDirectoryFileId=$sourceDirectoryFileId, errorMessage=$errorMessage, jobReference=$jobReference, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BatchGetResponse && - id == other.id && - config == other.config && - projectId == other.projectId && - sourceDirectoryId == other.sourceDirectoryId && - status == other.status && - createdAt == other.createdAt && - results == other.results && - updatedAt == other.updatedAt && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - config, - projectId, - sourceDirectoryId, - status, - createdAt, - results, - updatedAt, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BatchGetResponse{id=$id, config=$config, projectId=$projectId, sourceDirectoryId=$sourceDirectoryId, status=$status, createdAt=$createdAt, results=$results, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPage.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPage.kt deleted file mode 100644 index 9220e71..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPage.kt +++ /dev/null @@ -1,130 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.batches - -import ai.llamaindex.llamacloud.core.AutoPager -import ai.llamaindex.llamacloud.core.Page -import ai.llamaindex.llamacloud.core.checkRequired -import ai.llamaindex.llamacloud.services.blocking.BatchService -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** @see BatchService.list */ -class BatchListPage -private constructor( - private val service: BatchService, - private val params: BatchListParams, - private val response: BatchListPageResponse, -) : Page { - - /** - * Delegates to [BatchListPageResponse], but gracefully handles missing data. - * - * @see BatchListPageResponse.items - */ - override fun items(): List = - response._items().getOptional("items").getOrNull() ?: emptyList() - - /** - * Delegates to [BatchListPageResponse], but gracefully handles missing data. - * - * @see BatchListPageResponse.nextPageToken - */ - fun nextPageToken(): Optional = response._nextPageToken().getOptional("next_page_token") - - override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageToken().isPresent - - fun nextPageParams(): BatchListParams { - val nextCursor = - nextPageToken().getOrNull() - ?: throw IllegalStateException("Cannot construct next page params") - return params.toBuilder().pageToken(nextCursor).build() - } - - override fun nextPage(): BatchListPage = service.list(nextPageParams()) - - fun autoPager(): AutoPager = AutoPager.from(this) - - /** The parameters that were used to request this page. */ - fun params(): BatchListParams = params - - /** The response that this page was parsed from. */ - fun response(): BatchListPageResponse = response - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BatchListPage]. - * - * The following fields are required: - * ```java - * .service() - * .params() - * .response() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchListPage]. */ - class Builder internal constructor() { - - private var service: BatchService? = null - private var params: BatchListParams? = null - private var response: BatchListPageResponse? = null - - @JvmSynthetic - internal fun from(batchListPage: BatchListPage) = apply { - service = batchListPage.service - params = batchListPage.params - response = batchListPage.response - } - - fun service(service: BatchService) = apply { this.service = service } - - /** The parameters that were used to request this page. */ - fun params(params: BatchListParams) = apply { this.params = params } - - /** The response that this page was parsed from. */ - fun response(response: BatchListPageResponse) = apply { this.response = response } - - /** - * Returns an immutable instance of [BatchListPage]. - * - * 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(): BatchListPage = - BatchListPage( - checkRequired("service", service), - checkRequired("params", params), - checkRequired("response", response), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BatchListPage && - service == other.service && - params == other.params && - response == other.response - } - - override fun hashCode(): Int = Objects.hash(service, params, response) - - override fun toString() = "BatchListPage{service=$service, params=$params, response=$response}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageAsync.kt deleted file mode 100644 index fc395df..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageAsync.kt +++ /dev/null @@ -1,145 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.batches - -import ai.llamaindex.llamacloud.core.AutoPagerAsync -import ai.llamaindex.llamacloud.core.PageAsync -import ai.llamaindex.llamacloud.core.checkRequired -import ai.llamaindex.llamacloud.services.async.BatchServiceAsync -import java.util.Objects -import java.util.Optional -import java.util.concurrent.CompletableFuture -import java.util.concurrent.Executor -import kotlin.jvm.optionals.getOrNull - -/** @see BatchServiceAsync.list */ -class BatchListPageAsync -private constructor( - private val service: BatchServiceAsync, - private val streamHandlerExecutor: Executor, - private val params: BatchListParams, - private val response: BatchListPageResponse, -) : PageAsync { - - /** - * Delegates to [BatchListPageResponse], but gracefully handles missing data. - * - * @see BatchListPageResponse.items - */ - override fun items(): List = - response._items().getOptional("items").getOrNull() ?: emptyList() - - /** - * Delegates to [BatchListPageResponse], but gracefully handles missing data. - * - * @see BatchListPageResponse.nextPageToken - */ - fun nextPageToken(): Optional = response._nextPageToken().getOptional("next_page_token") - - override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageToken().isPresent - - fun nextPageParams(): BatchListParams { - 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(): BatchListParams = params - - /** The response that this page was parsed from. */ - fun response(): BatchListPageResponse = response - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BatchListPageAsync]. - * - * The following fields are required: - * ```java - * .service() - * .streamHandlerExecutor() - * .params() - * .response() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchListPageAsync]. */ - class Builder internal constructor() { - - private var service: BatchServiceAsync? = null - private var streamHandlerExecutor: Executor? = null - private var params: BatchListParams? = null - private var response: BatchListPageResponse? = null - - @JvmSynthetic - internal fun from(batchListPageAsync: BatchListPageAsync) = apply { - service = batchListPageAsync.service - streamHandlerExecutor = batchListPageAsync.streamHandlerExecutor - params = batchListPageAsync.params - response = batchListPageAsync.response - } - - fun service(service: BatchServiceAsync) = apply { this.service = service } - - fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { - this.streamHandlerExecutor = streamHandlerExecutor - } - - /** The parameters that were used to request this page. */ - fun params(params: BatchListParams) = apply { this.params = params } - - /** The response that this page was parsed from. */ - fun response(response: BatchListPageResponse) = apply { this.response = response } - - /** - * Returns an immutable instance of [BatchListPageAsync]. - * - * 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(): BatchListPageAsync = - BatchListPageAsync( - 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 BatchListPageAsync && - 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() = - "BatchListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageResponse.kt deleted file mode 100644 index 295de97..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageResponse.kt +++ /dev/null @@ -1,303 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.batches - -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 batches. */ -class BatchListPageResponse -@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 [BatchListPageResponse]. - * - * The following fields are required: - * ```java - * .items() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchListPageResponse]. */ - 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(batchListPageResponse: BatchListPageResponse) = apply { - items = batchListPageResponse.items.map { it.toMutableList() } - nextPageToken = batchListPageResponse.nextPageToken - totalSize = batchListPageResponse.totalSize - additionalProperties = batchListPageResponse.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 [BatchListResponse] to [items]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addItem(item: BatchListResponse) = 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 [BatchListPageResponse]. - * - * 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(): BatchListPageResponse = - BatchListPageResponse( - 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(): BatchListPageResponse = 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 BatchListPageResponse && - 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() = - "BatchListPageResponse{items=$items, nextPageToken=$nextPageToken, totalSize=$totalSize, additionalProperties=$additionalProperties}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListParams.kt deleted file mode 100644 index b207265..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListParams.kt +++ /dev/null @@ -1,490 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.batches - -import ai.llamaindex.llamacloud.core.Enum -import ai.llamaindex.llamacloud.core.JsonField -import ai.llamaindex.llamacloud.core.Params -import ai.llamaindex.llamacloud.core.http.Headers -import ai.llamaindex.llamacloud.core.http.QueryParams -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 - -/** List batches for the current project. */ -class BatchListParams -private constructor( - private val createdAtOnOrAfter: OffsetDateTime?, - private val createdAtOnOrBefore: OffsetDateTime?, - private val organizationId: String?, - private val pageSize: Long?, - private val pageToken: String?, - private val projectId: String?, - private val sourceDirectoryId: String?, - private val status: Status?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun createdAtOnOrAfter(): Optional = Optional.ofNullable(createdAtOnOrAfter) - - fun createdAtOnOrBefore(): Optional = Optional.ofNullable(createdAtOnOrBefore) - - fun organizationId(): Optional = Optional.ofNullable(organizationId) - - fun pageSize(): Optional = Optional.ofNullable(pageSize) - - fun pageToken(): Optional = Optional.ofNullable(pageToken) - - fun projectId(): Optional = Optional.ofNullable(projectId) - - fun sourceDirectoryId(): Optional = Optional.ofNullable(sourceDirectoryId) - - 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 { - - @JvmStatic fun none(): BatchListParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [BatchListParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchListParams]. */ - class Builder internal constructor() { - - private var createdAtOnOrAfter: OffsetDateTime? = null - private var createdAtOnOrBefore: OffsetDateTime? = null - private var organizationId: String? = null - private var pageSize: Long? = null - private var pageToken: String? = null - private var projectId: String? = null - private var sourceDirectoryId: String? = null - private var status: Status? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(batchListParams: BatchListParams) = apply { - createdAtOnOrAfter = batchListParams.createdAtOnOrAfter - createdAtOnOrBefore = batchListParams.createdAtOnOrBefore - organizationId = batchListParams.organizationId - pageSize = batchListParams.pageSize - pageToken = batchListParams.pageToken - projectId = batchListParams.projectId - sourceDirectoryId = batchListParams.sourceDirectoryId - status = batchListParams.status - additionalHeaders = batchListParams.additionalHeaders.toBuilder() - additionalQueryParams = batchListParams.additionalQueryParams.toBuilder() - } - - fun createdAtOnOrAfter(createdAtOnOrAfter: OffsetDateTime?) = apply { - this.createdAtOnOrAfter = createdAtOnOrAfter - } - - /** - * Alias for calling [Builder.createdAtOnOrAfter] with `createdAtOnOrAfter.orElse(null)`. - */ - fun createdAtOnOrAfter(createdAtOnOrAfter: Optional) = - createdAtOnOrAfter(createdAtOnOrAfter.getOrNull()) - - fun createdAtOnOrBefore(createdAtOnOrBefore: OffsetDateTime?) = apply { - this.createdAtOnOrBefore = createdAtOnOrBefore - } - - /** - * Alias for calling [Builder.createdAtOnOrBefore] with `createdAtOnOrBefore.orElse(null)`. - */ - fun createdAtOnOrBefore(createdAtOnOrBefore: Optional) = - createdAtOnOrBefore(createdAtOnOrBefore.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 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 sourceDirectoryId(sourceDirectoryId: String?) = apply { - this.sourceDirectoryId = sourceDirectoryId - } - - /** Alias for calling [Builder.sourceDirectoryId] with `sourceDirectoryId.orElse(null)`. */ - fun sourceDirectoryId(sourceDirectoryId: Optional) = - sourceDirectoryId(sourceDirectoryId.getOrNull()) - - fun status(status: Status?) = apply { this.status = status } - - /** Alias for calling [Builder.status] with `status.orElse(null)`. */ - fun status(status: Optional) = status(status.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 [BatchListParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BatchListParams = - BatchListParams( - createdAtOnOrAfter, - createdAtOnOrBefore, - organizationId, - pageSize, - pageToken, - projectId, - sourceDirectoryId, - status, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - 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), - ) - } - 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) } - sourceDirectoryId?.let { put("source_directory_id", it) } - status?.let { put("status", it.toString()) } - putAll(additionalQueryParams) - } - .build() - - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CANCELLED = of("CANCELLED") - - @JvmField val COMPLETED = of("COMPLETED") - - @JvmField val FAILED = of("FAILED") - - @JvmField val PENDING = of("PENDING") - - @JvmField val RUNNING = of("RUNNING") - - @JvmField val THROTTLED = of("THROTTLED") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - CANCELLED, - COMPLETED, - FAILED, - PENDING, - RUNNING, - THROTTLED, - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CANCELLED, - COMPLETED, - FAILED, - PENDING, - RUNNING, - THROTTLED, - /** An enum member indicating that [Status] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CANCELLED -> Value.CANCELLED - COMPLETED -> Value.COMPLETED - FAILED -> Value.FAILED - PENDING -> Value.PENDING - RUNNING -> Value.RUNNING - THROTTLED -> Value.THROTTLED - 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) { - CANCELLED -> Known.CANCELLED - COMPLETED -> Known.COMPLETED - FAILED -> Known.FAILED - PENDING -> Known.PENDING - RUNNING -> Known.RUNNING - THROTTLED -> Known.THROTTLED - else -> throw LlamaCloudInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws 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(): Status = 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 Status && 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 BatchListParams && - createdAtOnOrAfter == other.createdAtOnOrAfter && - createdAtOnOrBefore == other.createdAtOnOrBefore && - organizationId == other.organizationId && - pageSize == other.pageSize && - pageToken == other.pageToken && - projectId == other.projectId && - sourceDirectoryId == other.sourceDirectoryId && - status == other.status && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash( - createdAtOnOrAfter, - createdAtOnOrBefore, - organizationId, - pageSize, - pageToken, - projectId, - sourceDirectoryId, - status, - additionalHeaders, - additionalQueryParams, - ) - - override fun toString() = - "BatchListParams{createdAtOnOrAfter=$createdAtOnOrAfter, createdAtOnOrBefore=$createdAtOnOrBefore, organizationId=$organizationId, pageSize=$pageSize, pageToken=$pageToken, projectId=$projectId, sourceDirectoryId=$sourceDirectoryId, status=$status, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListResponse.kt deleted file mode 100644 index 63557d1..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListResponse.kt +++ /dev/null @@ -1,1867 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.batches - -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.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.time.OffsetDateTime -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * A top-level batch. - * - * Example: { "id": "bat-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "project_id": - * "prj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "source_directory_id": - * "dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "config": { "job": { "type": "parse_v2", - * "configuration_id": "cfg-PARSE_AGENTIC" } }, "status": "COMPLETED", "results": - * [ { "source_directory_file_id": "dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "job_reference": { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" }, "error_message": null } ] - * } - * - * Batch-level ``FAILED`` means the orchestration failed and cannot provide a reliable per-file - * result set. ``results`` is only populated when explicitly requested with ``expand=results`` and - * may be ``null`` while a batch is still running. - */ -class BatchListResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val id: JsonField, - private val config: JsonField, - private val projectId: JsonField, - private val sourceDirectoryId: JsonField, - private val status: JsonField, - private val createdAt: JsonField, - private val results: 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("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), - @JsonProperty("source_directory_id") - @ExcludeMissing - sourceDirectoryId: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("results") - @ExcludeMissing - results: JsonField> = JsonMissing.of(), - @JsonProperty("updated_at") - @ExcludeMissing - updatedAt: JsonField = JsonMissing.of(), - ) : this( - id, - config, - projectId, - sourceDirectoryId, - status, - createdAt, - results, - updatedAt, - mutableMapOf(), - ) - - /** - * Unique identifier - * - * @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") - - /** - * Batch configuration snapshot. - * - * @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") - - /** - * Project this batch 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") - - /** - * Directory being processed. - * - * @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 sourceDirectoryId(): String = sourceDirectoryId.getRequired("source_directory_id") - - /** - * Current batch 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(): Status = status.getRequired("status") - - /** - * Creation datetime - * - * @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") - - /** - * Expanded per-file result mappings. Null unless requested with expand=results, or while the - * batch is still running. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun results(): Optional> = results.getOptional("results") - - /** - * Update datetime - * - * @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 [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 [sourceDirectoryId]. - * - * Unlike [sourceDirectoryId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("source_directory_id") - @ExcludeMissing - fun _sourceDirectoryId(): JsonField = sourceDirectoryId - - /** - * 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 [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 [results]. - * - * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("results") @ExcludeMissing fun _results(): JsonField> = results - - /** - * 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 [BatchListResponse]. - * - * The following fields are required: - * ```java - * .id() - * .config() - * .projectId() - * .sourceDirectoryId() - * .status() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchListResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var config: JsonField? = null - private var projectId: JsonField? = null - private var sourceDirectoryId: JsonField? = null - private var status: JsonField? = null - private var createdAt: JsonField = JsonMissing.of() - private var results: JsonField>? = null - private var updatedAt: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(batchListResponse: BatchListResponse) = apply { - id = batchListResponse.id - config = batchListResponse.config - projectId = batchListResponse.projectId - sourceDirectoryId = batchListResponse.sourceDirectoryId - status = batchListResponse.status - createdAt = batchListResponse.createdAt - results = batchListResponse.results.map { it.toMutableList() } - updatedAt = batchListResponse.updatedAt - additionalProperties = batchListResponse.additionalProperties.toMutableMap() - } - - /** Unique identifier */ - 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 } - - /** Batch configuration snapshot. */ - 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 } - - /** Project this batch 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 } - - /** Directory being processed. */ - fun sourceDirectoryId(sourceDirectoryId: String) = - sourceDirectoryId(JsonField.of(sourceDirectoryId)) - - /** - * Sets [Builder.sourceDirectoryId] to an arbitrary JSON value. - * - * You should usually call [Builder.sourceDirectoryId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun sourceDirectoryId(sourceDirectoryId: JsonField) = apply { - this.sourceDirectoryId = sourceDirectoryId - } - - /** Current batch status. */ - fun status(status: Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - /** Creation datetime */ - 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 } - - /** - * Expanded per-file result mappings. Null unless requested with expand=results, or while - * the batch is still running. - */ - fun results(results: List?) = results(JsonField.ofNullable(results)) - - /** Alias for calling [Builder.results] with `results.orElse(null)`. */ - fun results(results: Optional>) = results(results.getOrNull()) - - /** - * Sets [Builder.results] to an arbitrary JSON value. - * - * You should usually call [Builder.results] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun results(results: JsonField>) = apply { - this.results = results.map { it.toMutableList() } - } - - /** - * Adds a single [Result] to [results]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addResult(result: Result) = apply { - results = - (results ?: JsonField.of(mutableListOf())).also { - checkKnown("results", it).add(result) - } - } - - /** Update datetime */ - 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 [BatchListResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .config() - * .projectId() - * .sourceDirectoryId() - * .status() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BatchListResponse = - BatchListResponse( - checkRequired("id", id), - checkRequired("config", config), - checkRequired("projectId", projectId), - checkRequired("sourceDirectoryId", sourceDirectoryId), - checkRequired("status", status), - createdAt, - (results ?: JsonMissing.of()).map { it.toImmutable() }, - 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(): BatchListResponse = apply { - if (validated) { - return@apply - } - - id() - config().validate() - projectId() - sourceDirectoryId() - status().validate() - createdAt() - results().ifPresent { it.forEach { 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) + - (if (projectId.asKnown().isPresent) 1 else 0) + - (if (sourceDirectoryId.asKnown().isPresent) 1 else 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (updatedAt.asKnown().isPresent) 1 else 0) - - /** Batch configuration snapshot. */ - class Config - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val job: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("job") @ExcludeMissing job: JsonField = JsonMissing.of() - ) : this(job, mutableMapOf()) - - /** - * Job to create for each file in the source directory. - * - * @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 job(): Job = job.getRequired("job") - - /** - * Returns the raw JSON value of [job]. - * - * Unlike [job], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("job") @ExcludeMissing fun _job(): JsonField = job - - @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]. - * - * The following fields are required: - * ```java - * .job() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Config]. */ - class Builder internal constructor() { - - private var job: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(config: Config) = apply { - job = config.job - additionalProperties = config.additionalProperties.toMutableMap() - } - - /** Job to create for each file in the source directory. */ - fun job(job: Job) = job(JsonField.of(job)) - - /** - * Sets [Builder.job] to an arbitrary JSON value. - * - * You should usually call [Builder.job] with a well-typed [Job] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun job(job: JsonField) = apply { this.job = job } - - 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. - * - * The following fields are required: - * ```java - * .job() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Config = - Config(checkRequired("job", job), 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 - } - - job().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 = (job.asKnown().getOrNull()?.validity() ?: 0) - - /** Job to create for each file in the source directory. */ - class Job - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val configurationId: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("configuration_id") - @ExcludeMissing - configurationId: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(configurationId, type, mutableMapOf()) - - /** - * Product configuration ID or built-in preset ID matching the job type. - * - * @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 configurationId(): String = configurationId.getRequired("configuration_id") - - /** - * Product job type to run for each source directory file. - * - * @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 type(): Type = type.getRequired("type") - - /** - * Returns the raw JSON value of [configurationId]. - * - * Unlike [configurationId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("configuration_id") - @ExcludeMissing - fun _configurationId(): JsonField = configurationId - - /** - * 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 [Job]. - * - * The following fields are required: - * ```java - * .configurationId() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Job]. */ - class Builder internal constructor() { - - private var configurationId: JsonField? = null - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(job: Job) = apply { - configurationId = job.configurationId - type = job.type - additionalProperties = job.additionalProperties.toMutableMap() - } - - /** Product configuration ID or built-in preset ID matching the job type. */ - fun configurationId(configurationId: String) = - configurationId(JsonField.of(configurationId)) - - /** - * Sets [Builder.configurationId] to an arbitrary JSON value. - * - * You should usually call [Builder.configurationId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun configurationId(configurationId: JsonField) = apply { - this.configurationId = configurationId - } - - /** Product job type to run for each source directory file. */ - 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 [Job]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .configurationId() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Job = - Job( - checkRequired("configurationId", configurationId), - checkRequired("type", 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(): Job = apply { - if (validated) { - return@apply - } - - configurationId() - type().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 (configurationId.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - /** Product job type to run for each source directory file. */ - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PARSE_V2 = of("parse_v2") - - @JvmField val EXTRACT_V2 = of("extract_v2") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - PARSE_V2, - EXTRACT_V2, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PARSE_V2, - EXTRACT_V2, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PARSE_V2 -> Value.PARSE_V2 - EXTRACT_V2 -> Value.EXTRACT_V2 - 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) { - PARSE_V2 -> Known.PARSE_V2 - EXTRACT_V2 -> Known.EXTRACT_V2 - else -> throw LlamaCloudInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws 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(): Type = 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 Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Job && - configurationId == other.configurationId && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(configurationId, type, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Job{configurationId=$configurationId, type=$type, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Config && - job == other.job && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(job, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Config{job=$job, additionalProperties=$additionalProperties}" - } - - /** Current batch status. */ - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CANCELLED = of("CANCELLED") - - @JvmField val COMPLETED = of("COMPLETED") - - @JvmField val FAILED = of("FAILED") - - @JvmField val PENDING = of("PENDING") - - @JvmField val RUNNING = of("RUNNING") - - @JvmField val THROTTLED = of("THROTTLED") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - CANCELLED, - COMPLETED, - FAILED, - PENDING, - RUNNING, - THROTTLED, - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CANCELLED, - COMPLETED, - FAILED, - PENDING, - RUNNING, - THROTTLED, - /** An enum member indicating that [Status] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CANCELLED -> Value.CANCELLED - COMPLETED -> Value.COMPLETED - FAILED -> Value.FAILED - PENDING -> Value.PENDING - RUNNING -> Value.RUNNING - THROTTLED -> Value.THROTTLED - 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) { - CANCELLED -> Known.CANCELLED - COMPLETED -> Known.COMPLETED - FAILED -> Known.FAILED - PENDING -> Known.PENDING - RUNNING -> Known.RUNNING - THROTTLED -> Known.THROTTLED - else -> throw LlamaCloudInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws 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(): Status = 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 Status && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * Result projection for one source directory file in a batch. - * - * Example: { "source_directory_file_id": "dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", - * "job_reference": { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" }, - * "error_message": null } - * - * This is a projection of directory-sync state, not a separate child resource that callers need - * to create. The source directory file ID is the stable correlation key. Underlying job - * progress and failures should be resolved through the referenced product job endpoint. - */ - class Result - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val sourceDirectoryFileId: JsonField, - private val errorMessage: JsonField, - private val jobReference: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("source_directory_file_id") - @ExcludeMissing - sourceDirectoryFileId: JsonField = JsonMissing.of(), - @JsonProperty("error_message") - @ExcludeMissing - errorMessage: JsonField = JsonMissing.of(), - @JsonProperty("job_reference") - @ExcludeMissing - jobReference: JsonField = JsonMissing.of(), - ) : this(sourceDirectoryFileId, errorMessage, jobReference, mutableMapOf()) - - /** - * Source directory file processed by this batch. - * - * @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 sourceDirectoryFileId(): String = - sourceDirectoryFileId.getRequired("source_directory_file_id") - - /** - * Batch-level mapping error if the system could not create or associate a job for this - * source file. - * - * @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") - - /** - * Reference to a job produced by a batch. - * - * Example: { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun jobReference(): Optional = jobReference.getOptional("job_reference") - - /** - * Returns the raw JSON value of [sourceDirectoryFileId]. - * - * Unlike [sourceDirectoryFileId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("source_directory_file_id") - @ExcludeMissing - fun _sourceDirectoryFileId(): JsonField = sourceDirectoryFileId - - /** - * 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 [jobReference]. - * - * Unlike [jobReference], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("job_reference") - @ExcludeMissing - fun _jobReference(): JsonField = jobReference - - @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 [Result]. - * - * The following fields are required: - * ```java - * .sourceDirectoryFileId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Result]. */ - class Builder internal constructor() { - - private var sourceDirectoryFileId: JsonField? = null - private var errorMessage: JsonField = JsonMissing.of() - private var jobReference: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(result: Result) = apply { - sourceDirectoryFileId = result.sourceDirectoryFileId - errorMessage = result.errorMessage - jobReference = result.jobReference - additionalProperties = result.additionalProperties.toMutableMap() - } - - /** Source directory file processed by this batch. */ - fun sourceDirectoryFileId(sourceDirectoryFileId: String) = - sourceDirectoryFileId(JsonField.of(sourceDirectoryFileId)) - - /** - * Sets [Builder.sourceDirectoryFileId] to an arbitrary JSON value. - * - * You should usually call [Builder.sourceDirectoryFileId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun sourceDirectoryFileId(sourceDirectoryFileId: JsonField) = apply { - this.sourceDirectoryFileId = sourceDirectoryFileId - } - - /** - * Batch-level mapping error if the system could not create or associate a job for this - * source file. - */ - 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 - } - - /** - * Reference to a job produced by a batch. - * - * Example: { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } - */ - fun jobReference(jobReference: JobReference?) = - jobReference(JsonField.ofNullable(jobReference)) - - /** Alias for calling [Builder.jobReference] with `jobReference.orElse(null)`. */ - fun jobReference(jobReference: Optional) = - jobReference(jobReference.getOrNull()) - - /** - * Sets [Builder.jobReference] to an arbitrary JSON value. - * - * You should usually call [Builder.jobReference] with a well-typed [JobReference] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun jobReference(jobReference: JsonField) = apply { - this.jobReference = jobReference - } - - 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 [Result]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .sourceDirectoryFileId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Result = - Result( - checkRequired("sourceDirectoryFileId", sourceDirectoryFileId), - errorMessage, - jobReference, - 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(): Result = apply { - if (validated) { - return@apply - } - - sourceDirectoryFileId() - errorMessage() - jobReference().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 (sourceDirectoryFileId.asKnown().isPresent) 1 else 0) + - (if (errorMessage.asKnown().isPresent) 1 else 0) + - (jobReference.asKnown().getOrNull()?.validity() ?: 0) - - /** - * Reference to a job produced by a batch. - * - * Example: { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } - */ - class JobReference - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(id, type, mutableMapOf()) - - /** - * Job ID, such as a parse 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") - - /** - * Type of job produced for the file. - * - * @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 type(): Type = type.getRequired("type") - - /** - * 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 [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 [JobReference]. - * - * The following fields are required: - * ```java - * .id() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [JobReference]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(jobReference: JobReference) = apply { - id = jobReference.id - type = jobReference.type - additionalProperties = jobReference.additionalProperties.toMutableMap() - } - - /** Job ID, such as a parse 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 } - - /** Type of job produced for the file. */ - 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 [JobReference]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): JobReference = - JobReference( - checkRequired("id", id), - checkRequired("type", 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(): JobReference = apply { - if (validated) { - return@apply - } - - id() - type().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) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - /** Type of job produced for the file. */ - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val PARSE_V2 = of("parse_v2") - - @JvmField val EXTRACT_V2 = of("extract_v2") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - PARSE_V2, - EXTRACT_V2, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PARSE_V2, - EXTRACT_V2, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - PARSE_V2 -> Value.PARSE_V2 - EXTRACT_V2 -> Value.EXTRACT_V2 - 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) { - PARSE_V2 -> Known.PARSE_V2 - EXTRACT_V2 -> Known.EXTRACT_V2 - else -> throw LlamaCloudInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws 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(): Type = 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 Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is JobReference && - id == other.id && - type == other.type && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(id, type, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "JobReference{id=$id, type=$type, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Result && - sourceDirectoryFileId == other.sourceDirectoryFileId && - errorMessage == other.errorMessage && - jobReference == other.jobReference && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(sourceDirectoryFileId, errorMessage, jobReference, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Result{sourceDirectoryFileId=$sourceDirectoryFileId, errorMessage=$errorMessage, jobReference=$jobReference, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BatchListResponse && - id == other.id && - config == other.config && - projectId == other.projectId && - sourceDirectoryId == other.sourceDirectoryId && - status == other.status && - createdAt == other.createdAt && - results == other.results && - updatedAt == other.updatedAt && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - config, - projectId, - sourceDirectoryId, - status, - createdAt, - results, - updatedAt, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BatchListResponse{id=$id, config=$config, projectId=$projectId, sourceDirectoryId=$sourceDirectoryId, status=$status, createdAt=$createdAt, results=$results, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCancelParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCancelParams.kt deleted file mode 100644 index b1c88b7..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCancelParams.kt +++ /dev/null @@ -1,489 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch - -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.Params -import ai.llamaindex.llamacloud.core.http.Headers -import ai.llamaindex.llamacloud.core.http.QueryParams -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 - -/** - * Cancel a running batch processing job. - * - * Stops processing and marks pending items as cancelled. Items currently being processed may still - * complete. - */ -class BatchCancelParams -private constructor( - private val jobId: String?, - private val organizationId: String?, - private val projectId: String?, - private val temporalNamespace: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun jobId(): Optional = Optional.ofNullable(jobId) - - fun organizationId(): Optional = Optional.ofNullable(organizationId) - - fun projectId(): Optional = Optional.ofNullable(projectId) - - fun temporalNamespace(): Optional = Optional.ofNullable(temporalNamespace) - - /** - * Optional reason for cancelling the job - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun reason(): Optional = body.reason() - - /** - * Returns the raw JSON value of [reason]. - * - * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _reason(): JsonField = body._reason() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - @JvmStatic fun none(): BatchCancelParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [BatchCancelParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchCancelParams]. */ - class Builder internal constructor() { - - private var jobId: String? = null - private var organizationId: String? = null - private var projectId: String? = null - private var temporalNamespace: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(batchCancelParams: BatchCancelParams) = apply { - jobId = batchCancelParams.jobId - organizationId = batchCancelParams.organizationId - projectId = batchCancelParams.projectId - temporalNamespace = batchCancelParams.temporalNamespace - body = batchCancelParams.body.toBuilder() - additionalHeaders = batchCancelParams.additionalHeaders.toBuilder() - additionalQueryParams = batchCancelParams.additionalQueryParams.toBuilder() - } - - 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 temporalNamespace(temporalNamespace: String?) = apply { - this.temporalNamespace = temporalNamespace - } - - /** Alias for calling [Builder.temporalNamespace] with `temporalNamespace.orElse(null)`. */ - fun temporalNamespace(temporalNamespace: Optional) = - temporalNamespace(temporalNamespace.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [reason] - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** Optional reason for cancelling the job */ - fun reason(reason: String?) = apply { body.reason(reason) } - - /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ - fun reason(reason: Optional) = reason(reason.getOrNull()) - - /** - * Sets [Builder.reason] to an arbitrary JSON value. - * - * You should usually call [Builder.reason] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun reason(reason: JsonField) = apply { body.reason(reason) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [BatchCancelParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BatchCancelParams = - BatchCancelParams( - jobId, - organizationId, - projectId, - temporalNamespace, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - fun _pathParam(index: Int): String = - when (index) { - 0 -> jobId ?: "" - else -> "" - } - - override fun _headers(): Headers = - Headers.builder() - .apply { - temporalNamespace?.let { put("temporal-namespace", it) } - putAll(additionalHeaders) - } - .build() - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - organizationId?.let { put("organization_id", it) } - projectId?.let { put("project_id", it) } - putAll(additionalQueryParams) - } - .build() - - /** Request to cancel a running batch job. */ - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val reason: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("reason") @ExcludeMissing reason: JsonField = JsonMissing.of() - ) : this(reason, mutableMapOf()) - - /** - * Optional reason for cancelling the job - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun reason(): Optional = reason.getOptional("reason") - - /** - * Returns the raw JSON value of [reason]. - * - * Unlike [reason], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Body]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var reason: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - reason = body.reason - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** Optional reason for cancelling the job */ - fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) - - /** Alias for calling [Builder.reason] with `reason.orElse(null)`. */ - fun reason(reason: Optional) = reason(reason.getOrNull()) - - /** - * Sets [Builder.reason] to an arbitrary JSON value. - * - * You should usually call [Builder.reason] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun reason(reason: JsonField) = apply { this.reason = reason } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Body = Body(reason, 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(): Body = apply { - if (validated) { - return@apply - } - - reason() - 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 (reason.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - reason == other.reason && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(reason, additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Body{reason=$reason, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BatchCancelParams && - jobId == other.jobId && - organizationId == other.organizationId && - projectId == other.projectId && - temporalNamespace == other.temporalNamespace && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash( - jobId, - organizationId, - projectId, - temporalNamespace, - body, - additionalHeaders, - additionalQueryParams, - ) - - override fun toString() = - "BatchCancelParams{jobId=$jobId, organizationId=$organizationId, projectId=$projectId, temporalNamespace=$temporalNamespace, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCancelResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCancelResponse.kt deleted file mode 100644 index e8d52f7..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCancelResponse.kt +++ /dev/null @@ -1,464 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch - -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.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 kotlin.jvm.optionals.getOrNull - -/** Response after cancelling a batch job. */ -class BatchCancelResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val jobId: JsonField, - private val message: JsonField, - private val processedItems: JsonField, - private val status: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("job_id") @ExcludeMissing jobId: JsonField = JsonMissing.of(), - @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), - @JsonProperty("processed_items") - @ExcludeMissing - processedItems: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - ) : this(jobId, message, processedItems, status, mutableMapOf()) - - /** - * ID of the cancelled 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 jobId(): String = jobId.getRequired("job_id") - - /** - * Confirmation message - * - * @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 message(): String = message.getRequired("message") - - /** - * Number of items processed before cancellation - * - * @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 processedItems(): Long = processedItems.getRequired("processed_items") - - /** - * New status (should be 'cancelled') - * - * @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(): Status = status.getRequired("status") - - /** - * Returns the raw JSON value of [jobId]. - * - * Unlike [jobId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("job_id") @ExcludeMissing fun _jobId(): JsonField = jobId - - /** - * Returns the raw JSON value of [message]. - * - * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message - - /** - * Returns the raw JSON value of [processedItems]. - * - * Unlike [processedItems], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("processed_items") - @ExcludeMissing - fun _processedItems(): JsonField = processedItems - - /** - * 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 - - @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 [BatchCancelResponse]. - * - * The following fields are required: - * ```java - * .jobId() - * .message() - * .processedItems() - * .status() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchCancelResponse]. */ - class Builder internal constructor() { - - private var jobId: JsonField? = null - private var message: JsonField? = null - private var processedItems: JsonField? = null - private var status: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(batchCancelResponse: BatchCancelResponse) = apply { - jobId = batchCancelResponse.jobId - message = batchCancelResponse.message - processedItems = batchCancelResponse.processedItems - status = batchCancelResponse.status - additionalProperties = batchCancelResponse.additionalProperties.toMutableMap() - } - - /** ID of the cancelled job */ - fun jobId(jobId: String) = jobId(JsonField.of(jobId)) - - /** - * Sets [Builder.jobId] to an arbitrary JSON value. - * - * You should usually call [Builder.jobId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun jobId(jobId: JsonField) = apply { this.jobId = jobId } - - /** Confirmation message */ - fun message(message: String) = message(JsonField.of(message)) - - /** - * Sets [Builder.message] to an arbitrary JSON value. - * - * You should usually call [Builder.message] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun message(message: JsonField) = apply { this.message = message } - - /** Number of items processed before cancellation */ - fun processedItems(processedItems: Long) = processedItems(JsonField.of(processedItems)) - - /** - * Sets [Builder.processedItems] to an arbitrary JSON value. - * - * You should usually call [Builder.processedItems] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun processedItems(processedItems: JsonField) = apply { - this.processedItems = processedItems - } - - /** New status (should be 'cancelled') */ - fun status(status: Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - fun 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 [BatchCancelResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .jobId() - * .message() - * .processedItems() - * .status() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BatchCancelResponse = - BatchCancelResponse( - checkRequired("jobId", jobId), - checkRequired("message", message), - checkRequired("processedItems", processedItems), - checkRequired("status", status), - 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(): BatchCancelResponse = apply { - if (validated) { - return@apply - } - - jobId() - message() - processedItems() - status().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 (jobId.asKnown().isPresent) 1 else 0) + - (if (message.asKnown().isPresent) 1 else 0) + - (if (processedItems.asKnown().isPresent) 1 else 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) - - /** New status (should be 'cancelled') */ - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CANCELLED = of("cancelled") - - @JvmField val COMPLETED = of("completed") - - @JvmField val DISPATCHED = of("dispatched") - - @JvmField val FAILED = of("failed") - - @JvmField val PENDING = of("pending") - - @JvmField val RUNNING = of("running") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - CANCELLED, - COMPLETED, - DISPATCHED, - FAILED, - PENDING, - RUNNING, - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CANCELLED, - COMPLETED, - DISPATCHED, - FAILED, - PENDING, - RUNNING, - /** An enum member indicating that [Status] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CANCELLED -> Value.CANCELLED - COMPLETED -> Value.COMPLETED - DISPATCHED -> Value.DISPATCHED - FAILED -> Value.FAILED - PENDING -> Value.PENDING - RUNNING -> Value.RUNNING - 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) { - CANCELLED -> Known.CANCELLED - COMPLETED -> Known.COMPLETED - DISPATCHED -> Known.DISPATCHED - FAILED -> Known.FAILED - PENDING -> Known.PENDING - RUNNING -> Known.RUNNING - else -> throw LlamaCloudInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws 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(): Status = 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 Status && 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 BatchCancelResponse && - jobId == other.jobId && - message == other.message && - processedItems == other.processedItems && - status == other.status && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(jobId, message, processedItems, status, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BatchCancelResponse{jobId=$jobId, message=$message, processedItems=$processedItems, status=$status, additionalProperties=$additionalProperties}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateParams.kt deleted file mode 100644 index 69334ca..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateParams.kt +++ /dev/null @@ -1,10788 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch - -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 -import ai.llamaindex.llamacloud.core.JsonValue -import ai.llamaindex.llamacloud.core.Params -import ai.llamaindex.llamacloud.core.allMaxBy -import ai.llamaindex.llamacloud.core.checkKnown -import ai.llamaindex.llamacloud.core.checkRequired -import ai.llamaindex.llamacloud.core.getOrThrow -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 ai.llamaindex.llamacloud.models.classifier.jobs.ClassifyJob -import ai.llamaindex.llamacloud.models.parsing.FailPageMode -import ai.llamaindex.llamacloud.models.parsing.ParsingLanguages -import ai.llamaindex.llamacloud.models.parsing.ParsingMode -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * Create a batch processing job. - * - * Processes files from a directory or a specific list of item IDs. Supports batch parsing and - * classification operations. - * - * Provide either `directory_id` to process all files in a directory, or `item_ids` for specific - * items. The job runs asynchronously — poll `GET /batch/{job_id}` for progress. - */ -class BatchCreateParams -private constructor( - private val organizationId: String?, - private val projectId: String?, - private val temporalNamespace: String?, - private val body: Body, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun organizationId(): Optional = Optional.ofNullable(organizationId) - - fun projectId(): Optional = Optional.ofNullable(projectId) - - fun temporalNamespace(): Optional = Optional.ofNullable(temporalNamespace) - - /** - * Job configuration — either a parse or classify config - * - * @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 jobConfig(): JobConfig = body.jobConfig() - - /** - * Maximum files to process per execution cycle in directory mode. Defaults to page_size. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun continueAsNewThreshold(): Optional = body.continueAsNewThreshold() - - /** - * ID of the directory containing files to process - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun directoryId(): Optional = body.directoryId() - - /** - * List of specific item IDs to process. Either this or directory_id must be provided. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun itemIds(): Optional> = body.itemIds() - - /** - * Number of files to process per batch when using directory mode - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun pageSize(): Optional = body.pageSize() - - /** - * Returns the raw JSON value of [jobConfig]. - * - * Unlike [jobConfig], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _jobConfig(): JsonField = body._jobConfig() - - /** - * Returns the raw JSON value of [continueAsNewThreshold]. - * - * Unlike [continueAsNewThreshold], this method doesn't throw if the JSON field has an - * unexpected type. - */ - fun _continueAsNewThreshold(): JsonField = body._continueAsNewThreshold() - - /** - * Returns the raw JSON value of [directoryId]. - * - * Unlike [directoryId], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _directoryId(): JsonField = body._directoryId() - - /** - * Returns the raw JSON value of [itemIds]. - * - * Unlike [itemIds], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _itemIds(): JsonField> = body._itemIds() - - /** - * Returns the raw JSON value of [pageSize]. - * - * Unlike [pageSize], this method doesn't throw if the JSON field has an unexpected type. - */ - fun _pageSize(): JsonField = body._pageSize() - - fun _additionalBodyProperties(): Map = body._additionalProperties() - - /** Additional headers to send with the request. */ - fun _additionalHeaders(): Headers = additionalHeaders - - /** Additional query param to send with the request. */ - fun _additionalQueryParams(): QueryParams = additionalQueryParams - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BatchCreateParams]. - * - * The following fields are required: - * ```java - * .jobConfig() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchCreateParams]. */ - class Builder internal constructor() { - - private var organizationId: String? = null - private var projectId: String? = null - private var temporalNamespace: String? = null - private var body: Body.Builder = Body.builder() - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(batchCreateParams: BatchCreateParams) = apply { - organizationId = batchCreateParams.organizationId - projectId = batchCreateParams.projectId - temporalNamespace = batchCreateParams.temporalNamespace - body = batchCreateParams.body.toBuilder() - additionalHeaders = batchCreateParams.additionalHeaders.toBuilder() - additionalQueryParams = batchCreateParams.additionalQueryParams.toBuilder() - } - - 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 temporalNamespace(temporalNamespace: String?) = apply { - this.temporalNamespace = temporalNamespace - } - - /** Alias for calling [Builder.temporalNamespace] with `temporalNamespace.orElse(null)`. */ - fun temporalNamespace(temporalNamespace: Optional) = - temporalNamespace(temporalNamespace.getOrNull()) - - /** - * Sets the entire request body. - * - * This is generally only useful if you are already constructing the body separately. - * Otherwise, it's more convenient to use the top-level setters instead: - * - [jobConfig] - * - [continueAsNewThreshold] - * - [directoryId] - * - [itemIds] - * - [pageSize] - * - etc. - */ - fun body(body: Body) = apply { this.body = body.toBuilder() } - - /** Job configuration — either a parse or classify config */ - fun jobConfig(jobConfig: JobConfig) = apply { body.jobConfig(jobConfig) } - - /** - * Sets [Builder.jobConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.jobConfig] with a well-typed [JobConfig] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun jobConfig(jobConfig: JsonField) = apply { body.jobConfig(jobConfig) } - - /** - * Alias for calling [jobConfig] with - * `JobConfig.ofBatchParseJobRecordCreate(batchParseJobRecordCreate)`. - */ - fun jobConfig(batchParseJobRecordCreate: JobConfig.BatchParseJobRecordCreate) = apply { - body.jobConfig(batchParseJobRecordCreate) - } - - /** Alias for calling [jobConfig] with `JobConfig.ofClassifyJob(classifyJob)`. */ - fun jobConfig(classifyJob: ClassifyJob) = apply { body.jobConfig(classifyJob) } - - /** - * Maximum files to process per execution cycle in directory mode. Defaults to page_size. - */ - fun continueAsNewThreshold(continueAsNewThreshold: Long?) = apply { - body.continueAsNewThreshold(continueAsNewThreshold) - } - - /** - * Alias for [Builder.continueAsNewThreshold]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun continueAsNewThreshold(continueAsNewThreshold: Long) = - continueAsNewThreshold(continueAsNewThreshold as Long?) - - /** - * Alias for calling [Builder.continueAsNewThreshold] with - * `continueAsNewThreshold.orElse(null)`. - */ - fun continueAsNewThreshold(continueAsNewThreshold: Optional) = - continueAsNewThreshold(continueAsNewThreshold.getOrNull()) - - /** - * Sets [Builder.continueAsNewThreshold] to an arbitrary JSON value. - * - * You should usually call [Builder.continueAsNewThreshold] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun continueAsNewThreshold(continueAsNewThreshold: JsonField) = apply { - body.continueAsNewThreshold(continueAsNewThreshold) - } - - /** ID of the directory containing files to process */ - fun directoryId(directoryId: String?) = apply { body.directoryId(directoryId) } - - /** Alias for calling [Builder.directoryId] with `directoryId.orElse(null)`. */ - fun directoryId(directoryId: Optional) = directoryId(directoryId.getOrNull()) - - /** - * Sets [Builder.directoryId] to an arbitrary JSON value. - * - * You should usually call [Builder.directoryId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun directoryId(directoryId: JsonField) = apply { body.directoryId(directoryId) } - - /** List of specific item IDs to process. Either this or directory_id must be provided. */ - fun itemIds(itemIds: List?) = apply { body.itemIds(itemIds) } - - /** Alias for calling [Builder.itemIds] with `itemIds.orElse(null)`. */ - fun itemIds(itemIds: Optional>) = itemIds(itemIds.getOrNull()) - - /** - * Sets [Builder.itemIds] to an arbitrary JSON value. - * - * You should usually call [Builder.itemIds] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun itemIds(itemIds: JsonField>) = apply { body.itemIds(itemIds) } - - /** - * Adds a single [String] to [itemIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addItemId(itemId: String) = apply { body.addItemId(itemId) } - - /** Number of files to process per batch when using directory mode */ - fun pageSize(pageSize: Long) = apply { body.pageSize(pageSize) } - - /** - * Sets [Builder.pageSize] to an arbitrary JSON value. - * - * You should usually call [Builder.pageSize] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun pageSize(pageSize: JsonField) = apply { body.pageSize(pageSize) } - - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - - fun additionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun additionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.clear() - putAllAdditionalHeaders(additionalHeaders) - } - - fun putAdditionalHeader(name: String, value: String) = apply { - additionalHeaders.put(name, value) - } - - fun putAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.put(name, values) - } - - fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.putAll(additionalHeaders) - } - - fun replaceAdditionalHeaders(name: String, value: String) = apply { - additionalHeaders.replace(name, value) - } - - fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { - additionalHeaders.replace(name, values) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { - this.additionalHeaders.replaceAll(additionalHeaders) - } - - fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } - - fun removeAllAdditionalHeaders(names: Set) = apply { - additionalHeaders.removeAll(names) - } - - fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun additionalQueryParams(additionalQueryParams: Map>) = apply { - this.additionalQueryParams.clear() - putAllAdditionalQueryParams(additionalQueryParams) - } - - fun putAdditionalQueryParam(key: String, value: String) = apply { - additionalQueryParams.put(key, value) - } - - fun putAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.put(key, values) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.putAll(additionalQueryParams) - } - - fun replaceAdditionalQueryParams(key: String, value: String) = apply { - additionalQueryParams.replace(key, value) - } - - fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { - additionalQueryParams.replace(key, values) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = - apply { - this.additionalQueryParams.replaceAll(additionalQueryParams) - } - - fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } - - fun removeAllAdditionalQueryParams(keys: Set) = apply { - additionalQueryParams.removeAll(keys) - } - - /** - * Returns an immutable instance of [BatchCreateParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .jobConfig() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BatchCreateParams = - BatchCreateParams( - organizationId, - projectId, - temporalNamespace, - body.build(), - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _body(): Body = body - - override fun _headers(): Headers = - Headers.builder() - .apply { - temporalNamespace?.let { put("temporal-namespace", it) } - putAll(additionalHeaders) - } - .build() - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - organizationId?.let { put("organization_id", it) } - projectId?.let { put("project_id", it) } - putAll(additionalQueryParams) - } - .build() - - /** - * Request to create a batch processing job. - * - * Supports two modes: - * 1. Directory mode: Process all files in a directory (use directory_id) - * 2. Item list mode: Process specific items (use item_ids). Project must be provided via - * validate_project dependency. - */ - class Body - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val jobConfig: JsonField, - private val continueAsNewThreshold: JsonField, - private val directoryId: JsonField, - private val itemIds: JsonField>, - private val pageSize: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("job_config") - @ExcludeMissing - jobConfig: JsonField = JsonMissing.of(), - @JsonProperty("continue_as_new_threshold") - @ExcludeMissing - continueAsNewThreshold: JsonField = JsonMissing.of(), - @JsonProperty("directory_id") - @ExcludeMissing - directoryId: JsonField = JsonMissing.of(), - @JsonProperty("item_ids") - @ExcludeMissing - itemIds: JsonField> = JsonMissing.of(), - @JsonProperty("page_size") @ExcludeMissing pageSize: JsonField = JsonMissing.of(), - ) : this(jobConfig, continueAsNewThreshold, directoryId, itemIds, pageSize, mutableMapOf()) - - /** - * Job configuration — either a parse or classify config - * - * @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 jobConfig(): JobConfig = jobConfig.getRequired("job_config") - - /** - * Maximum files to process per execution cycle in directory mode. Defaults to page_size. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun continueAsNewThreshold(): Optional = - continueAsNewThreshold.getOptional("continue_as_new_threshold") - - /** - * ID of the directory containing files to process - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun directoryId(): Optional = directoryId.getOptional("directory_id") - - /** - * List of specific item IDs to process. Either this or directory_id must be provided. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun itemIds(): Optional> = itemIds.getOptional("item_ids") - - /** - * Number of files to process per batch when using directory mode - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun pageSize(): Optional = pageSize.getOptional("page_size") - - /** - * Returns the raw JSON value of [jobConfig]. - * - * Unlike [jobConfig], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("job_config") - @ExcludeMissing - fun _jobConfig(): JsonField = jobConfig - - /** - * Returns the raw JSON value of [continueAsNewThreshold]. - * - * Unlike [continueAsNewThreshold], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("continue_as_new_threshold") - @ExcludeMissing - fun _continueAsNewThreshold(): JsonField = continueAsNewThreshold - - /** - * Returns the raw JSON value of [directoryId]. - * - * Unlike [directoryId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("directory_id") - @ExcludeMissing - fun _directoryId(): JsonField = directoryId - - /** - * Returns the raw JSON value of [itemIds]. - * - * Unlike [itemIds], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item_ids") @ExcludeMissing fun _itemIds(): JsonField> = itemIds - - /** - * Returns the raw JSON value of [pageSize]. - * - * Unlike [pageSize], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("page_size") @ExcludeMissing fun _pageSize(): JsonField = pageSize - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Body]. - * - * The following fields are required: - * ```java - * .jobConfig() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var jobConfig: JsonField? = null - private var continueAsNewThreshold: JsonField = JsonMissing.of() - private var directoryId: JsonField = JsonMissing.of() - private var itemIds: JsonField>? = null - private var pageSize: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - jobConfig = body.jobConfig - continueAsNewThreshold = body.continueAsNewThreshold - directoryId = body.directoryId - itemIds = body.itemIds.map { it.toMutableList() } - pageSize = body.pageSize - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** Job configuration — either a parse or classify config */ - fun jobConfig(jobConfig: JobConfig) = jobConfig(JsonField.of(jobConfig)) - - /** - * Sets [Builder.jobConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.jobConfig] with a well-typed [JobConfig] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun jobConfig(jobConfig: JsonField) = apply { this.jobConfig = jobConfig } - - /** - * Alias for calling [jobConfig] with - * `JobConfig.ofBatchParseJobRecordCreate(batchParseJobRecordCreate)`. - */ - fun jobConfig(batchParseJobRecordCreate: JobConfig.BatchParseJobRecordCreate) = - jobConfig(JobConfig.ofBatchParseJobRecordCreate(batchParseJobRecordCreate)) - - /** Alias for calling [jobConfig] with `JobConfig.ofClassifyJob(classifyJob)`. */ - fun jobConfig(classifyJob: ClassifyJob) = - jobConfig(JobConfig.ofClassifyJob(classifyJob)) - - /** - * Maximum files to process per execution cycle in directory mode. Defaults to - * page_size. - */ - fun continueAsNewThreshold(continueAsNewThreshold: Long?) = - continueAsNewThreshold(JsonField.ofNullable(continueAsNewThreshold)) - - /** - * Alias for [Builder.continueAsNewThreshold]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun continueAsNewThreshold(continueAsNewThreshold: Long) = - continueAsNewThreshold(continueAsNewThreshold as Long?) - - /** - * Alias for calling [Builder.continueAsNewThreshold] with - * `continueAsNewThreshold.orElse(null)`. - */ - fun continueAsNewThreshold(continueAsNewThreshold: Optional) = - continueAsNewThreshold(continueAsNewThreshold.getOrNull()) - - /** - * Sets [Builder.continueAsNewThreshold] to an arbitrary JSON value. - * - * You should usually call [Builder.continueAsNewThreshold] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun continueAsNewThreshold(continueAsNewThreshold: JsonField) = apply { - this.continueAsNewThreshold = continueAsNewThreshold - } - - /** ID of the directory containing files to process */ - fun directoryId(directoryId: String?) = directoryId(JsonField.ofNullable(directoryId)) - - /** Alias for calling [Builder.directoryId] with `directoryId.orElse(null)`. */ - fun directoryId(directoryId: Optional) = directoryId(directoryId.getOrNull()) - - /** - * Sets [Builder.directoryId] to an arbitrary JSON value. - * - * You should usually call [Builder.directoryId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun directoryId(directoryId: JsonField) = apply { - this.directoryId = directoryId - } - - /** - * List of specific item IDs to process. Either this or directory_id must be provided. - */ - fun itemIds(itemIds: List?) = itemIds(JsonField.ofNullable(itemIds)) - - /** Alias for calling [Builder.itemIds] with `itemIds.orElse(null)`. */ - fun itemIds(itemIds: Optional>) = itemIds(itemIds.getOrNull()) - - /** - * Sets [Builder.itemIds] to an arbitrary JSON value. - * - * You should usually call [Builder.itemIds] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun itemIds(itemIds: JsonField>) = apply { - this.itemIds = itemIds.map { it.toMutableList() } - } - - /** - * Adds a single [String] to [itemIds]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addItemId(itemId: String) = apply { - itemIds = - (itemIds ?: JsonField.of(mutableListOf())).also { - checkKnown("itemIds", it).add(itemId) - } - } - - /** Number of files to process per batch when using directory mode */ - fun pageSize(pageSize: Long) = pageSize(JsonField.of(pageSize)) - - /** - * Sets [Builder.pageSize] to an arbitrary JSON value. - * - * You should usually call [Builder.pageSize] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun pageSize(pageSize: JsonField) = apply { this.pageSize = pageSize } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .jobConfig() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Body = - Body( - checkRequired("jobConfig", jobConfig), - continueAsNewThreshold, - directoryId, - (itemIds ?: JsonMissing.of()).map { it.toImmutable() }, - pageSize, - 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(): Body = apply { - if (validated) { - return@apply - } - - jobConfig().validate() - continueAsNewThreshold() - directoryId() - itemIds() - pageSize() - 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 = - (jobConfig.asKnown().getOrNull()?.validity() ?: 0) + - (if (continueAsNewThreshold.asKnown().isPresent) 1 else 0) + - (if (directoryId.asKnown().isPresent) 1 else 0) + - (itemIds.asKnown().getOrNull()?.size ?: 0) + - (if (pageSize.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Body && - jobConfig == other.jobConfig && - continueAsNewThreshold == other.continueAsNewThreshold && - directoryId == other.directoryId && - itemIds == other.itemIds && - pageSize == other.pageSize && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - jobConfig, - continueAsNewThreshold, - directoryId, - itemIds, - pageSize, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{jobConfig=$jobConfig, continueAsNewThreshold=$continueAsNewThreshold, directoryId=$directoryId, itemIds=$itemIds, pageSize=$pageSize, additionalProperties=$additionalProperties}" - } - - /** Job configuration — either a parse or classify config */ - @JsonDeserialize(using = JobConfig.Deserializer::class) - @JsonSerialize(using = JobConfig.Serializer::class) - class JobConfig - private constructor( - private val batchParseJobRecordCreate: BatchParseJobRecordCreate? = null, - private val classifyJob: ClassifyJob? = null, - private val _json: JsonValue? = null, - ) { - - /** - * Batch-specific parse job record for batch processing. - * - * This model contains the metadata and configuration for a batch parse job, but excludes - * file-specific information. It's used as input to the batch parent workflow and combined - * with DirectoryFile data to create full ParseJobRecordCreate instances for each file. - * - * Attributes: job_name: Must be PARSE_RAW_FILE partitions: Partitions for job output - * location parameters: Generic parse configuration (BatchParseJobConfig) session_id: - * Upstream request ID for tracking correlation_id: Correlation ID for cross-service - * tracking parent_job_execution_id: Parent job execution ID if nested user_id: User who - * created the job project_id: Project this job belongs to webhook_url: Optional webhook URL - * for job completion notifications - */ - fun batchParseJobRecordCreate(): Optional = - Optional.ofNullable(batchParseJobRecordCreate) - - /** A classify job. */ - fun classifyJob(): Optional = Optional.ofNullable(classifyJob) - - fun isBatchParseJobRecordCreate(): Boolean = batchParseJobRecordCreate != null - - fun isClassifyJob(): Boolean = classifyJob != null - - /** - * Batch-specific parse job record for batch processing. - * - * This model contains the metadata and configuration for a batch parse job, but excludes - * file-specific information. It's used as input to the batch parent workflow and combined - * with DirectoryFile data to create full ParseJobRecordCreate instances for each file. - * - * Attributes: job_name: Must be PARSE_RAW_FILE partitions: Partitions for job output - * location parameters: Generic parse configuration (BatchParseJobConfig) session_id: - * Upstream request ID for tracking correlation_id: Correlation ID for cross-service - * tracking parent_job_execution_id: Parent job execution ID if nested user_id: User who - * created the job project_id: Project this job belongs to webhook_url: Optional webhook URL - * for job completion notifications - */ - fun asBatchParseJobRecordCreate(): BatchParseJobRecordCreate = - batchParseJobRecordCreate.getOrThrow("batchParseJobRecordCreate") - - /** A classify job. */ - fun asClassifyJob(): ClassifyJob = classifyJob.getOrThrow("classifyJob") - - fun _json(): Optional = Optional.ofNullable(_json) - - /** - * Maps this instance's current variant to a value of type [T] using the given [visitor]. - * - * Note that this method is _not_ forwards compatible with new variants from the API, unless - * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of - * the SDK gracefully, consider overriding [Visitor.unknown]: - * ```java - * import ai.llamaindex.llamacloud.core.JsonValue; - * import java.util.Optional; - * - * Optional result = jobConfig.accept(new JobConfig.Visitor>() { - * @Override - * public Optional visitBatchParseJobRecordCreate(BatchParseJobRecordCreate batchParseJobRecordCreate) { - * return Optional.of(batchParseJobRecordCreate.toString()); - * } - * - * // ... - * - * @Override - * public Optional unknown(JsonValue json) { - * // Or inspect the `json`. - * return Optional.empty(); - * } - * }); - * ``` - * - * @throws LlamaCloudInvalidDataException if [Visitor.unknown] is not overridden in - * [visitor] and the current variant is unknown. - */ - fun accept(visitor: Visitor): T = - when { - batchParseJobRecordCreate != null -> - visitor.visitBatchParseJobRecordCreate(batchParseJobRecordCreate) - classifyJob != null -> visitor.visitClassifyJob(classifyJob) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing fields. - * - * @throws LlamaCloudInvalidDataException if any value type in this object doesn't match its - * expected type. - */ - fun validate(): JobConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitBatchParseJobRecordCreate( - batchParseJobRecordCreate: BatchParseJobRecordCreate - ) { - batchParseJobRecordCreate.validate() - } - - override fun visitClassifyJob(classifyJob: ClassifyJob) { - classifyJob.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 = - accept( - object : Visitor { - override fun visitBatchParseJobRecordCreate( - batchParseJobRecordCreate: BatchParseJobRecordCreate - ) = batchParseJobRecordCreate.validity() - - override fun visitClassifyJob(classifyJob: ClassifyJob) = classifyJob.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is JobConfig && - batchParseJobRecordCreate == other.batchParseJobRecordCreate && - classifyJob == other.classifyJob - } - - override fun hashCode(): Int = Objects.hash(batchParseJobRecordCreate, classifyJob) - - override fun toString(): String = - when { - batchParseJobRecordCreate != null -> - "JobConfig{batchParseJobRecordCreate=$batchParseJobRecordCreate}" - classifyJob != null -> "JobConfig{classifyJob=$classifyJob}" - _json != null -> "JobConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid JobConfig") - } - - companion object { - - /** - * Batch-specific parse job record for batch processing. - * - * This model contains the metadata and configuration for a batch parse job, but - * excludes file-specific information. It's used as input to the batch parent workflow - * and combined with DirectoryFile data to create full ParseJobRecordCreate instances - * for each file. - * - * Attributes: job_name: Must be PARSE_RAW_FILE partitions: Partitions for job output - * location parameters: Generic parse configuration (BatchParseJobConfig) session_id: - * Upstream request ID for tracking correlation_id: Correlation ID for cross-service - * tracking parent_job_execution_id: Parent job execution ID if nested user_id: User who - * created the job project_id: Project this job belongs to webhook_url: Optional webhook - * URL for job completion notifications - */ - @JvmStatic - fun ofBatchParseJobRecordCreate(batchParseJobRecordCreate: BatchParseJobRecordCreate) = - JobConfig(batchParseJobRecordCreate = batchParseJobRecordCreate) - - /** A classify job. */ - @JvmStatic - fun ofClassifyJob(classifyJob: ClassifyJob) = JobConfig(classifyJob = classifyJob) - } - - /** - * An interface that defines how to map each variant of [JobConfig] to a value of type [T]. - */ - interface Visitor { - - /** - * Batch-specific parse job record for batch processing. - * - * This model contains the metadata and configuration for a batch parse job, but - * excludes file-specific information. It's used as input to the batch parent workflow - * and combined with DirectoryFile data to create full ParseJobRecordCreate instances - * for each file. - * - * Attributes: job_name: Must be PARSE_RAW_FILE partitions: Partitions for job output - * location parameters: Generic parse configuration (BatchParseJobConfig) session_id: - * Upstream request ID for tracking correlation_id: Correlation ID for cross-service - * tracking parent_job_execution_id: Parent job execution ID if nested user_id: User who - * created the job project_id: Project this job belongs to webhook_url: Optional webhook - * URL for job completion notifications - */ - fun visitBatchParseJobRecordCreate( - batchParseJobRecordCreate: BatchParseJobRecordCreate - ): T - - /** A classify job. */ - fun visitClassifyJob(classifyJob: ClassifyJob): T - - /** - * Maps an unknown variant of [JobConfig] to a value of type [T]. - * - * An instance of [JobConfig] can contain an unknown variant if it was deserialized from - * data that doesn't match any known variant. For example, if the SDK is on an older - * version than the API, then the API may respond with new variants that the SDK is - * unaware of. - * - * @throws LlamaCloudInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw LlamaCloudInvalidDataException("Unknown JobConfig: $json") - } - } - - internal class Deserializer : BaseDeserializer(JobConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): JobConfig { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - JobConfig(batchParseJobRecordCreate = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - JobConfig(classifyJob = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with - // all the possible variants (e.g. deserializing from boolean). - 0 -> JobConfig(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely - // valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(JobConfig::class) { - - override fun serialize( - value: JobConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.batchParseJobRecordCreate != null -> - generator.writeObject(value.batchParseJobRecordCreate) - value.classifyJob != null -> generator.writeObject(value.classifyJob) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid JobConfig") - } - } - } - - /** - * Batch-specific parse job record for batch processing. - * - * This model contains the metadata and configuration for a batch parse job, but excludes - * file-specific information. It's used as input to the batch parent workflow and combined - * with DirectoryFile data to create full ParseJobRecordCreate instances for each file. - * - * Attributes: job_name: Must be PARSE_RAW_FILE partitions: Partitions for job output - * location parameters: Generic parse configuration (BatchParseJobConfig) session_id: - * Upstream request ID for tracking correlation_id: Correlation ID for cross-service - * tracking parent_job_execution_id: Parent job execution ID if nested user_id: User who - * created the job project_id: Project this job belongs to webhook_url: Optional webhook URL - * for job completion notifications - */ - class BatchParseJobRecordCreate - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val correlationId: JsonField, - private val jobName: JsonField, - private val parameters: JsonField, - private val parentJobExecutionId: JsonField, - private val partitions: JsonField, - private val projectId: JsonField, - private val sessionId: JsonField, - private val userId: JsonField, - private val webhookUrl: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("correlation_id") - @ExcludeMissing - correlationId: JsonField = JsonMissing.of(), - @JsonProperty("job_name") - @ExcludeMissing - jobName: JsonField = JsonMissing.of(), - @JsonProperty("parameters") - @ExcludeMissing - parameters: JsonField = JsonMissing.of(), - @JsonProperty("parent_job_execution_id") - @ExcludeMissing - parentJobExecutionId: JsonField = JsonMissing.of(), - @JsonProperty("partitions") - @ExcludeMissing - partitions: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - projectId: JsonField = JsonMissing.of(), - @JsonProperty("session_id") - @ExcludeMissing - sessionId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - userId: JsonField = JsonMissing.of(), - @JsonProperty("webhook_url") - @ExcludeMissing - webhookUrl: JsonField = JsonMissing.of(), - ) : this( - correlationId, - jobName, - parameters, - parentJobExecutionId, - partitions, - projectId, - sessionId, - userId, - webhookUrl, - mutableMapOf(), - ) - - /** - * The correlation ID for this job. Used for tracking the job across services. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun correlationId(): Optional = correlationId.getOptional("correlation_id") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun jobName(): Optional = jobName.getOptional("job_name") - - /** - * Generic parse job configuration for batch processing. - * - * This model contains the parsing configuration that applies to all files in a batch, - * but excludes file-specific fields like file_name, file_id, etc. Those file-specific - * fields are populated from DirectoryFile data when creating individual - * ParseJobRecordCreate instances for each file. - * - * The fields in this model should be generic settings that apply uniformly to all files - * being processed in the batch. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun parameters(): Optional = parameters.getOptional("parameters") - - /** - * The ID of the parent job execution. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun parentJobExecutionId(): Optional = - parentJobExecutionId.getOptional("parent_job_execution_id") - - /** - * The partitions for this execution. Used for determining where to save job output. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun partitions(): Optional = partitions.getOptional("partitions") - - /** - * The ID of the project this job belongs 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") - - /** - * The upstream request ID that created this job. Used for tracking the job across - * services. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun sessionId(): Optional = sessionId.getOptional("session_id") - - /** - * The ID of the user that created this job - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun userId(): Optional = userId.getOptional("user_id") - - /** - * The URL that needs to be called at the end of the parsing job. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun webhookUrl(): Optional = webhookUrl.getOptional("webhook_url") - - /** - * Returns the raw JSON value of [correlationId]. - * - * Unlike [correlationId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("correlation_id") - @ExcludeMissing - fun _correlationId(): JsonField = correlationId - - /** - * Returns the raw JSON value of [jobName]. - * - * Unlike [jobName], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("job_name") @ExcludeMissing fun _jobName(): JsonField = jobName - - /** - * Returns the raw JSON value of [parameters]. - * - * Unlike [parameters], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("parameters") - @ExcludeMissing - fun _parameters(): JsonField = parameters - - /** - * Returns the raw JSON value of [parentJobExecutionId]. - * - * Unlike [parentJobExecutionId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("parent_job_execution_id") - @ExcludeMissing - fun _parentJobExecutionId(): JsonField = parentJobExecutionId - - /** - * Returns the raw JSON value of [partitions]. - * - * Unlike [partitions], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("partitions") - @ExcludeMissing - fun _partitions(): JsonField = partitions - - /** - * 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 [sessionId]. - * - * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("session_id") - @ExcludeMissing - fun _sessionId(): JsonField = sessionId - - /** - * Returns the raw JSON value of [userId]. - * - * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId - - /** - * Returns the raw JSON value of [webhookUrl]. - * - * Unlike [webhookUrl], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("webhook_url") - @ExcludeMissing - fun _webhookUrl(): JsonField = webhookUrl - - @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 - * [BatchParseJobRecordCreate]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchParseJobRecordCreate]. */ - class Builder internal constructor() { - - private var correlationId: JsonField = JsonMissing.of() - private var jobName: JsonField = JsonMissing.of() - private var parameters: JsonField = JsonMissing.of() - private var parentJobExecutionId: JsonField = JsonMissing.of() - private var partitions: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var sessionId: JsonField = JsonMissing.of() - private var userId: JsonField = JsonMissing.of() - private var webhookUrl: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(batchParseJobRecordCreate: BatchParseJobRecordCreate) = apply { - correlationId = batchParseJobRecordCreate.correlationId - jobName = batchParseJobRecordCreate.jobName - parameters = batchParseJobRecordCreate.parameters - parentJobExecutionId = batchParseJobRecordCreate.parentJobExecutionId - partitions = batchParseJobRecordCreate.partitions - projectId = batchParseJobRecordCreate.projectId - sessionId = batchParseJobRecordCreate.sessionId - userId = batchParseJobRecordCreate.userId - webhookUrl = batchParseJobRecordCreate.webhookUrl - additionalProperties = - batchParseJobRecordCreate.additionalProperties.toMutableMap() - } - - /** The correlation ID for this job. Used for tracking the job across services. */ - fun correlationId(correlationId: String?) = - correlationId(JsonField.ofNullable(correlationId)) - - /** Alias for calling [Builder.correlationId] with `correlationId.orElse(null)`. */ - fun correlationId(correlationId: Optional) = - correlationId(correlationId.getOrNull()) - - /** - * Sets [Builder.correlationId] to an arbitrary JSON value. - * - * You should usually call [Builder.correlationId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun correlationId(correlationId: JsonField) = apply { - this.correlationId = correlationId - } - - fun jobName(jobName: JobName) = jobName(JsonField.of(jobName)) - - /** - * Sets [Builder.jobName] to an arbitrary JSON value. - * - * You should usually call [Builder.jobName] with a well-typed [JobName] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun jobName(jobName: JsonField) = apply { this.jobName = jobName } - - /** - * Generic parse job configuration for batch processing. - * - * This model contains the parsing configuration that applies to all files in a - * batch, but excludes file-specific fields like file_name, file_id, etc. Those - * file-specific fields are populated from DirectoryFile data when creating - * individual ParseJobRecordCreate instances for each file. - * - * The fields in this model should be generic settings that apply uniformly to all - * files being processed in the batch. - */ - fun parameters(parameters: Parameters?) = - parameters(JsonField.ofNullable(parameters)) - - /** Alias for calling [Builder.parameters] with `parameters.orElse(null)`. */ - fun parameters(parameters: Optional) = - parameters(parameters.getOrNull()) - - /** - * Sets [Builder.parameters] to an arbitrary JSON value. - * - * You should usually call [Builder.parameters] with a well-typed [Parameters] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun parameters(parameters: JsonField) = apply { - this.parameters = parameters - } - - /** The ID of the parent job execution. */ - fun parentJobExecutionId(parentJobExecutionId: String?) = - parentJobExecutionId(JsonField.ofNullable(parentJobExecutionId)) - - /** - * Alias for calling [Builder.parentJobExecutionId] with - * `parentJobExecutionId.orElse(null)`. - */ - fun parentJobExecutionId(parentJobExecutionId: Optional) = - parentJobExecutionId(parentJobExecutionId.getOrNull()) - - /** - * Sets [Builder.parentJobExecutionId] to an arbitrary JSON value. - * - * You should usually call [Builder.parentJobExecutionId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun parentJobExecutionId(parentJobExecutionId: JsonField) = apply { - this.parentJobExecutionId = parentJobExecutionId - } - - /** - * The partitions for this execution. Used for determining where to save job output. - */ - fun partitions(partitions: Partitions) = partitions(JsonField.of(partitions)) - - /** - * Sets [Builder.partitions] to an arbitrary JSON value. - * - * You should usually call [Builder.partitions] with a well-typed [Partitions] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun partitions(partitions: JsonField) = apply { - this.partitions = partitions - } - - /** The ID of the project this job belongs 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 } - - /** - * The upstream request ID that created this job. Used for tracking the job across - * services. - */ - fun sessionId(sessionId: String?) = sessionId(JsonField.ofNullable(sessionId)) - - /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ - fun sessionId(sessionId: Optional) = sessionId(sessionId.getOrNull()) - - /** - * Sets [Builder.sessionId] to an arbitrary JSON value. - * - * You should usually call [Builder.sessionId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun sessionId(sessionId: JsonField) = apply { this.sessionId = sessionId } - - /** The ID of the user that created this job */ - fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - /** - * Sets [Builder.userId] to an arbitrary JSON value. - * - * You should usually call [Builder.userId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - /** The URL that needs to be called at the end of the parsing job. */ - fun webhookUrl(webhookUrl: String?) = webhookUrl(JsonField.ofNullable(webhookUrl)) - - /** Alias for calling [Builder.webhookUrl] with `webhookUrl.orElse(null)`. */ - fun webhookUrl(webhookUrl: Optional) = webhookUrl(webhookUrl.getOrNull()) - - /** - * Sets [Builder.webhookUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun webhookUrl(webhookUrl: JsonField) = apply { - this.webhookUrl = webhookUrl - } - - 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 [BatchParseJobRecordCreate]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BatchParseJobRecordCreate = - BatchParseJobRecordCreate( - correlationId, - jobName, - parameters, - parentJobExecutionId, - partitions, - projectId, - sessionId, - userId, - webhookUrl, - 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(): BatchParseJobRecordCreate = apply { - if (validated) { - return@apply - } - - correlationId() - jobName().ifPresent { it.validate() } - parameters().ifPresent { it.validate() } - parentJobExecutionId() - partitions().ifPresent { it.validate() } - projectId() - sessionId() - userId() - webhookUrl() - 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 (correlationId.asKnown().isPresent) 1 else 0) + - (jobName.asKnown().getOrNull()?.validity() ?: 0) + - (parameters.asKnown().getOrNull()?.validity() ?: 0) + - (if (parentJobExecutionId.asKnown().isPresent) 1 else 0) + - (partitions.asKnown().getOrNull()?.validity() ?: 0) + - (if (projectId.asKnown().isPresent) 1 else 0) + - (if (sessionId.asKnown().isPresent) 1 else 0) + - (if (userId.asKnown().isPresent) 1 else 0) + - (if (webhookUrl.asKnown().isPresent) 1 else 0) - - class JobName @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 PARSE_RAW_FILE_JOB = of("parse_raw_file_job") - - @JvmStatic fun of(value: String) = JobName(JsonField.of(value)) - } - - /** An enum containing [JobName]'s known values. */ - enum class Known { - PARSE_RAW_FILE_JOB - } - - /** - * An enum containing [JobName]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [JobName] 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 { - PARSE_RAW_FILE_JOB, - /** - * An enum member indicating that [JobName] 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) { - PARSE_RAW_FILE_JOB -> Value.PARSE_RAW_FILE_JOB - 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) { - PARSE_RAW_FILE_JOB -> Known.PARSE_RAW_FILE_JOB - else -> throw LlamaCloudInvalidDataException("Unknown JobName: $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(): JobName = 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 JobName && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * Generic parse job configuration for batch processing. - * - * This model contains the parsing configuration that applies to all files in a batch, - * but excludes file-specific fields like file_name, file_id, etc. Those file-specific - * fields are populated from DirectoryFile data when creating individual - * ParseJobRecordCreate instances for each file. - * - * The fields in this model should be generic settings that apply uniformly to all files - * being processed in the batch. - */ - class Parameters - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adaptiveLongTable: JsonField, - private val aggressiveTableExtraction: JsonField, - private val annotateLinks: JsonField, - private val annotateRevisions: JsonField, - private val autoMode: JsonField, - private val autoModeConfigurationJson: JsonField, - private val autoModeTriggerOnImageInPage: JsonField, - private val autoModeTriggerOnRegexpInPage: JsonField, - private val autoModeTriggerOnTableInPage: JsonField, - private val autoModeTriggerOnTextInPage: JsonField, - private val azureOpenAIApiVersion: JsonField, - private val azureOpenAIDeploymentName: JsonField, - private val azureOpenAIEndpoint: JsonField, - private val azureOpenAIKey: JsonField, - private val bboxBottom: JsonField, - private val bboxLeft: JsonField, - private val bboxRight: JsonField, - private val bboxTop: JsonField, - private val boundingBox: JsonField, - private val compactMarkdownTable: JsonField, - private val complementalFormattingInstruction: JsonField, - private val confidenceScoreEffort: JsonField, - private val contentGuidelineInstruction: JsonField, - private val continuousMode: JsonField, - private val customMetadata: JsonField, - private val disableImageExtraction: JsonField, - private val disableOcr: JsonField, - private val disableReconstruction: JsonField, - private val doNotCache: JsonField, - private val doNotUnrollColumns: JsonField, - private val enableCostOptimizer: JsonField, - private val extractCharts: JsonField, - private val extractLayout: JsonField, - private val extractPrintedPageNumber: JsonField, - private val fastMode: JsonField, - private val formattingInstruction: JsonField, - private val gpt4oApiKey: JsonField, - private val gpt4oMode: JsonField, - private val guessXlsxSheetName: JsonField, - private val hideFooters: JsonField, - private val hideHeaders: JsonField, - private val highResOcr: JsonField, - private val htmlMakeAllElementsVisible: JsonField, - private val htmlRemoveFixedElements: JsonField, - private val htmlRemoveNavigationElements: JsonField, - private val httpProxy: JsonField, - private val ignoreDocumentElementsForLayoutDetection: JsonField, - private val imagesToSave: JsonField>, - private val inlineImagesInMarkdown: JsonField, - private val inputS3Path: JsonField, - private val inputS3Region: JsonField, - private val inputUrl: JsonField, - private val internalIsScreenshotJob: JsonField, - private val invalidateCache: JsonField, - private val isFormattingInstruction: JsonField, - private val jobTimeoutExtraTimePerPageInSeconds: JsonField, - private val jobTimeoutInSeconds: JsonField, - private val keepPageSeparatorWhenMergingTables: JsonField, - private val lang: JsonField, - private val languages: JsonField>, - private val layoutAware: JsonField, - private val lineLevelBoundingBox: JsonField, - private val markdownTableMultilineHeaderSeparator: JsonField, - private val maxPages: JsonField, - private val maxPagesEnforced: JsonField, - private val mergeTablesAcrossPagesInMarkdown: JsonField, - private val model: JsonField, - private val outlinedTableExtraction: JsonField, - private val outputPdfOfDocument: JsonField, - private val outputS3PathPrefix: JsonField, - private val outputS3Region: JsonField, - private val outputTablesAsHtml: JsonField, - private val outputBucket: JsonField, - private val pageErrorTolerance: JsonField, - private val pageFooterPrefix: JsonField, - private val pageFooterSuffix: JsonField, - private val pageHeaderPrefix: JsonField, - private val pageHeaderSuffix: JsonField, - private val pagePrefix: JsonField, - private val pageSeparator: JsonField, - private val pageSuffix: JsonField, - private val parseMode: JsonField, - private val parsingInstruction: JsonField, - private val pipelineId: JsonField, - private val preciseBoundingBox: JsonField, - private val premiumMode: JsonField, - private val presentationOutOfBoundsContent: JsonField, - private val presentationSkipEmbeddedData: JsonField, - private val preserveLayoutAlignmentAcrossPages: JsonField, - private val preserveVerySmallText: JsonField, - private val preset: JsonField, - private val priority: JsonField, - private val projectId: JsonField, - private val removeHiddenText: JsonField, - private val replaceFailedPageMode: JsonField, - private val replaceFailedPageWithErrorMessagePrefix: JsonField, - private val replaceFailedPageWithErrorMessageSuffix: JsonField, - private val resourceInfo: JsonField, - private val saveImages: JsonField, - private val skipDiagonalText: JsonField, - private val specializedChartParsingAgentic: JsonField, - private val specializedChartParsingEfficient: JsonField, - private val specializedChartParsingPlus: JsonField, - private val specializedImageParsing: JsonField, - private val spreadsheetExtractSubTables: JsonField, - private val spreadsheetForceFormulaComputation: JsonField, - private val spreadsheetIncludeHiddenSheets: JsonField, - private val strictModeBuggyFont: JsonField, - private val strictModeImageExtraction: JsonField, - private val strictModeImageOcr: JsonField, - private val strictModeReconstruction: JsonField, - private val structuredOutput: JsonField, - private val structuredOutputJsonSchema: JsonField, - private val structuredOutputJsonSchemaName: JsonField, - private val systemPrompt: JsonField, - private val systemPromptAppend: JsonField, - private val takeScreenshot: JsonField, - private val targetPages: JsonField, - private val tier: JsonField, - private val type: JsonField, - private val useVendorMultimodalModel: JsonField, - private val userPrompt: JsonField, - private val vendorMultimodalApiKey: JsonField, - private val vendorMultimodalModelName: JsonField, - private val version: JsonField, - private val webhookConfigurations: JsonField>, - private val webhookUrl: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("adaptive_long_table") - @ExcludeMissing - adaptiveLongTable: JsonField = JsonMissing.of(), - @JsonProperty("aggressive_table_extraction") - @ExcludeMissing - aggressiveTableExtraction: JsonField = JsonMissing.of(), - @JsonProperty("annotate_links") - @ExcludeMissing - annotateLinks: JsonField = JsonMissing.of(), - @JsonProperty("annotate_revisions") - @ExcludeMissing - annotateRevisions: JsonField = JsonMissing.of(), - @JsonProperty("auto_mode") - @ExcludeMissing - autoMode: JsonField = JsonMissing.of(), - @JsonProperty("auto_mode_configuration_json") - @ExcludeMissing - autoModeConfigurationJson: JsonField = JsonMissing.of(), - @JsonProperty("auto_mode_trigger_on_image_in_page") - @ExcludeMissing - autoModeTriggerOnImageInPage: JsonField = JsonMissing.of(), - @JsonProperty("auto_mode_trigger_on_regexp_in_page") - @ExcludeMissing - autoModeTriggerOnRegexpInPage: JsonField = JsonMissing.of(), - @JsonProperty("auto_mode_trigger_on_table_in_page") - @ExcludeMissing - autoModeTriggerOnTableInPage: JsonField = JsonMissing.of(), - @JsonProperty("auto_mode_trigger_on_text_in_page") - @ExcludeMissing - autoModeTriggerOnTextInPage: JsonField = JsonMissing.of(), - @JsonProperty("azure_openai_api_version") - @ExcludeMissing - azureOpenAIApiVersion: JsonField = JsonMissing.of(), - @JsonProperty("azure_openai_deployment_name") - @ExcludeMissing - azureOpenAIDeploymentName: JsonField = JsonMissing.of(), - @JsonProperty("azure_openai_endpoint") - @ExcludeMissing - azureOpenAIEndpoint: JsonField = JsonMissing.of(), - @JsonProperty("azure_openai_key") - @ExcludeMissing - azureOpenAIKey: JsonField = JsonMissing.of(), - @JsonProperty("bbox_bottom") - @ExcludeMissing - bboxBottom: JsonField = JsonMissing.of(), - @JsonProperty("bbox_left") - @ExcludeMissing - bboxLeft: JsonField = JsonMissing.of(), - @JsonProperty("bbox_right") - @ExcludeMissing - bboxRight: JsonField = JsonMissing.of(), - @JsonProperty("bbox_top") - @ExcludeMissing - bboxTop: JsonField = JsonMissing.of(), - @JsonProperty("bounding_box") - @ExcludeMissing - boundingBox: JsonField = JsonMissing.of(), - @JsonProperty("compact_markdown_table") - @ExcludeMissing - compactMarkdownTable: JsonField = JsonMissing.of(), - @JsonProperty("complemental_formatting_instruction") - @ExcludeMissing - complementalFormattingInstruction: JsonField = JsonMissing.of(), - @JsonProperty("confidence_score_effort") - @ExcludeMissing - confidenceScoreEffort: JsonField = JsonMissing.of(), - @JsonProperty("content_guideline_instruction") - @ExcludeMissing - contentGuidelineInstruction: JsonField = JsonMissing.of(), - @JsonProperty("continuous_mode") - @ExcludeMissing - continuousMode: JsonField = JsonMissing.of(), - @JsonProperty("custom_metadata") - @ExcludeMissing - customMetadata: JsonField = JsonMissing.of(), - @JsonProperty("disable_image_extraction") - @ExcludeMissing - disableImageExtraction: JsonField = JsonMissing.of(), - @JsonProperty("disable_ocr") - @ExcludeMissing - disableOcr: JsonField = JsonMissing.of(), - @JsonProperty("disable_reconstruction") - @ExcludeMissing - disableReconstruction: JsonField = JsonMissing.of(), - @JsonProperty("do_not_cache") - @ExcludeMissing - doNotCache: JsonField = JsonMissing.of(), - @JsonProperty("do_not_unroll_columns") - @ExcludeMissing - doNotUnrollColumns: JsonField = JsonMissing.of(), - @JsonProperty("enable_cost_optimizer") - @ExcludeMissing - enableCostOptimizer: JsonField = JsonMissing.of(), - @JsonProperty("extract_charts") - @ExcludeMissing - extractCharts: JsonField = JsonMissing.of(), - @JsonProperty("extract_layout") - @ExcludeMissing - extractLayout: JsonField = JsonMissing.of(), - @JsonProperty("extract_printed_page_number") - @ExcludeMissing - extractPrintedPageNumber: JsonField = JsonMissing.of(), - @JsonProperty("fast_mode") - @ExcludeMissing - fastMode: JsonField = JsonMissing.of(), - @JsonProperty("formatting_instruction") - @ExcludeMissing - formattingInstruction: JsonField = JsonMissing.of(), - @JsonProperty("gpt4o_api_key") - @ExcludeMissing - gpt4oApiKey: JsonField = JsonMissing.of(), - @JsonProperty("gpt4o_mode") - @ExcludeMissing - gpt4oMode: JsonField = JsonMissing.of(), - @JsonProperty("guess_xlsx_sheet_name") - @ExcludeMissing - guessXlsxSheetName: JsonField = JsonMissing.of(), - @JsonProperty("hide_footers") - @ExcludeMissing - hideFooters: JsonField = JsonMissing.of(), - @JsonProperty("hide_headers") - @ExcludeMissing - hideHeaders: JsonField = JsonMissing.of(), - @JsonProperty("high_res_ocr") - @ExcludeMissing - highResOcr: JsonField = JsonMissing.of(), - @JsonProperty("html_make_all_elements_visible") - @ExcludeMissing - htmlMakeAllElementsVisible: JsonField = JsonMissing.of(), - @JsonProperty("html_remove_fixed_elements") - @ExcludeMissing - htmlRemoveFixedElements: JsonField = JsonMissing.of(), - @JsonProperty("html_remove_navigation_elements") - @ExcludeMissing - htmlRemoveNavigationElements: JsonField = JsonMissing.of(), - @JsonProperty("http_proxy") - @ExcludeMissing - httpProxy: JsonField = JsonMissing.of(), - @JsonProperty("ignore_document_elements_for_layout_detection") - @ExcludeMissing - ignoreDocumentElementsForLayoutDetection: JsonField = JsonMissing.of(), - @JsonProperty("images_to_save") - @ExcludeMissing - imagesToSave: JsonField> = JsonMissing.of(), - @JsonProperty("inline_images_in_markdown") - @ExcludeMissing - inlineImagesInMarkdown: JsonField = JsonMissing.of(), - @JsonProperty("input_s3_path") - @ExcludeMissing - inputS3Path: JsonField = JsonMissing.of(), - @JsonProperty("input_s3_region") - @ExcludeMissing - inputS3Region: JsonField = JsonMissing.of(), - @JsonProperty("input_url") - @ExcludeMissing - inputUrl: JsonField = JsonMissing.of(), - @JsonProperty("internal_is_screenshot_job") - @ExcludeMissing - internalIsScreenshotJob: JsonField = JsonMissing.of(), - @JsonProperty("invalidate_cache") - @ExcludeMissing - invalidateCache: JsonField = JsonMissing.of(), - @JsonProperty("is_formatting_instruction") - @ExcludeMissing - isFormattingInstruction: JsonField = JsonMissing.of(), - @JsonProperty("job_timeout_extra_time_per_page_in_seconds") - @ExcludeMissing - jobTimeoutExtraTimePerPageInSeconds: JsonField = JsonMissing.of(), - @JsonProperty("job_timeout_in_seconds") - @ExcludeMissing - jobTimeoutInSeconds: JsonField = JsonMissing.of(), - @JsonProperty("keep_page_separator_when_merging_tables") - @ExcludeMissing - keepPageSeparatorWhenMergingTables: JsonField = JsonMissing.of(), - @JsonProperty("lang") - @ExcludeMissing - lang: JsonField = JsonMissing.of(), - @JsonProperty("languages") - @ExcludeMissing - languages: JsonField> = JsonMissing.of(), - @JsonProperty("layout_aware") - @ExcludeMissing - layoutAware: JsonField = JsonMissing.of(), - @JsonProperty("line_level_bounding_box") - @ExcludeMissing - lineLevelBoundingBox: JsonField = JsonMissing.of(), - @JsonProperty("markdown_table_multiline_header_separator") - @ExcludeMissing - markdownTableMultilineHeaderSeparator: JsonField = JsonMissing.of(), - @JsonProperty("max_pages") - @ExcludeMissing - maxPages: JsonField = JsonMissing.of(), - @JsonProperty("max_pages_enforced") - @ExcludeMissing - maxPagesEnforced: JsonField = JsonMissing.of(), - @JsonProperty("merge_tables_across_pages_in_markdown") - @ExcludeMissing - mergeTablesAcrossPagesInMarkdown: JsonField = JsonMissing.of(), - @JsonProperty("model") - @ExcludeMissing - model: JsonField = JsonMissing.of(), - @JsonProperty("outlined_table_extraction") - @ExcludeMissing - outlinedTableExtraction: JsonField = JsonMissing.of(), - @JsonProperty("output_pdf_of_document") - @ExcludeMissing - outputPdfOfDocument: JsonField = JsonMissing.of(), - @JsonProperty("output_s3_path_prefix") - @ExcludeMissing - outputS3PathPrefix: JsonField = JsonMissing.of(), - @JsonProperty("output_s3_region") - @ExcludeMissing - outputS3Region: JsonField = JsonMissing.of(), - @JsonProperty("output_tables_as_HTML") - @ExcludeMissing - outputTablesAsHtml: JsonField = JsonMissing.of(), - @JsonProperty("outputBucket") - @ExcludeMissing - outputBucket: JsonField = JsonMissing.of(), - @JsonProperty("page_error_tolerance") - @ExcludeMissing - pageErrorTolerance: JsonField = JsonMissing.of(), - @JsonProperty("page_footer_prefix") - @ExcludeMissing - pageFooterPrefix: JsonField = JsonMissing.of(), - @JsonProperty("page_footer_suffix") - @ExcludeMissing - pageFooterSuffix: JsonField = JsonMissing.of(), - @JsonProperty("page_header_prefix") - @ExcludeMissing - pageHeaderPrefix: JsonField = JsonMissing.of(), - @JsonProperty("page_header_suffix") - @ExcludeMissing - pageHeaderSuffix: JsonField = JsonMissing.of(), - @JsonProperty("page_prefix") - @ExcludeMissing - pagePrefix: JsonField = JsonMissing.of(), - @JsonProperty("page_separator") - @ExcludeMissing - pageSeparator: JsonField = JsonMissing.of(), - @JsonProperty("page_suffix") - @ExcludeMissing - pageSuffix: JsonField = JsonMissing.of(), - @JsonProperty("parse_mode") - @ExcludeMissing - parseMode: JsonField = JsonMissing.of(), - @JsonProperty("parsing_instruction") - @ExcludeMissing - parsingInstruction: JsonField = JsonMissing.of(), - @JsonProperty("pipeline_id") - @ExcludeMissing - pipelineId: JsonField = JsonMissing.of(), - @JsonProperty("precise_bounding_box") - @ExcludeMissing - preciseBoundingBox: JsonField = JsonMissing.of(), - @JsonProperty("premium_mode") - @ExcludeMissing - premiumMode: JsonField = JsonMissing.of(), - @JsonProperty("presentation_out_of_bounds_content") - @ExcludeMissing - presentationOutOfBoundsContent: JsonField = JsonMissing.of(), - @JsonProperty("presentation_skip_embedded_data") - @ExcludeMissing - presentationSkipEmbeddedData: JsonField = JsonMissing.of(), - @JsonProperty("preserve_layout_alignment_across_pages") - @ExcludeMissing - preserveLayoutAlignmentAcrossPages: JsonField = JsonMissing.of(), - @JsonProperty("preserve_very_small_text") - @ExcludeMissing - preserveVerySmallText: JsonField = JsonMissing.of(), - @JsonProperty("preset") - @ExcludeMissing - preset: JsonField = JsonMissing.of(), - @JsonProperty("priority") - @ExcludeMissing - priority: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - projectId: JsonField = JsonMissing.of(), - @JsonProperty("remove_hidden_text") - @ExcludeMissing - removeHiddenText: JsonField = JsonMissing.of(), - @JsonProperty("replace_failed_page_mode") - @ExcludeMissing - replaceFailedPageMode: JsonField = JsonMissing.of(), - @JsonProperty("replace_failed_page_with_error_message_prefix") - @ExcludeMissing - replaceFailedPageWithErrorMessagePrefix: JsonField = JsonMissing.of(), - @JsonProperty("replace_failed_page_with_error_message_suffix") - @ExcludeMissing - replaceFailedPageWithErrorMessageSuffix: JsonField = JsonMissing.of(), - @JsonProperty("resource_info") - @ExcludeMissing - resourceInfo: JsonField = JsonMissing.of(), - @JsonProperty("save_images") - @ExcludeMissing - saveImages: JsonField = JsonMissing.of(), - @JsonProperty("skip_diagonal_text") - @ExcludeMissing - skipDiagonalText: JsonField = JsonMissing.of(), - @JsonProperty("specialized_chart_parsing_agentic") - @ExcludeMissing - specializedChartParsingAgentic: JsonField = JsonMissing.of(), - @JsonProperty("specialized_chart_parsing_efficient") - @ExcludeMissing - specializedChartParsingEfficient: JsonField = JsonMissing.of(), - @JsonProperty("specialized_chart_parsing_plus") - @ExcludeMissing - specializedChartParsingPlus: JsonField = JsonMissing.of(), - @JsonProperty("specialized_image_parsing") - @ExcludeMissing - specializedImageParsing: JsonField = JsonMissing.of(), - @JsonProperty("spreadsheet_extract_sub_tables") - @ExcludeMissing - spreadsheetExtractSubTables: JsonField = JsonMissing.of(), - @JsonProperty("spreadsheet_force_formula_computation") - @ExcludeMissing - spreadsheetForceFormulaComputation: JsonField = JsonMissing.of(), - @JsonProperty("spreadsheet_include_hidden_sheets") - @ExcludeMissing - spreadsheetIncludeHiddenSheets: JsonField = JsonMissing.of(), - @JsonProperty("strict_mode_buggy_font") - @ExcludeMissing - strictModeBuggyFont: JsonField = JsonMissing.of(), - @JsonProperty("strict_mode_image_extraction") - @ExcludeMissing - strictModeImageExtraction: JsonField = JsonMissing.of(), - @JsonProperty("strict_mode_image_ocr") - @ExcludeMissing - strictModeImageOcr: JsonField = JsonMissing.of(), - @JsonProperty("strict_mode_reconstruction") - @ExcludeMissing - strictModeReconstruction: JsonField = JsonMissing.of(), - @JsonProperty("structured_output") - @ExcludeMissing - structuredOutput: JsonField = JsonMissing.of(), - @JsonProperty("structured_output_json_schema") - @ExcludeMissing - structuredOutputJsonSchema: JsonField = JsonMissing.of(), - @JsonProperty("structured_output_json_schema_name") - @ExcludeMissing - structuredOutputJsonSchemaName: JsonField = JsonMissing.of(), - @JsonProperty("system_prompt") - @ExcludeMissing - systemPrompt: JsonField = JsonMissing.of(), - @JsonProperty("system_prompt_append") - @ExcludeMissing - systemPromptAppend: JsonField = JsonMissing.of(), - @JsonProperty("take_screenshot") - @ExcludeMissing - takeScreenshot: JsonField = JsonMissing.of(), - @JsonProperty("target_pages") - @ExcludeMissing - targetPages: JsonField = JsonMissing.of(), - @JsonProperty("tier") - @ExcludeMissing - tier: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("use_vendor_multimodal_model") - @ExcludeMissing - useVendorMultimodalModel: JsonField = JsonMissing.of(), - @JsonProperty("user_prompt") - @ExcludeMissing - userPrompt: JsonField = JsonMissing.of(), - @JsonProperty("vendor_multimodal_api_key") - @ExcludeMissing - vendorMultimodalApiKey: JsonField = JsonMissing.of(), - @JsonProperty("vendor_multimodal_model_name") - @ExcludeMissing - vendorMultimodalModelName: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - version: JsonField = JsonMissing.of(), - @JsonProperty("webhook_configurations") - @ExcludeMissing - webhookConfigurations: JsonField> = JsonMissing.of(), - @JsonProperty("webhook_url") - @ExcludeMissing - webhookUrl: JsonField = JsonMissing.of(), - ) : this( - adaptiveLongTable, - aggressiveTableExtraction, - annotateLinks, - annotateRevisions, - autoMode, - autoModeConfigurationJson, - autoModeTriggerOnImageInPage, - autoModeTriggerOnRegexpInPage, - autoModeTriggerOnTableInPage, - autoModeTriggerOnTextInPage, - azureOpenAIApiVersion, - azureOpenAIDeploymentName, - azureOpenAIEndpoint, - azureOpenAIKey, - bboxBottom, - bboxLeft, - bboxRight, - bboxTop, - boundingBox, - compactMarkdownTable, - complementalFormattingInstruction, - confidenceScoreEffort, - contentGuidelineInstruction, - continuousMode, - customMetadata, - disableImageExtraction, - disableOcr, - disableReconstruction, - doNotCache, - doNotUnrollColumns, - enableCostOptimizer, - extractCharts, - extractLayout, - extractPrintedPageNumber, - fastMode, - formattingInstruction, - gpt4oApiKey, - gpt4oMode, - guessXlsxSheetName, - hideFooters, - hideHeaders, - highResOcr, - htmlMakeAllElementsVisible, - htmlRemoveFixedElements, - htmlRemoveNavigationElements, - httpProxy, - ignoreDocumentElementsForLayoutDetection, - imagesToSave, - inlineImagesInMarkdown, - inputS3Path, - inputS3Region, - inputUrl, - internalIsScreenshotJob, - invalidateCache, - isFormattingInstruction, - jobTimeoutExtraTimePerPageInSeconds, - jobTimeoutInSeconds, - keepPageSeparatorWhenMergingTables, - lang, - languages, - layoutAware, - lineLevelBoundingBox, - markdownTableMultilineHeaderSeparator, - maxPages, - maxPagesEnforced, - mergeTablesAcrossPagesInMarkdown, - model, - outlinedTableExtraction, - outputPdfOfDocument, - outputS3PathPrefix, - outputS3Region, - outputTablesAsHtml, - outputBucket, - pageErrorTolerance, - pageFooterPrefix, - pageFooterSuffix, - pageHeaderPrefix, - pageHeaderSuffix, - pagePrefix, - pageSeparator, - pageSuffix, - parseMode, - parsingInstruction, - pipelineId, - preciseBoundingBox, - premiumMode, - presentationOutOfBoundsContent, - presentationSkipEmbeddedData, - preserveLayoutAlignmentAcrossPages, - preserveVerySmallText, - preset, - priority, - projectId, - removeHiddenText, - replaceFailedPageMode, - replaceFailedPageWithErrorMessagePrefix, - replaceFailedPageWithErrorMessageSuffix, - resourceInfo, - saveImages, - skipDiagonalText, - specializedChartParsingAgentic, - specializedChartParsingEfficient, - specializedChartParsingPlus, - specializedImageParsing, - spreadsheetExtractSubTables, - spreadsheetForceFormulaComputation, - spreadsheetIncludeHiddenSheets, - strictModeBuggyFont, - strictModeImageExtraction, - strictModeImageOcr, - strictModeReconstruction, - structuredOutput, - structuredOutputJsonSchema, - structuredOutputJsonSchemaName, - systemPrompt, - systemPromptAppend, - takeScreenshot, - targetPages, - tier, - type, - useVendorMultimodalModel, - userPrompt, - vendorMultimodalApiKey, - vendorMultimodalModelName, - version, - webhookConfigurations, - webhookUrl, - mutableMapOf(), - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun adaptiveLongTable(): Optional = - adaptiveLongTable.getOptional("adaptive_long_table") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun aggressiveTableExtraction(): Optional = - aggressiveTableExtraction.getOptional("aggressive_table_extraction") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun annotateLinks(): Optional = annotateLinks.getOptional("annotate_links") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun annotateRevisions(): Optional = - annotateRevisions.getOptional("annotate_revisions") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun autoMode(): Optional = autoMode.getOptional("auto_mode") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun autoModeConfigurationJson(): Optional = - autoModeConfigurationJson.getOptional("auto_mode_configuration_json") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun autoModeTriggerOnImageInPage(): Optional = - autoModeTriggerOnImageInPage.getOptional("auto_mode_trigger_on_image_in_page") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun autoModeTriggerOnRegexpInPage(): Optional = - autoModeTriggerOnRegexpInPage.getOptional("auto_mode_trigger_on_regexp_in_page") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun autoModeTriggerOnTableInPage(): Optional = - autoModeTriggerOnTableInPage.getOptional("auto_mode_trigger_on_table_in_page") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun autoModeTriggerOnTextInPage(): Optional = - autoModeTriggerOnTextInPage.getOptional("auto_mode_trigger_on_text_in_page") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun azureOpenAIApiVersion(): Optional = - azureOpenAIApiVersion.getOptional("azure_openai_api_version") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun azureOpenAIDeploymentName(): Optional = - azureOpenAIDeploymentName.getOptional("azure_openai_deployment_name") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun azureOpenAIEndpoint(): Optional = - azureOpenAIEndpoint.getOptional("azure_openai_endpoint") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun azureOpenAIKey(): Optional = - azureOpenAIKey.getOptional("azure_openai_key") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun bboxBottom(): Optional = bboxBottom.getOptional("bbox_bottom") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun bboxLeft(): Optional = bboxLeft.getOptional("bbox_left") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun bboxRight(): Optional = bboxRight.getOptional("bbox_right") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun bboxTop(): Optional = bboxTop.getOptional("bbox_top") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun boundingBox(): Optional = boundingBox.getOptional("bounding_box") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun compactMarkdownTable(): Optional = - compactMarkdownTable.getOptional("compact_markdown_table") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun complementalFormattingInstruction(): Optional = - complementalFormattingInstruction.getOptional( - "complemental_formatting_instruction" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun confidenceScoreEffort(): Optional = - confidenceScoreEffort.getOptional("confidence_score_effort") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun contentGuidelineInstruction(): Optional = - contentGuidelineInstruction.getOptional("content_guideline_instruction") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun continuousMode(): Optional = - continuousMode.getOptional("continuous_mode") - - /** - * The custom metadata to attach to the documents. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun customMetadata(): Optional = - customMetadata.getOptional("custom_metadata") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun disableImageExtraction(): Optional = - disableImageExtraction.getOptional("disable_image_extraction") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun disableOcr(): Optional = disableOcr.getOptional("disable_ocr") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun disableReconstruction(): Optional = - disableReconstruction.getOptional("disable_reconstruction") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun doNotCache(): Optional = doNotCache.getOptional("do_not_cache") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun doNotUnrollColumns(): Optional = - doNotUnrollColumns.getOptional("do_not_unroll_columns") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun enableCostOptimizer(): Optional = - enableCostOptimizer.getOptional("enable_cost_optimizer") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun extractCharts(): Optional = extractCharts.getOptional("extract_charts") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun extractLayout(): Optional = extractLayout.getOptional("extract_layout") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun extractPrintedPageNumber(): Optional = - extractPrintedPageNumber.getOptional("extract_printed_page_number") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun fastMode(): Optional = fastMode.getOptional("fast_mode") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun formattingInstruction(): Optional = - formattingInstruction.getOptional("formatting_instruction") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun gpt4oApiKey(): Optional = gpt4oApiKey.getOptional("gpt4o_api_key") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun gpt4oMode(): Optional = gpt4oMode.getOptional("gpt4o_mode") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun guessXlsxSheetName(): Optional = - guessXlsxSheetName.getOptional("guess_xlsx_sheet_name") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun hideFooters(): Optional = hideFooters.getOptional("hide_footers") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun hideHeaders(): Optional = hideHeaders.getOptional("hide_headers") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun highResOcr(): Optional = highResOcr.getOptional("high_res_ocr") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun htmlMakeAllElementsVisible(): Optional = - htmlMakeAllElementsVisible.getOptional("html_make_all_elements_visible") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun htmlRemoveFixedElements(): Optional = - htmlRemoveFixedElements.getOptional("html_remove_fixed_elements") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun htmlRemoveNavigationElements(): Optional = - htmlRemoveNavigationElements.getOptional("html_remove_navigation_elements") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun httpProxy(): Optional = httpProxy.getOptional("http_proxy") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun ignoreDocumentElementsForLayoutDetection(): Optional = - ignoreDocumentElementsForLayoutDetection.getOptional( - "ignore_document_elements_for_layout_detection" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun imagesToSave(): Optional> = - imagesToSave.getOptional("images_to_save") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun inlineImagesInMarkdown(): Optional = - inlineImagesInMarkdown.getOptional("inline_images_in_markdown") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun inputS3Path(): Optional = inputS3Path.getOptional("input_s3_path") - - /** - * The region for the input S3 bucket. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun inputS3Region(): Optional = inputS3Region.getOptional("input_s3_region") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun inputUrl(): Optional = inputUrl.getOptional("input_url") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun internalIsScreenshotJob(): Optional = - internalIsScreenshotJob.getOptional("internal_is_screenshot_job") - - /** - * @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") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun isFormattingInstruction(): Optional = - isFormattingInstruction.getOptional("is_formatting_instruction") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun jobTimeoutExtraTimePerPageInSeconds(): Optional = - jobTimeoutExtraTimePerPageInSeconds.getOptional( - "job_timeout_extra_time_per_page_in_seconds" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun jobTimeoutInSeconds(): Optional = - jobTimeoutInSeconds.getOptional("job_timeout_in_seconds") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun keepPageSeparatorWhenMergingTables(): Optional = - keepPageSeparatorWhenMergingTables.getOptional( - "keep_page_separator_when_merging_tables" - ) - - /** - * The language. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun lang(): Optional = lang.getOptional("lang") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun languages(): Optional> = - languages.getOptional("languages") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun layoutAware(): Optional = layoutAware.getOptional("layout_aware") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun lineLevelBoundingBox(): Optional = - lineLevelBoundingBox.getOptional("line_level_bounding_box") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun markdownTableMultilineHeaderSeparator(): Optional = - markdownTableMultilineHeaderSeparator.getOptional( - "markdown_table_multiline_header_separator" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun maxPages(): Optional = maxPages.getOptional("max_pages") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun maxPagesEnforced(): Optional = - maxPagesEnforced.getOptional("max_pages_enforced") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun mergeTablesAcrossPagesInMarkdown(): Optional = - mergeTablesAcrossPagesInMarkdown.getOptional( - "merge_tables_across_pages_in_markdown" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun model(): Optional = model.getOptional("model") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun outlinedTableExtraction(): Optional = - outlinedTableExtraction.getOptional("outlined_table_extraction") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun outputPdfOfDocument(): Optional = - outputPdfOfDocument.getOptional("output_pdf_of_document") - - /** - * If specified, llamaParse will save the output to the specified path. All output - * file will use this 'prefix' should be a valid s3:// url - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun outputS3PathPrefix(): Optional = - outputS3PathPrefix.getOptional("output_s3_path_prefix") - - /** - * The region for the output S3 bucket. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun outputS3Region(): Optional = - outputS3Region.getOptional("output_s3_region") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun outputTablesAsHtml(): Optional = - outputTablesAsHtml.getOptional("output_tables_as_HTML") - - /** - * The output bucket. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun outputBucket(): Optional = outputBucket.getOptional("outputBucket") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun pageErrorTolerance(): Optional = - pageErrorTolerance.getOptional("page_error_tolerance") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun pageFooterPrefix(): Optional = - pageFooterPrefix.getOptional("page_footer_prefix") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun pageFooterSuffix(): Optional = - pageFooterSuffix.getOptional("page_footer_suffix") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun pageHeaderPrefix(): Optional = - pageHeaderPrefix.getOptional("page_header_prefix") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun pageHeaderSuffix(): Optional = - pageHeaderSuffix.getOptional("page_header_suffix") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun pagePrefix(): Optional = pagePrefix.getOptional("page_prefix") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun pageSeparator(): Optional = pageSeparator.getOptional("page_separator") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun pageSuffix(): Optional = pageSuffix.getOptional("page_suffix") - - /** - * Enum for representing the mode of parsing to be used. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun parseMode(): Optional = parseMode.getOptional("parse_mode") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun parsingInstruction(): Optional = - parsingInstruction.getOptional("parsing_instruction") - - /** - * The pipeline ID. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun pipelineId(): Optional = pipelineId.getOptional("pipeline_id") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun preciseBoundingBox(): Optional = - preciseBoundingBox.getOptional("precise_bounding_box") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun premiumMode(): Optional = premiumMode.getOptional("premium_mode") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun presentationOutOfBoundsContent(): Optional = - presentationOutOfBoundsContent.getOptional("presentation_out_of_bounds_content") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun presentationSkipEmbeddedData(): Optional = - presentationSkipEmbeddedData.getOptional("presentation_skip_embedded_data") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun preserveLayoutAlignmentAcrossPages(): Optional = - preserveLayoutAlignmentAcrossPages.getOptional( - "preserve_layout_alignment_across_pages" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun preserveVerySmallText(): Optional = - preserveVerySmallText.getOptional("preserve_very_small_text") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun preset(): Optional = preset.getOptional("preset") - - /** - * 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") - - /** - * @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") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun removeHiddenText(): Optional = - removeHiddenText.getOptional("remove_hidden_text") - - /** - * Enum for representing the different available page error handling modes. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun replaceFailedPageMode(): Optional = - replaceFailedPageMode.getOptional("replace_failed_page_mode") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun replaceFailedPageWithErrorMessagePrefix(): Optional = - replaceFailedPageWithErrorMessagePrefix.getOptional( - "replace_failed_page_with_error_message_prefix" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun replaceFailedPageWithErrorMessageSuffix(): Optional = - replaceFailedPageWithErrorMessageSuffix.getOptional( - "replace_failed_page_with_error_message_suffix" - ) - - /** - * The resource info about the file - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun resourceInfo(): Optional = - resourceInfo.getOptional("resource_info") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun saveImages(): Optional = saveImages.getOptional("save_images") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun skipDiagonalText(): Optional = - skipDiagonalText.getOptional("skip_diagonal_text") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun specializedChartParsingAgentic(): Optional = - specializedChartParsingAgentic.getOptional("specialized_chart_parsing_agentic") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun specializedChartParsingEfficient(): Optional = - specializedChartParsingEfficient.getOptional( - "specialized_chart_parsing_efficient" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun specializedChartParsingPlus(): Optional = - specializedChartParsingPlus.getOptional("specialized_chart_parsing_plus") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun specializedImageParsing(): Optional = - specializedImageParsing.getOptional("specialized_image_parsing") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun spreadsheetExtractSubTables(): Optional = - spreadsheetExtractSubTables.getOptional("spreadsheet_extract_sub_tables") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun spreadsheetForceFormulaComputation(): Optional = - spreadsheetForceFormulaComputation.getOptional( - "spreadsheet_force_formula_computation" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun spreadsheetIncludeHiddenSheets(): Optional = - spreadsheetIncludeHiddenSheets.getOptional("spreadsheet_include_hidden_sheets") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun strictModeBuggyFont(): Optional = - strictModeBuggyFont.getOptional("strict_mode_buggy_font") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun strictModeImageExtraction(): Optional = - strictModeImageExtraction.getOptional("strict_mode_image_extraction") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun strictModeImageOcr(): Optional = - strictModeImageOcr.getOptional("strict_mode_image_ocr") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun strictModeReconstruction(): Optional = - strictModeReconstruction.getOptional("strict_mode_reconstruction") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun structuredOutput(): Optional = - structuredOutput.getOptional("structured_output") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun structuredOutputJsonSchema(): Optional = - structuredOutputJsonSchema.getOptional("structured_output_json_schema") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun structuredOutputJsonSchemaName(): Optional = - structuredOutputJsonSchemaName.getOptional("structured_output_json_schema_name") - - /** - * @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") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun systemPromptAppend(): Optional = - systemPromptAppend.getOptional("system_prompt_append") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun takeScreenshot(): Optional = - takeScreenshot.getOptional("take_screenshot") - - /** - * @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") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun tier(): Optional = tier.getOptional("tier") - - /** - * @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") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun useVendorMultimodalModel(): Optional = - useVendorMultimodalModel.getOptional("use_vendor_multimodal_model") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun userPrompt(): Optional = userPrompt.getOptional("user_prompt") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun vendorMultimodalApiKey(): Optional = - vendorMultimodalApiKey.getOptional("vendor_multimodal_api_key") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun vendorMultimodalModelName(): Optional = - vendorMultimodalModelName.getOptional("vendor_multimodal_model_name") - - /** - * @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") - - /** - * Outbound webhook endpoints to notify on job status changes - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun webhookConfigurations(): Optional> = - webhookConfigurations.getOptional("webhook_configurations") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun webhookUrl(): Optional = webhookUrl.getOptional("webhook_url") - - /** - * Returns the raw JSON value of [adaptiveLongTable]. - * - * Unlike [adaptiveLongTable], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("adaptive_long_table") - @ExcludeMissing - fun _adaptiveLongTable(): JsonField = adaptiveLongTable - - /** - * Returns the raw JSON value of [aggressiveTableExtraction]. - * - * Unlike [aggressiveTableExtraction], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("aggressive_table_extraction") - @ExcludeMissing - fun _aggressiveTableExtraction(): JsonField = aggressiveTableExtraction - - /** - * Returns the raw JSON value of [annotateLinks]. - * - * Unlike [annotateLinks], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("annotate_links") - @ExcludeMissing - fun _annotateLinks(): JsonField = annotateLinks - - /** - * Returns the raw JSON value of [annotateRevisions]. - * - * Unlike [annotateRevisions], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("annotate_revisions") - @ExcludeMissing - fun _annotateRevisions(): JsonField = annotateRevisions - - /** - * Returns the raw JSON value of [autoMode]. - * - * Unlike [autoMode], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("auto_mode") - @ExcludeMissing - fun _autoMode(): JsonField = autoMode - - /** - * Returns the raw JSON value of [autoModeConfigurationJson]. - * - * Unlike [autoModeConfigurationJson], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("auto_mode_configuration_json") - @ExcludeMissing - fun _autoModeConfigurationJson(): JsonField = autoModeConfigurationJson - - /** - * Returns the raw JSON value of [autoModeTriggerOnImageInPage]. - * - * Unlike [autoModeTriggerOnImageInPage], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("auto_mode_trigger_on_image_in_page") - @ExcludeMissing - fun _autoModeTriggerOnImageInPage(): JsonField = - autoModeTriggerOnImageInPage - - /** - * Returns the raw JSON value of [autoModeTriggerOnRegexpInPage]. - * - * Unlike [autoModeTriggerOnRegexpInPage], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("auto_mode_trigger_on_regexp_in_page") - @ExcludeMissing - fun _autoModeTriggerOnRegexpInPage(): JsonField = - autoModeTriggerOnRegexpInPage - - /** - * Returns the raw JSON value of [autoModeTriggerOnTableInPage]. - * - * Unlike [autoModeTriggerOnTableInPage], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("auto_mode_trigger_on_table_in_page") - @ExcludeMissing - fun _autoModeTriggerOnTableInPage(): JsonField = - autoModeTriggerOnTableInPage - - /** - * Returns the raw JSON value of [autoModeTriggerOnTextInPage]. - * - * Unlike [autoModeTriggerOnTextInPage], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("auto_mode_trigger_on_text_in_page") - @ExcludeMissing - fun _autoModeTriggerOnTextInPage(): JsonField = autoModeTriggerOnTextInPage - - /** - * Returns the raw JSON value of [azureOpenAIApiVersion]. - * - * Unlike [azureOpenAIApiVersion], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("azure_openai_api_version") - @ExcludeMissing - fun _azureOpenAIApiVersion(): JsonField = azureOpenAIApiVersion - - /** - * Returns the raw JSON value of [azureOpenAIDeploymentName]. - * - * Unlike [azureOpenAIDeploymentName], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("azure_openai_deployment_name") - @ExcludeMissing - fun _azureOpenAIDeploymentName(): JsonField = azureOpenAIDeploymentName - - /** - * Returns the raw JSON value of [azureOpenAIEndpoint]. - * - * Unlike [azureOpenAIEndpoint], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("azure_openai_endpoint") - @ExcludeMissing - fun _azureOpenAIEndpoint(): JsonField = azureOpenAIEndpoint - - /** - * Returns the raw JSON value of [azureOpenAIKey]. - * - * Unlike [azureOpenAIKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("azure_openai_key") - @ExcludeMissing - fun _azureOpenAIKey(): JsonField = azureOpenAIKey - - /** - * Returns the raw JSON value of [bboxBottom]. - * - * Unlike [bboxBottom], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("bbox_bottom") - @ExcludeMissing - fun _bboxBottom(): JsonField = bboxBottom - - /** - * Returns the raw JSON value of [bboxLeft]. - * - * Unlike [bboxLeft], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("bbox_left") - @ExcludeMissing - fun _bboxLeft(): JsonField = bboxLeft - - /** - * Returns the raw JSON value of [bboxRight]. - * - * Unlike [bboxRight], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("bbox_right") - @ExcludeMissing - fun _bboxRight(): JsonField = bboxRight - - /** - * Returns the raw JSON value of [bboxTop]. - * - * Unlike [bboxTop], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("bbox_top") - @ExcludeMissing - fun _bboxTop(): JsonField = bboxTop - - /** - * Returns the raw JSON value of [boundingBox]. - * - * Unlike [boundingBox], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("bounding_box") - @ExcludeMissing - fun _boundingBox(): JsonField = boundingBox - - /** - * Returns the raw JSON value of [compactMarkdownTable]. - * - * Unlike [compactMarkdownTable], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("compact_markdown_table") - @ExcludeMissing - fun _compactMarkdownTable(): JsonField = compactMarkdownTable - - /** - * Returns the raw JSON value of [complementalFormattingInstruction]. - * - * Unlike [complementalFormattingInstruction], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("complemental_formatting_instruction") - @ExcludeMissing - fun _complementalFormattingInstruction(): JsonField = - complementalFormattingInstruction - - /** - * Returns the raw JSON value of [confidenceScoreEffort]. - * - * Unlike [confidenceScoreEffort], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("confidence_score_effort") - @ExcludeMissing - fun _confidenceScoreEffort(): JsonField = confidenceScoreEffort - - /** - * Returns the raw JSON value of [contentGuidelineInstruction]. - * - * Unlike [contentGuidelineInstruction], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("content_guideline_instruction") - @ExcludeMissing - fun _contentGuidelineInstruction(): JsonField = contentGuidelineInstruction - - /** - * Returns the raw JSON value of [continuousMode]. - * - * Unlike [continuousMode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("continuous_mode") - @ExcludeMissing - fun _continuousMode(): JsonField = continuousMode - - /** - * Returns the raw JSON value of [customMetadata]. - * - * Unlike [customMetadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("custom_metadata") - @ExcludeMissing - fun _customMetadata(): JsonField = customMetadata - - /** - * Returns the raw JSON value of [disableImageExtraction]. - * - * Unlike [disableImageExtraction], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("disable_image_extraction") - @ExcludeMissing - fun _disableImageExtraction(): JsonField = disableImageExtraction - - /** - * Returns the raw JSON value of [disableOcr]. - * - * Unlike [disableOcr], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("disable_ocr") - @ExcludeMissing - fun _disableOcr(): JsonField = disableOcr - - /** - * Returns the raw JSON value of [disableReconstruction]. - * - * Unlike [disableReconstruction], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("disable_reconstruction") - @ExcludeMissing - fun _disableReconstruction(): JsonField = disableReconstruction - - /** - * Returns the raw JSON value of [doNotCache]. - * - * Unlike [doNotCache], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("do_not_cache") - @ExcludeMissing - fun _doNotCache(): JsonField = doNotCache - - /** - * Returns the raw JSON value of [doNotUnrollColumns]. - * - * Unlike [doNotUnrollColumns], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("do_not_unroll_columns") - @ExcludeMissing - fun _doNotUnrollColumns(): JsonField = doNotUnrollColumns - - /** - * Returns the raw JSON value of [enableCostOptimizer]. - * - * Unlike [enableCostOptimizer], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("enable_cost_optimizer") - @ExcludeMissing - fun _enableCostOptimizer(): JsonField = enableCostOptimizer - - /** - * Returns the raw JSON value of [extractCharts]. - * - * Unlike [extractCharts], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("extract_charts") - @ExcludeMissing - fun _extractCharts(): JsonField = extractCharts - - /** - * Returns the raw JSON value of [extractLayout]. - * - * Unlike [extractLayout], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("extract_layout") - @ExcludeMissing - fun _extractLayout(): JsonField = extractLayout - - /** - * Returns the raw JSON value of [extractPrintedPageNumber]. - * - * Unlike [extractPrintedPageNumber], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("extract_printed_page_number") - @ExcludeMissing - fun _extractPrintedPageNumber(): JsonField = extractPrintedPageNumber - - /** - * Returns the raw JSON value of [fastMode]. - * - * Unlike [fastMode], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("fast_mode") - @ExcludeMissing - fun _fastMode(): JsonField = fastMode - - /** - * Returns the raw JSON value of [formattingInstruction]. - * - * Unlike [formattingInstruction], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("formatting_instruction") - @ExcludeMissing - fun _formattingInstruction(): JsonField = formattingInstruction - - /** - * Returns the raw JSON value of [gpt4oApiKey]. - * - * Unlike [gpt4oApiKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("gpt4o_api_key") - @ExcludeMissing - fun _gpt4oApiKey(): JsonField = gpt4oApiKey - - /** - * Returns the raw JSON value of [gpt4oMode]. - * - * Unlike [gpt4oMode], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("gpt4o_mode") - @ExcludeMissing - fun _gpt4oMode(): JsonField = gpt4oMode - - /** - * Returns the raw JSON value of [guessXlsxSheetName]. - * - * Unlike [guessXlsxSheetName], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("guess_xlsx_sheet_name") - @ExcludeMissing - fun _guessXlsxSheetName(): JsonField = guessXlsxSheetName - - /** - * Returns the raw JSON value of [hideFooters]. - * - * Unlike [hideFooters], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("hide_footers") - @ExcludeMissing - fun _hideFooters(): JsonField = hideFooters - - /** - * Returns the raw JSON value of [hideHeaders]. - * - * Unlike [hideHeaders], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("hide_headers") - @ExcludeMissing - fun _hideHeaders(): JsonField = hideHeaders - - /** - * Returns the raw JSON value of [highResOcr]. - * - * Unlike [highResOcr], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("high_res_ocr") - @ExcludeMissing - fun _highResOcr(): JsonField = highResOcr - - /** - * Returns the raw JSON value of [htmlMakeAllElementsVisible]. - * - * Unlike [htmlMakeAllElementsVisible], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("html_make_all_elements_visible") - @ExcludeMissing - fun _htmlMakeAllElementsVisible(): JsonField = htmlMakeAllElementsVisible - - /** - * Returns the raw JSON value of [htmlRemoveFixedElements]. - * - * Unlike [htmlRemoveFixedElements], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("html_remove_fixed_elements") - @ExcludeMissing - fun _htmlRemoveFixedElements(): JsonField = htmlRemoveFixedElements - - /** - * Returns the raw JSON value of [htmlRemoveNavigationElements]. - * - * Unlike [htmlRemoveNavigationElements], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("html_remove_navigation_elements") - @ExcludeMissing - fun _htmlRemoveNavigationElements(): JsonField = - htmlRemoveNavigationElements - - /** - * Returns the raw JSON value of [httpProxy]. - * - * Unlike [httpProxy], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("http_proxy") - @ExcludeMissing - fun _httpProxy(): JsonField = httpProxy - - /** - * Returns the raw JSON value of [ignoreDocumentElementsForLayoutDetection]. - * - * Unlike [ignoreDocumentElementsForLayoutDetection], this method doesn't throw if - * the JSON field has an unexpected type. - */ - @JsonProperty("ignore_document_elements_for_layout_detection") - @ExcludeMissing - fun _ignoreDocumentElementsForLayoutDetection(): JsonField = - ignoreDocumentElementsForLayoutDetection - - /** - * Returns the raw JSON value of [imagesToSave]. - * - * Unlike [imagesToSave], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("images_to_save") - @ExcludeMissing - fun _imagesToSave(): JsonField> = imagesToSave - - /** - * Returns the raw JSON value of [inlineImagesInMarkdown]. - * - * Unlike [inlineImagesInMarkdown], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("inline_images_in_markdown") - @ExcludeMissing - fun _inlineImagesInMarkdown(): JsonField = inlineImagesInMarkdown - - /** - * Returns the raw JSON value of [inputS3Path]. - * - * Unlike [inputS3Path], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("input_s3_path") - @ExcludeMissing - fun _inputS3Path(): JsonField = inputS3Path - - /** - * Returns the raw JSON value of [inputS3Region]. - * - * Unlike [inputS3Region], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("input_s3_region") - @ExcludeMissing - fun _inputS3Region(): JsonField = inputS3Region - - /** - * Returns the raw JSON value of [inputUrl]. - * - * Unlike [inputUrl], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("input_url") - @ExcludeMissing - fun _inputUrl(): JsonField = inputUrl - - /** - * Returns the raw JSON value of [internalIsScreenshotJob]. - * - * Unlike [internalIsScreenshotJob], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("internal_is_screenshot_job") - @ExcludeMissing - fun _internalIsScreenshotJob(): JsonField = internalIsScreenshotJob - - /** - * 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 [isFormattingInstruction]. - * - * Unlike [isFormattingInstruction], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("is_formatting_instruction") - @ExcludeMissing - fun _isFormattingInstruction(): JsonField = isFormattingInstruction - - /** - * Returns the raw JSON value of [jobTimeoutExtraTimePerPageInSeconds]. - * - * Unlike [jobTimeoutExtraTimePerPageInSeconds], this method doesn't throw if the - * JSON field has an unexpected type. - */ - @JsonProperty("job_timeout_extra_time_per_page_in_seconds") - @ExcludeMissing - fun _jobTimeoutExtraTimePerPageInSeconds(): JsonField = - jobTimeoutExtraTimePerPageInSeconds - - /** - * Returns the raw JSON value of [jobTimeoutInSeconds]. - * - * Unlike [jobTimeoutInSeconds], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("job_timeout_in_seconds") - @ExcludeMissing - fun _jobTimeoutInSeconds(): JsonField = jobTimeoutInSeconds - - /** - * Returns the raw JSON value of [keepPageSeparatorWhenMergingTables]. - * - * Unlike [keepPageSeparatorWhenMergingTables], this method doesn't throw if the - * JSON field has an unexpected type. - */ - @JsonProperty("keep_page_separator_when_merging_tables") - @ExcludeMissing - fun _keepPageSeparatorWhenMergingTables(): JsonField = - keepPageSeparatorWhenMergingTables - - /** - * Returns the raw JSON value of [lang]. - * - * Unlike [lang], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("lang") @ExcludeMissing fun _lang(): JsonField = lang - - /** - * Returns the raw JSON value of [languages]. - * - * Unlike [languages], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("languages") - @ExcludeMissing - fun _languages(): JsonField> = languages - - /** - * Returns the raw JSON value of [layoutAware]. - * - * Unlike [layoutAware], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("layout_aware") - @ExcludeMissing - fun _layoutAware(): JsonField = layoutAware - - /** - * Returns the raw JSON value of [lineLevelBoundingBox]. - * - * Unlike [lineLevelBoundingBox], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("line_level_bounding_box") - @ExcludeMissing - fun _lineLevelBoundingBox(): JsonField = lineLevelBoundingBox - - /** - * Returns the raw JSON value of [markdownTableMultilineHeaderSeparator]. - * - * Unlike [markdownTableMultilineHeaderSeparator], this method doesn't throw if the - * JSON field has an unexpected type. - */ - @JsonProperty("markdown_table_multiline_header_separator") - @ExcludeMissing - fun _markdownTableMultilineHeaderSeparator(): JsonField = - markdownTableMultilineHeaderSeparator - - /** - * Returns the raw JSON value of [maxPages]. - * - * Unlike [maxPages], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("max_pages") - @ExcludeMissing - fun _maxPages(): JsonField = maxPages - - /** - * Returns the raw JSON value of [maxPagesEnforced]. - * - * Unlike [maxPagesEnforced], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("max_pages_enforced") - @ExcludeMissing - fun _maxPagesEnforced(): JsonField = maxPagesEnforced - - /** - * Returns the raw JSON value of [mergeTablesAcrossPagesInMarkdown]. - * - * Unlike [mergeTablesAcrossPagesInMarkdown], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("merge_tables_across_pages_in_markdown") - @ExcludeMissing - fun _mergeTablesAcrossPagesInMarkdown(): JsonField = - mergeTablesAcrossPagesInMarkdown - - /** - * Returns the raw JSON value of [model]. - * - * Unlike [model], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model - - /** - * Returns the raw JSON value of [outlinedTableExtraction]. - * - * Unlike [outlinedTableExtraction], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("outlined_table_extraction") - @ExcludeMissing - fun _outlinedTableExtraction(): JsonField = outlinedTableExtraction - - /** - * Returns the raw JSON value of [outputPdfOfDocument]. - * - * Unlike [outputPdfOfDocument], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("output_pdf_of_document") - @ExcludeMissing - fun _outputPdfOfDocument(): JsonField = outputPdfOfDocument - - /** - * Returns the raw JSON value of [outputS3PathPrefix]. - * - * Unlike [outputS3PathPrefix], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("output_s3_path_prefix") - @ExcludeMissing - fun _outputS3PathPrefix(): JsonField = outputS3PathPrefix - - /** - * Returns the raw JSON value of [outputS3Region]. - * - * Unlike [outputS3Region], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("output_s3_region") - @ExcludeMissing - fun _outputS3Region(): JsonField = outputS3Region - - /** - * Returns the raw JSON value of [outputTablesAsHtml]. - * - * Unlike [outputTablesAsHtml], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("output_tables_as_HTML") - @ExcludeMissing - fun _outputTablesAsHtml(): JsonField = outputTablesAsHtml - - /** - * Returns the raw JSON value of [outputBucket]. - * - * Unlike [outputBucket], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("outputBucket") - @ExcludeMissing - fun _outputBucket(): JsonField = outputBucket - - /** - * Returns the raw JSON value of [pageErrorTolerance]. - * - * Unlike [pageErrorTolerance], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("page_error_tolerance") - @ExcludeMissing - fun _pageErrorTolerance(): JsonField = pageErrorTolerance - - /** - * Returns the raw JSON value of [pageFooterPrefix]. - * - * Unlike [pageFooterPrefix], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("page_footer_prefix") - @ExcludeMissing - fun _pageFooterPrefix(): JsonField = pageFooterPrefix - - /** - * Returns the raw JSON value of [pageFooterSuffix]. - * - * Unlike [pageFooterSuffix], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("page_footer_suffix") - @ExcludeMissing - fun _pageFooterSuffix(): JsonField = pageFooterSuffix - - /** - * Returns the raw JSON value of [pageHeaderPrefix]. - * - * Unlike [pageHeaderPrefix], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("page_header_prefix") - @ExcludeMissing - fun _pageHeaderPrefix(): JsonField = pageHeaderPrefix - - /** - * Returns the raw JSON value of [pageHeaderSuffix]. - * - * Unlike [pageHeaderSuffix], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("page_header_suffix") - @ExcludeMissing - fun _pageHeaderSuffix(): JsonField = pageHeaderSuffix - - /** - * Returns the raw JSON value of [pagePrefix]. - * - * Unlike [pagePrefix], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("page_prefix") - @ExcludeMissing - fun _pagePrefix(): JsonField = pagePrefix - - /** - * Returns the raw JSON value of [pageSeparator]. - * - * Unlike [pageSeparator], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("page_separator") - @ExcludeMissing - fun _pageSeparator(): JsonField = pageSeparator - - /** - * Returns the raw JSON value of [pageSuffix]. - * - * Unlike [pageSuffix], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("page_suffix") - @ExcludeMissing - fun _pageSuffix(): JsonField = pageSuffix - - /** - * Returns the raw JSON value of [parseMode]. - * - * Unlike [parseMode], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("parse_mode") - @ExcludeMissing - fun _parseMode(): JsonField = parseMode - - /** - * Returns the raw JSON value of [parsingInstruction]. - * - * Unlike [parsingInstruction], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("parsing_instruction") - @ExcludeMissing - fun _parsingInstruction(): JsonField = parsingInstruction - - /** - * Returns the raw JSON value of [pipelineId]. - * - * Unlike [pipelineId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("pipeline_id") - @ExcludeMissing - fun _pipelineId(): JsonField = pipelineId - - /** - * Returns the raw JSON value of [preciseBoundingBox]. - * - * Unlike [preciseBoundingBox], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("precise_bounding_box") - @ExcludeMissing - fun _preciseBoundingBox(): JsonField = preciseBoundingBox - - /** - * Returns the raw JSON value of [premiumMode]. - * - * Unlike [premiumMode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("premium_mode") - @ExcludeMissing - fun _premiumMode(): JsonField = premiumMode - - /** - * Returns the raw JSON value of [presentationOutOfBoundsContent]. - * - * Unlike [presentationOutOfBoundsContent], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("presentation_out_of_bounds_content") - @ExcludeMissing - fun _presentationOutOfBoundsContent(): JsonField = - presentationOutOfBoundsContent - - /** - * Returns the raw JSON value of [presentationSkipEmbeddedData]. - * - * Unlike [presentationSkipEmbeddedData], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("presentation_skip_embedded_data") - @ExcludeMissing - fun _presentationSkipEmbeddedData(): JsonField = - presentationSkipEmbeddedData - - /** - * Returns the raw JSON value of [preserveLayoutAlignmentAcrossPages]. - * - * Unlike [preserveLayoutAlignmentAcrossPages], this method doesn't throw if the - * JSON field has an unexpected type. - */ - @JsonProperty("preserve_layout_alignment_across_pages") - @ExcludeMissing - fun _preserveLayoutAlignmentAcrossPages(): JsonField = - preserveLayoutAlignmentAcrossPages - - /** - * Returns the raw JSON value of [preserveVerySmallText]. - * - * Unlike [preserveVerySmallText], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("preserve_very_small_text") - @ExcludeMissing - fun _preserveVerySmallText(): JsonField = preserveVerySmallText - - /** - * Returns the raw JSON value of [preset]. - * - * Unlike [preset], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("preset") @ExcludeMissing fun _preset(): JsonField = preset - - /** - * 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 [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 [removeHiddenText]. - * - * Unlike [removeHiddenText], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("remove_hidden_text") - @ExcludeMissing - fun _removeHiddenText(): JsonField = removeHiddenText - - /** - * Returns the raw JSON value of [replaceFailedPageMode]. - * - * Unlike [replaceFailedPageMode], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("replace_failed_page_mode") - @ExcludeMissing - fun _replaceFailedPageMode(): JsonField = replaceFailedPageMode - - /** - * Returns the raw JSON value of [replaceFailedPageWithErrorMessagePrefix]. - * - * Unlike [replaceFailedPageWithErrorMessagePrefix], this method doesn't throw if - * the JSON field has an unexpected type. - */ - @JsonProperty("replace_failed_page_with_error_message_prefix") - @ExcludeMissing - fun _replaceFailedPageWithErrorMessagePrefix(): JsonField = - replaceFailedPageWithErrorMessagePrefix - - /** - * Returns the raw JSON value of [replaceFailedPageWithErrorMessageSuffix]. - * - * Unlike [replaceFailedPageWithErrorMessageSuffix], this method doesn't throw if - * the JSON field has an unexpected type. - */ - @JsonProperty("replace_failed_page_with_error_message_suffix") - @ExcludeMissing - fun _replaceFailedPageWithErrorMessageSuffix(): JsonField = - replaceFailedPageWithErrorMessageSuffix - - /** - * Returns the raw JSON value of [resourceInfo]. - * - * Unlike [resourceInfo], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("resource_info") - @ExcludeMissing - fun _resourceInfo(): JsonField = resourceInfo - - /** - * Returns the raw JSON value of [saveImages]. - * - * Unlike [saveImages], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("save_images") - @ExcludeMissing - fun _saveImages(): JsonField = saveImages - - /** - * Returns the raw JSON value of [skipDiagonalText]. - * - * Unlike [skipDiagonalText], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("skip_diagonal_text") - @ExcludeMissing - fun _skipDiagonalText(): JsonField = skipDiagonalText - - /** - * Returns the raw JSON value of [specializedChartParsingAgentic]. - * - * Unlike [specializedChartParsingAgentic], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("specialized_chart_parsing_agentic") - @ExcludeMissing - fun _specializedChartParsingAgentic(): JsonField = - specializedChartParsingAgentic - - /** - * Returns the raw JSON value of [specializedChartParsingEfficient]. - * - * Unlike [specializedChartParsingEfficient], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("specialized_chart_parsing_efficient") - @ExcludeMissing - fun _specializedChartParsingEfficient(): JsonField = - specializedChartParsingEfficient - - /** - * Returns the raw JSON value of [specializedChartParsingPlus]. - * - * Unlike [specializedChartParsingPlus], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("specialized_chart_parsing_plus") - @ExcludeMissing - fun _specializedChartParsingPlus(): JsonField = specializedChartParsingPlus - - /** - * Returns the raw JSON value of [specializedImageParsing]. - * - * Unlike [specializedImageParsing], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("specialized_image_parsing") - @ExcludeMissing - fun _specializedImageParsing(): JsonField = specializedImageParsing - - /** - * Returns the raw JSON value of [spreadsheetExtractSubTables]. - * - * Unlike [spreadsheetExtractSubTables], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("spreadsheet_extract_sub_tables") - @ExcludeMissing - fun _spreadsheetExtractSubTables(): JsonField = spreadsheetExtractSubTables - - /** - * Returns the raw JSON value of [spreadsheetForceFormulaComputation]. - * - * Unlike [spreadsheetForceFormulaComputation], this method doesn't throw if the - * JSON field has an unexpected type. - */ - @JsonProperty("spreadsheet_force_formula_computation") - @ExcludeMissing - fun _spreadsheetForceFormulaComputation(): JsonField = - spreadsheetForceFormulaComputation - - /** - * Returns the raw JSON value of [spreadsheetIncludeHiddenSheets]. - * - * Unlike [spreadsheetIncludeHiddenSheets], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("spreadsheet_include_hidden_sheets") - @ExcludeMissing - fun _spreadsheetIncludeHiddenSheets(): JsonField = - spreadsheetIncludeHiddenSheets - - /** - * Returns the raw JSON value of [strictModeBuggyFont]. - * - * Unlike [strictModeBuggyFont], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("strict_mode_buggy_font") - @ExcludeMissing - fun _strictModeBuggyFont(): JsonField = strictModeBuggyFont - - /** - * Returns the raw JSON value of [strictModeImageExtraction]. - * - * Unlike [strictModeImageExtraction], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("strict_mode_image_extraction") - @ExcludeMissing - fun _strictModeImageExtraction(): JsonField = strictModeImageExtraction - - /** - * Returns the raw JSON value of [strictModeImageOcr]. - * - * Unlike [strictModeImageOcr], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("strict_mode_image_ocr") - @ExcludeMissing - fun _strictModeImageOcr(): JsonField = strictModeImageOcr - - /** - * Returns the raw JSON value of [strictModeReconstruction]. - * - * Unlike [strictModeReconstruction], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("strict_mode_reconstruction") - @ExcludeMissing - fun _strictModeReconstruction(): JsonField = strictModeReconstruction - - /** - * Returns the raw JSON value of [structuredOutput]. - * - * Unlike [structuredOutput], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("structured_output") - @ExcludeMissing - fun _structuredOutput(): JsonField = structuredOutput - - /** - * Returns the raw JSON value of [structuredOutputJsonSchema]. - * - * Unlike [structuredOutputJsonSchema], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("structured_output_json_schema") - @ExcludeMissing - fun _structuredOutputJsonSchema(): JsonField = structuredOutputJsonSchema - - /** - * Returns the raw JSON value of [structuredOutputJsonSchemaName]. - * - * Unlike [structuredOutputJsonSchemaName], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("structured_output_json_schema_name") - @ExcludeMissing - fun _structuredOutputJsonSchemaName(): JsonField = - structuredOutputJsonSchemaName - - /** - * 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 [systemPromptAppend]. - * - * Unlike [systemPromptAppend], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("system_prompt_append") - @ExcludeMissing - fun _systemPromptAppend(): JsonField = systemPromptAppend - - /** - * Returns the raw JSON value of [takeScreenshot]. - * - * Unlike [takeScreenshot], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("take_screenshot") - @ExcludeMissing - fun _takeScreenshot(): JsonField = takeScreenshot - - /** - * 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 [tier]. - * - * Unlike [tier], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tier") @ExcludeMissing fun _tier(): JsonField = tier - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [useVendorMultimodalModel]. - * - * Unlike [useVendorMultimodalModel], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("use_vendor_multimodal_model") - @ExcludeMissing - fun _useVendorMultimodalModel(): JsonField = useVendorMultimodalModel - - /** - * Returns the raw JSON value of [userPrompt]. - * - * Unlike [userPrompt], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("user_prompt") - @ExcludeMissing - fun _userPrompt(): JsonField = userPrompt - - /** - * Returns the raw JSON value of [vendorMultimodalApiKey]. - * - * Unlike [vendorMultimodalApiKey], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("vendor_multimodal_api_key") - @ExcludeMissing - fun _vendorMultimodalApiKey(): JsonField = vendorMultimodalApiKey - - /** - * Returns the raw JSON value of [vendorMultimodalModelName]. - * - * Unlike [vendorMultimodalModelName], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("vendor_multimodal_model_name") - @ExcludeMissing - fun _vendorMultimodalModelName(): JsonField = vendorMultimodalModelName - - /** - * 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 - - /** - * Returns the raw JSON value of [webhookConfigurations]. - * - * Unlike [webhookConfigurations], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("webhook_configurations") - @ExcludeMissing - fun _webhookConfigurations(): JsonField> = - webhookConfigurations - - /** - * Returns the raw JSON value of [webhookUrl]. - * - * Unlike [webhookUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("webhook_url") - @ExcludeMissing - fun _webhookUrl(): JsonField = webhookUrl - - @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 [Parameters]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Parameters]. */ - class Builder internal constructor() { - - private var adaptiveLongTable: JsonField = JsonMissing.of() - private var aggressiveTableExtraction: JsonField = JsonMissing.of() - private var annotateLinks: JsonField = JsonMissing.of() - private var annotateRevisions: JsonField = JsonMissing.of() - private var autoMode: JsonField = JsonMissing.of() - private var autoModeConfigurationJson: JsonField = JsonMissing.of() - private var autoModeTriggerOnImageInPage: JsonField = JsonMissing.of() - private var autoModeTriggerOnRegexpInPage: JsonField = JsonMissing.of() - private var autoModeTriggerOnTableInPage: JsonField = JsonMissing.of() - private var autoModeTriggerOnTextInPage: JsonField = JsonMissing.of() - private var azureOpenAIApiVersion: JsonField = JsonMissing.of() - private var azureOpenAIDeploymentName: JsonField = JsonMissing.of() - private var azureOpenAIEndpoint: JsonField = JsonMissing.of() - private var azureOpenAIKey: JsonField = JsonMissing.of() - private var bboxBottom: JsonField = JsonMissing.of() - private var bboxLeft: JsonField = JsonMissing.of() - private var bboxRight: JsonField = JsonMissing.of() - private var bboxTop: JsonField = JsonMissing.of() - private var boundingBox: JsonField = JsonMissing.of() - private var compactMarkdownTable: JsonField = JsonMissing.of() - private var complementalFormattingInstruction: JsonField = - JsonMissing.of() - private var confidenceScoreEffort: JsonField = JsonMissing.of() - private var contentGuidelineInstruction: JsonField = JsonMissing.of() - private var continuousMode: JsonField = JsonMissing.of() - private var customMetadata: JsonField = JsonMissing.of() - private var disableImageExtraction: JsonField = JsonMissing.of() - private var disableOcr: JsonField = JsonMissing.of() - private var disableReconstruction: JsonField = JsonMissing.of() - private var doNotCache: JsonField = JsonMissing.of() - private var doNotUnrollColumns: JsonField = JsonMissing.of() - private var enableCostOptimizer: JsonField = JsonMissing.of() - private var extractCharts: JsonField = JsonMissing.of() - private var extractLayout: JsonField = JsonMissing.of() - private var extractPrintedPageNumber: JsonField = JsonMissing.of() - private var fastMode: JsonField = JsonMissing.of() - private var formattingInstruction: JsonField = JsonMissing.of() - private var gpt4oApiKey: JsonField = JsonMissing.of() - private var gpt4oMode: JsonField = JsonMissing.of() - private var guessXlsxSheetName: JsonField = JsonMissing.of() - private var hideFooters: JsonField = JsonMissing.of() - private var hideHeaders: JsonField = JsonMissing.of() - private var highResOcr: JsonField = JsonMissing.of() - private var htmlMakeAllElementsVisible: JsonField = JsonMissing.of() - private var htmlRemoveFixedElements: JsonField = JsonMissing.of() - private var htmlRemoveNavigationElements: JsonField = JsonMissing.of() - private var httpProxy: JsonField = JsonMissing.of() - private var ignoreDocumentElementsForLayoutDetection: JsonField = - JsonMissing.of() - private var imagesToSave: JsonField>? = null - private var inlineImagesInMarkdown: JsonField = JsonMissing.of() - private var inputS3Path: JsonField = JsonMissing.of() - private var inputS3Region: JsonField = JsonMissing.of() - private var inputUrl: JsonField = JsonMissing.of() - private var internalIsScreenshotJob: JsonField = JsonMissing.of() - private var invalidateCache: JsonField = JsonMissing.of() - private var isFormattingInstruction: JsonField = JsonMissing.of() - private var jobTimeoutExtraTimePerPageInSeconds: JsonField = - JsonMissing.of() - private var jobTimeoutInSeconds: JsonField = JsonMissing.of() - private var keepPageSeparatorWhenMergingTables: JsonField = - JsonMissing.of() - private var lang: JsonField = JsonMissing.of() - private var languages: JsonField>? = null - private var layoutAware: JsonField = JsonMissing.of() - private var lineLevelBoundingBox: JsonField = JsonMissing.of() - private var markdownTableMultilineHeaderSeparator: JsonField = - JsonMissing.of() - private var maxPages: JsonField = JsonMissing.of() - private var maxPagesEnforced: JsonField = JsonMissing.of() - private var mergeTablesAcrossPagesInMarkdown: JsonField = - JsonMissing.of() - private var model: JsonField = JsonMissing.of() - private var outlinedTableExtraction: JsonField = JsonMissing.of() - private var outputPdfOfDocument: JsonField = JsonMissing.of() - private var outputS3PathPrefix: JsonField = JsonMissing.of() - private var outputS3Region: JsonField = JsonMissing.of() - private var outputTablesAsHtml: JsonField = JsonMissing.of() - private var outputBucket: JsonField = JsonMissing.of() - private var pageErrorTolerance: JsonField = JsonMissing.of() - private var pageFooterPrefix: JsonField = JsonMissing.of() - private var pageFooterSuffix: JsonField = JsonMissing.of() - private var pageHeaderPrefix: JsonField = JsonMissing.of() - private var pageHeaderSuffix: JsonField = JsonMissing.of() - private var pagePrefix: JsonField = JsonMissing.of() - private var pageSeparator: JsonField = JsonMissing.of() - private var pageSuffix: JsonField = JsonMissing.of() - private var parseMode: JsonField = JsonMissing.of() - private var parsingInstruction: JsonField = JsonMissing.of() - private var pipelineId: JsonField = JsonMissing.of() - private var preciseBoundingBox: JsonField = JsonMissing.of() - private var premiumMode: JsonField = JsonMissing.of() - private var presentationOutOfBoundsContent: JsonField = - JsonMissing.of() - private var presentationSkipEmbeddedData: JsonField = JsonMissing.of() - private var preserveLayoutAlignmentAcrossPages: JsonField = - JsonMissing.of() - private var preserveVerySmallText: JsonField = JsonMissing.of() - private var preset: JsonField = JsonMissing.of() - private var priority: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var removeHiddenText: JsonField = JsonMissing.of() - private var replaceFailedPageMode: JsonField = JsonMissing.of() - private var replaceFailedPageWithErrorMessagePrefix: JsonField = - JsonMissing.of() - private var replaceFailedPageWithErrorMessageSuffix: JsonField = - JsonMissing.of() - private var resourceInfo: JsonField = JsonMissing.of() - private var saveImages: JsonField = JsonMissing.of() - private var skipDiagonalText: JsonField = JsonMissing.of() - private var specializedChartParsingAgentic: JsonField = - JsonMissing.of() - private var specializedChartParsingEfficient: JsonField = - JsonMissing.of() - private var specializedChartParsingPlus: JsonField = JsonMissing.of() - private var specializedImageParsing: JsonField = JsonMissing.of() - private var spreadsheetExtractSubTables: JsonField = JsonMissing.of() - private var spreadsheetForceFormulaComputation: JsonField = - JsonMissing.of() - private var spreadsheetIncludeHiddenSheets: JsonField = - JsonMissing.of() - private var strictModeBuggyFont: JsonField = JsonMissing.of() - private var strictModeImageExtraction: JsonField = JsonMissing.of() - private var strictModeImageOcr: JsonField = JsonMissing.of() - private var strictModeReconstruction: JsonField = JsonMissing.of() - private var structuredOutput: JsonField = JsonMissing.of() - private var structuredOutputJsonSchema: JsonField = JsonMissing.of() - private var structuredOutputJsonSchemaName: JsonField = JsonMissing.of() - private var systemPrompt: JsonField = JsonMissing.of() - private var systemPromptAppend: JsonField = JsonMissing.of() - private var takeScreenshot: JsonField = JsonMissing.of() - private var targetPages: JsonField = JsonMissing.of() - private var tier: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var useVendorMultimodalModel: JsonField = JsonMissing.of() - private var userPrompt: JsonField = JsonMissing.of() - private var vendorMultimodalApiKey: JsonField = JsonMissing.of() - private var vendorMultimodalModelName: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var webhookConfigurations: - JsonField>? = - null - private var webhookUrl: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(parameters: Parameters) = apply { - adaptiveLongTable = parameters.adaptiveLongTable - aggressiveTableExtraction = parameters.aggressiveTableExtraction - annotateLinks = parameters.annotateLinks - annotateRevisions = parameters.annotateRevisions - autoMode = parameters.autoMode - autoModeConfigurationJson = parameters.autoModeConfigurationJson - autoModeTriggerOnImageInPage = parameters.autoModeTriggerOnImageInPage - autoModeTriggerOnRegexpInPage = parameters.autoModeTriggerOnRegexpInPage - autoModeTriggerOnTableInPage = parameters.autoModeTriggerOnTableInPage - autoModeTriggerOnTextInPage = parameters.autoModeTriggerOnTextInPage - azureOpenAIApiVersion = parameters.azureOpenAIApiVersion - azureOpenAIDeploymentName = parameters.azureOpenAIDeploymentName - azureOpenAIEndpoint = parameters.azureOpenAIEndpoint - azureOpenAIKey = parameters.azureOpenAIKey - bboxBottom = parameters.bboxBottom - bboxLeft = parameters.bboxLeft - bboxRight = parameters.bboxRight - bboxTop = parameters.bboxTop - boundingBox = parameters.boundingBox - compactMarkdownTable = parameters.compactMarkdownTable - complementalFormattingInstruction = - parameters.complementalFormattingInstruction - confidenceScoreEffort = parameters.confidenceScoreEffort - contentGuidelineInstruction = parameters.contentGuidelineInstruction - continuousMode = parameters.continuousMode - customMetadata = parameters.customMetadata - disableImageExtraction = parameters.disableImageExtraction - disableOcr = parameters.disableOcr - disableReconstruction = parameters.disableReconstruction - doNotCache = parameters.doNotCache - doNotUnrollColumns = parameters.doNotUnrollColumns - enableCostOptimizer = parameters.enableCostOptimizer - extractCharts = parameters.extractCharts - extractLayout = parameters.extractLayout - extractPrintedPageNumber = parameters.extractPrintedPageNumber - fastMode = parameters.fastMode - formattingInstruction = parameters.formattingInstruction - gpt4oApiKey = parameters.gpt4oApiKey - gpt4oMode = parameters.gpt4oMode - guessXlsxSheetName = parameters.guessXlsxSheetName - hideFooters = parameters.hideFooters - hideHeaders = parameters.hideHeaders - highResOcr = parameters.highResOcr - htmlMakeAllElementsVisible = parameters.htmlMakeAllElementsVisible - htmlRemoveFixedElements = parameters.htmlRemoveFixedElements - htmlRemoveNavigationElements = parameters.htmlRemoveNavigationElements - httpProxy = parameters.httpProxy - ignoreDocumentElementsForLayoutDetection = - parameters.ignoreDocumentElementsForLayoutDetection - imagesToSave = parameters.imagesToSave.map { it.toMutableList() } - inlineImagesInMarkdown = parameters.inlineImagesInMarkdown - inputS3Path = parameters.inputS3Path - inputS3Region = parameters.inputS3Region - inputUrl = parameters.inputUrl - internalIsScreenshotJob = parameters.internalIsScreenshotJob - invalidateCache = parameters.invalidateCache - isFormattingInstruction = parameters.isFormattingInstruction - jobTimeoutExtraTimePerPageInSeconds = - parameters.jobTimeoutExtraTimePerPageInSeconds - jobTimeoutInSeconds = parameters.jobTimeoutInSeconds - keepPageSeparatorWhenMergingTables = - parameters.keepPageSeparatorWhenMergingTables - lang = parameters.lang - languages = parameters.languages.map { it.toMutableList() } - layoutAware = parameters.layoutAware - lineLevelBoundingBox = parameters.lineLevelBoundingBox - markdownTableMultilineHeaderSeparator = - parameters.markdownTableMultilineHeaderSeparator - maxPages = parameters.maxPages - maxPagesEnforced = parameters.maxPagesEnforced - mergeTablesAcrossPagesInMarkdown = - parameters.mergeTablesAcrossPagesInMarkdown - model = parameters.model - outlinedTableExtraction = parameters.outlinedTableExtraction - outputPdfOfDocument = parameters.outputPdfOfDocument - outputS3PathPrefix = parameters.outputS3PathPrefix - outputS3Region = parameters.outputS3Region - outputTablesAsHtml = parameters.outputTablesAsHtml - outputBucket = parameters.outputBucket - pageErrorTolerance = parameters.pageErrorTolerance - pageFooterPrefix = parameters.pageFooterPrefix - pageFooterSuffix = parameters.pageFooterSuffix - pageHeaderPrefix = parameters.pageHeaderPrefix - pageHeaderSuffix = parameters.pageHeaderSuffix - pagePrefix = parameters.pagePrefix - pageSeparator = parameters.pageSeparator - pageSuffix = parameters.pageSuffix - parseMode = parameters.parseMode - parsingInstruction = parameters.parsingInstruction - pipelineId = parameters.pipelineId - preciseBoundingBox = parameters.preciseBoundingBox - premiumMode = parameters.premiumMode - presentationOutOfBoundsContent = parameters.presentationOutOfBoundsContent - presentationSkipEmbeddedData = parameters.presentationSkipEmbeddedData - preserveLayoutAlignmentAcrossPages = - parameters.preserveLayoutAlignmentAcrossPages - preserveVerySmallText = parameters.preserveVerySmallText - preset = parameters.preset - priority = parameters.priority - projectId = parameters.projectId - removeHiddenText = parameters.removeHiddenText - replaceFailedPageMode = parameters.replaceFailedPageMode - replaceFailedPageWithErrorMessagePrefix = - parameters.replaceFailedPageWithErrorMessagePrefix - replaceFailedPageWithErrorMessageSuffix = - parameters.replaceFailedPageWithErrorMessageSuffix - resourceInfo = parameters.resourceInfo - saveImages = parameters.saveImages - skipDiagonalText = parameters.skipDiagonalText - specializedChartParsingAgentic = parameters.specializedChartParsingAgentic - specializedChartParsingEfficient = - parameters.specializedChartParsingEfficient - specializedChartParsingPlus = parameters.specializedChartParsingPlus - specializedImageParsing = parameters.specializedImageParsing - spreadsheetExtractSubTables = parameters.spreadsheetExtractSubTables - spreadsheetForceFormulaComputation = - parameters.spreadsheetForceFormulaComputation - spreadsheetIncludeHiddenSheets = parameters.spreadsheetIncludeHiddenSheets - strictModeBuggyFont = parameters.strictModeBuggyFont - strictModeImageExtraction = parameters.strictModeImageExtraction - strictModeImageOcr = parameters.strictModeImageOcr - strictModeReconstruction = parameters.strictModeReconstruction - structuredOutput = parameters.structuredOutput - structuredOutputJsonSchema = parameters.structuredOutputJsonSchema - structuredOutputJsonSchemaName = parameters.structuredOutputJsonSchemaName - systemPrompt = parameters.systemPrompt - systemPromptAppend = parameters.systemPromptAppend - takeScreenshot = parameters.takeScreenshot - targetPages = parameters.targetPages - tier = parameters.tier - type = parameters.type - useVendorMultimodalModel = parameters.useVendorMultimodalModel - userPrompt = parameters.userPrompt - vendorMultimodalApiKey = parameters.vendorMultimodalApiKey - vendorMultimodalModelName = parameters.vendorMultimodalModelName - version = parameters.version - webhookConfigurations = - parameters.webhookConfigurations.map { it.toMutableList() } - webhookUrl = parameters.webhookUrl - additionalProperties = parameters.additionalProperties.toMutableMap() - } - - fun adaptiveLongTable(adaptiveLongTable: Boolean?) = - adaptiveLongTable(JsonField.ofNullable(adaptiveLongTable)) - - /** - * Alias for [Builder.adaptiveLongTable]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun adaptiveLongTable(adaptiveLongTable: Boolean) = - adaptiveLongTable(adaptiveLongTable as Boolean?) - - /** - * Alias for calling [Builder.adaptiveLongTable] with - * `adaptiveLongTable.orElse(null)`. - */ - fun adaptiveLongTable(adaptiveLongTable: Optional) = - adaptiveLongTable(adaptiveLongTable.getOrNull()) - - /** - * Sets [Builder.adaptiveLongTable] to an arbitrary JSON value. - * - * You should usually call [Builder.adaptiveLongTable] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun adaptiveLongTable(adaptiveLongTable: JsonField) = apply { - this.adaptiveLongTable = adaptiveLongTable - } - - fun aggressiveTableExtraction(aggressiveTableExtraction: Boolean?) = - aggressiveTableExtraction(JsonField.ofNullable(aggressiveTableExtraction)) - - /** - * Alias for [Builder.aggressiveTableExtraction]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun aggressiveTableExtraction(aggressiveTableExtraction: Boolean) = - aggressiveTableExtraction(aggressiveTableExtraction as Boolean?) - - /** - * Alias for calling [Builder.aggressiveTableExtraction] with - * `aggressiveTableExtraction.orElse(null)`. - */ - fun aggressiveTableExtraction(aggressiveTableExtraction: Optional) = - aggressiveTableExtraction(aggressiveTableExtraction.getOrNull()) - - /** - * Sets [Builder.aggressiveTableExtraction] to an arbitrary JSON value. - * - * You should usually call [Builder.aggressiveTableExtraction] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun aggressiveTableExtraction(aggressiveTableExtraction: JsonField) = - apply { - this.aggressiveTableExtraction = aggressiveTableExtraction - } - - fun annotateLinks(annotateLinks: Boolean?) = - annotateLinks(JsonField.ofNullable(annotateLinks)) - - /** - * Alias for [Builder.annotateLinks]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun annotateLinks(annotateLinks: Boolean) = - annotateLinks(annotateLinks as Boolean?) - - /** - * Alias for calling [Builder.annotateLinks] with `annotateLinks.orElse(null)`. - */ - fun annotateLinks(annotateLinks: Optional) = - annotateLinks(annotateLinks.getOrNull()) - - /** - * Sets [Builder.annotateLinks] to an arbitrary JSON value. - * - * You should usually call [Builder.annotateLinks] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun annotateLinks(annotateLinks: JsonField) = apply { - this.annotateLinks = annotateLinks - } - - fun annotateRevisions(annotateRevisions: Boolean?) = - annotateRevisions(JsonField.ofNullable(annotateRevisions)) - - /** - * Alias for [Builder.annotateRevisions]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun annotateRevisions(annotateRevisions: Boolean) = - annotateRevisions(annotateRevisions as Boolean?) - - /** - * Alias for calling [Builder.annotateRevisions] with - * `annotateRevisions.orElse(null)`. - */ - fun annotateRevisions(annotateRevisions: Optional) = - annotateRevisions(annotateRevisions.getOrNull()) - - /** - * Sets [Builder.annotateRevisions] to an arbitrary JSON value. - * - * You should usually call [Builder.annotateRevisions] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun annotateRevisions(annotateRevisions: JsonField) = apply { - this.annotateRevisions = annotateRevisions - } - - fun autoMode(autoMode: Boolean?) = autoMode(JsonField.ofNullable(autoMode)) - - /** - * Alias for [Builder.autoMode]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun autoMode(autoMode: Boolean) = autoMode(autoMode as Boolean?) - - /** Alias for calling [Builder.autoMode] with `autoMode.orElse(null)`. */ - fun autoMode(autoMode: Optional) = autoMode(autoMode.getOrNull()) - - /** - * Sets [Builder.autoMode] to an arbitrary JSON value. - * - * You should usually call [Builder.autoMode] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun autoMode(autoMode: JsonField) = apply { this.autoMode = autoMode } - - fun autoModeConfigurationJson(autoModeConfigurationJson: String?) = - autoModeConfigurationJson(JsonField.ofNullable(autoModeConfigurationJson)) - - /** - * Alias for calling [Builder.autoModeConfigurationJson] with - * `autoModeConfigurationJson.orElse(null)`. - */ - fun autoModeConfigurationJson(autoModeConfigurationJson: Optional) = - autoModeConfigurationJson(autoModeConfigurationJson.getOrNull()) - - /** - * Sets [Builder.autoModeConfigurationJson] to an arbitrary JSON value. - * - * You should usually call [Builder.autoModeConfigurationJson] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun autoModeConfigurationJson(autoModeConfigurationJson: JsonField) = - apply { - this.autoModeConfigurationJson = autoModeConfigurationJson - } - - fun autoModeTriggerOnImageInPage(autoModeTriggerOnImageInPage: Boolean?) = - autoModeTriggerOnImageInPage( - JsonField.ofNullable(autoModeTriggerOnImageInPage) - ) - - /** - * Alias for [Builder.autoModeTriggerOnImageInPage]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun autoModeTriggerOnImageInPage(autoModeTriggerOnImageInPage: Boolean) = - autoModeTriggerOnImageInPage(autoModeTriggerOnImageInPage as Boolean?) - - /** - * Alias for calling [Builder.autoModeTriggerOnImageInPage] with - * `autoModeTriggerOnImageInPage.orElse(null)`. - */ - fun autoModeTriggerOnImageInPage( - autoModeTriggerOnImageInPage: Optional - ) = autoModeTriggerOnImageInPage(autoModeTriggerOnImageInPage.getOrNull()) - - /** - * Sets [Builder.autoModeTriggerOnImageInPage] to an arbitrary JSON value. - * - * You should usually call [Builder.autoModeTriggerOnImageInPage] with a - * well-typed [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun autoModeTriggerOnImageInPage( - autoModeTriggerOnImageInPage: JsonField - ) = apply { this.autoModeTriggerOnImageInPage = autoModeTriggerOnImageInPage } - - fun autoModeTriggerOnRegexpInPage(autoModeTriggerOnRegexpInPage: String?) = - autoModeTriggerOnRegexpInPage( - JsonField.ofNullable(autoModeTriggerOnRegexpInPage) - ) - - /** - * Alias for calling [Builder.autoModeTriggerOnRegexpInPage] with - * `autoModeTriggerOnRegexpInPage.orElse(null)`. - */ - fun autoModeTriggerOnRegexpInPage( - autoModeTriggerOnRegexpInPage: Optional - ) = autoModeTriggerOnRegexpInPage(autoModeTriggerOnRegexpInPage.getOrNull()) - - /** - * Sets [Builder.autoModeTriggerOnRegexpInPage] to an arbitrary JSON value. - * - * You should usually call [Builder.autoModeTriggerOnRegexpInPage] with a - * well-typed [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun autoModeTriggerOnRegexpInPage( - autoModeTriggerOnRegexpInPage: JsonField - ) = apply { this.autoModeTriggerOnRegexpInPage = autoModeTriggerOnRegexpInPage } - - fun autoModeTriggerOnTableInPage(autoModeTriggerOnTableInPage: Boolean?) = - autoModeTriggerOnTableInPage( - JsonField.ofNullable(autoModeTriggerOnTableInPage) - ) - - /** - * Alias for [Builder.autoModeTriggerOnTableInPage]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun autoModeTriggerOnTableInPage(autoModeTriggerOnTableInPage: Boolean) = - autoModeTriggerOnTableInPage(autoModeTriggerOnTableInPage as Boolean?) - - /** - * Alias for calling [Builder.autoModeTriggerOnTableInPage] with - * `autoModeTriggerOnTableInPage.orElse(null)`. - */ - fun autoModeTriggerOnTableInPage( - autoModeTriggerOnTableInPage: Optional - ) = autoModeTriggerOnTableInPage(autoModeTriggerOnTableInPage.getOrNull()) - - /** - * Sets [Builder.autoModeTriggerOnTableInPage] to an arbitrary JSON value. - * - * You should usually call [Builder.autoModeTriggerOnTableInPage] with a - * well-typed [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun autoModeTriggerOnTableInPage( - autoModeTriggerOnTableInPage: JsonField - ) = apply { this.autoModeTriggerOnTableInPage = autoModeTriggerOnTableInPage } - - fun autoModeTriggerOnTextInPage(autoModeTriggerOnTextInPage: String?) = - autoModeTriggerOnTextInPage( - JsonField.ofNullable(autoModeTriggerOnTextInPage) - ) - - /** - * Alias for calling [Builder.autoModeTriggerOnTextInPage] with - * `autoModeTriggerOnTextInPage.orElse(null)`. - */ - fun autoModeTriggerOnTextInPage(autoModeTriggerOnTextInPage: Optional) = - autoModeTriggerOnTextInPage(autoModeTriggerOnTextInPage.getOrNull()) - - /** - * Sets [Builder.autoModeTriggerOnTextInPage] to an arbitrary JSON value. - * - * You should usually call [Builder.autoModeTriggerOnTextInPage] with a - * well-typed [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun autoModeTriggerOnTextInPage( - autoModeTriggerOnTextInPage: JsonField - ) = apply { this.autoModeTriggerOnTextInPage = autoModeTriggerOnTextInPage } - - fun azureOpenAIApiVersion(azureOpenAIApiVersion: String?) = - azureOpenAIApiVersion(JsonField.ofNullable(azureOpenAIApiVersion)) - - /** - * Alias for calling [Builder.azureOpenAIApiVersion] with - * `azureOpenAIApiVersion.orElse(null)`. - */ - fun azureOpenAIApiVersion(azureOpenAIApiVersion: Optional) = - azureOpenAIApiVersion(azureOpenAIApiVersion.getOrNull()) - - /** - * Sets [Builder.azureOpenAIApiVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.azureOpenAIApiVersion] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun azureOpenAIApiVersion(azureOpenAIApiVersion: JsonField) = apply { - this.azureOpenAIApiVersion = azureOpenAIApiVersion - } - - fun azureOpenAIDeploymentName(azureOpenAIDeploymentName: String?) = - azureOpenAIDeploymentName(JsonField.ofNullable(azureOpenAIDeploymentName)) - - /** - * Alias for calling [Builder.azureOpenAIDeploymentName] with - * `azureOpenAIDeploymentName.orElse(null)`. - */ - fun azureOpenAIDeploymentName(azureOpenAIDeploymentName: Optional) = - azureOpenAIDeploymentName(azureOpenAIDeploymentName.getOrNull()) - - /** - * Sets [Builder.azureOpenAIDeploymentName] to an arbitrary JSON value. - * - * You should usually call [Builder.azureOpenAIDeploymentName] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun azureOpenAIDeploymentName(azureOpenAIDeploymentName: JsonField) = - apply { - this.azureOpenAIDeploymentName = azureOpenAIDeploymentName - } - - fun azureOpenAIEndpoint(azureOpenAIEndpoint: String?) = - azureOpenAIEndpoint(JsonField.ofNullable(azureOpenAIEndpoint)) - - /** - * Alias for calling [Builder.azureOpenAIEndpoint] with - * `azureOpenAIEndpoint.orElse(null)`. - */ - fun azureOpenAIEndpoint(azureOpenAIEndpoint: Optional) = - azureOpenAIEndpoint(azureOpenAIEndpoint.getOrNull()) - - /** - * Sets [Builder.azureOpenAIEndpoint] to an arbitrary JSON value. - * - * You should usually call [Builder.azureOpenAIEndpoint] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun azureOpenAIEndpoint(azureOpenAIEndpoint: JsonField) = apply { - this.azureOpenAIEndpoint = azureOpenAIEndpoint - } - - fun azureOpenAIKey(azureOpenAIKey: String?) = - azureOpenAIKey(JsonField.ofNullable(azureOpenAIKey)) - - /** - * Alias for calling [Builder.azureOpenAIKey] with - * `azureOpenAIKey.orElse(null)`. - */ - fun azureOpenAIKey(azureOpenAIKey: Optional) = - azureOpenAIKey(azureOpenAIKey.getOrNull()) - - /** - * Sets [Builder.azureOpenAIKey] to an arbitrary JSON value. - * - * You should usually call [Builder.azureOpenAIKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun azureOpenAIKey(azureOpenAIKey: JsonField) = apply { - this.azureOpenAIKey = azureOpenAIKey - } - - fun bboxBottom(bboxBottom: Double?) = - bboxBottom(JsonField.ofNullable(bboxBottom)) - - /** - * Alias for [Builder.bboxBottom]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun bboxBottom(bboxBottom: Double) = bboxBottom(bboxBottom as Double?) - - /** Alias for calling [Builder.bboxBottom] with `bboxBottom.orElse(null)`. */ - fun bboxBottom(bboxBottom: Optional) = - bboxBottom(bboxBottom.getOrNull()) - - /** - * Sets [Builder.bboxBottom] to an arbitrary JSON value. - * - * You should usually call [Builder.bboxBottom] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun bboxBottom(bboxBottom: JsonField) = apply { - this.bboxBottom = bboxBottom - } - - fun bboxLeft(bboxLeft: Double?) = bboxLeft(JsonField.ofNullable(bboxLeft)) - - /** - * Alias for [Builder.bboxLeft]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun bboxLeft(bboxLeft: Double) = bboxLeft(bboxLeft as Double?) - - /** Alias for calling [Builder.bboxLeft] with `bboxLeft.orElse(null)`. */ - fun bboxLeft(bboxLeft: Optional) = bboxLeft(bboxLeft.getOrNull()) - - /** - * Sets [Builder.bboxLeft] to an arbitrary JSON value. - * - * You should usually call [Builder.bboxLeft] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun bboxLeft(bboxLeft: JsonField) = apply { this.bboxLeft = bboxLeft } - - fun bboxRight(bboxRight: Double?) = bboxRight(JsonField.ofNullable(bboxRight)) - - /** - * Alias for [Builder.bboxRight]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun bboxRight(bboxRight: Double) = bboxRight(bboxRight as Double?) - - /** Alias for calling [Builder.bboxRight] with `bboxRight.orElse(null)`. */ - fun bboxRight(bboxRight: Optional) = bboxRight(bboxRight.getOrNull()) - - /** - * Sets [Builder.bboxRight] to an arbitrary JSON value. - * - * You should usually call [Builder.bboxRight] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun bboxRight(bboxRight: JsonField) = apply { - this.bboxRight = bboxRight - } - - fun bboxTop(bboxTop: Double?) = bboxTop(JsonField.ofNullable(bboxTop)) - - /** - * Alias for [Builder.bboxTop]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun bboxTop(bboxTop: Double) = bboxTop(bboxTop as Double?) - - /** Alias for calling [Builder.bboxTop] with `bboxTop.orElse(null)`. */ - fun bboxTop(bboxTop: Optional) = bboxTop(bboxTop.getOrNull()) - - /** - * Sets [Builder.bboxTop] to an arbitrary JSON value. - * - * You should usually call [Builder.bboxTop] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun bboxTop(bboxTop: JsonField) = apply { this.bboxTop = bboxTop } - - fun boundingBox(boundingBox: String?) = - boundingBox(JsonField.ofNullable(boundingBox)) - - /** Alias for calling [Builder.boundingBox] with `boundingBox.orElse(null)`. */ - fun boundingBox(boundingBox: Optional) = - boundingBox(boundingBox.getOrNull()) - - /** - * Sets [Builder.boundingBox] to an arbitrary JSON value. - * - * You should usually call [Builder.boundingBox] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun boundingBox(boundingBox: JsonField) = apply { - this.boundingBox = boundingBox - } - - fun compactMarkdownTable(compactMarkdownTable: Boolean?) = - compactMarkdownTable(JsonField.ofNullable(compactMarkdownTable)) - - /** - * Alias for [Builder.compactMarkdownTable]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun compactMarkdownTable(compactMarkdownTable: Boolean) = - compactMarkdownTable(compactMarkdownTable as Boolean?) - - /** - * Alias for calling [Builder.compactMarkdownTable] with - * `compactMarkdownTable.orElse(null)`. - */ - fun compactMarkdownTable(compactMarkdownTable: Optional) = - compactMarkdownTable(compactMarkdownTable.getOrNull()) - - /** - * Sets [Builder.compactMarkdownTable] to an arbitrary JSON value. - * - * You should usually call [Builder.compactMarkdownTable] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun compactMarkdownTable(compactMarkdownTable: JsonField) = apply { - this.compactMarkdownTable = compactMarkdownTable - } - - fun complementalFormattingInstruction( - complementalFormattingInstruction: String? - ) = - complementalFormattingInstruction( - JsonField.ofNullable(complementalFormattingInstruction) - ) - - /** - * Alias for calling [Builder.complementalFormattingInstruction] with - * `complementalFormattingInstruction.orElse(null)`. - */ - fun complementalFormattingInstruction( - complementalFormattingInstruction: Optional - ) = - complementalFormattingInstruction( - complementalFormattingInstruction.getOrNull() - ) - - /** - * Sets [Builder.complementalFormattingInstruction] to an arbitrary JSON value. - * - * You should usually call [Builder.complementalFormattingInstruction] with a - * well-typed [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun complementalFormattingInstruction( - complementalFormattingInstruction: JsonField - ) = apply { - this.complementalFormattingInstruction = complementalFormattingInstruction - } - - fun confidenceScoreEffort(confidenceScoreEffort: String?) = - confidenceScoreEffort(JsonField.ofNullable(confidenceScoreEffort)) - - /** - * Alias for calling [Builder.confidenceScoreEffort] with - * `confidenceScoreEffort.orElse(null)`. - */ - fun confidenceScoreEffort(confidenceScoreEffort: Optional) = - confidenceScoreEffort(confidenceScoreEffort.getOrNull()) - - /** - * Sets [Builder.confidenceScoreEffort] to an arbitrary JSON value. - * - * You should usually call [Builder.confidenceScoreEffort] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun confidenceScoreEffort(confidenceScoreEffort: JsonField) = apply { - this.confidenceScoreEffort = confidenceScoreEffort - } - - fun contentGuidelineInstruction(contentGuidelineInstruction: String?) = - contentGuidelineInstruction( - JsonField.ofNullable(contentGuidelineInstruction) - ) - - /** - * Alias for calling [Builder.contentGuidelineInstruction] with - * `contentGuidelineInstruction.orElse(null)`. - */ - fun contentGuidelineInstruction(contentGuidelineInstruction: Optional) = - contentGuidelineInstruction(contentGuidelineInstruction.getOrNull()) - - /** - * Sets [Builder.contentGuidelineInstruction] to an arbitrary JSON value. - * - * You should usually call [Builder.contentGuidelineInstruction] with a - * well-typed [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun contentGuidelineInstruction( - contentGuidelineInstruction: JsonField - ) = apply { this.contentGuidelineInstruction = contentGuidelineInstruction } - - fun continuousMode(continuousMode: Boolean?) = - continuousMode(JsonField.ofNullable(continuousMode)) - - /** - * Alias for [Builder.continuousMode]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun continuousMode(continuousMode: Boolean) = - continuousMode(continuousMode as Boolean?) - - /** - * Alias for calling [Builder.continuousMode] with - * `continuousMode.orElse(null)`. - */ - fun continuousMode(continuousMode: Optional) = - continuousMode(continuousMode.getOrNull()) - - /** - * Sets [Builder.continuousMode] to an arbitrary JSON value. - * - * You should usually call [Builder.continuousMode] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun continuousMode(continuousMode: JsonField) = apply { - this.continuousMode = continuousMode - } - - /** The custom metadata to attach to the documents. */ - fun customMetadata(customMetadata: CustomMetadata?) = - customMetadata(JsonField.ofNullable(customMetadata)) - - /** - * Alias for calling [Builder.customMetadata] with - * `customMetadata.orElse(null)`. - */ - fun customMetadata(customMetadata: Optional) = - customMetadata(customMetadata.getOrNull()) - - /** - * Sets [Builder.customMetadata] to an arbitrary JSON value. - * - * You should usually call [Builder.customMetadata] with a well-typed - * [CustomMetadata] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun customMetadata(customMetadata: JsonField) = apply { - this.customMetadata = customMetadata - } - - fun disableImageExtraction(disableImageExtraction: Boolean?) = - disableImageExtraction(JsonField.ofNullable(disableImageExtraction)) - - /** - * Alias for [Builder.disableImageExtraction]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun disableImageExtraction(disableImageExtraction: Boolean) = - disableImageExtraction(disableImageExtraction as Boolean?) - - /** - * Alias for calling [Builder.disableImageExtraction] with - * `disableImageExtraction.orElse(null)`. - */ - fun disableImageExtraction(disableImageExtraction: Optional) = - disableImageExtraction(disableImageExtraction.getOrNull()) - - /** - * Sets [Builder.disableImageExtraction] to an arbitrary JSON value. - * - * You should usually call [Builder.disableImageExtraction] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun disableImageExtraction(disableImageExtraction: JsonField) = apply { - this.disableImageExtraction = disableImageExtraction - } - - fun disableOcr(disableOcr: Boolean?) = - disableOcr(JsonField.ofNullable(disableOcr)) - - /** - * Alias for [Builder.disableOcr]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun disableOcr(disableOcr: Boolean) = disableOcr(disableOcr as Boolean?) - - /** Alias for calling [Builder.disableOcr] with `disableOcr.orElse(null)`. */ - fun disableOcr(disableOcr: Optional) = - disableOcr(disableOcr.getOrNull()) - - /** - * Sets [Builder.disableOcr] to an arbitrary JSON value. - * - * You should usually call [Builder.disableOcr] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun disableOcr(disableOcr: JsonField) = apply { - this.disableOcr = disableOcr - } - - fun disableReconstruction(disableReconstruction: Boolean?) = - disableReconstruction(JsonField.ofNullable(disableReconstruction)) - - /** - * Alias for [Builder.disableReconstruction]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun disableReconstruction(disableReconstruction: Boolean) = - disableReconstruction(disableReconstruction as Boolean?) - - /** - * Alias for calling [Builder.disableReconstruction] with - * `disableReconstruction.orElse(null)`. - */ - fun disableReconstruction(disableReconstruction: Optional) = - disableReconstruction(disableReconstruction.getOrNull()) - - /** - * Sets [Builder.disableReconstruction] to an arbitrary JSON value. - * - * You should usually call [Builder.disableReconstruction] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun disableReconstruction(disableReconstruction: JsonField) = apply { - this.disableReconstruction = disableReconstruction - } - - fun doNotCache(doNotCache: Boolean?) = - doNotCache(JsonField.ofNullable(doNotCache)) - - /** - * Alias for [Builder.doNotCache]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun doNotCache(doNotCache: Boolean) = doNotCache(doNotCache as Boolean?) - - /** Alias for calling [Builder.doNotCache] with `doNotCache.orElse(null)`. */ - fun doNotCache(doNotCache: Optional) = - doNotCache(doNotCache.getOrNull()) - - /** - * Sets [Builder.doNotCache] to an arbitrary JSON value. - * - * You should usually call [Builder.doNotCache] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun doNotCache(doNotCache: JsonField) = apply { - this.doNotCache = doNotCache - } - - fun doNotUnrollColumns(doNotUnrollColumns: Boolean?) = - doNotUnrollColumns(JsonField.ofNullable(doNotUnrollColumns)) - - /** - * Alias for [Builder.doNotUnrollColumns]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun doNotUnrollColumns(doNotUnrollColumns: Boolean) = - doNotUnrollColumns(doNotUnrollColumns as Boolean?) - - /** - * Alias for calling [Builder.doNotUnrollColumns] with - * `doNotUnrollColumns.orElse(null)`. - */ - fun doNotUnrollColumns(doNotUnrollColumns: Optional) = - doNotUnrollColumns(doNotUnrollColumns.getOrNull()) - - /** - * Sets [Builder.doNotUnrollColumns] to an arbitrary JSON value. - * - * You should usually call [Builder.doNotUnrollColumns] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun doNotUnrollColumns(doNotUnrollColumns: JsonField) = apply { - this.doNotUnrollColumns = doNotUnrollColumns - } - - fun enableCostOptimizer(enableCostOptimizer: Boolean?) = - enableCostOptimizer(JsonField.ofNullable(enableCostOptimizer)) - - /** - * Alias for [Builder.enableCostOptimizer]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun enableCostOptimizer(enableCostOptimizer: Boolean) = - enableCostOptimizer(enableCostOptimizer as Boolean?) - - /** - * Alias for calling [Builder.enableCostOptimizer] with - * `enableCostOptimizer.orElse(null)`. - */ - fun enableCostOptimizer(enableCostOptimizer: Optional) = - enableCostOptimizer(enableCostOptimizer.getOrNull()) - - /** - * Sets [Builder.enableCostOptimizer] to an arbitrary JSON value. - * - * You should usually call [Builder.enableCostOptimizer] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun enableCostOptimizer(enableCostOptimizer: JsonField) = apply { - this.enableCostOptimizer = enableCostOptimizer - } - - fun extractCharts(extractCharts: Boolean?) = - extractCharts(JsonField.ofNullable(extractCharts)) - - /** - * Alias for [Builder.extractCharts]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun extractCharts(extractCharts: Boolean) = - extractCharts(extractCharts as Boolean?) - - /** - * Alias for calling [Builder.extractCharts] with `extractCharts.orElse(null)`. - */ - fun extractCharts(extractCharts: Optional) = - extractCharts(extractCharts.getOrNull()) - - /** - * Sets [Builder.extractCharts] to an arbitrary JSON value. - * - * You should usually call [Builder.extractCharts] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun extractCharts(extractCharts: JsonField) = apply { - this.extractCharts = extractCharts - } - - fun extractLayout(extractLayout: Boolean?) = - extractLayout(JsonField.ofNullable(extractLayout)) - - /** - * Alias for [Builder.extractLayout]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun extractLayout(extractLayout: Boolean) = - extractLayout(extractLayout as Boolean?) - - /** - * Alias for calling [Builder.extractLayout] with `extractLayout.orElse(null)`. - */ - fun extractLayout(extractLayout: Optional) = - extractLayout(extractLayout.getOrNull()) - - /** - * Sets [Builder.extractLayout] to an arbitrary JSON value. - * - * You should usually call [Builder.extractLayout] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun extractLayout(extractLayout: JsonField) = apply { - this.extractLayout = extractLayout - } - - fun extractPrintedPageNumber(extractPrintedPageNumber: Boolean?) = - extractPrintedPageNumber(JsonField.ofNullable(extractPrintedPageNumber)) - - /** - * Alias for [Builder.extractPrintedPageNumber]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun extractPrintedPageNumber(extractPrintedPageNumber: Boolean) = - extractPrintedPageNumber(extractPrintedPageNumber as Boolean?) - - /** - * Alias for calling [Builder.extractPrintedPageNumber] with - * `extractPrintedPageNumber.orElse(null)`. - */ - fun extractPrintedPageNumber(extractPrintedPageNumber: Optional) = - extractPrintedPageNumber(extractPrintedPageNumber.getOrNull()) - - /** - * Sets [Builder.extractPrintedPageNumber] to an arbitrary JSON value. - * - * You should usually call [Builder.extractPrintedPageNumber] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun extractPrintedPageNumber(extractPrintedPageNumber: JsonField) = - apply { - this.extractPrintedPageNumber = extractPrintedPageNumber - } - - fun fastMode(fastMode: Boolean?) = fastMode(JsonField.ofNullable(fastMode)) - - /** - * Alias for [Builder.fastMode]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fastMode(fastMode: Boolean) = fastMode(fastMode as Boolean?) - - /** Alias for calling [Builder.fastMode] with `fastMode.orElse(null)`. */ - fun fastMode(fastMode: Optional) = fastMode(fastMode.getOrNull()) - - /** - * Sets [Builder.fastMode] to an arbitrary JSON value. - * - * You should usually call [Builder.fastMode] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun fastMode(fastMode: JsonField) = apply { this.fastMode = fastMode } - - fun formattingInstruction(formattingInstruction: String?) = - formattingInstruction(JsonField.ofNullable(formattingInstruction)) - - /** - * Alias for calling [Builder.formattingInstruction] with - * `formattingInstruction.orElse(null)`. - */ - fun formattingInstruction(formattingInstruction: Optional) = - formattingInstruction(formattingInstruction.getOrNull()) - - /** - * Sets [Builder.formattingInstruction] to an arbitrary JSON value. - * - * You should usually call [Builder.formattingInstruction] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun formattingInstruction(formattingInstruction: JsonField) = apply { - this.formattingInstruction = formattingInstruction - } - - fun gpt4oApiKey(gpt4oApiKey: String?) = - gpt4oApiKey(JsonField.ofNullable(gpt4oApiKey)) - - /** Alias for calling [Builder.gpt4oApiKey] with `gpt4oApiKey.orElse(null)`. */ - fun gpt4oApiKey(gpt4oApiKey: Optional) = - gpt4oApiKey(gpt4oApiKey.getOrNull()) - - /** - * Sets [Builder.gpt4oApiKey] to an arbitrary JSON value. - * - * You should usually call [Builder.gpt4oApiKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun gpt4oApiKey(gpt4oApiKey: JsonField) = apply { - this.gpt4oApiKey = gpt4oApiKey - } - - fun gpt4oMode(gpt4oMode: Boolean?) = gpt4oMode(JsonField.ofNullable(gpt4oMode)) - - /** - * Alias for [Builder.gpt4oMode]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun gpt4oMode(gpt4oMode: Boolean) = gpt4oMode(gpt4oMode as Boolean?) - - /** Alias for calling [Builder.gpt4oMode] with `gpt4oMode.orElse(null)`. */ - fun gpt4oMode(gpt4oMode: Optional) = gpt4oMode(gpt4oMode.getOrNull()) - - /** - * Sets [Builder.gpt4oMode] to an arbitrary JSON value. - * - * You should usually call [Builder.gpt4oMode] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun gpt4oMode(gpt4oMode: JsonField) = apply { - this.gpt4oMode = gpt4oMode - } - - fun guessXlsxSheetName(guessXlsxSheetName: Boolean?) = - guessXlsxSheetName(JsonField.ofNullable(guessXlsxSheetName)) - - /** - * Alias for [Builder.guessXlsxSheetName]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun guessXlsxSheetName(guessXlsxSheetName: Boolean) = - guessXlsxSheetName(guessXlsxSheetName as Boolean?) - - /** - * Alias for calling [Builder.guessXlsxSheetName] with - * `guessXlsxSheetName.orElse(null)`. - */ - fun guessXlsxSheetName(guessXlsxSheetName: Optional) = - guessXlsxSheetName(guessXlsxSheetName.getOrNull()) - - /** - * Sets [Builder.guessXlsxSheetName] to an arbitrary JSON value. - * - * You should usually call [Builder.guessXlsxSheetName] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun guessXlsxSheetName(guessXlsxSheetName: JsonField) = apply { - this.guessXlsxSheetName = guessXlsxSheetName - } - - fun hideFooters(hideFooters: Boolean?) = - hideFooters(JsonField.ofNullable(hideFooters)) - - /** - * Alias for [Builder.hideFooters]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun hideFooters(hideFooters: Boolean) = hideFooters(hideFooters as Boolean?) - - /** Alias for calling [Builder.hideFooters] with `hideFooters.orElse(null)`. */ - fun hideFooters(hideFooters: Optional) = - hideFooters(hideFooters.getOrNull()) - - /** - * Sets [Builder.hideFooters] to an arbitrary JSON value. - * - * You should usually call [Builder.hideFooters] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun hideFooters(hideFooters: JsonField) = apply { - this.hideFooters = hideFooters - } - - fun hideHeaders(hideHeaders: Boolean?) = - hideHeaders(JsonField.ofNullable(hideHeaders)) - - /** - * Alias for [Builder.hideHeaders]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun hideHeaders(hideHeaders: Boolean) = hideHeaders(hideHeaders as Boolean?) - - /** Alias for calling [Builder.hideHeaders] with `hideHeaders.orElse(null)`. */ - fun hideHeaders(hideHeaders: Optional) = - hideHeaders(hideHeaders.getOrNull()) - - /** - * Sets [Builder.hideHeaders] to an arbitrary JSON value. - * - * You should usually call [Builder.hideHeaders] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun hideHeaders(hideHeaders: JsonField) = apply { - this.hideHeaders = hideHeaders - } - - fun highResOcr(highResOcr: Boolean?) = - highResOcr(JsonField.ofNullable(highResOcr)) - - /** - * Alias for [Builder.highResOcr]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun highResOcr(highResOcr: Boolean) = highResOcr(highResOcr as Boolean?) - - /** Alias for calling [Builder.highResOcr] with `highResOcr.orElse(null)`. */ - fun highResOcr(highResOcr: Optional) = - highResOcr(highResOcr.getOrNull()) - - /** - * Sets [Builder.highResOcr] to an arbitrary JSON value. - * - * You should usually call [Builder.highResOcr] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun highResOcr(highResOcr: JsonField) = apply { - this.highResOcr = highResOcr - } - - fun htmlMakeAllElementsVisible(htmlMakeAllElementsVisible: Boolean?) = - htmlMakeAllElementsVisible(JsonField.ofNullable(htmlMakeAllElementsVisible)) - - /** - * Alias for [Builder.htmlMakeAllElementsVisible]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun htmlMakeAllElementsVisible(htmlMakeAllElementsVisible: Boolean) = - htmlMakeAllElementsVisible(htmlMakeAllElementsVisible as Boolean?) - - /** - * Alias for calling [Builder.htmlMakeAllElementsVisible] with - * `htmlMakeAllElementsVisible.orElse(null)`. - */ - fun htmlMakeAllElementsVisible(htmlMakeAllElementsVisible: Optional) = - htmlMakeAllElementsVisible(htmlMakeAllElementsVisible.getOrNull()) - - /** - * Sets [Builder.htmlMakeAllElementsVisible] to an arbitrary JSON value. - * - * You should usually call [Builder.htmlMakeAllElementsVisible] with a - * well-typed [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun htmlMakeAllElementsVisible(htmlMakeAllElementsVisible: JsonField) = - apply { - this.htmlMakeAllElementsVisible = htmlMakeAllElementsVisible - } - - fun htmlRemoveFixedElements(htmlRemoveFixedElements: Boolean?) = - htmlRemoveFixedElements(JsonField.ofNullable(htmlRemoveFixedElements)) - - /** - * Alias for [Builder.htmlRemoveFixedElements]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun htmlRemoveFixedElements(htmlRemoveFixedElements: Boolean) = - htmlRemoveFixedElements(htmlRemoveFixedElements as Boolean?) - - /** - * Alias for calling [Builder.htmlRemoveFixedElements] with - * `htmlRemoveFixedElements.orElse(null)`. - */ - fun htmlRemoveFixedElements(htmlRemoveFixedElements: Optional) = - htmlRemoveFixedElements(htmlRemoveFixedElements.getOrNull()) - - /** - * Sets [Builder.htmlRemoveFixedElements] to an arbitrary JSON value. - * - * You should usually call [Builder.htmlRemoveFixedElements] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun htmlRemoveFixedElements(htmlRemoveFixedElements: JsonField) = - apply { - this.htmlRemoveFixedElements = htmlRemoveFixedElements - } - - fun htmlRemoveNavigationElements(htmlRemoveNavigationElements: Boolean?) = - htmlRemoveNavigationElements( - JsonField.ofNullable(htmlRemoveNavigationElements) - ) - - /** - * Alias for [Builder.htmlRemoveNavigationElements]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun htmlRemoveNavigationElements(htmlRemoveNavigationElements: Boolean) = - htmlRemoveNavigationElements(htmlRemoveNavigationElements as Boolean?) - - /** - * Alias for calling [Builder.htmlRemoveNavigationElements] with - * `htmlRemoveNavigationElements.orElse(null)`. - */ - fun htmlRemoveNavigationElements( - htmlRemoveNavigationElements: Optional - ) = htmlRemoveNavigationElements(htmlRemoveNavigationElements.getOrNull()) - - /** - * Sets [Builder.htmlRemoveNavigationElements] to an arbitrary JSON value. - * - * You should usually call [Builder.htmlRemoveNavigationElements] with a - * well-typed [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun htmlRemoveNavigationElements( - htmlRemoveNavigationElements: JsonField - ) = apply { this.htmlRemoveNavigationElements = htmlRemoveNavigationElements } - - fun httpProxy(httpProxy: String?) = httpProxy(JsonField.ofNullable(httpProxy)) - - /** Alias for calling [Builder.httpProxy] with `httpProxy.orElse(null)`. */ - fun httpProxy(httpProxy: Optional) = httpProxy(httpProxy.getOrNull()) - - /** - * Sets [Builder.httpProxy] to an arbitrary JSON value. - * - * You should usually call [Builder.httpProxy] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun httpProxy(httpProxy: JsonField) = apply { - this.httpProxy = httpProxy - } - - fun ignoreDocumentElementsForLayoutDetection( - ignoreDocumentElementsForLayoutDetection: Boolean? - ) = - ignoreDocumentElementsForLayoutDetection( - JsonField.ofNullable(ignoreDocumentElementsForLayoutDetection) - ) - - /** - * Alias for [Builder.ignoreDocumentElementsForLayoutDetection]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun ignoreDocumentElementsForLayoutDetection( - ignoreDocumentElementsForLayoutDetection: Boolean - ) = - ignoreDocumentElementsForLayoutDetection( - ignoreDocumentElementsForLayoutDetection as Boolean? - ) - - /** - * Alias for calling [Builder.ignoreDocumentElementsForLayoutDetection] with - * `ignoreDocumentElementsForLayoutDetection.orElse(null)`. - */ - fun ignoreDocumentElementsForLayoutDetection( - ignoreDocumentElementsForLayoutDetection: Optional - ) = - ignoreDocumentElementsForLayoutDetection( - ignoreDocumentElementsForLayoutDetection.getOrNull() - ) - - /** - * Sets [Builder.ignoreDocumentElementsForLayoutDetection] to an arbitrary JSON - * value. - * - * You should usually call [Builder.ignoreDocumentElementsForLayoutDetection] - * with a well-typed [Boolean] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun ignoreDocumentElementsForLayoutDetection( - ignoreDocumentElementsForLayoutDetection: JsonField - ) = apply { - this.ignoreDocumentElementsForLayoutDetection = - ignoreDocumentElementsForLayoutDetection - } - - fun imagesToSave(imagesToSave: List?) = - imagesToSave(JsonField.ofNullable(imagesToSave)) - - /** - * Alias for calling [Builder.imagesToSave] with `imagesToSave.orElse(null)`. - */ - fun imagesToSave(imagesToSave: Optional>) = - imagesToSave(imagesToSave.getOrNull()) - - /** - * Sets [Builder.imagesToSave] to an arbitrary JSON value. - * - * You should usually call [Builder.imagesToSave] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun imagesToSave(imagesToSave: JsonField>) = apply { - this.imagesToSave = imagesToSave.map { it.toMutableList() } - } - - /** - * Adds a single [ImagesToSave] to [Builder.imagesToSave]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addImagesToSave(imagesToSave: ImagesToSave) = apply { - this.imagesToSave = - (this.imagesToSave ?: JsonField.of(mutableListOf())).also { - checkKnown("imagesToSave", it).add(imagesToSave) - } - } - - fun inlineImagesInMarkdown(inlineImagesInMarkdown: Boolean?) = - inlineImagesInMarkdown(JsonField.ofNullable(inlineImagesInMarkdown)) - - /** - * Alias for [Builder.inlineImagesInMarkdown]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun inlineImagesInMarkdown(inlineImagesInMarkdown: Boolean) = - inlineImagesInMarkdown(inlineImagesInMarkdown as Boolean?) - - /** - * Alias for calling [Builder.inlineImagesInMarkdown] with - * `inlineImagesInMarkdown.orElse(null)`. - */ - fun inlineImagesInMarkdown(inlineImagesInMarkdown: Optional) = - inlineImagesInMarkdown(inlineImagesInMarkdown.getOrNull()) - - /** - * Sets [Builder.inlineImagesInMarkdown] to an arbitrary JSON value. - * - * You should usually call [Builder.inlineImagesInMarkdown] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun inlineImagesInMarkdown(inlineImagesInMarkdown: JsonField) = apply { - this.inlineImagesInMarkdown = inlineImagesInMarkdown - } - - fun inputS3Path(inputS3Path: String?) = - inputS3Path(JsonField.ofNullable(inputS3Path)) - - /** Alias for calling [Builder.inputS3Path] with `inputS3Path.orElse(null)`. */ - fun inputS3Path(inputS3Path: Optional) = - inputS3Path(inputS3Path.getOrNull()) - - /** - * Sets [Builder.inputS3Path] to an arbitrary JSON value. - * - * You should usually call [Builder.inputS3Path] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun inputS3Path(inputS3Path: JsonField) = apply { - this.inputS3Path = inputS3Path - } - - /** The region for the input S3 bucket. */ - fun inputS3Region(inputS3Region: String?) = - inputS3Region(JsonField.ofNullable(inputS3Region)) - - /** - * Alias for calling [Builder.inputS3Region] with `inputS3Region.orElse(null)`. - */ - fun inputS3Region(inputS3Region: Optional) = - inputS3Region(inputS3Region.getOrNull()) - - /** - * Sets [Builder.inputS3Region] to an arbitrary JSON value. - * - * You should usually call [Builder.inputS3Region] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun inputS3Region(inputS3Region: JsonField) = apply { - this.inputS3Region = inputS3Region - } - - fun inputUrl(inputUrl: String?) = inputUrl(JsonField.ofNullable(inputUrl)) - - /** Alias for calling [Builder.inputUrl] with `inputUrl.orElse(null)`. */ - fun inputUrl(inputUrl: Optional) = inputUrl(inputUrl.getOrNull()) - - /** - * Sets [Builder.inputUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.inputUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun inputUrl(inputUrl: JsonField) = apply { this.inputUrl = inputUrl } - - fun internalIsScreenshotJob(internalIsScreenshotJob: Boolean?) = - internalIsScreenshotJob(JsonField.ofNullable(internalIsScreenshotJob)) - - /** - * Alias for [Builder.internalIsScreenshotJob]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun internalIsScreenshotJob(internalIsScreenshotJob: Boolean) = - internalIsScreenshotJob(internalIsScreenshotJob as Boolean?) - - /** - * Alias for calling [Builder.internalIsScreenshotJob] with - * `internalIsScreenshotJob.orElse(null)`. - */ - fun internalIsScreenshotJob(internalIsScreenshotJob: Optional) = - internalIsScreenshotJob(internalIsScreenshotJob.getOrNull()) - - /** - * Sets [Builder.internalIsScreenshotJob] to an arbitrary JSON value. - * - * You should usually call [Builder.internalIsScreenshotJob] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun internalIsScreenshotJob(internalIsScreenshotJob: JsonField) = - apply { - this.internalIsScreenshotJob = internalIsScreenshotJob - } - - fun invalidateCache(invalidateCache: Boolean?) = - invalidateCache(JsonField.ofNullable(invalidateCache)) - - /** - * Alias for [Builder.invalidateCache]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun invalidateCache(invalidateCache: Boolean) = - invalidateCache(invalidateCache as Boolean?) - - /** - * Alias for calling [Builder.invalidateCache] with - * `invalidateCache.orElse(null)`. - */ - fun invalidateCache(invalidateCache: Optional) = - invalidateCache(invalidateCache.getOrNull()) - - /** - * 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 - } - - fun isFormattingInstruction(isFormattingInstruction: Boolean?) = - isFormattingInstruction(JsonField.ofNullable(isFormattingInstruction)) - - /** - * Alias for [Builder.isFormattingInstruction]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun isFormattingInstruction(isFormattingInstruction: Boolean) = - isFormattingInstruction(isFormattingInstruction as Boolean?) - - /** - * Alias for calling [Builder.isFormattingInstruction] with - * `isFormattingInstruction.orElse(null)`. - */ - fun isFormattingInstruction(isFormattingInstruction: Optional) = - isFormattingInstruction(isFormattingInstruction.getOrNull()) - - /** - * Sets [Builder.isFormattingInstruction] to an arbitrary JSON value. - * - * You should usually call [Builder.isFormattingInstruction] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun isFormattingInstruction(isFormattingInstruction: JsonField) = - apply { - this.isFormattingInstruction = isFormattingInstruction - } - - fun jobTimeoutExtraTimePerPageInSeconds( - jobTimeoutExtraTimePerPageInSeconds: Double? - ) = - jobTimeoutExtraTimePerPageInSeconds( - JsonField.ofNullable(jobTimeoutExtraTimePerPageInSeconds) - ) - - /** - * Alias for [Builder.jobTimeoutExtraTimePerPageInSeconds]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun jobTimeoutExtraTimePerPageInSeconds( - jobTimeoutExtraTimePerPageInSeconds: Double - ) = - jobTimeoutExtraTimePerPageInSeconds( - jobTimeoutExtraTimePerPageInSeconds as Double? - ) - - /** - * Alias for calling [Builder.jobTimeoutExtraTimePerPageInSeconds] with - * `jobTimeoutExtraTimePerPageInSeconds.orElse(null)`. - */ - fun jobTimeoutExtraTimePerPageInSeconds( - jobTimeoutExtraTimePerPageInSeconds: Optional - ) = - jobTimeoutExtraTimePerPageInSeconds( - jobTimeoutExtraTimePerPageInSeconds.getOrNull() - ) - - /** - * Sets [Builder.jobTimeoutExtraTimePerPageInSeconds] to an arbitrary JSON - * value. - * - * You should usually call [Builder.jobTimeoutExtraTimePerPageInSeconds] with a - * well-typed [Double] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun jobTimeoutExtraTimePerPageInSeconds( - jobTimeoutExtraTimePerPageInSeconds: JsonField - ) = apply { - this.jobTimeoutExtraTimePerPageInSeconds = - jobTimeoutExtraTimePerPageInSeconds - } - - fun jobTimeoutInSeconds(jobTimeoutInSeconds: Double?) = - jobTimeoutInSeconds(JsonField.ofNullable(jobTimeoutInSeconds)) - - /** - * Alias for [Builder.jobTimeoutInSeconds]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun jobTimeoutInSeconds(jobTimeoutInSeconds: Double) = - jobTimeoutInSeconds(jobTimeoutInSeconds as Double?) - - /** - * Alias for calling [Builder.jobTimeoutInSeconds] with - * `jobTimeoutInSeconds.orElse(null)`. - */ - fun jobTimeoutInSeconds(jobTimeoutInSeconds: Optional) = - jobTimeoutInSeconds(jobTimeoutInSeconds.getOrNull()) - - /** - * Sets [Builder.jobTimeoutInSeconds] to an arbitrary JSON value. - * - * You should usually call [Builder.jobTimeoutInSeconds] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun jobTimeoutInSeconds(jobTimeoutInSeconds: JsonField) = apply { - this.jobTimeoutInSeconds = jobTimeoutInSeconds - } - - fun keepPageSeparatorWhenMergingTables( - keepPageSeparatorWhenMergingTables: Boolean? - ) = - keepPageSeparatorWhenMergingTables( - JsonField.ofNullable(keepPageSeparatorWhenMergingTables) - ) - - /** - * Alias for [Builder.keepPageSeparatorWhenMergingTables]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun keepPageSeparatorWhenMergingTables( - keepPageSeparatorWhenMergingTables: Boolean - ) = - keepPageSeparatorWhenMergingTables( - keepPageSeparatorWhenMergingTables as Boolean? - ) - - /** - * Alias for calling [Builder.keepPageSeparatorWhenMergingTables] with - * `keepPageSeparatorWhenMergingTables.orElse(null)`. - */ - fun keepPageSeparatorWhenMergingTables( - keepPageSeparatorWhenMergingTables: Optional - ) = - keepPageSeparatorWhenMergingTables( - keepPageSeparatorWhenMergingTables.getOrNull() - ) - - /** - * Sets [Builder.keepPageSeparatorWhenMergingTables] to an arbitrary JSON value. - * - * You should usually call [Builder.keepPageSeparatorWhenMergingTables] with a - * well-typed [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun keepPageSeparatorWhenMergingTables( - keepPageSeparatorWhenMergingTables: JsonField - ) = apply { - this.keepPageSeparatorWhenMergingTables = keepPageSeparatorWhenMergingTables - } - - /** The language. */ - fun lang(lang: String) = lang(JsonField.of(lang)) - - /** - * Sets [Builder.lang] to an arbitrary JSON value. - * - * You should usually call [Builder.lang] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun lang(lang: JsonField) = apply { this.lang = lang } - - fun languages(languages: List) = - languages(JsonField.of(languages)) - - /** - * Sets [Builder.languages] to an arbitrary JSON value. - * - * You should usually call [Builder.languages] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun languages(languages: JsonField>) = apply { - this.languages = languages.map { it.toMutableList() } - } - - /** - * Adds a single [ParsingLanguages] to [languages]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addLanguage(language: ParsingLanguages) = apply { - languages = - (languages ?: JsonField.of(mutableListOf())).also { - checkKnown("languages", it).add(language) - } - } - - fun layoutAware(layoutAware: Boolean?) = - layoutAware(JsonField.ofNullable(layoutAware)) - - /** - * Alias for [Builder.layoutAware]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun layoutAware(layoutAware: Boolean) = layoutAware(layoutAware as Boolean?) - - /** Alias for calling [Builder.layoutAware] with `layoutAware.orElse(null)`. */ - fun layoutAware(layoutAware: Optional) = - layoutAware(layoutAware.getOrNull()) - - /** - * Sets [Builder.layoutAware] to an arbitrary JSON value. - * - * You should usually call [Builder.layoutAware] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun layoutAware(layoutAware: JsonField) = apply { - this.layoutAware = layoutAware - } - - fun lineLevelBoundingBox(lineLevelBoundingBox: Boolean?) = - lineLevelBoundingBox(JsonField.ofNullable(lineLevelBoundingBox)) - - /** - * Alias for [Builder.lineLevelBoundingBox]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun lineLevelBoundingBox(lineLevelBoundingBox: Boolean) = - lineLevelBoundingBox(lineLevelBoundingBox as Boolean?) - - /** - * Alias for calling [Builder.lineLevelBoundingBox] with - * `lineLevelBoundingBox.orElse(null)`. - */ - fun lineLevelBoundingBox(lineLevelBoundingBox: Optional) = - lineLevelBoundingBox(lineLevelBoundingBox.getOrNull()) - - /** - * Sets [Builder.lineLevelBoundingBox] to an arbitrary JSON value. - * - * You should usually call [Builder.lineLevelBoundingBox] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun lineLevelBoundingBox(lineLevelBoundingBox: JsonField) = apply { - this.lineLevelBoundingBox = lineLevelBoundingBox - } - - fun markdownTableMultilineHeaderSeparator( - markdownTableMultilineHeaderSeparator: String? - ) = - markdownTableMultilineHeaderSeparator( - JsonField.ofNullable(markdownTableMultilineHeaderSeparator) - ) - - /** - * Alias for calling [Builder.markdownTableMultilineHeaderSeparator] with - * `markdownTableMultilineHeaderSeparator.orElse(null)`. - */ - fun markdownTableMultilineHeaderSeparator( - markdownTableMultilineHeaderSeparator: Optional - ) = - markdownTableMultilineHeaderSeparator( - markdownTableMultilineHeaderSeparator.getOrNull() - ) - - /** - * Sets [Builder.markdownTableMultilineHeaderSeparator] to an arbitrary JSON - * value. - * - * You should usually call [Builder.markdownTableMultilineHeaderSeparator] with - * a well-typed [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun markdownTableMultilineHeaderSeparator( - markdownTableMultilineHeaderSeparator: JsonField - ) = apply { - this.markdownTableMultilineHeaderSeparator = - markdownTableMultilineHeaderSeparator - } - - fun maxPages(maxPages: Long?) = maxPages(JsonField.ofNullable(maxPages)) - - /** - * Alias for [Builder.maxPages]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun maxPages(maxPages: Long) = maxPages(maxPages as Long?) - - /** Alias for calling [Builder.maxPages] with `maxPages.orElse(null)`. */ - fun maxPages(maxPages: Optional) = maxPages(maxPages.getOrNull()) - - /** - * Sets [Builder.maxPages] to an arbitrary JSON value. - * - * You should usually call [Builder.maxPages] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun maxPages(maxPages: JsonField) = apply { this.maxPages = maxPages } - - fun maxPagesEnforced(maxPagesEnforced: Long?) = - maxPagesEnforced(JsonField.ofNullable(maxPagesEnforced)) - - /** - * Alias for [Builder.maxPagesEnforced]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun maxPagesEnforced(maxPagesEnforced: Long) = - maxPagesEnforced(maxPagesEnforced as Long?) - - /** - * Alias for calling [Builder.maxPagesEnforced] with - * `maxPagesEnforced.orElse(null)`. - */ - fun maxPagesEnforced(maxPagesEnforced: Optional) = - maxPagesEnforced(maxPagesEnforced.getOrNull()) - - /** - * Sets [Builder.maxPagesEnforced] to an arbitrary JSON value. - * - * You should usually call [Builder.maxPagesEnforced] with a well-typed [Long] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun maxPagesEnforced(maxPagesEnforced: JsonField) = apply { - this.maxPagesEnforced = maxPagesEnforced - } - - fun mergeTablesAcrossPagesInMarkdown( - mergeTablesAcrossPagesInMarkdown: Boolean? - ) = - mergeTablesAcrossPagesInMarkdown( - JsonField.ofNullable(mergeTablesAcrossPagesInMarkdown) - ) - - /** - * Alias for [Builder.mergeTablesAcrossPagesInMarkdown]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun mergeTablesAcrossPagesInMarkdown( - mergeTablesAcrossPagesInMarkdown: Boolean - ) = - mergeTablesAcrossPagesInMarkdown( - mergeTablesAcrossPagesInMarkdown as Boolean? - ) - - /** - * Alias for calling [Builder.mergeTablesAcrossPagesInMarkdown] with - * `mergeTablesAcrossPagesInMarkdown.orElse(null)`. - */ - fun mergeTablesAcrossPagesInMarkdown( - mergeTablesAcrossPagesInMarkdown: Optional - ) = - mergeTablesAcrossPagesInMarkdown( - mergeTablesAcrossPagesInMarkdown.getOrNull() - ) - - /** - * Sets [Builder.mergeTablesAcrossPagesInMarkdown] to an arbitrary JSON value. - * - * You should usually call [Builder.mergeTablesAcrossPagesInMarkdown] with a - * well-typed [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun mergeTablesAcrossPagesInMarkdown( - mergeTablesAcrossPagesInMarkdown: JsonField - ) = apply { - this.mergeTablesAcrossPagesInMarkdown = mergeTablesAcrossPagesInMarkdown - } - - fun model(model: String?) = model(JsonField.ofNullable(model)) - - /** Alias for calling [Builder.model] with `model.orElse(null)`. */ - fun model(model: Optional) = model(model.getOrNull()) - - /** - * Sets [Builder.model] to an arbitrary JSON value. - * - * You should usually call [Builder.model] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun model(model: JsonField) = apply { this.model = model } - - fun outlinedTableExtraction(outlinedTableExtraction: Boolean?) = - outlinedTableExtraction(JsonField.ofNullable(outlinedTableExtraction)) - - /** - * Alias for [Builder.outlinedTableExtraction]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun outlinedTableExtraction(outlinedTableExtraction: Boolean) = - outlinedTableExtraction(outlinedTableExtraction as Boolean?) - - /** - * Alias for calling [Builder.outlinedTableExtraction] with - * `outlinedTableExtraction.orElse(null)`. - */ - fun outlinedTableExtraction(outlinedTableExtraction: Optional) = - outlinedTableExtraction(outlinedTableExtraction.getOrNull()) - - /** - * Sets [Builder.outlinedTableExtraction] to an arbitrary JSON value. - * - * You should usually call [Builder.outlinedTableExtraction] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun outlinedTableExtraction(outlinedTableExtraction: JsonField) = - apply { - this.outlinedTableExtraction = outlinedTableExtraction - } - - fun outputPdfOfDocument(outputPdfOfDocument: Boolean?) = - outputPdfOfDocument(JsonField.ofNullable(outputPdfOfDocument)) - - /** - * Alias for [Builder.outputPdfOfDocument]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun outputPdfOfDocument(outputPdfOfDocument: Boolean) = - outputPdfOfDocument(outputPdfOfDocument as Boolean?) - - /** - * Alias for calling [Builder.outputPdfOfDocument] with - * `outputPdfOfDocument.orElse(null)`. - */ - fun outputPdfOfDocument(outputPdfOfDocument: Optional) = - outputPdfOfDocument(outputPdfOfDocument.getOrNull()) - - /** - * Sets [Builder.outputPdfOfDocument] to an arbitrary JSON value. - * - * You should usually call [Builder.outputPdfOfDocument] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun outputPdfOfDocument(outputPdfOfDocument: JsonField) = apply { - this.outputPdfOfDocument = outputPdfOfDocument - } - - /** - * If specified, llamaParse will save the output to the specified path. All - * output file will use this 'prefix' should be a valid s3:// url - */ - fun outputS3PathPrefix(outputS3PathPrefix: String?) = - outputS3PathPrefix(JsonField.ofNullable(outputS3PathPrefix)) - - /** - * Alias for calling [Builder.outputS3PathPrefix] with - * `outputS3PathPrefix.orElse(null)`. - */ - fun outputS3PathPrefix(outputS3PathPrefix: Optional) = - outputS3PathPrefix(outputS3PathPrefix.getOrNull()) - - /** - * Sets [Builder.outputS3PathPrefix] to an arbitrary JSON value. - * - * You should usually call [Builder.outputS3PathPrefix] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun outputS3PathPrefix(outputS3PathPrefix: JsonField) = apply { - this.outputS3PathPrefix = outputS3PathPrefix - } - - /** The region for the output S3 bucket. */ - fun outputS3Region(outputS3Region: String?) = - outputS3Region(JsonField.ofNullable(outputS3Region)) - - /** - * Alias for calling [Builder.outputS3Region] with - * `outputS3Region.orElse(null)`. - */ - fun outputS3Region(outputS3Region: Optional) = - outputS3Region(outputS3Region.getOrNull()) - - /** - * Sets [Builder.outputS3Region] to an arbitrary JSON value. - * - * You should usually call [Builder.outputS3Region] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun outputS3Region(outputS3Region: JsonField) = apply { - this.outputS3Region = outputS3Region - } - - fun outputTablesAsHtml(outputTablesAsHtml: Boolean?) = - outputTablesAsHtml(JsonField.ofNullable(outputTablesAsHtml)) - - /** - * Alias for [Builder.outputTablesAsHtml]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun outputTablesAsHtml(outputTablesAsHtml: Boolean) = - outputTablesAsHtml(outputTablesAsHtml as Boolean?) - - /** - * Alias for calling [Builder.outputTablesAsHtml] with - * `outputTablesAsHtml.orElse(null)`. - */ - fun outputTablesAsHtml(outputTablesAsHtml: Optional) = - outputTablesAsHtml(outputTablesAsHtml.getOrNull()) - - /** - * Sets [Builder.outputTablesAsHtml] to an arbitrary JSON value. - * - * You should usually call [Builder.outputTablesAsHtml] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun outputTablesAsHtml(outputTablesAsHtml: JsonField) = apply { - this.outputTablesAsHtml = outputTablesAsHtml - } - - /** The output bucket. */ - fun outputBucket(outputBucket: String?) = - outputBucket(JsonField.ofNullable(outputBucket)) - - /** - * Alias for calling [Builder.outputBucket] with `outputBucket.orElse(null)`. - */ - fun outputBucket(outputBucket: Optional) = - outputBucket(outputBucket.getOrNull()) - - /** - * Sets [Builder.outputBucket] to an arbitrary JSON value. - * - * You should usually call [Builder.outputBucket] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun outputBucket(outputBucket: JsonField) = apply { - this.outputBucket = outputBucket - } - - fun pageErrorTolerance(pageErrorTolerance: Double?) = - pageErrorTolerance(JsonField.ofNullable(pageErrorTolerance)) - - /** - * Alias for [Builder.pageErrorTolerance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun pageErrorTolerance(pageErrorTolerance: Double) = - pageErrorTolerance(pageErrorTolerance as Double?) - - /** - * Alias for calling [Builder.pageErrorTolerance] with - * `pageErrorTolerance.orElse(null)`. - */ - fun pageErrorTolerance(pageErrorTolerance: Optional) = - pageErrorTolerance(pageErrorTolerance.getOrNull()) - - /** - * Sets [Builder.pageErrorTolerance] to an arbitrary JSON value. - * - * You should usually call [Builder.pageErrorTolerance] with a well-typed - * [Double] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun pageErrorTolerance(pageErrorTolerance: JsonField) = apply { - this.pageErrorTolerance = pageErrorTolerance - } - - fun pageFooterPrefix(pageFooterPrefix: String?) = - pageFooterPrefix(JsonField.ofNullable(pageFooterPrefix)) - - /** - * Alias for calling [Builder.pageFooterPrefix] with - * `pageFooterPrefix.orElse(null)`. - */ - fun pageFooterPrefix(pageFooterPrefix: Optional) = - pageFooterPrefix(pageFooterPrefix.getOrNull()) - - /** - * Sets [Builder.pageFooterPrefix] to an arbitrary JSON value. - * - * You should usually call [Builder.pageFooterPrefix] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun pageFooterPrefix(pageFooterPrefix: JsonField) = apply { - this.pageFooterPrefix = pageFooterPrefix - } - - fun pageFooterSuffix(pageFooterSuffix: String?) = - pageFooterSuffix(JsonField.ofNullable(pageFooterSuffix)) - - /** - * Alias for calling [Builder.pageFooterSuffix] with - * `pageFooterSuffix.orElse(null)`. - */ - fun pageFooterSuffix(pageFooterSuffix: Optional) = - pageFooterSuffix(pageFooterSuffix.getOrNull()) - - /** - * Sets [Builder.pageFooterSuffix] to an arbitrary JSON value. - * - * You should usually call [Builder.pageFooterSuffix] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun pageFooterSuffix(pageFooterSuffix: JsonField) = apply { - this.pageFooterSuffix = pageFooterSuffix - } - - fun pageHeaderPrefix(pageHeaderPrefix: String?) = - pageHeaderPrefix(JsonField.ofNullable(pageHeaderPrefix)) - - /** - * Alias for calling [Builder.pageHeaderPrefix] with - * `pageHeaderPrefix.orElse(null)`. - */ - fun pageHeaderPrefix(pageHeaderPrefix: Optional) = - pageHeaderPrefix(pageHeaderPrefix.getOrNull()) - - /** - * Sets [Builder.pageHeaderPrefix] to an arbitrary JSON value. - * - * You should usually call [Builder.pageHeaderPrefix] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun pageHeaderPrefix(pageHeaderPrefix: JsonField) = apply { - this.pageHeaderPrefix = pageHeaderPrefix - } - - fun pageHeaderSuffix(pageHeaderSuffix: String?) = - pageHeaderSuffix(JsonField.ofNullable(pageHeaderSuffix)) - - /** - * Alias for calling [Builder.pageHeaderSuffix] with - * `pageHeaderSuffix.orElse(null)`. - */ - fun pageHeaderSuffix(pageHeaderSuffix: Optional) = - pageHeaderSuffix(pageHeaderSuffix.getOrNull()) - - /** - * Sets [Builder.pageHeaderSuffix] to an arbitrary JSON value. - * - * You should usually call [Builder.pageHeaderSuffix] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun pageHeaderSuffix(pageHeaderSuffix: JsonField) = apply { - this.pageHeaderSuffix = pageHeaderSuffix - } - - fun pagePrefix(pagePrefix: String?) = - pagePrefix(JsonField.ofNullable(pagePrefix)) - - /** Alias for calling [Builder.pagePrefix] with `pagePrefix.orElse(null)`. */ - fun pagePrefix(pagePrefix: Optional) = - pagePrefix(pagePrefix.getOrNull()) - - /** - * Sets [Builder.pagePrefix] to an arbitrary JSON value. - * - * You should usually call [Builder.pagePrefix] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun pagePrefix(pagePrefix: JsonField) = apply { - this.pagePrefix = pagePrefix - } - - fun pageSeparator(pageSeparator: String?) = - pageSeparator(JsonField.ofNullable(pageSeparator)) - - /** - * Alias for calling [Builder.pageSeparator] with `pageSeparator.orElse(null)`. - */ - fun pageSeparator(pageSeparator: Optional) = - pageSeparator(pageSeparator.getOrNull()) - - /** - * Sets [Builder.pageSeparator] to an arbitrary JSON value. - * - * You should usually call [Builder.pageSeparator] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun pageSeparator(pageSeparator: JsonField) = apply { - this.pageSeparator = pageSeparator - } - - fun pageSuffix(pageSuffix: String?) = - pageSuffix(JsonField.ofNullable(pageSuffix)) - - /** Alias for calling [Builder.pageSuffix] with `pageSuffix.orElse(null)`. */ - fun pageSuffix(pageSuffix: Optional) = - pageSuffix(pageSuffix.getOrNull()) - - /** - * Sets [Builder.pageSuffix] to an arbitrary JSON value. - * - * You should usually call [Builder.pageSuffix] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun pageSuffix(pageSuffix: JsonField) = apply { - this.pageSuffix = pageSuffix - } - - /** Enum for representing the mode of parsing to be used. */ - fun parseMode(parseMode: ParsingMode?) = - parseMode(JsonField.ofNullable(parseMode)) - - /** Alias for calling [Builder.parseMode] with `parseMode.orElse(null)`. */ - fun parseMode(parseMode: Optional) = - parseMode(parseMode.getOrNull()) - - /** - * Sets [Builder.parseMode] to an arbitrary JSON value. - * - * You should usually call [Builder.parseMode] with a well-typed [ParsingMode] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun parseMode(parseMode: JsonField) = apply { - this.parseMode = parseMode - } - - fun parsingInstruction(parsingInstruction: String?) = - parsingInstruction(JsonField.ofNullable(parsingInstruction)) - - /** - * Alias for calling [Builder.parsingInstruction] with - * `parsingInstruction.orElse(null)`. - */ - fun parsingInstruction(parsingInstruction: Optional) = - parsingInstruction(parsingInstruction.getOrNull()) - - /** - * Sets [Builder.parsingInstruction] to an arbitrary JSON value. - * - * You should usually call [Builder.parsingInstruction] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun parsingInstruction(parsingInstruction: JsonField) = apply { - this.parsingInstruction = parsingInstruction - } - - /** The pipeline ID. */ - fun pipelineId(pipelineId: String?) = - pipelineId(JsonField.ofNullable(pipelineId)) - - /** Alias for calling [Builder.pipelineId] with `pipelineId.orElse(null)`. */ - fun pipelineId(pipelineId: Optional) = - pipelineId(pipelineId.getOrNull()) - - /** - * Sets [Builder.pipelineId] to an arbitrary JSON value. - * - * You should usually call [Builder.pipelineId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun pipelineId(pipelineId: JsonField) = apply { - this.pipelineId = pipelineId - } - - fun preciseBoundingBox(preciseBoundingBox: Boolean?) = - preciseBoundingBox(JsonField.ofNullable(preciseBoundingBox)) - - /** - * Alias for [Builder.preciseBoundingBox]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun preciseBoundingBox(preciseBoundingBox: Boolean) = - preciseBoundingBox(preciseBoundingBox as Boolean?) - - /** - * Alias for calling [Builder.preciseBoundingBox] with - * `preciseBoundingBox.orElse(null)`. - */ - fun preciseBoundingBox(preciseBoundingBox: Optional) = - preciseBoundingBox(preciseBoundingBox.getOrNull()) - - /** - * Sets [Builder.preciseBoundingBox] to an arbitrary JSON value. - * - * You should usually call [Builder.preciseBoundingBox] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun preciseBoundingBox(preciseBoundingBox: JsonField) = apply { - this.preciseBoundingBox = preciseBoundingBox - } - - fun premiumMode(premiumMode: Boolean?) = - premiumMode(JsonField.ofNullable(premiumMode)) - - /** - * Alias for [Builder.premiumMode]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun premiumMode(premiumMode: Boolean) = premiumMode(premiumMode as Boolean?) - - /** Alias for calling [Builder.premiumMode] with `premiumMode.orElse(null)`. */ - fun premiumMode(premiumMode: Optional) = - premiumMode(premiumMode.getOrNull()) - - /** - * Sets [Builder.premiumMode] to an arbitrary JSON value. - * - * You should usually call [Builder.premiumMode] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun premiumMode(premiumMode: JsonField) = apply { - this.premiumMode = premiumMode - } - - fun presentationOutOfBoundsContent(presentationOutOfBoundsContent: Boolean?) = - presentationOutOfBoundsContent( - JsonField.ofNullable(presentationOutOfBoundsContent) - ) - - /** - * Alias for [Builder.presentationOutOfBoundsContent]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun presentationOutOfBoundsContent(presentationOutOfBoundsContent: Boolean) = - presentationOutOfBoundsContent(presentationOutOfBoundsContent as Boolean?) - - /** - * Alias for calling [Builder.presentationOutOfBoundsContent] with - * `presentationOutOfBoundsContent.orElse(null)`. - */ - fun presentationOutOfBoundsContent( - presentationOutOfBoundsContent: Optional - ) = presentationOutOfBoundsContent(presentationOutOfBoundsContent.getOrNull()) - - /** - * Sets [Builder.presentationOutOfBoundsContent] to an arbitrary JSON value. - * - * You should usually call [Builder.presentationOutOfBoundsContent] with a - * well-typed [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun presentationOutOfBoundsContent( - presentationOutOfBoundsContent: JsonField - ) = apply { - this.presentationOutOfBoundsContent = presentationOutOfBoundsContent - } - - fun presentationSkipEmbeddedData(presentationSkipEmbeddedData: Boolean?) = - presentationSkipEmbeddedData( - JsonField.ofNullable(presentationSkipEmbeddedData) - ) - - /** - * Alias for [Builder.presentationSkipEmbeddedData]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun presentationSkipEmbeddedData(presentationSkipEmbeddedData: Boolean) = - presentationSkipEmbeddedData(presentationSkipEmbeddedData as Boolean?) - - /** - * Alias for calling [Builder.presentationSkipEmbeddedData] with - * `presentationSkipEmbeddedData.orElse(null)`. - */ - fun presentationSkipEmbeddedData( - presentationSkipEmbeddedData: Optional - ) = presentationSkipEmbeddedData(presentationSkipEmbeddedData.getOrNull()) - - /** - * Sets [Builder.presentationSkipEmbeddedData] to an arbitrary JSON value. - * - * You should usually call [Builder.presentationSkipEmbeddedData] with a - * well-typed [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun presentationSkipEmbeddedData( - presentationSkipEmbeddedData: JsonField - ) = apply { this.presentationSkipEmbeddedData = presentationSkipEmbeddedData } - - fun preserveLayoutAlignmentAcrossPages( - preserveLayoutAlignmentAcrossPages: Boolean? - ) = - preserveLayoutAlignmentAcrossPages( - JsonField.ofNullable(preserveLayoutAlignmentAcrossPages) - ) - - /** - * Alias for [Builder.preserveLayoutAlignmentAcrossPages]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun preserveLayoutAlignmentAcrossPages( - preserveLayoutAlignmentAcrossPages: Boolean - ) = - preserveLayoutAlignmentAcrossPages( - preserveLayoutAlignmentAcrossPages as Boolean? - ) - - /** - * Alias for calling [Builder.preserveLayoutAlignmentAcrossPages] with - * `preserveLayoutAlignmentAcrossPages.orElse(null)`. - */ - fun preserveLayoutAlignmentAcrossPages( - preserveLayoutAlignmentAcrossPages: Optional - ) = - preserveLayoutAlignmentAcrossPages( - preserveLayoutAlignmentAcrossPages.getOrNull() - ) - - /** - * Sets [Builder.preserveLayoutAlignmentAcrossPages] to an arbitrary JSON value. - * - * You should usually call [Builder.preserveLayoutAlignmentAcrossPages] with a - * well-typed [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun preserveLayoutAlignmentAcrossPages( - preserveLayoutAlignmentAcrossPages: JsonField - ) = apply { - this.preserveLayoutAlignmentAcrossPages = preserveLayoutAlignmentAcrossPages - } - - fun preserveVerySmallText(preserveVerySmallText: Boolean?) = - preserveVerySmallText(JsonField.ofNullable(preserveVerySmallText)) - - /** - * Alias for [Builder.preserveVerySmallText]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun preserveVerySmallText(preserveVerySmallText: Boolean) = - preserveVerySmallText(preserveVerySmallText as Boolean?) - - /** - * Alias for calling [Builder.preserveVerySmallText] with - * `preserveVerySmallText.orElse(null)`. - */ - fun preserveVerySmallText(preserveVerySmallText: Optional) = - preserveVerySmallText(preserveVerySmallText.getOrNull()) - - /** - * Sets [Builder.preserveVerySmallText] to an arbitrary JSON value. - * - * You should usually call [Builder.preserveVerySmallText] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun preserveVerySmallText(preserveVerySmallText: JsonField) = apply { - this.preserveVerySmallText = preserveVerySmallText - } - - fun preset(preset: String?) = preset(JsonField.ofNullable(preset)) - - /** Alias for calling [Builder.preset] with `preset.orElse(null)`. */ - fun preset(preset: Optional) = preset(preset.getOrNull()) - - /** - * Sets [Builder.preset] to an arbitrary JSON value. - * - * You should usually call [Builder.preset] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun preset(preset: JsonField) = apply { this.preset = preset } - - /** - * 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 } - - 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 removeHiddenText(removeHiddenText: Boolean?) = - removeHiddenText(JsonField.ofNullable(removeHiddenText)) - - /** - * Alias for [Builder.removeHiddenText]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun removeHiddenText(removeHiddenText: Boolean) = - removeHiddenText(removeHiddenText as Boolean?) - - /** - * Alias for calling [Builder.removeHiddenText] with - * `removeHiddenText.orElse(null)`. - */ - fun removeHiddenText(removeHiddenText: Optional) = - removeHiddenText(removeHiddenText.getOrNull()) - - /** - * Sets [Builder.removeHiddenText] to an arbitrary JSON value. - * - * You should usually call [Builder.removeHiddenText] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun removeHiddenText(removeHiddenText: JsonField) = apply { - this.removeHiddenText = removeHiddenText - } - - /** Enum for representing the different available page error handling modes. */ - fun replaceFailedPageMode(replaceFailedPageMode: FailPageMode?) = - replaceFailedPageMode(JsonField.ofNullable(replaceFailedPageMode)) - - /** - * Alias for calling [Builder.replaceFailedPageMode] with - * `replaceFailedPageMode.orElse(null)`. - */ - fun replaceFailedPageMode(replaceFailedPageMode: Optional) = - replaceFailedPageMode(replaceFailedPageMode.getOrNull()) - - /** - * Sets [Builder.replaceFailedPageMode] to an arbitrary JSON value. - * - * You should usually call [Builder.replaceFailedPageMode] with a well-typed - * [FailPageMode] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun replaceFailedPageMode(replaceFailedPageMode: JsonField) = - apply { - this.replaceFailedPageMode = replaceFailedPageMode - } - - fun replaceFailedPageWithErrorMessagePrefix( - replaceFailedPageWithErrorMessagePrefix: String? - ) = - replaceFailedPageWithErrorMessagePrefix( - JsonField.ofNullable(replaceFailedPageWithErrorMessagePrefix) - ) - - /** - * Alias for calling [Builder.replaceFailedPageWithErrorMessagePrefix] with - * `replaceFailedPageWithErrorMessagePrefix.orElse(null)`. - */ - fun replaceFailedPageWithErrorMessagePrefix( - replaceFailedPageWithErrorMessagePrefix: Optional - ) = - replaceFailedPageWithErrorMessagePrefix( - replaceFailedPageWithErrorMessagePrefix.getOrNull() - ) - - /** - * Sets [Builder.replaceFailedPageWithErrorMessagePrefix] to an arbitrary JSON - * value. - * - * You should usually call [Builder.replaceFailedPageWithErrorMessagePrefix] - * with a well-typed [String] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun replaceFailedPageWithErrorMessagePrefix( - replaceFailedPageWithErrorMessagePrefix: JsonField - ) = apply { - this.replaceFailedPageWithErrorMessagePrefix = - replaceFailedPageWithErrorMessagePrefix - } - - fun replaceFailedPageWithErrorMessageSuffix( - replaceFailedPageWithErrorMessageSuffix: String? - ) = - replaceFailedPageWithErrorMessageSuffix( - JsonField.ofNullable(replaceFailedPageWithErrorMessageSuffix) - ) - - /** - * Alias for calling [Builder.replaceFailedPageWithErrorMessageSuffix] with - * `replaceFailedPageWithErrorMessageSuffix.orElse(null)`. - */ - fun replaceFailedPageWithErrorMessageSuffix( - replaceFailedPageWithErrorMessageSuffix: Optional - ) = - replaceFailedPageWithErrorMessageSuffix( - replaceFailedPageWithErrorMessageSuffix.getOrNull() - ) - - /** - * Sets [Builder.replaceFailedPageWithErrorMessageSuffix] to an arbitrary JSON - * value. - * - * You should usually call [Builder.replaceFailedPageWithErrorMessageSuffix] - * with a well-typed [String] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun replaceFailedPageWithErrorMessageSuffix( - replaceFailedPageWithErrorMessageSuffix: JsonField - ) = apply { - this.replaceFailedPageWithErrorMessageSuffix = - replaceFailedPageWithErrorMessageSuffix - } - - /** The resource info about the file */ - fun resourceInfo(resourceInfo: ResourceInfo?) = - resourceInfo(JsonField.ofNullable(resourceInfo)) - - /** - * Alias for calling [Builder.resourceInfo] with `resourceInfo.orElse(null)`. - */ - fun resourceInfo(resourceInfo: Optional) = - resourceInfo(resourceInfo.getOrNull()) - - /** - * Sets [Builder.resourceInfo] to an arbitrary JSON value. - * - * You should usually call [Builder.resourceInfo] with a well-typed - * [ResourceInfo] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun resourceInfo(resourceInfo: JsonField) = apply { - this.resourceInfo = resourceInfo - } - - fun saveImages(saveImages: Boolean?) = - saveImages(JsonField.ofNullable(saveImages)) - - /** - * Alias for [Builder.saveImages]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun saveImages(saveImages: Boolean) = saveImages(saveImages as Boolean?) - - /** Alias for calling [Builder.saveImages] with `saveImages.orElse(null)`. */ - fun saveImages(saveImages: Optional) = - saveImages(saveImages.getOrNull()) - - /** - * Sets [Builder.saveImages] to an arbitrary JSON value. - * - * You should usually call [Builder.saveImages] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun saveImages(saveImages: JsonField) = apply { - this.saveImages = saveImages - } - - fun skipDiagonalText(skipDiagonalText: Boolean?) = - skipDiagonalText(JsonField.ofNullable(skipDiagonalText)) - - /** - * Alias for [Builder.skipDiagonalText]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun skipDiagonalText(skipDiagonalText: Boolean) = - skipDiagonalText(skipDiagonalText as Boolean?) - - /** - * Alias for calling [Builder.skipDiagonalText] with - * `skipDiagonalText.orElse(null)`. - */ - fun skipDiagonalText(skipDiagonalText: Optional) = - skipDiagonalText(skipDiagonalText.getOrNull()) - - /** - * Sets [Builder.skipDiagonalText] to an arbitrary JSON value. - * - * You should usually call [Builder.skipDiagonalText] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun skipDiagonalText(skipDiagonalText: JsonField) = apply { - this.skipDiagonalText = skipDiagonalText - } - - fun specializedChartParsingAgentic(specializedChartParsingAgentic: Boolean?) = - specializedChartParsingAgentic( - JsonField.ofNullable(specializedChartParsingAgentic) - ) - - /** - * Alias for [Builder.specializedChartParsingAgentic]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun specializedChartParsingAgentic(specializedChartParsingAgentic: Boolean) = - specializedChartParsingAgentic(specializedChartParsingAgentic as Boolean?) - - /** - * Alias for calling [Builder.specializedChartParsingAgentic] with - * `specializedChartParsingAgentic.orElse(null)`. - */ - fun specializedChartParsingAgentic( - specializedChartParsingAgentic: Optional - ) = specializedChartParsingAgentic(specializedChartParsingAgentic.getOrNull()) - - /** - * Sets [Builder.specializedChartParsingAgentic] to an arbitrary JSON value. - * - * You should usually call [Builder.specializedChartParsingAgentic] with a - * well-typed [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun specializedChartParsingAgentic( - specializedChartParsingAgentic: JsonField - ) = apply { - this.specializedChartParsingAgentic = specializedChartParsingAgentic - } - - fun specializedChartParsingEfficient( - specializedChartParsingEfficient: Boolean? - ) = - specializedChartParsingEfficient( - JsonField.ofNullable(specializedChartParsingEfficient) - ) - - /** - * Alias for [Builder.specializedChartParsingEfficient]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun specializedChartParsingEfficient( - specializedChartParsingEfficient: Boolean - ) = - specializedChartParsingEfficient( - specializedChartParsingEfficient as Boolean? - ) - - /** - * Alias for calling [Builder.specializedChartParsingEfficient] with - * `specializedChartParsingEfficient.orElse(null)`. - */ - fun specializedChartParsingEfficient( - specializedChartParsingEfficient: Optional - ) = - specializedChartParsingEfficient( - specializedChartParsingEfficient.getOrNull() - ) - - /** - * Sets [Builder.specializedChartParsingEfficient] to an arbitrary JSON value. - * - * You should usually call [Builder.specializedChartParsingEfficient] with a - * well-typed [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun specializedChartParsingEfficient( - specializedChartParsingEfficient: JsonField - ) = apply { - this.specializedChartParsingEfficient = specializedChartParsingEfficient - } - - fun specializedChartParsingPlus(specializedChartParsingPlus: Boolean?) = - specializedChartParsingPlus( - JsonField.ofNullable(specializedChartParsingPlus) - ) - - /** - * Alias for [Builder.specializedChartParsingPlus]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun specializedChartParsingPlus(specializedChartParsingPlus: Boolean) = - specializedChartParsingPlus(specializedChartParsingPlus as Boolean?) - - /** - * Alias for calling [Builder.specializedChartParsingPlus] with - * `specializedChartParsingPlus.orElse(null)`. - */ - fun specializedChartParsingPlus( - specializedChartParsingPlus: Optional - ) = specializedChartParsingPlus(specializedChartParsingPlus.getOrNull()) - - /** - * Sets [Builder.specializedChartParsingPlus] to an arbitrary JSON value. - * - * You should usually call [Builder.specializedChartParsingPlus] with a - * well-typed [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun specializedChartParsingPlus( - specializedChartParsingPlus: JsonField - ) = apply { this.specializedChartParsingPlus = specializedChartParsingPlus } - - fun specializedImageParsing(specializedImageParsing: Boolean?) = - specializedImageParsing(JsonField.ofNullable(specializedImageParsing)) - - /** - * Alias for [Builder.specializedImageParsing]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun specializedImageParsing(specializedImageParsing: Boolean) = - specializedImageParsing(specializedImageParsing as Boolean?) - - /** - * Alias for calling [Builder.specializedImageParsing] with - * `specializedImageParsing.orElse(null)`. - */ - fun specializedImageParsing(specializedImageParsing: Optional) = - specializedImageParsing(specializedImageParsing.getOrNull()) - - /** - * Sets [Builder.specializedImageParsing] to an arbitrary JSON value. - * - * You should usually call [Builder.specializedImageParsing] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun specializedImageParsing(specializedImageParsing: JsonField) = - apply { - this.specializedImageParsing = specializedImageParsing - } - - fun spreadsheetExtractSubTables(spreadsheetExtractSubTables: Boolean?) = - spreadsheetExtractSubTables( - JsonField.ofNullable(spreadsheetExtractSubTables) - ) - - /** - * Alias for [Builder.spreadsheetExtractSubTables]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun spreadsheetExtractSubTables(spreadsheetExtractSubTables: Boolean) = - spreadsheetExtractSubTables(spreadsheetExtractSubTables as Boolean?) - - /** - * Alias for calling [Builder.spreadsheetExtractSubTables] with - * `spreadsheetExtractSubTables.orElse(null)`. - */ - fun spreadsheetExtractSubTables( - spreadsheetExtractSubTables: Optional - ) = spreadsheetExtractSubTables(spreadsheetExtractSubTables.getOrNull()) - - /** - * Sets [Builder.spreadsheetExtractSubTables] to an arbitrary JSON value. - * - * You should usually call [Builder.spreadsheetExtractSubTables] with a - * well-typed [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun spreadsheetExtractSubTables( - spreadsheetExtractSubTables: JsonField - ) = apply { this.spreadsheetExtractSubTables = spreadsheetExtractSubTables } - - fun spreadsheetForceFormulaComputation( - spreadsheetForceFormulaComputation: Boolean? - ) = - spreadsheetForceFormulaComputation( - JsonField.ofNullable(spreadsheetForceFormulaComputation) - ) - - /** - * Alias for [Builder.spreadsheetForceFormulaComputation]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun spreadsheetForceFormulaComputation( - spreadsheetForceFormulaComputation: Boolean - ) = - spreadsheetForceFormulaComputation( - spreadsheetForceFormulaComputation as Boolean? - ) - - /** - * Alias for calling [Builder.spreadsheetForceFormulaComputation] with - * `spreadsheetForceFormulaComputation.orElse(null)`. - */ - fun spreadsheetForceFormulaComputation( - spreadsheetForceFormulaComputation: Optional - ) = - spreadsheetForceFormulaComputation( - spreadsheetForceFormulaComputation.getOrNull() - ) - - /** - * Sets [Builder.spreadsheetForceFormulaComputation] to an arbitrary JSON value. - * - * You should usually call [Builder.spreadsheetForceFormulaComputation] with a - * well-typed [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun spreadsheetForceFormulaComputation( - spreadsheetForceFormulaComputation: JsonField - ) = apply { - this.spreadsheetForceFormulaComputation = spreadsheetForceFormulaComputation - } - - fun spreadsheetIncludeHiddenSheets(spreadsheetIncludeHiddenSheets: Boolean?) = - spreadsheetIncludeHiddenSheets( - JsonField.ofNullable(spreadsheetIncludeHiddenSheets) - ) - - /** - * Alias for [Builder.spreadsheetIncludeHiddenSheets]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun spreadsheetIncludeHiddenSheets(spreadsheetIncludeHiddenSheets: Boolean) = - spreadsheetIncludeHiddenSheets(spreadsheetIncludeHiddenSheets as Boolean?) - - /** - * Alias for calling [Builder.spreadsheetIncludeHiddenSheets] with - * `spreadsheetIncludeHiddenSheets.orElse(null)`. - */ - fun spreadsheetIncludeHiddenSheets( - spreadsheetIncludeHiddenSheets: Optional - ) = spreadsheetIncludeHiddenSheets(spreadsheetIncludeHiddenSheets.getOrNull()) - - /** - * Sets [Builder.spreadsheetIncludeHiddenSheets] to an arbitrary JSON value. - * - * You should usually call [Builder.spreadsheetIncludeHiddenSheets] with a - * well-typed [Boolean] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun spreadsheetIncludeHiddenSheets( - spreadsheetIncludeHiddenSheets: JsonField - ) = apply { - this.spreadsheetIncludeHiddenSheets = spreadsheetIncludeHiddenSheets - } - - fun strictModeBuggyFont(strictModeBuggyFont: Boolean?) = - strictModeBuggyFont(JsonField.ofNullable(strictModeBuggyFont)) - - /** - * Alias for [Builder.strictModeBuggyFont]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun strictModeBuggyFont(strictModeBuggyFont: Boolean) = - strictModeBuggyFont(strictModeBuggyFont as Boolean?) - - /** - * Alias for calling [Builder.strictModeBuggyFont] with - * `strictModeBuggyFont.orElse(null)`. - */ - fun strictModeBuggyFont(strictModeBuggyFont: Optional) = - strictModeBuggyFont(strictModeBuggyFont.getOrNull()) - - /** - * Sets [Builder.strictModeBuggyFont] to an arbitrary JSON value. - * - * You should usually call [Builder.strictModeBuggyFont] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun strictModeBuggyFont(strictModeBuggyFont: JsonField) = apply { - this.strictModeBuggyFont = strictModeBuggyFont - } - - fun strictModeImageExtraction(strictModeImageExtraction: Boolean?) = - strictModeImageExtraction(JsonField.ofNullable(strictModeImageExtraction)) - - /** - * Alias for [Builder.strictModeImageExtraction]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun strictModeImageExtraction(strictModeImageExtraction: Boolean) = - strictModeImageExtraction(strictModeImageExtraction as Boolean?) - - /** - * Alias for calling [Builder.strictModeImageExtraction] with - * `strictModeImageExtraction.orElse(null)`. - */ - fun strictModeImageExtraction(strictModeImageExtraction: Optional) = - strictModeImageExtraction(strictModeImageExtraction.getOrNull()) - - /** - * Sets [Builder.strictModeImageExtraction] to an arbitrary JSON value. - * - * You should usually call [Builder.strictModeImageExtraction] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun strictModeImageExtraction(strictModeImageExtraction: JsonField) = - apply { - this.strictModeImageExtraction = strictModeImageExtraction - } - - fun strictModeImageOcr(strictModeImageOcr: Boolean?) = - strictModeImageOcr(JsonField.ofNullable(strictModeImageOcr)) - - /** - * Alias for [Builder.strictModeImageOcr]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun strictModeImageOcr(strictModeImageOcr: Boolean) = - strictModeImageOcr(strictModeImageOcr as Boolean?) - - /** - * Alias for calling [Builder.strictModeImageOcr] with - * `strictModeImageOcr.orElse(null)`. - */ - fun strictModeImageOcr(strictModeImageOcr: Optional) = - strictModeImageOcr(strictModeImageOcr.getOrNull()) - - /** - * Sets [Builder.strictModeImageOcr] to an arbitrary JSON value. - * - * You should usually call [Builder.strictModeImageOcr] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun strictModeImageOcr(strictModeImageOcr: JsonField) = apply { - this.strictModeImageOcr = strictModeImageOcr - } - - fun strictModeReconstruction(strictModeReconstruction: Boolean?) = - strictModeReconstruction(JsonField.ofNullable(strictModeReconstruction)) - - /** - * Alias for [Builder.strictModeReconstruction]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun strictModeReconstruction(strictModeReconstruction: Boolean) = - strictModeReconstruction(strictModeReconstruction as Boolean?) - - /** - * Alias for calling [Builder.strictModeReconstruction] with - * `strictModeReconstruction.orElse(null)`. - */ - fun strictModeReconstruction(strictModeReconstruction: Optional) = - strictModeReconstruction(strictModeReconstruction.getOrNull()) - - /** - * Sets [Builder.strictModeReconstruction] to an arbitrary JSON value. - * - * You should usually call [Builder.strictModeReconstruction] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun strictModeReconstruction(strictModeReconstruction: JsonField) = - apply { - this.strictModeReconstruction = strictModeReconstruction - } - - fun structuredOutput(structuredOutput: Boolean?) = - structuredOutput(JsonField.ofNullable(structuredOutput)) - - /** - * Alias for [Builder.structuredOutput]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun structuredOutput(structuredOutput: Boolean) = - structuredOutput(structuredOutput as Boolean?) - - /** - * Alias for calling [Builder.structuredOutput] with - * `structuredOutput.orElse(null)`. - */ - fun structuredOutput(structuredOutput: Optional) = - structuredOutput(structuredOutput.getOrNull()) - - /** - * Sets [Builder.structuredOutput] to an arbitrary JSON value. - * - * You should usually call [Builder.structuredOutput] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun structuredOutput(structuredOutput: JsonField) = apply { - this.structuredOutput = structuredOutput - } - - fun structuredOutputJsonSchema(structuredOutputJsonSchema: String?) = - structuredOutputJsonSchema(JsonField.ofNullable(structuredOutputJsonSchema)) - - /** - * Alias for calling [Builder.structuredOutputJsonSchema] with - * `structuredOutputJsonSchema.orElse(null)`. - */ - fun structuredOutputJsonSchema(structuredOutputJsonSchema: Optional) = - structuredOutputJsonSchema(structuredOutputJsonSchema.getOrNull()) - - /** - * Sets [Builder.structuredOutputJsonSchema] to an arbitrary JSON value. - * - * You should usually call [Builder.structuredOutputJsonSchema] with a - * well-typed [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun structuredOutputJsonSchema(structuredOutputJsonSchema: JsonField) = - apply { - this.structuredOutputJsonSchema = structuredOutputJsonSchema - } - - fun structuredOutputJsonSchemaName(structuredOutputJsonSchemaName: String?) = - structuredOutputJsonSchemaName( - JsonField.ofNullable(structuredOutputJsonSchemaName) - ) - - /** - * Alias for calling [Builder.structuredOutputJsonSchemaName] with - * `structuredOutputJsonSchemaName.orElse(null)`. - */ - fun structuredOutputJsonSchemaName( - structuredOutputJsonSchemaName: Optional - ) = structuredOutputJsonSchemaName(structuredOutputJsonSchemaName.getOrNull()) - - /** - * Sets [Builder.structuredOutputJsonSchemaName] to an arbitrary JSON value. - * - * You should usually call [Builder.structuredOutputJsonSchemaName] with a - * well-typed [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun structuredOutputJsonSchemaName( - structuredOutputJsonSchemaName: JsonField - ) = apply { - this.structuredOutputJsonSchemaName = structuredOutputJsonSchemaName - } - - 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 - } - - fun systemPromptAppend(systemPromptAppend: String?) = - systemPromptAppend(JsonField.ofNullable(systemPromptAppend)) - - /** - * Alias for calling [Builder.systemPromptAppend] with - * `systemPromptAppend.orElse(null)`. - */ - fun systemPromptAppend(systemPromptAppend: Optional) = - systemPromptAppend(systemPromptAppend.getOrNull()) - - /** - * Sets [Builder.systemPromptAppend] to an arbitrary JSON value. - * - * You should usually call [Builder.systemPromptAppend] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun systemPromptAppend(systemPromptAppend: JsonField) = apply { - this.systemPromptAppend = systemPromptAppend - } - - fun takeScreenshot(takeScreenshot: Boolean?) = - takeScreenshot(JsonField.ofNullable(takeScreenshot)) - - /** - * Alias for [Builder.takeScreenshot]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun takeScreenshot(takeScreenshot: Boolean) = - takeScreenshot(takeScreenshot as Boolean?) - - /** - * Alias for calling [Builder.takeScreenshot] with - * `takeScreenshot.orElse(null)`. - */ - fun takeScreenshot(takeScreenshot: Optional) = - takeScreenshot(takeScreenshot.getOrNull()) - - /** - * Sets [Builder.takeScreenshot] to an arbitrary JSON value. - * - * You should usually call [Builder.takeScreenshot] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun takeScreenshot(takeScreenshot: JsonField) = apply { - this.takeScreenshot = takeScreenshot - } - - 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 - } - - fun tier(tier: String?) = tier(JsonField.ofNullable(tier)) - - /** Alias for calling [Builder.tier] with `tier.orElse(null)`. */ - fun tier(tier: Optional) = tier(tier.getOrNull()) - - /** - * Sets [Builder.tier] to an arbitrary JSON value. - * - * You should usually call [Builder.tier] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun tier(tier: JsonField) = apply { this.tier = tier } - - 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 useVendorMultimodalModel(useVendorMultimodalModel: Boolean?) = - useVendorMultimodalModel(JsonField.ofNullable(useVendorMultimodalModel)) - - /** - * Alias for [Builder.useVendorMultimodalModel]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun useVendorMultimodalModel(useVendorMultimodalModel: Boolean) = - useVendorMultimodalModel(useVendorMultimodalModel as Boolean?) - - /** - * Alias for calling [Builder.useVendorMultimodalModel] with - * `useVendorMultimodalModel.orElse(null)`. - */ - fun useVendorMultimodalModel(useVendorMultimodalModel: Optional) = - useVendorMultimodalModel(useVendorMultimodalModel.getOrNull()) - - /** - * Sets [Builder.useVendorMultimodalModel] to an arbitrary JSON value. - * - * You should usually call [Builder.useVendorMultimodalModel] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun useVendorMultimodalModel(useVendorMultimodalModel: JsonField) = - apply { - this.useVendorMultimodalModel = useVendorMultimodalModel - } - - fun userPrompt(userPrompt: String?) = - userPrompt(JsonField.ofNullable(userPrompt)) - - /** Alias for calling [Builder.userPrompt] with `userPrompt.orElse(null)`. */ - fun userPrompt(userPrompt: Optional) = - userPrompt(userPrompt.getOrNull()) - - /** - * Sets [Builder.userPrompt] to an arbitrary JSON value. - * - * You should usually call [Builder.userPrompt] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun userPrompt(userPrompt: JsonField) = apply { - this.userPrompt = userPrompt - } - - fun vendorMultimodalApiKey(vendorMultimodalApiKey: String?) = - vendorMultimodalApiKey(JsonField.ofNullable(vendorMultimodalApiKey)) - - /** - * Alias for calling [Builder.vendorMultimodalApiKey] with - * `vendorMultimodalApiKey.orElse(null)`. - */ - fun vendorMultimodalApiKey(vendorMultimodalApiKey: Optional) = - vendorMultimodalApiKey(vendorMultimodalApiKey.getOrNull()) - - /** - * Sets [Builder.vendorMultimodalApiKey] to an arbitrary JSON value. - * - * You should usually call [Builder.vendorMultimodalApiKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun vendorMultimodalApiKey(vendorMultimodalApiKey: JsonField) = apply { - this.vendorMultimodalApiKey = vendorMultimodalApiKey - } - - fun vendorMultimodalModelName(vendorMultimodalModelName: String?) = - vendorMultimodalModelName(JsonField.ofNullable(vendorMultimodalModelName)) - - /** - * Alias for calling [Builder.vendorMultimodalModelName] with - * `vendorMultimodalModelName.orElse(null)`. - */ - fun vendorMultimodalModelName(vendorMultimodalModelName: Optional) = - vendorMultimodalModelName(vendorMultimodalModelName.getOrNull()) - - /** - * Sets [Builder.vendorMultimodalModelName] to an arbitrary JSON value. - * - * You should usually call [Builder.vendorMultimodalModelName] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun vendorMultimodalModelName(vendorMultimodalModelName: JsonField) = - apply { - this.vendorMultimodalModelName = vendorMultimodalModelName - } - - 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 } - - /** Outbound webhook endpoints to notify on job status changes */ - fun webhookConfigurations(webhookConfigurations: List?) = - webhookConfigurations(JsonField.ofNullable(webhookConfigurations)) - - /** - * Alias for calling [Builder.webhookConfigurations] with - * `webhookConfigurations.orElse(null)`. - */ - fun webhookConfigurations( - webhookConfigurations: Optional> - ) = webhookConfigurations(webhookConfigurations.getOrNull()) - - /** - * Sets [Builder.webhookConfigurations] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookConfigurations] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun webhookConfigurations( - webhookConfigurations: JsonField> - ) = apply { - this.webhookConfigurations = - webhookConfigurations.map { it.toMutableList() } - } - - /** - * Adds a single [WebhookConfiguration] to [webhookConfigurations]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addWebhookConfiguration(webhookConfiguration: WebhookConfiguration) = - apply { - webhookConfigurations = - (webhookConfigurations ?: JsonField.of(mutableListOf())).also { - checkKnown("webhookConfigurations", it) - .add(webhookConfiguration) - } - } - - fun webhookUrl(webhookUrl: String?) = - webhookUrl(JsonField.ofNullable(webhookUrl)) - - /** Alias for calling [Builder.webhookUrl] with `webhookUrl.orElse(null)`. */ - fun webhookUrl(webhookUrl: Optional) = - webhookUrl(webhookUrl.getOrNull()) - - /** - * Sets [Builder.webhookUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun webhookUrl(webhookUrl: JsonField) = apply { - this.webhookUrl = webhookUrl - } - - 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 [Parameters]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Parameters = - Parameters( - adaptiveLongTable, - aggressiveTableExtraction, - annotateLinks, - annotateRevisions, - autoMode, - autoModeConfigurationJson, - autoModeTriggerOnImageInPage, - autoModeTriggerOnRegexpInPage, - autoModeTriggerOnTableInPage, - autoModeTriggerOnTextInPage, - azureOpenAIApiVersion, - azureOpenAIDeploymentName, - azureOpenAIEndpoint, - azureOpenAIKey, - bboxBottom, - bboxLeft, - bboxRight, - bboxTop, - boundingBox, - compactMarkdownTable, - complementalFormattingInstruction, - confidenceScoreEffort, - contentGuidelineInstruction, - continuousMode, - customMetadata, - disableImageExtraction, - disableOcr, - disableReconstruction, - doNotCache, - doNotUnrollColumns, - enableCostOptimizer, - extractCharts, - extractLayout, - extractPrintedPageNumber, - fastMode, - formattingInstruction, - gpt4oApiKey, - gpt4oMode, - guessXlsxSheetName, - hideFooters, - hideHeaders, - highResOcr, - htmlMakeAllElementsVisible, - htmlRemoveFixedElements, - htmlRemoveNavigationElements, - httpProxy, - ignoreDocumentElementsForLayoutDetection, - (imagesToSave ?: JsonMissing.of()).map { it.toImmutable() }, - inlineImagesInMarkdown, - inputS3Path, - inputS3Region, - inputUrl, - internalIsScreenshotJob, - invalidateCache, - isFormattingInstruction, - jobTimeoutExtraTimePerPageInSeconds, - jobTimeoutInSeconds, - keepPageSeparatorWhenMergingTables, - lang, - (languages ?: JsonMissing.of()).map { it.toImmutable() }, - layoutAware, - lineLevelBoundingBox, - markdownTableMultilineHeaderSeparator, - maxPages, - maxPagesEnforced, - mergeTablesAcrossPagesInMarkdown, - model, - outlinedTableExtraction, - outputPdfOfDocument, - outputS3PathPrefix, - outputS3Region, - outputTablesAsHtml, - outputBucket, - pageErrorTolerance, - pageFooterPrefix, - pageFooterSuffix, - pageHeaderPrefix, - pageHeaderSuffix, - pagePrefix, - pageSeparator, - pageSuffix, - parseMode, - parsingInstruction, - pipelineId, - preciseBoundingBox, - premiumMode, - presentationOutOfBoundsContent, - presentationSkipEmbeddedData, - preserveLayoutAlignmentAcrossPages, - preserveVerySmallText, - preset, - priority, - projectId, - removeHiddenText, - replaceFailedPageMode, - replaceFailedPageWithErrorMessagePrefix, - replaceFailedPageWithErrorMessageSuffix, - resourceInfo, - saveImages, - skipDiagonalText, - specializedChartParsingAgentic, - specializedChartParsingEfficient, - specializedChartParsingPlus, - specializedImageParsing, - spreadsheetExtractSubTables, - spreadsheetForceFormulaComputation, - spreadsheetIncludeHiddenSheets, - strictModeBuggyFont, - strictModeImageExtraction, - strictModeImageOcr, - strictModeReconstruction, - structuredOutput, - structuredOutputJsonSchema, - structuredOutputJsonSchemaName, - systemPrompt, - systemPromptAppend, - takeScreenshot, - targetPages, - tier, - type, - useVendorMultimodalModel, - userPrompt, - vendorMultimodalApiKey, - vendorMultimodalModelName, - version, - (webhookConfigurations ?: JsonMissing.of()).map { it.toImmutable() }, - webhookUrl, - 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(): Parameters = apply { - if (validated) { - return@apply - } - - adaptiveLongTable() - aggressiveTableExtraction() - annotateLinks() - annotateRevisions() - autoMode() - autoModeConfigurationJson() - autoModeTriggerOnImageInPage() - autoModeTriggerOnRegexpInPage() - autoModeTriggerOnTableInPage() - autoModeTriggerOnTextInPage() - azureOpenAIApiVersion() - azureOpenAIDeploymentName() - azureOpenAIEndpoint() - azureOpenAIKey() - bboxBottom() - bboxLeft() - bboxRight() - bboxTop() - boundingBox() - compactMarkdownTable() - complementalFormattingInstruction() - confidenceScoreEffort() - contentGuidelineInstruction() - continuousMode() - customMetadata().ifPresent { it.validate() } - disableImageExtraction() - disableOcr() - disableReconstruction() - doNotCache() - doNotUnrollColumns() - enableCostOptimizer() - extractCharts() - extractLayout() - extractPrintedPageNumber() - fastMode() - formattingInstruction() - gpt4oApiKey() - gpt4oMode() - guessXlsxSheetName() - hideFooters() - hideHeaders() - highResOcr() - htmlMakeAllElementsVisible() - htmlRemoveFixedElements() - htmlRemoveNavigationElements() - httpProxy() - ignoreDocumentElementsForLayoutDetection() - imagesToSave().ifPresent { it.forEach { it.validate() } } - inlineImagesInMarkdown() - inputS3Path() - inputS3Region() - inputUrl() - internalIsScreenshotJob() - invalidateCache() - isFormattingInstruction() - jobTimeoutExtraTimePerPageInSeconds() - jobTimeoutInSeconds() - keepPageSeparatorWhenMergingTables() - lang() - languages().ifPresent { it.forEach { it.validate() } } - layoutAware() - lineLevelBoundingBox() - markdownTableMultilineHeaderSeparator() - maxPages() - maxPagesEnforced() - mergeTablesAcrossPagesInMarkdown() - model() - outlinedTableExtraction() - outputPdfOfDocument() - outputS3PathPrefix() - outputS3Region() - outputTablesAsHtml() - outputBucket() - pageErrorTolerance() - pageFooterPrefix() - pageFooterSuffix() - pageHeaderPrefix() - pageHeaderSuffix() - pagePrefix() - pageSeparator() - pageSuffix() - parseMode().ifPresent { it.validate() } - parsingInstruction() - pipelineId() - preciseBoundingBox() - premiumMode() - presentationOutOfBoundsContent() - presentationSkipEmbeddedData() - preserveLayoutAlignmentAcrossPages() - preserveVerySmallText() - preset() - priority().ifPresent { it.validate() } - projectId() - removeHiddenText() - replaceFailedPageMode().ifPresent { it.validate() } - replaceFailedPageWithErrorMessagePrefix() - replaceFailedPageWithErrorMessageSuffix() - resourceInfo().ifPresent { it.validate() } - saveImages() - skipDiagonalText() - specializedChartParsingAgentic() - specializedChartParsingEfficient() - specializedChartParsingPlus() - specializedImageParsing() - spreadsheetExtractSubTables() - spreadsheetForceFormulaComputation() - spreadsheetIncludeHiddenSheets() - strictModeBuggyFont() - strictModeImageExtraction() - strictModeImageOcr() - strictModeReconstruction() - structuredOutput() - structuredOutputJsonSchema() - structuredOutputJsonSchemaName() - systemPrompt() - systemPromptAppend() - takeScreenshot() - targetPages() - tier() - type().ifPresent { it.validate() } - useVendorMultimodalModel() - userPrompt() - vendorMultimodalApiKey() - vendorMultimodalModelName() - version() - webhookConfigurations().ifPresent { it.forEach { it.validate() } } - webhookUrl() - 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 (adaptiveLongTable.asKnown().isPresent) 1 else 0) + - (if (aggressiveTableExtraction.asKnown().isPresent) 1 else 0) + - (if (annotateLinks.asKnown().isPresent) 1 else 0) + - (if (annotateRevisions.asKnown().isPresent) 1 else 0) + - (if (autoMode.asKnown().isPresent) 1 else 0) + - (if (autoModeConfigurationJson.asKnown().isPresent) 1 else 0) + - (if (autoModeTriggerOnImageInPage.asKnown().isPresent) 1 else 0) + - (if (autoModeTriggerOnRegexpInPage.asKnown().isPresent) 1 else 0) + - (if (autoModeTriggerOnTableInPage.asKnown().isPresent) 1 else 0) + - (if (autoModeTriggerOnTextInPage.asKnown().isPresent) 1 else 0) + - (if (azureOpenAIApiVersion.asKnown().isPresent) 1 else 0) + - (if (azureOpenAIDeploymentName.asKnown().isPresent) 1 else 0) + - (if (azureOpenAIEndpoint.asKnown().isPresent) 1 else 0) + - (if (azureOpenAIKey.asKnown().isPresent) 1 else 0) + - (if (bboxBottom.asKnown().isPresent) 1 else 0) + - (if (bboxLeft.asKnown().isPresent) 1 else 0) + - (if (bboxRight.asKnown().isPresent) 1 else 0) + - (if (bboxTop.asKnown().isPresent) 1 else 0) + - (if (boundingBox.asKnown().isPresent) 1 else 0) + - (if (compactMarkdownTable.asKnown().isPresent) 1 else 0) + - (if (complementalFormattingInstruction.asKnown().isPresent) 1 else 0) + - (if (confidenceScoreEffort.asKnown().isPresent) 1 else 0) + - (if (contentGuidelineInstruction.asKnown().isPresent) 1 else 0) + - (if (continuousMode.asKnown().isPresent) 1 else 0) + - (customMetadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (disableImageExtraction.asKnown().isPresent) 1 else 0) + - (if (disableOcr.asKnown().isPresent) 1 else 0) + - (if (disableReconstruction.asKnown().isPresent) 1 else 0) + - (if (doNotCache.asKnown().isPresent) 1 else 0) + - (if (doNotUnrollColumns.asKnown().isPresent) 1 else 0) + - (if (enableCostOptimizer.asKnown().isPresent) 1 else 0) + - (if (extractCharts.asKnown().isPresent) 1 else 0) + - (if (extractLayout.asKnown().isPresent) 1 else 0) + - (if (extractPrintedPageNumber.asKnown().isPresent) 1 else 0) + - (if (fastMode.asKnown().isPresent) 1 else 0) + - (if (formattingInstruction.asKnown().isPresent) 1 else 0) + - (if (gpt4oApiKey.asKnown().isPresent) 1 else 0) + - (if (gpt4oMode.asKnown().isPresent) 1 else 0) + - (if (guessXlsxSheetName.asKnown().isPresent) 1 else 0) + - (if (hideFooters.asKnown().isPresent) 1 else 0) + - (if (hideHeaders.asKnown().isPresent) 1 else 0) + - (if (highResOcr.asKnown().isPresent) 1 else 0) + - (if (htmlMakeAllElementsVisible.asKnown().isPresent) 1 else 0) + - (if (htmlRemoveFixedElements.asKnown().isPresent) 1 else 0) + - (if (htmlRemoveNavigationElements.asKnown().isPresent) 1 else 0) + - (if (httpProxy.asKnown().isPresent) 1 else 0) + - (if (ignoreDocumentElementsForLayoutDetection.asKnown().isPresent) 1 - else 0) + - (imagesToSave.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (inlineImagesInMarkdown.asKnown().isPresent) 1 else 0) + - (if (inputS3Path.asKnown().isPresent) 1 else 0) + - (if (inputS3Region.asKnown().isPresent) 1 else 0) + - (if (inputUrl.asKnown().isPresent) 1 else 0) + - (if (internalIsScreenshotJob.asKnown().isPresent) 1 else 0) + - (if (invalidateCache.asKnown().isPresent) 1 else 0) + - (if (isFormattingInstruction.asKnown().isPresent) 1 else 0) + - (if (jobTimeoutExtraTimePerPageInSeconds.asKnown().isPresent) 1 else 0) + - (if (jobTimeoutInSeconds.asKnown().isPresent) 1 else 0) + - (if (keepPageSeparatorWhenMergingTables.asKnown().isPresent) 1 else 0) + - (if (lang.asKnown().isPresent) 1 else 0) + - (languages.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (if (layoutAware.asKnown().isPresent) 1 else 0) + - (if (lineLevelBoundingBox.asKnown().isPresent) 1 else 0) + - (if (markdownTableMultilineHeaderSeparator.asKnown().isPresent) 1 else 0) + - (if (maxPages.asKnown().isPresent) 1 else 0) + - (if (maxPagesEnforced.asKnown().isPresent) 1 else 0) + - (if (mergeTablesAcrossPagesInMarkdown.asKnown().isPresent) 1 else 0) + - (if (model.asKnown().isPresent) 1 else 0) + - (if (outlinedTableExtraction.asKnown().isPresent) 1 else 0) + - (if (outputPdfOfDocument.asKnown().isPresent) 1 else 0) + - (if (outputS3PathPrefix.asKnown().isPresent) 1 else 0) + - (if (outputS3Region.asKnown().isPresent) 1 else 0) + - (if (outputTablesAsHtml.asKnown().isPresent) 1 else 0) + - (if (outputBucket.asKnown().isPresent) 1 else 0) + - (if (pageErrorTolerance.asKnown().isPresent) 1 else 0) + - (if (pageFooterPrefix.asKnown().isPresent) 1 else 0) + - (if (pageFooterSuffix.asKnown().isPresent) 1 else 0) + - (if (pageHeaderPrefix.asKnown().isPresent) 1 else 0) + - (if (pageHeaderSuffix.asKnown().isPresent) 1 else 0) + - (if (pagePrefix.asKnown().isPresent) 1 else 0) + - (if (pageSeparator.asKnown().isPresent) 1 else 0) + - (if (pageSuffix.asKnown().isPresent) 1 else 0) + - (parseMode.asKnown().getOrNull()?.validity() ?: 0) + - (if (parsingInstruction.asKnown().isPresent) 1 else 0) + - (if (pipelineId.asKnown().isPresent) 1 else 0) + - (if (preciseBoundingBox.asKnown().isPresent) 1 else 0) + - (if (premiumMode.asKnown().isPresent) 1 else 0) + - (if (presentationOutOfBoundsContent.asKnown().isPresent) 1 else 0) + - (if (presentationSkipEmbeddedData.asKnown().isPresent) 1 else 0) + - (if (preserveLayoutAlignmentAcrossPages.asKnown().isPresent) 1 else 0) + - (if (preserveVerySmallText.asKnown().isPresent) 1 else 0) + - (if (preset.asKnown().isPresent) 1 else 0) + - (priority.asKnown().getOrNull()?.validity() ?: 0) + - (if (projectId.asKnown().isPresent) 1 else 0) + - (if (removeHiddenText.asKnown().isPresent) 1 else 0) + - (replaceFailedPageMode.asKnown().getOrNull()?.validity() ?: 0) + - (if (replaceFailedPageWithErrorMessagePrefix.asKnown().isPresent) 1 - else 0) + - (if (replaceFailedPageWithErrorMessageSuffix.asKnown().isPresent) 1 - else 0) + - (resourceInfo.asKnown().getOrNull()?.validity() ?: 0) + - (if (saveImages.asKnown().isPresent) 1 else 0) + - (if (skipDiagonalText.asKnown().isPresent) 1 else 0) + - (if (specializedChartParsingAgentic.asKnown().isPresent) 1 else 0) + - (if (specializedChartParsingEfficient.asKnown().isPresent) 1 else 0) + - (if (specializedChartParsingPlus.asKnown().isPresent) 1 else 0) + - (if (specializedImageParsing.asKnown().isPresent) 1 else 0) + - (if (spreadsheetExtractSubTables.asKnown().isPresent) 1 else 0) + - (if (spreadsheetForceFormulaComputation.asKnown().isPresent) 1 else 0) + - (if (spreadsheetIncludeHiddenSheets.asKnown().isPresent) 1 else 0) + - (if (strictModeBuggyFont.asKnown().isPresent) 1 else 0) + - (if (strictModeImageExtraction.asKnown().isPresent) 1 else 0) + - (if (strictModeImageOcr.asKnown().isPresent) 1 else 0) + - (if (strictModeReconstruction.asKnown().isPresent) 1 else 0) + - (if (structuredOutput.asKnown().isPresent) 1 else 0) + - (if (structuredOutputJsonSchema.asKnown().isPresent) 1 else 0) + - (if (structuredOutputJsonSchemaName.asKnown().isPresent) 1 else 0) + - (if (systemPrompt.asKnown().isPresent) 1 else 0) + - (if (systemPromptAppend.asKnown().isPresent) 1 else 0) + - (if (takeScreenshot.asKnown().isPresent) 1 else 0) + - (if (targetPages.asKnown().isPresent) 1 else 0) + - (if (tier.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (useVendorMultimodalModel.asKnown().isPresent) 1 else 0) + - (if (userPrompt.asKnown().isPresent) 1 else 0) + - (if (vendorMultimodalApiKey.asKnown().isPresent) 1 else 0) + - (if (vendorMultimodalModelName.asKnown().isPresent) 1 else 0) + - (if (version.asKnown().isPresent) 1 else 0) + - (webhookConfigurations.asKnown().getOrNull()?.sumOf { - it.validity().toInt() - } ?: 0) + - (if (webhookUrl.asKnown().isPresent) 1 else 0) - - /** The custom metadata to attach to the documents. */ - class CustomMetadata - @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 - * [CustomMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(customMetadata: CustomMetadata) = apply { - additionalProperties = - customMetadata.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 [CustomMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CustomMetadata = - CustomMetadata(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(): CustomMetadata = 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 CustomMetadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CustomMetadata{additionalProperties=$additionalProperties}" - } - - class ImagesToSave - @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 EMBEDDED = of("embedded") - - @JvmField val LAYOUT = of("layout") - - @JvmField val SCREENSHOT = of("screenshot") - - @JvmStatic fun of(value: String) = ImagesToSave(JsonField.of(value)) - } - - /** An enum containing [ImagesToSave]'s known values. */ - enum class Known { - EMBEDDED, - LAYOUT, - SCREENSHOT, - } - - /** - * An enum containing [ImagesToSave]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [ImagesToSave] 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 { - EMBEDDED, - LAYOUT, - SCREENSHOT, - /** - * An enum member indicating that [ImagesToSave] 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) { - EMBEDDED -> Value.EMBEDDED - LAYOUT -> Value.LAYOUT - SCREENSHOT -> Value.SCREENSHOT - 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) { - EMBEDDED -> Known.EMBEDDED - LAYOUT -> Known.LAYOUT - SCREENSHOT -> Known.SCREENSHOT - else -> - throw LlamaCloudInvalidDataException("Unknown ImagesToSave: $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(): ImagesToSave = 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 ImagesToSave && 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() - } - - /** The resource info about the file */ - class ResourceInfo - @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 [ResourceInfo]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ResourceInfo]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(resourceInfo: ResourceInfo) = apply { - additionalProperties = resourceInfo.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 [ResourceInfo]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): ResourceInfo = ResourceInfo(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(): ResourceInfo = 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 ResourceInfo && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ResourceInfo{additionalProperties=$additionalProperties}" - } - - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PARSE = of("parse") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - PARSE - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PARSE, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - 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) { - PARSE -> Known.PARSE - else -> throw LlamaCloudInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws 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(): Type = 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 Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Configuration for a single outbound webhook endpoint. */ - class WebhookConfiguration - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val webhookEvents: JsonField>, - private val webhookHeaders: JsonField, - private val webhookOutputFormat: JsonField, - private val webhookSigningSecret: JsonField, - private val webhookUrl: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("webhook_events") - @ExcludeMissing - webhookEvents: JsonField> = JsonMissing.of(), - @JsonProperty("webhook_headers") - @ExcludeMissing - webhookHeaders: JsonField = JsonMissing.of(), - @JsonProperty("webhook_output_format") - @ExcludeMissing - webhookOutputFormat: JsonField = JsonMissing.of(), - @JsonProperty("webhook_signing_secret") - @ExcludeMissing - webhookSigningSecret: JsonField = JsonMissing.of(), - @JsonProperty("webhook_url") - @ExcludeMissing - webhookUrl: JsonField = JsonMissing.of(), - ) : this( - webhookEvents, - webhookHeaders, - webhookOutputFormat, - webhookSigningSecret, - webhookUrl, - mutableMapOf(), - ) - - /** - * Events to subscribe to (e.g. 'parse.success', 'extract.error'). If null, all - * events are delivered. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun webhookEvents(): Optional> = - webhookEvents.getOptional("webhook_events") - - /** - * Custom HTTP headers sent with each webhook request (e.g. auth tokens) - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun webhookHeaders(): Optional = - webhookHeaders.getOptional("webhook_headers") - - /** - * Response format sent to the webhook: 'string' (default) or 'json' - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun webhookOutputFormat(): Optional = - webhookOutputFormat.getOptional("webhook_output_format") - - /** - * Shared signing secret used to sign webhook deliveries. When set, each request - * includes an HMAC-SHA256 signature of the request body in the 'LC-Signature' - * header (value 'sha256='). Recompute the HMAC over the raw request body - * with this secret to verify the delivery is authentic. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun webhookSigningSecret(): Optional = - webhookSigningSecret.getOptional("webhook_signing_secret") - - /** - * URL to receive webhook POST notifications - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun webhookUrl(): Optional = webhookUrl.getOptional("webhook_url") - - /** - * Returns the raw JSON value of [webhookEvents]. - * - * Unlike [webhookEvents], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("webhook_events") - @ExcludeMissing - fun _webhookEvents(): JsonField> = webhookEvents - - /** - * Returns the raw JSON value of [webhookHeaders]. - * - * Unlike [webhookHeaders], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("webhook_headers") - @ExcludeMissing - fun _webhookHeaders(): JsonField = webhookHeaders - - /** - * Returns the raw JSON value of [webhookOutputFormat]. - * - * Unlike [webhookOutputFormat], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("webhook_output_format") - @ExcludeMissing - fun _webhookOutputFormat(): JsonField = webhookOutputFormat - - /** - * Returns the raw JSON value of [webhookSigningSecret]. - * - * Unlike [webhookSigningSecret], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("webhook_signing_secret") - @ExcludeMissing - fun _webhookSigningSecret(): JsonField = webhookSigningSecret - - /** - * Returns the raw JSON value of [webhookUrl]. - * - * Unlike [webhookUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("webhook_url") - @ExcludeMissing - fun _webhookUrl(): JsonField = webhookUrl - - @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 - * [WebhookConfiguration]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [WebhookConfiguration]. */ - class Builder internal constructor() { - - private var webhookEvents: JsonField>? = null - private var webhookHeaders: JsonField = JsonMissing.of() - private var webhookOutputFormat: JsonField = JsonMissing.of() - private var webhookSigningSecret: JsonField = JsonMissing.of() - private var webhookUrl: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(webhookConfiguration: WebhookConfiguration) = apply { - webhookEvents = - webhookConfiguration.webhookEvents.map { it.toMutableList() } - webhookHeaders = webhookConfiguration.webhookHeaders - webhookOutputFormat = webhookConfiguration.webhookOutputFormat - webhookSigningSecret = webhookConfiguration.webhookSigningSecret - webhookUrl = webhookConfiguration.webhookUrl - additionalProperties = - webhookConfiguration.additionalProperties.toMutableMap() - } - - /** - * Events to subscribe to (e.g. 'parse.success', 'extract.error'). If null, - * all events are delivered. - */ - fun webhookEvents(webhookEvents: List?) = - webhookEvents(JsonField.ofNullable(webhookEvents)) - - /** - * Alias for calling [Builder.webhookEvents] with - * `webhookEvents.orElse(null)`. - */ - fun webhookEvents(webhookEvents: Optional>) = - webhookEvents(webhookEvents.getOrNull()) - - /** - * Sets [Builder.webhookEvents] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookEvents] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun webhookEvents(webhookEvents: JsonField>) = apply { - this.webhookEvents = webhookEvents.map { it.toMutableList() } - } - - /** - * Adds a single [WebhookEvent] to [webhookEvents]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addWebhookEvent(webhookEvent: WebhookEvent) = apply { - webhookEvents = - (webhookEvents ?: JsonField.of(mutableListOf())).also { - checkKnown("webhookEvents", it).add(webhookEvent) - } - } - - /** Custom HTTP headers sent with each webhook request (e.g. auth tokens) */ - fun webhookHeaders(webhookHeaders: WebhookHeaders?) = - webhookHeaders(JsonField.ofNullable(webhookHeaders)) - - /** - * Alias for calling [Builder.webhookHeaders] with - * `webhookHeaders.orElse(null)`. - */ - fun webhookHeaders(webhookHeaders: Optional) = - webhookHeaders(webhookHeaders.getOrNull()) - - /** - * Sets [Builder.webhookHeaders] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookHeaders] with a well-typed - * [WebhookHeaders] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun webhookHeaders(webhookHeaders: JsonField) = apply { - this.webhookHeaders = webhookHeaders - } - - /** Response format sent to the webhook: 'string' (default) or 'json' */ - fun webhookOutputFormat(webhookOutputFormat: String?) = - webhookOutputFormat(JsonField.ofNullable(webhookOutputFormat)) - - /** - * Alias for calling [Builder.webhookOutputFormat] with - * `webhookOutputFormat.orElse(null)`. - */ - fun webhookOutputFormat(webhookOutputFormat: Optional) = - webhookOutputFormat(webhookOutputFormat.getOrNull()) - - /** - * Sets [Builder.webhookOutputFormat] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookOutputFormat] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun webhookOutputFormat(webhookOutputFormat: JsonField) = apply { - this.webhookOutputFormat = webhookOutputFormat - } - - /** - * Shared signing secret used to sign webhook deliveries. When set, each - * request includes an HMAC-SHA256 signature of the request body in the - * 'LC-Signature' header (value 'sha256='). Recompute the HMAC over the - * raw request body with this secret to verify the delivery is authentic. - */ - fun webhookSigningSecret(webhookSigningSecret: String?) = - webhookSigningSecret(JsonField.ofNullable(webhookSigningSecret)) - - /** - * Alias for calling [Builder.webhookSigningSecret] with - * `webhookSigningSecret.orElse(null)`. - */ - fun webhookSigningSecret(webhookSigningSecret: Optional) = - webhookSigningSecret(webhookSigningSecret.getOrNull()) - - /** - * Sets [Builder.webhookSigningSecret] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookSigningSecret] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun webhookSigningSecret(webhookSigningSecret: JsonField) = apply { - this.webhookSigningSecret = webhookSigningSecret - } - - /** URL to receive webhook POST notifications */ - fun webhookUrl(webhookUrl: String?) = - webhookUrl(JsonField.ofNullable(webhookUrl)) - - /** - * Alias for calling [Builder.webhookUrl] with `webhookUrl.orElse(null)`. - */ - fun webhookUrl(webhookUrl: Optional) = - webhookUrl(webhookUrl.getOrNull()) - - /** - * Sets [Builder.webhookUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookUrl] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun webhookUrl(webhookUrl: JsonField) = apply { - this.webhookUrl = webhookUrl - } - - 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 [WebhookConfiguration]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): WebhookConfiguration = - WebhookConfiguration( - (webhookEvents ?: JsonMissing.of()).map { it.toImmutable() }, - webhookHeaders, - webhookOutputFormat, - webhookSigningSecret, - webhookUrl, - 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(): WebhookConfiguration = apply { - if (validated) { - return@apply - } - - webhookEvents().ifPresent { it.forEach { it.validate() } } - webhookHeaders().ifPresent { it.validate() } - webhookOutputFormat() - webhookSigningSecret() - webhookUrl() - 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 = - (webhookEvents.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (webhookHeaders.asKnown().getOrNull()?.validity() ?: 0) + - (if (webhookOutputFormat.asKnown().isPresent) 1 else 0) + - (if (webhookSigningSecret.asKnown().isPresent) 1 else 0) + - (if (webhookUrl.asKnown().isPresent) 1 else 0) - - class WebhookEvent - @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 BATCH_CANCELLED = of("batch.cancelled") - - @JvmField val BATCH_ERROR = of("batch.error") - - @JvmField val BATCH_PENDING = of("batch.pending") - - @JvmField val BATCH_RUNNING = of("batch.running") - - @JvmField val BATCH_SUCCESS = of("batch.success") - - @JvmField val CLASSIFY_CANCELLED = of("classify.cancelled") - - @JvmField val CLASSIFY_ERROR = of("classify.error") - - @JvmField val CLASSIFY_PARTIAL_SUCCESS = of("classify.partial_success") - - @JvmField val CLASSIFY_PENDING = of("classify.pending") - - @JvmField val CLASSIFY_RUNNING = of("classify.running") - - @JvmField val CLASSIFY_SUCCESS = of("classify.success") - - @JvmField val EXTRACT_CANCELLED = of("extract.cancelled") - - @JvmField val EXTRACT_ERROR = of("extract.error") - - @JvmField val EXTRACT_PARTIAL_SUCCESS = of("extract.partial_success") - - @JvmField val EXTRACT_PENDING = of("extract.pending") - - @JvmField val EXTRACT_SUCCESS = of("extract.success") - - @JvmField val PARSE_CANCELLED = of("parse.cancelled") - - @JvmField val PARSE_ERROR = of("parse.error") - - @JvmField val PARSE_PARTIAL_SUCCESS = of("parse.partial_success") - - @JvmField val PARSE_PENDING = of("parse.pending") - - @JvmField val PARSE_RUNNING = of("parse.running") - - @JvmField val PARSE_SUCCESS = of("parse.success") - - @JvmField val SHEETS_CANCELLED = of("sheets.cancelled") - - @JvmField val SHEETS_ERROR = of("sheets.error") - - @JvmField val SHEETS_PARTIAL_SUCCESS = of("sheets.partial_success") - - @JvmField val SHEETS_PENDING = of("sheets.pending") - - @JvmField val SHEETS_SUCCESS = of("sheets.success") - - @JvmField val SPLIT_CANCELLED = of("split.cancelled") - - @JvmField val SPLIT_ERROR = of("split.error") - - @JvmField val SPLIT_PENDING = of("split.pending") - - @JvmField val SPLIT_PROCESSING = of("split.processing") - - @JvmField val SPLIT_SUCCESS = of("split.success") - - @JvmField val UNMAPPED_EVENT = of("unmapped_event") - - @JvmStatic fun of(value: String) = WebhookEvent(JsonField.of(value)) - } - - /** An enum containing [WebhookEvent]'s known values. */ - enum class Known { - BATCH_CANCELLED, - BATCH_ERROR, - BATCH_PENDING, - BATCH_RUNNING, - BATCH_SUCCESS, - CLASSIFY_CANCELLED, - CLASSIFY_ERROR, - CLASSIFY_PARTIAL_SUCCESS, - CLASSIFY_PENDING, - CLASSIFY_RUNNING, - CLASSIFY_SUCCESS, - EXTRACT_CANCELLED, - EXTRACT_ERROR, - EXTRACT_PARTIAL_SUCCESS, - EXTRACT_PENDING, - EXTRACT_SUCCESS, - PARSE_CANCELLED, - PARSE_ERROR, - PARSE_PARTIAL_SUCCESS, - PARSE_PENDING, - PARSE_RUNNING, - PARSE_SUCCESS, - SHEETS_CANCELLED, - SHEETS_ERROR, - SHEETS_PARTIAL_SUCCESS, - SHEETS_PENDING, - SHEETS_SUCCESS, - SPLIT_CANCELLED, - SPLIT_ERROR, - SPLIT_PENDING, - SPLIT_PROCESSING, - SPLIT_SUCCESS, - UNMAPPED_EVENT, - } - - /** - * An enum containing [WebhookEvent]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [WebhookEvent] 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 { - BATCH_CANCELLED, - BATCH_ERROR, - BATCH_PENDING, - BATCH_RUNNING, - BATCH_SUCCESS, - CLASSIFY_CANCELLED, - CLASSIFY_ERROR, - CLASSIFY_PARTIAL_SUCCESS, - CLASSIFY_PENDING, - CLASSIFY_RUNNING, - CLASSIFY_SUCCESS, - EXTRACT_CANCELLED, - EXTRACT_ERROR, - EXTRACT_PARTIAL_SUCCESS, - EXTRACT_PENDING, - EXTRACT_SUCCESS, - PARSE_CANCELLED, - PARSE_ERROR, - PARSE_PARTIAL_SUCCESS, - PARSE_PENDING, - PARSE_RUNNING, - PARSE_SUCCESS, - SHEETS_CANCELLED, - SHEETS_ERROR, - SHEETS_PARTIAL_SUCCESS, - SHEETS_PENDING, - SHEETS_SUCCESS, - SPLIT_CANCELLED, - SPLIT_ERROR, - SPLIT_PENDING, - SPLIT_PROCESSING, - SPLIT_SUCCESS, - UNMAPPED_EVENT, - /** - * An enum member indicating that [WebhookEvent] 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) { - BATCH_CANCELLED -> Value.BATCH_CANCELLED - BATCH_ERROR -> Value.BATCH_ERROR - BATCH_PENDING -> Value.BATCH_PENDING - BATCH_RUNNING -> Value.BATCH_RUNNING - BATCH_SUCCESS -> Value.BATCH_SUCCESS - CLASSIFY_CANCELLED -> Value.CLASSIFY_CANCELLED - CLASSIFY_ERROR -> Value.CLASSIFY_ERROR - CLASSIFY_PARTIAL_SUCCESS -> Value.CLASSIFY_PARTIAL_SUCCESS - CLASSIFY_PENDING -> Value.CLASSIFY_PENDING - CLASSIFY_RUNNING -> Value.CLASSIFY_RUNNING - CLASSIFY_SUCCESS -> Value.CLASSIFY_SUCCESS - EXTRACT_CANCELLED -> Value.EXTRACT_CANCELLED - EXTRACT_ERROR -> Value.EXTRACT_ERROR - EXTRACT_PARTIAL_SUCCESS -> Value.EXTRACT_PARTIAL_SUCCESS - EXTRACT_PENDING -> Value.EXTRACT_PENDING - EXTRACT_SUCCESS -> Value.EXTRACT_SUCCESS - PARSE_CANCELLED -> Value.PARSE_CANCELLED - PARSE_ERROR -> Value.PARSE_ERROR - PARSE_PARTIAL_SUCCESS -> Value.PARSE_PARTIAL_SUCCESS - PARSE_PENDING -> Value.PARSE_PENDING - PARSE_RUNNING -> Value.PARSE_RUNNING - PARSE_SUCCESS -> Value.PARSE_SUCCESS - SHEETS_CANCELLED -> Value.SHEETS_CANCELLED - SHEETS_ERROR -> Value.SHEETS_ERROR - SHEETS_PARTIAL_SUCCESS -> Value.SHEETS_PARTIAL_SUCCESS - SHEETS_PENDING -> Value.SHEETS_PENDING - SHEETS_SUCCESS -> Value.SHEETS_SUCCESS - SPLIT_CANCELLED -> Value.SPLIT_CANCELLED - SPLIT_ERROR -> Value.SPLIT_ERROR - SPLIT_PENDING -> Value.SPLIT_PENDING - SPLIT_PROCESSING -> Value.SPLIT_PROCESSING - SPLIT_SUCCESS -> Value.SPLIT_SUCCESS - UNMAPPED_EVENT -> Value.UNMAPPED_EVENT - 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) { - BATCH_CANCELLED -> Known.BATCH_CANCELLED - BATCH_ERROR -> Known.BATCH_ERROR - BATCH_PENDING -> Known.BATCH_PENDING - BATCH_RUNNING -> Known.BATCH_RUNNING - BATCH_SUCCESS -> Known.BATCH_SUCCESS - CLASSIFY_CANCELLED -> Known.CLASSIFY_CANCELLED - CLASSIFY_ERROR -> Known.CLASSIFY_ERROR - CLASSIFY_PARTIAL_SUCCESS -> Known.CLASSIFY_PARTIAL_SUCCESS - CLASSIFY_PENDING -> Known.CLASSIFY_PENDING - CLASSIFY_RUNNING -> Known.CLASSIFY_RUNNING - CLASSIFY_SUCCESS -> Known.CLASSIFY_SUCCESS - EXTRACT_CANCELLED -> Known.EXTRACT_CANCELLED - EXTRACT_ERROR -> Known.EXTRACT_ERROR - EXTRACT_PARTIAL_SUCCESS -> Known.EXTRACT_PARTIAL_SUCCESS - EXTRACT_PENDING -> Known.EXTRACT_PENDING - EXTRACT_SUCCESS -> Known.EXTRACT_SUCCESS - PARSE_CANCELLED -> Known.PARSE_CANCELLED - PARSE_ERROR -> Known.PARSE_ERROR - PARSE_PARTIAL_SUCCESS -> Known.PARSE_PARTIAL_SUCCESS - PARSE_PENDING -> Known.PARSE_PENDING - PARSE_RUNNING -> Known.PARSE_RUNNING - PARSE_SUCCESS -> Known.PARSE_SUCCESS - SHEETS_CANCELLED -> Known.SHEETS_CANCELLED - SHEETS_ERROR -> Known.SHEETS_ERROR - SHEETS_PARTIAL_SUCCESS -> Known.SHEETS_PARTIAL_SUCCESS - SHEETS_PENDING -> Known.SHEETS_PENDING - SHEETS_SUCCESS -> Known.SHEETS_SUCCESS - SPLIT_CANCELLED -> Known.SPLIT_CANCELLED - SPLIT_ERROR -> Known.SPLIT_ERROR - SPLIT_PENDING -> Known.SPLIT_PENDING - SPLIT_PROCESSING -> Known.SPLIT_PROCESSING - SPLIT_SUCCESS -> Known.SPLIT_SUCCESS - UNMAPPED_EVENT -> Known.UNMAPPED_EVENT - else -> - throw LlamaCloudInvalidDataException( - "Unknown WebhookEvent: $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(): WebhookEvent = 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 WebhookEvent && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Custom HTTP headers sent with each webhook request (e.g. auth tokens) */ - class WebhookHeaders - @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 - * [WebhookHeaders]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [WebhookHeaders]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(webhookHeaders: WebhookHeaders) = apply { - additionalProperties = - webhookHeaders.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 [WebhookHeaders]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): WebhookHeaders = - WebhookHeaders(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(): WebhookHeaders = 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 WebhookHeaders && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "WebhookHeaders{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is WebhookConfiguration && - webhookEvents == other.webhookEvents && - webhookHeaders == other.webhookHeaders && - webhookOutputFormat == other.webhookOutputFormat && - webhookSigningSecret == other.webhookSigningSecret && - webhookUrl == other.webhookUrl && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - webhookEvents, - webhookHeaders, - webhookOutputFormat, - webhookSigningSecret, - webhookUrl, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "WebhookConfiguration{webhookEvents=$webhookEvents, webhookHeaders=$webhookHeaders, webhookOutputFormat=$webhookOutputFormat, webhookSigningSecret=$webhookSigningSecret, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Parameters && - adaptiveLongTable == other.adaptiveLongTable && - aggressiveTableExtraction == other.aggressiveTableExtraction && - annotateLinks == other.annotateLinks && - annotateRevisions == other.annotateRevisions && - autoMode == other.autoMode && - autoModeConfigurationJson == other.autoModeConfigurationJson && - autoModeTriggerOnImageInPage == other.autoModeTriggerOnImageInPage && - autoModeTriggerOnRegexpInPage == other.autoModeTriggerOnRegexpInPage && - autoModeTriggerOnTableInPage == other.autoModeTriggerOnTableInPage && - autoModeTriggerOnTextInPage == other.autoModeTriggerOnTextInPage && - azureOpenAIApiVersion == other.azureOpenAIApiVersion && - azureOpenAIDeploymentName == other.azureOpenAIDeploymentName && - azureOpenAIEndpoint == other.azureOpenAIEndpoint && - azureOpenAIKey == other.azureOpenAIKey && - bboxBottom == other.bboxBottom && - bboxLeft == other.bboxLeft && - bboxRight == other.bboxRight && - bboxTop == other.bboxTop && - boundingBox == other.boundingBox && - compactMarkdownTable == other.compactMarkdownTable && - complementalFormattingInstruction == - other.complementalFormattingInstruction && - confidenceScoreEffort == other.confidenceScoreEffort && - contentGuidelineInstruction == other.contentGuidelineInstruction && - continuousMode == other.continuousMode && - customMetadata == other.customMetadata && - disableImageExtraction == other.disableImageExtraction && - disableOcr == other.disableOcr && - disableReconstruction == other.disableReconstruction && - doNotCache == other.doNotCache && - doNotUnrollColumns == other.doNotUnrollColumns && - enableCostOptimizer == other.enableCostOptimizer && - extractCharts == other.extractCharts && - extractLayout == other.extractLayout && - extractPrintedPageNumber == other.extractPrintedPageNumber && - fastMode == other.fastMode && - formattingInstruction == other.formattingInstruction && - gpt4oApiKey == other.gpt4oApiKey && - gpt4oMode == other.gpt4oMode && - guessXlsxSheetName == other.guessXlsxSheetName && - hideFooters == other.hideFooters && - hideHeaders == other.hideHeaders && - highResOcr == other.highResOcr && - htmlMakeAllElementsVisible == other.htmlMakeAllElementsVisible && - htmlRemoveFixedElements == other.htmlRemoveFixedElements && - htmlRemoveNavigationElements == other.htmlRemoveNavigationElements && - httpProxy == other.httpProxy && - ignoreDocumentElementsForLayoutDetection == - other.ignoreDocumentElementsForLayoutDetection && - imagesToSave == other.imagesToSave && - inlineImagesInMarkdown == other.inlineImagesInMarkdown && - inputS3Path == other.inputS3Path && - inputS3Region == other.inputS3Region && - inputUrl == other.inputUrl && - internalIsScreenshotJob == other.internalIsScreenshotJob && - invalidateCache == other.invalidateCache && - isFormattingInstruction == other.isFormattingInstruction && - jobTimeoutExtraTimePerPageInSeconds == - other.jobTimeoutExtraTimePerPageInSeconds && - jobTimeoutInSeconds == other.jobTimeoutInSeconds && - keepPageSeparatorWhenMergingTables == - other.keepPageSeparatorWhenMergingTables && - lang == other.lang && - languages == other.languages && - layoutAware == other.layoutAware && - lineLevelBoundingBox == other.lineLevelBoundingBox && - markdownTableMultilineHeaderSeparator == - other.markdownTableMultilineHeaderSeparator && - maxPages == other.maxPages && - maxPagesEnforced == other.maxPagesEnforced && - mergeTablesAcrossPagesInMarkdown == - other.mergeTablesAcrossPagesInMarkdown && - model == other.model && - outlinedTableExtraction == other.outlinedTableExtraction && - outputPdfOfDocument == other.outputPdfOfDocument && - outputS3PathPrefix == other.outputS3PathPrefix && - outputS3Region == other.outputS3Region && - outputTablesAsHtml == other.outputTablesAsHtml && - outputBucket == other.outputBucket && - pageErrorTolerance == other.pageErrorTolerance && - pageFooterPrefix == other.pageFooterPrefix && - pageFooterSuffix == other.pageFooterSuffix && - pageHeaderPrefix == other.pageHeaderPrefix && - pageHeaderSuffix == other.pageHeaderSuffix && - pagePrefix == other.pagePrefix && - pageSeparator == other.pageSeparator && - pageSuffix == other.pageSuffix && - parseMode == other.parseMode && - parsingInstruction == other.parsingInstruction && - pipelineId == other.pipelineId && - preciseBoundingBox == other.preciseBoundingBox && - premiumMode == other.premiumMode && - presentationOutOfBoundsContent == other.presentationOutOfBoundsContent && - presentationSkipEmbeddedData == other.presentationSkipEmbeddedData && - preserveLayoutAlignmentAcrossPages == - other.preserveLayoutAlignmentAcrossPages && - preserveVerySmallText == other.preserveVerySmallText && - preset == other.preset && - priority == other.priority && - projectId == other.projectId && - removeHiddenText == other.removeHiddenText && - replaceFailedPageMode == other.replaceFailedPageMode && - replaceFailedPageWithErrorMessagePrefix == - other.replaceFailedPageWithErrorMessagePrefix && - replaceFailedPageWithErrorMessageSuffix == - other.replaceFailedPageWithErrorMessageSuffix && - resourceInfo == other.resourceInfo && - saveImages == other.saveImages && - skipDiagonalText == other.skipDiagonalText && - specializedChartParsingAgentic == other.specializedChartParsingAgentic && - specializedChartParsingEfficient == - other.specializedChartParsingEfficient && - specializedChartParsingPlus == other.specializedChartParsingPlus && - specializedImageParsing == other.specializedImageParsing && - spreadsheetExtractSubTables == other.spreadsheetExtractSubTables && - spreadsheetForceFormulaComputation == - other.spreadsheetForceFormulaComputation && - spreadsheetIncludeHiddenSheets == other.spreadsheetIncludeHiddenSheets && - strictModeBuggyFont == other.strictModeBuggyFont && - strictModeImageExtraction == other.strictModeImageExtraction && - strictModeImageOcr == other.strictModeImageOcr && - strictModeReconstruction == other.strictModeReconstruction && - structuredOutput == other.structuredOutput && - structuredOutputJsonSchema == other.structuredOutputJsonSchema && - structuredOutputJsonSchemaName == other.structuredOutputJsonSchemaName && - systemPrompt == other.systemPrompt && - systemPromptAppend == other.systemPromptAppend && - takeScreenshot == other.takeScreenshot && - targetPages == other.targetPages && - tier == other.tier && - type == other.type && - useVendorMultimodalModel == other.useVendorMultimodalModel && - userPrompt == other.userPrompt && - vendorMultimodalApiKey == other.vendorMultimodalApiKey && - vendorMultimodalModelName == other.vendorMultimodalModelName && - version == other.version && - webhookConfigurations == other.webhookConfigurations && - webhookUrl == other.webhookUrl && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - adaptiveLongTable, - aggressiveTableExtraction, - annotateLinks, - annotateRevisions, - autoMode, - autoModeConfigurationJson, - autoModeTriggerOnImageInPage, - autoModeTriggerOnRegexpInPage, - autoModeTriggerOnTableInPage, - autoModeTriggerOnTextInPage, - azureOpenAIApiVersion, - azureOpenAIDeploymentName, - azureOpenAIEndpoint, - azureOpenAIKey, - bboxBottom, - bboxLeft, - bboxRight, - bboxTop, - boundingBox, - compactMarkdownTable, - complementalFormattingInstruction, - confidenceScoreEffort, - contentGuidelineInstruction, - continuousMode, - customMetadata, - disableImageExtraction, - disableOcr, - disableReconstruction, - doNotCache, - doNotUnrollColumns, - enableCostOptimizer, - extractCharts, - extractLayout, - extractPrintedPageNumber, - fastMode, - formattingInstruction, - gpt4oApiKey, - gpt4oMode, - guessXlsxSheetName, - hideFooters, - hideHeaders, - highResOcr, - htmlMakeAllElementsVisible, - htmlRemoveFixedElements, - htmlRemoveNavigationElements, - httpProxy, - ignoreDocumentElementsForLayoutDetection, - imagesToSave, - inlineImagesInMarkdown, - inputS3Path, - inputS3Region, - inputUrl, - internalIsScreenshotJob, - invalidateCache, - isFormattingInstruction, - jobTimeoutExtraTimePerPageInSeconds, - jobTimeoutInSeconds, - keepPageSeparatorWhenMergingTables, - lang, - languages, - layoutAware, - lineLevelBoundingBox, - markdownTableMultilineHeaderSeparator, - maxPages, - maxPagesEnforced, - mergeTablesAcrossPagesInMarkdown, - model, - outlinedTableExtraction, - outputPdfOfDocument, - outputS3PathPrefix, - outputS3Region, - outputTablesAsHtml, - outputBucket, - pageErrorTolerance, - pageFooterPrefix, - pageFooterSuffix, - pageHeaderPrefix, - pageHeaderSuffix, - pagePrefix, - pageSeparator, - pageSuffix, - parseMode, - parsingInstruction, - pipelineId, - preciseBoundingBox, - premiumMode, - presentationOutOfBoundsContent, - presentationSkipEmbeddedData, - preserveLayoutAlignmentAcrossPages, - preserveVerySmallText, - preset, - priority, - projectId, - removeHiddenText, - replaceFailedPageMode, - replaceFailedPageWithErrorMessagePrefix, - replaceFailedPageWithErrorMessageSuffix, - resourceInfo, - saveImages, - skipDiagonalText, - specializedChartParsingAgentic, - specializedChartParsingEfficient, - specializedChartParsingPlus, - specializedImageParsing, - spreadsheetExtractSubTables, - spreadsheetForceFormulaComputation, - spreadsheetIncludeHiddenSheets, - strictModeBuggyFont, - strictModeImageExtraction, - strictModeImageOcr, - strictModeReconstruction, - structuredOutput, - structuredOutputJsonSchema, - structuredOutputJsonSchemaName, - systemPrompt, - systemPromptAppend, - takeScreenshot, - targetPages, - tier, - type, - useVendorMultimodalModel, - userPrompt, - vendorMultimodalApiKey, - vendorMultimodalModelName, - version, - webhookConfigurations, - webhookUrl, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Parameters{adaptiveLongTable=$adaptiveLongTable, aggressiveTableExtraction=$aggressiveTableExtraction, annotateLinks=$annotateLinks, annotateRevisions=$annotateRevisions, autoMode=$autoMode, autoModeConfigurationJson=$autoModeConfigurationJson, autoModeTriggerOnImageInPage=$autoModeTriggerOnImageInPage, autoModeTriggerOnRegexpInPage=$autoModeTriggerOnRegexpInPage, autoModeTriggerOnTableInPage=$autoModeTriggerOnTableInPage, autoModeTriggerOnTextInPage=$autoModeTriggerOnTextInPage, azureOpenAIApiVersion=$azureOpenAIApiVersion, azureOpenAIDeploymentName=$azureOpenAIDeploymentName, azureOpenAIEndpoint=$azureOpenAIEndpoint, azureOpenAIKey=$azureOpenAIKey, bboxBottom=$bboxBottom, bboxLeft=$bboxLeft, bboxRight=$bboxRight, bboxTop=$bboxTop, boundingBox=$boundingBox, compactMarkdownTable=$compactMarkdownTable, complementalFormattingInstruction=$complementalFormattingInstruction, confidenceScoreEffort=$confidenceScoreEffort, contentGuidelineInstruction=$contentGuidelineInstruction, continuousMode=$continuousMode, customMetadata=$customMetadata, disableImageExtraction=$disableImageExtraction, disableOcr=$disableOcr, disableReconstruction=$disableReconstruction, doNotCache=$doNotCache, doNotUnrollColumns=$doNotUnrollColumns, enableCostOptimizer=$enableCostOptimizer, extractCharts=$extractCharts, extractLayout=$extractLayout, extractPrintedPageNumber=$extractPrintedPageNumber, fastMode=$fastMode, formattingInstruction=$formattingInstruction, gpt4oApiKey=$gpt4oApiKey, gpt4oMode=$gpt4oMode, guessXlsxSheetName=$guessXlsxSheetName, hideFooters=$hideFooters, hideHeaders=$hideHeaders, highResOcr=$highResOcr, htmlMakeAllElementsVisible=$htmlMakeAllElementsVisible, htmlRemoveFixedElements=$htmlRemoveFixedElements, htmlRemoveNavigationElements=$htmlRemoveNavigationElements, httpProxy=$httpProxy, ignoreDocumentElementsForLayoutDetection=$ignoreDocumentElementsForLayoutDetection, imagesToSave=$imagesToSave, inlineImagesInMarkdown=$inlineImagesInMarkdown, inputS3Path=$inputS3Path, inputS3Region=$inputS3Region, inputUrl=$inputUrl, internalIsScreenshotJob=$internalIsScreenshotJob, invalidateCache=$invalidateCache, isFormattingInstruction=$isFormattingInstruction, jobTimeoutExtraTimePerPageInSeconds=$jobTimeoutExtraTimePerPageInSeconds, jobTimeoutInSeconds=$jobTimeoutInSeconds, keepPageSeparatorWhenMergingTables=$keepPageSeparatorWhenMergingTables, lang=$lang, languages=$languages, layoutAware=$layoutAware, lineLevelBoundingBox=$lineLevelBoundingBox, markdownTableMultilineHeaderSeparator=$markdownTableMultilineHeaderSeparator, maxPages=$maxPages, maxPagesEnforced=$maxPagesEnforced, mergeTablesAcrossPagesInMarkdown=$mergeTablesAcrossPagesInMarkdown, model=$model, outlinedTableExtraction=$outlinedTableExtraction, outputPdfOfDocument=$outputPdfOfDocument, outputS3PathPrefix=$outputS3PathPrefix, outputS3Region=$outputS3Region, outputTablesAsHtml=$outputTablesAsHtml, outputBucket=$outputBucket, pageErrorTolerance=$pageErrorTolerance, pageFooterPrefix=$pageFooterPrefix, pageFooterSuffix=$pageFooterSuffix, pageHeaderPrefix=$pageHeaderPrefix, pageHeaderSuffix=$pageHeaderSuffix, pagePrefix=$pagePrefix, pageSeparator=$pageSeparator, pageSuffix=$pageSuffix, parseMode=$parseMode, parsingInstruction=$parsingInstruction, pipelineId=$pipelineId, preciseBoundingBox=$preciseBoundingBox, premiumMode=$premiumMode, presentationOutOfBoundsContent=$presentationOutOfBoundsContent, presentationSkipEmbeddedData=$presentationSkipEmbeddedData, preserveLayoutAlignmentAcrossPages=$preserveLayoutAlignmentAcrossPages, preserveVerySmallText=$preserveVerySmallText, preset=$preset, priority=$priority, projectId=$projectId, removeHiddenText=$removeHiddenText, replaceFailedPageMode=$replaceFailedPageMode, replaceFailedPageWithErrorMessagePrefix=$replaceFailedPageWithErrorMessagePrefix, replaceFailedPageWithErrorMessageSuffix=$replaceFailedPageWithErrorMessageSuffix, resourceInfo=$resourceInfo, saveImages=$saveImages, skipDiagonalText=$skipDiagonalText, specializedChartParsingAgentic=$specializedChartParsingAgentic, specializedChartParsingEfficient=$specializedChartParsingEfficient, specializedChartParsingPlus=$specializedChartParsingPlus, specializedImageParsing=$specializedImageParsing, spreadsheetExtractSubTables=$spreadsheetExtractSubTables, spreadsheetForceFormulaComputation=$spreadsheetForceFormulaComputation, spreadsheetIncludeHiddenSheets=$spreadsheetIncludeHiddenSheets, strictModeBuggyFont=$strictModeBuggyFont, strictModeImageExtraction=$strictModeImageExtraction, strictModeImageOcr=$strictModeImageOcr, strictModeReconstruction=$strictModeReconstruction, structuredOutput=$structuredOutput, structuredOutputJsonSchema=$structuredOutputJsonSchema, structuredOutputJsonSchemaName=$structuredOutputJsonSchemaName, systemPrompt=$systemPrompt, systemPromptAppend=$systemPromptAppend, takeScreenshot=$takeScreenshot, targetPages=$targetPages, tier=$tier, type=$type, useVendorMultimodalModel=$useVendorMultimodalModel, userPrompt=$userPrompt, vendorMultimodalApiKey=$vendorMultimodalApiKey, vendorMultimodalModelName=$vendorMultimodalModelName, version=$version, webhookConfigurations=$webhookConfigurations, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" - } - - /** The partitions for this execution. Used for determining where to save job output. */ - class Partitions - @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 [Partitions]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Partitions]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(partitions: Partitions) = apply { - additionalProperties = partitions.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 [Partitions]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Partitions = Partitions(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(): Partitions = 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 Partitions && additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = "Partitions{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BatchParseJobRecordCreate && - correlationId == other.correlationId && - jobName == other.jobName && - parameters == other.parameters && - parentJobExecutionId == other.parentJobExecutionId && - partitions == other.partitions && - projectId == other.projectId && - sessionId == other.sessionId && - userId == other.userId && - webhookUrl == other.webhookUrl && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - correlationId, - jobName, - parameters, - parentJobExecutionId, - partitions, - projectId, - sessionId, - userId, - webhookUrl, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BatchParseJobRecordCreate{correlationId=$correlationId, jobName=$jobName, parameters=$parameters, parentJobExecutionId=$parentJobExecutionId, partitions=$partitions, projectId=$projectId, sessionId=$sessionId, userId=$userId, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BatchCreateParams && - organizationId == other.organizationId && - projectId == other.projectId && - temporalNamespace == other.temporalNamespace && - body == other.body && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash( - organizationId, - projectId, - temporalNamespace, - body, - additionalHeaders, - additionalQueryParams, - ) - - override fun toString() = - "BatchCreateParams{organizationId=$organizationId, projectId=$projectId, temporalNamespace=$temporalNamespace, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateResponse.kt deleted file mode 100644 index 1af69ae..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateResponse.kt +++ /dev/null @@ -1,1172 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch - -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.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 - -/** Response schema for a batch processing job. */ -class BatchCreateResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val id: JsonField, - private val jobType: JsonField, - private val projectId: JsonField, - private val status: JsonField, - private val totalItems: JsonField, - private val completedAt: JsonField, - private val createdAt: JsonField, - private val directoryId: JsonField, - private val effectiveAt: JsonField, - private val errorMessage: JsonField, - private val failedItems: JsonField, - private val jobRecordId: JsonField, - private val processedItems: JsonField, - private val skippedItems: JsonField, - private val startedAt: JsonField, - private val updatedAt: JsonField, - private val workflowId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("job_type") @ExcludeMissing jobType: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("total_items") @ExcludeMissing totalItems: JsonField = JsonMissing.of(), - @JsonProperty("completed_at") - @ExcludeMissing - completedAt: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("directory_id") - @ExcludeMissing - directoryId: JsonField = JsonMissing.of(), - @JsonProperty("effective_at") - @ExcludeMissing - effectiveAt: JsonField = JsonMissing.of(), - @JsonProperty("error_message") - @ExcludeMissing - errorMessage: JsonField = JsonMissing.of(), - @JsonProperty("failed_items") - @ExcludeMissing - failedItems: JsonField = JsonMissing.of(), - @JsonProperty("job_record_id") - @ExcludeMissing - jobRecordId: JsonField = JsonMissing.of(), - @JsonProperty("processed_items") - @ExcludeMissing - processedItems: JsonField = JsonMissing.of(), - @JsonProperty("skipped_items") - @ExcludeMissing - skippedItems: JsonField = JsonMissing.of(), - @JsonProperty("started_at") - @ExcludeMissing - startedAt: JsonField = JsonMissing.of(), - @JsonProperty("updated_at") - @ExcludeMissing - updatedAt: JsonField = JsonMissing.of(), - @JsonProperty("workflow_id") - @ExcludeMissing - workflowId: JsonField = JsonMissing.of(), - ) : this( - id, - jobType, - projectId, - status, - totalItems, - completedAt, - createdAt, - directoryId, - effectiveAt, - errorMessage, - failedItems, - jobRecordId, - processedItems, - skippedItems, - startedAt, - updatedAt, - workflowId, - mutableMapOf(), - ) - - /** - * Unique identifier for the batch 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") - - /** - * Type of processing operation (parse or classify) - * - * @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 jobType(): JobType = jobType.getRequired("job_type") - - /** - * Project this job 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") - - /** - * Current 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(): Status = status.getRequired("status") - - /** - * Total number of items in the 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 totalItems(): Long = totalItems.getRequired("total_items") - - /** - * Timestamp when job completed - * - * @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") - - /** - * Creation datetime - * - * @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") - - /** - * Directory being processed - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun directoryId(): Optional = directoryId.getOptional("directory_id") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun effectiveAt(): Optional = effectiveAt.getOptional("effective_at") - - /** - * Error message for the latest job attempt, 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") - - /** - * Number of items that failed processing - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun failedItems(): Optional = failedItems.getOptional("failed_items") - - /** - * The job record ID associated with this status, if any. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun jobRecordId(): Optional = jobRecordId.getOptional("job_record_id") - - /** - * Number of items processed so far - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun processedItems(): Optional = processedItems.getOptional("processed_items") - - /** - * Number of items skipped (already processed or size limit) - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun skippedItems(): Optional = skippedItems.getOptional("skipped_items") - - /** - * Timestamp when job processing started - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun startedAt(): Optional = startedAt.getOptional("started_at") - - /** - * Update datetime - * - * @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") - - /** - * Async job tracking ID - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun workflowId(): Optional = workflowId.getOptional("workflow_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 [jobType]. - * - * Unlike [jobType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("job_type") @ExcludeMissing fun _jobType(): JsonField = jobType - - /** - * 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 [totalItems]. - * - * Unlike [totalItems], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("total_items") @ExcludeMissing fun _totalItems(): JsonField = totalItems - - /** - * 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 [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 [directoryId]. - * - * Unlike [directoryId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("directory_id") - @ExcludeMissing - fun _directoryId(): JsonField = directoryId - - /** - * Returns the raw JSON value of [effectiveAt]. - * - * Unlike [effectiveAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("effective_at") - @ExcludeMissing - fun _effectiveAt(): JsonField = effectiveAt - - /** - * 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 [failedItems]. - * - * Unlike [failedItems], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("failed_items") @ExcludeMissing fun _failedItems(): JsonField = failedItems - - /** - * Returns the raw JSON value of [jobRecordId]. - * - * Unlike [jobRecordId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("job_record_id") - @ExcludeMissing - fun _jobRecordId(): JsonField = jobRecordId - - /** - * Returns the raw JSON value of [processedItems]. - * - * Unlike [processedItems], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("processed_items") - @ExcludeMissing - fun _processedItems(): JsonField = processedItems - - /** - * Returns the raw JSON value of [skippedItems]. - * - * Unlike [skippedItems], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("skipped_items") - @ExcludeMissing - fun _skippedItems(): JsonField = skippedItems - - /** - * Returns the raw JSON value of [startedAt]. - * - * Unlike [startedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("started_at") - @ExcludeMissing - fun _startedAt(): JsonField = startedAt - - /** - * 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 [workflowId]. - * - * Unlike [workflowId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("workflow_id") @ExcludeMissing fun _workflowId(): JsonField = workflowId - - @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 [BatchCreateResponse]. - * - * The following fields are required: - * ```java - * .id() - * .jobType() - * .projectId() - * .status() - * .totalItems() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchCreateResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var jobType: JsonField? = null - private var projectId: JsonField? = null - private var status: JsonField? = null - private var totalItems: JsonField? = null - private var completedAt: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var directoryId: JsonField = JsonMissing.of() - private var effectiveAt: JsonField = JsonMissing.of() - private var errorMessage: JsonField = JsonMissing.of() - private var failedItems: JsonField = JsonMissing.of() - private var jobRecordId: JsonField = JsonMissing.of() - private var processedItems: JsonField = JsonMissing.of() - private var skippedItems: JsonField = JsonMissing.of() - private var startedAt: JsonField = JsonMissing.of() - private var updatedAt: JsonField = JsonMissing.of() - private var workflowId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(batchCreateResponse: BatchCreateResponse) = apply { - id = batchCreateResponse.id - jobType = batchCreateResponse.jobType - projectId = batchCreateResponse.projectId - status = batchCreateResponse.status - totalItems = batchCreateResponse.totalItems - completedAt = batchCreateResponse.completedAt - createdAt = batchCreateResponse.createdAt - directoryId = batchCreateResponse.directoryId - effectiveAt = batchCreateResponse.effectiveAt - errorMessage = batchCreateResponse.errorMessage - failedItems = batchCreateResponse.failedItems - jobRecordId = batchCreateResponse.jobRecordId - processedItems = batchCreateResponse.processedItems - skippedItems = batchCreateResponse.skippedItems - startedAt = batchCreateResponse.startedAt - updatedAt = batchCreateResponse.updatedAt - workflowId = batchCreateResponse.workflowId - additionalProperties = batchCreateResponse.additionalProperties.toMutableMap() - } - - /** Unique identifier for the batch 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 } - - /** Type of processing operation (parse or classify) */ - fun jobType(jobType: JobType) = jobType(JsonField.of(jobType)) - - /** - * Sets [Builder.jobType] to an arbitrary JSON value. - * - * You should usually call [Builder.jobType] with a well-typed [JobType] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun jobType(jobType: JsonField) = apply { this.jobType = jobType } - - /** Project this job 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 } - - /** Current job status */ - fun status(status: Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - /** Total number of items in the job */ - fun totalItems(totalItems: Long) = totalItems(JsonField.of(totalItems)) - - /** - * Sets [Builder.totalItems] to an arbitrary JSON value. - * - * You should usually call [Builder.totalItems] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun totalItems(totalItems: JsonField) = apply { this.totalItems = totalItems } - - /** Timestamp when job completed */ - 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 - } - - /** Creation datetime */ - 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 } - - /** Directory being processed */ - fun directoryId(directoryId: String?) = directoryId(JsonField.ofNullable(directoryId)) - - /** Alias for calling [Builder.directoryId] with `directoryId.orElse(null)`. */ - fun directoryId(directoryId: Optional) = directoryId(directoryId.getOrNull()) - - /** - * Sets [Builder.directoryId] to an arbitrary JSON value. - * - * You should usually call [Builder.directoryId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun directoryId(directoryId: JsonField) = apply { this.directoryId = directoryId } - - fun effectiveAt(effectiveAt: OffsetDateTime) = effectiveAt(JsonField.of(effectiveAt)) - - /** - * Sets [Builder.effectiveAt] to an arbitrary JSON value. - * - * You should usually call [Builder.effectiveAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun effectiveAt(effectiveAt: JsonField) = apply { - this.effectiveAt = effectiveAt - } - - /** Error message for the latest job attempt, 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 - } - - /** Number of items that failed processing */ - fun failedItems(failedItems: Long) = failedItems(JsonField.of(failedItems)) - - /** - * Sets [Builder.failedItems] to an arbitrary JSON value. - * - * You should usually call [Builder.failedItems] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun failedItems(failedItems: JsonField) = apply { this.failedItems = failedItems } - - /** The job record ID associated with this status, if any. */ - fun jobRecordId(jobRecordId: String?) = jobRecordId(JsonField.ofNullable(jobRecordId)) - - /** Alias for calling [Builder.jobRecordId] with `jobRecordId.orElse(null)`. */ - fun jobRecordId(jobRecordId: Optional) = jobRecordId(jobRecordId.getOrNull()) - - /** - * Sets [Builder.jobRecordId] to an arbitrary JSON value. - * - * You should usually call [Builder.jobRecordId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun jobRecordId(jobRecordId: JsonField) = apply { this.jobRecordId = jobRecordId } - - /** Number of items processed so far */ - fun processedItems(processedItems: Long) = processedItems(JsonField.of(processedItems)) - - /** - * Sets [Builder.processedItems] to an arbitrary JSON value. - * - * You should usually call [Builder.processedItems] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun processedItems(processedItems: JsonField) = apply { - this.processedItems = processedItems - } - - /** Number of items skipped (already processed or size limit) */ - fun skippedItems(skippedItems: Long) = skippedItems(JsonField.of(skippedItems)) - - /** - * Sets [Builder.skippedItems] to an arbitrary JSON value. - * - * You should usually call [Builder.skippedItems] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun skippedItems(skippedItems: JsonField) = apply { this.skippedItems = skippedItems } - - /** Timestamp when job processing started */ - fun startedAt(startedAt: OffsetDateTime?) = startedAt(JsonField.ofNullable(startedAt)) - - /** Alias for calling [Builder.startedAt] with `startedAt.orElse(null)`. */ - fun startedAt(startedAt: Optional) = startedAt(startedAt.getOrNull()) - - /** - * Sets [Builder.startedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startedAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun startedAt(startedAt: JsonField) = apply { this.startedAt = startedAt } - - /** Update datetime */ - 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 } - - /** Async job tracking ID */ - fun workflowId(workflowId: String?) = workflowId(JsonField.ofNullable(workflowId)) - - /** Alias for calling [Builder.workflowId] with `workflowId.orElse(null)`. */ - fun workflowId(workflowId: Optional) = workflowId(workflowId.getOrNull()) - - /** - * Sets [Builder.workflowId] to an arbitrary JSON value. - * - * You should usually call [Builder.workflowId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun workflowId(workflowId: JsonField) = apply { this.workflowId = workflowId } - - 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 [BatchCreateResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .jobType() - * .projectId() - * .status() - * .totalItems() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BatchCreateResponse = - BatchCreateResponse( - checkRequired("id", id), - checkRequired("jobType", jobType), - checkRequired("projectId", projectId), - checkRequired("status", status), - checkRequired("totalItems", totalItems), - completedAt, - createdAt, - directoryId, - effectiveAt, - errorMessage, - failedItems, - jobRecordId, - processedItems, - skippedItems, - startedAt, - updatedAt, - workflowId, - 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(): BatchCreateResponse = apply { - if (validated) { - return@apply - } - - id() - jobType().validate() - projectId() - status().validate() - totalItems() - completedAt() - createdAt() - directoryId() - effectiveAt() - errorMessage() - failedItems() - jobRecordId() - processedItems() - skippedItems() - startedAt() - updatedAt() - workflowId() - 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) + - (jobType.asKnown().getOrNull()?.validity() ?: 0) + - (if (projectId.asKnown().isPresent) 1 else 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) + - (if (totalItems.asKnown().isPresent) 1 else 0) + - (if (completedAt.asKnown().isPresent) 1 else 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (if (directoryId.asKnown().isPresent) 1 else 0) + - (if (effectiveAt.asKnown().isPresent) 1 else 0) + - (if (errorMessage.asKnown().isPresent) 1 else 0) + - (if (failedItems.asKnown().isPresent) 1 else 0) + - (if (jobRecordId.asKnown().isPresent) 1 else 0) + - (if (processedItems.asKnown().isPresent) 1 else 0) + - (if (skippedItems.asKnown().isPresent) 1 else 0) + - (if (startedAt.asKnown().isPresent) 1 else 0) + - (if (updatedAt.asKnown().isPresent) 1 else 0) + - (if (workflowId.asKnown().isPresent) 1 else 0) - - /** Type of processing operation (parse or classify) */ - 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() - } - - /** Current job status */ - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CANCELLED = of("cancelled") - - @JvmField val COMPLETED = of("completed") - - @JvmField val DISPATCHED = of("dispatched") - - @JvmField val FAILED = of("failed") - - @JvmField val PENDING = of("pending") - - @JvmField val RUNNING = of("running") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - CANCELLED, - COMPLETED, - DISPATCHED, - FAILED, - PENDING, - RUNNING, - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CANCELLED, - COMPLETED, - DISPATCHED, - FAILED, - PENDING, - RUNNING, - /** An enum member indicating that [Status] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CANCELLED -> Value.CANCELLED - COMPLETED -> Value.COMPLETED - DISPATCHED -> Value.DISPATCHED - FAILED -> Value.FAILED - PENDING -> Value.PENDING - RUNNING -> Value.RUNNING - 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) { - CANCELLED -> Known.CANCELLED - COMPLETED -> Known.COMPLETED - DISPATCHED -> Known.DISPATCHED - FAILED -> Known.FAILED - PENDING -> Known.PENDING - RUNNING -> Known.RUNNING - else -> throw LlamaCloudInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws 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(): Status = 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 Status && 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 BatchCreateResponse && - id == other.id && - jobType == other.jobType && - projectId == other.projectId && - status == other.status && - totalItems == other.totalItems && - completedAt == other.completedAt && - createdAt == other.createdAt && - directoryId == other.directoryId && - effectiveAt == other.effectiveAt && - errorMessage == other.errorMessage && - failedItems == other.failedItems && - jobRecordId == other.jobRecordId && - processedItems == other.processedItems && - skippedItems == other.skippedItems && - startedAt == other.startedAt && - updatedAt == other.updatedAt && - workflowId == other.workflowId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - jobType, - projectId, - status, - totalItems, - completedAt, - createdAt, - directoryId, - effectiveAt, - errorMessage, - failedItems, - jobRecordId, - processedItems, - skippedItems, - startedAt, - updatedAt, - workflowId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BatchCreateResponse{id=$id, jobType=$jobType, projectId=$projectId, status=$status, totalItems=$totalItems, completedAt=$completedAt, createdAt=$createdAt, directoryId=$directoryId, effectiveAt=$effectiveAt, errorMessage=$errorMessage, failedItems=$failedItems, jobRecordId=$jobRecordId, processedItems=$processedItems, skippedItems=$skippedItems, startedAt=$startedAt, updatedAt=$updatedAt, workflowId=$workflowId, additionalProperties=$additionalProperties}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchGetStatusResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchGetStatusResponse.kt deleted file mode 100644 index 689e82b..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchGetStatusResponse.kt +++ /dev/null @@ -1,1427 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch - -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.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 - -/** Detailed status response for a batch processing job. */ -class BatchGetStatusResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val job: JsonField, - private val progressPercentage: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("job") @ExcludeMissing job: JsonField = JsonMissing.of(), - @JsonProperty("progress_percentage") - @ExcludeMissing - progressPercentage: JsonField = JsonMissing.of(), - ) : this(job, progressPercentage, mutableMapOf()) - - /** - * Response schema for a batch processing 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 job(): Job = job.getRequired("job") - - /** - * Percentage of items processed (0-100) - * - * @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 progressPercentage(): Double = progressPercentage.getRequired("progress_percentage") - - /** - * Returns the raw JSON value of [job]. - * - * Unlike [job], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("job") @ExcludeMissing fun _job(): JsonField = job - - /** - * Returns the raw JSON value of [progressPercentage]. - * - * Unlike [progressPercentage], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("progress_percentage") - @ExcludeMissing - fun _progressPercentage(): JsonField = progressPercentage - - @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 [BatchGetStatusResponse]. - * - * The following fields are required: - * ```java - * .job() - * .progressPercentage() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchGetStatusResponse]. */ - class Builder internal constructor() { - - private var job: JsonField? = null - private var progressPercentage: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(batchGetStatusResponse: BatchGetStatusResponse) = apply { - job = batchGetStatusResponse.job - progressPercentage = batchGetStatusResponse.progressPercentage - additionalProperties = batchGetStatusResponse.additionalProperties.toMutableMap() - } - - /** Response schema for a batch processing job. */ - fun job(job: Job) = job(JsonField.of(job)) - - /** - * Sets [Builder.job] to an arbitrary JSON value. - * - * You should usually call [Builder.job] with a well-typed [Job] value instead. This method - * is primarily for setting the field to an undocumented or not yet supported value. - */ - fun job(job: JsonField) = apply { this.job = job } - - /** Percentage of items processed (0-100) */ - fun progressPercentage(progressPercentage: Double) = - progressPercentage(JsonField.of(progressPercentage)) - - /** - * Sets [Builder.progressPercentage] to an arbitrary JSON value. - * - * You should usually call [Builder.progressPercentage] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun progressPercentage(progressPercentage: JsonField) = apply { - this.progressPercentage = progressPercentage - } - - 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 [BatchGetStatusResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .job() - * .progressPercentage() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BatchGetStatusResponse = - BatchGetStatusResponse( - checkRequired("job", job), - checkRequired("progressPercentage", progressPercentage), - 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(): BatchGetStatusResponse = apply { - if (validated) { - return@apply - } - - job().validate() - progressPercentage() - 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 = - (job.asKnown().getOrNull()?.validity() ?: 0) + - (if (progressPercentage.asKnown().isPresent) 1 else 0) - - /** Response schema for a batch processing job. */ - class Job - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val id: JsonField, - private val jobType: JsonField, - private val projectId: JsonField, - private val status: JsonField, - private val totalItems: JsonField, - private val completedAt: JsonField, - private val createdAt: JsonField, - private val directoryId: JsonField, - private val effectiveAt: JsonField, - private val errorMessage: JsonField, - private val failedItems: JsonField, - private val jobRecordId: JsonField, - private val processedItems: JsonField, - private val skippedItems: JsonField, - private val startedAt: JsonField, - private val updatedAt: JsonField, - private val workflowId: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("job_type") - @ExcludeMissing - jobType: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - projectId: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("total_items") - @ExcludeMissing - totalItems: JsonField = JsonMissing.of(), - @JsonProperty("completed_at") - @ExcludeMissing - completedAt: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("directory_id") - @ExcludeMissing - directoryId: JsonField = JsonMissing.of(), - @JsonProperty("effective_at") - @ExcludeMissing - effectiveAt: JsonField = JsonMissing.of(), - @JsonProperty("error_message") - @ExcludeMissing - errorMessage: JsonField = JsonMissing.of(), - @JsonProperty("failed_items") - @ExcludeMissing - failedItems: JsonField = JsonMissing.of(), - @JsonProperty("job_record_id") - @ExcludeMissing - jobRecordId: JsonField = JsonMissing.of(), - @JsonProperty("processed_items") - @ExcludeMissing - processedItems: JsonField = JsonMissing.of(), - @JsonProperty("skipped_items") - @ExcludeMissing - skippedItems: JsonField = JsonMissing.of(), - @JsonProperty("started_at") - @ExcludeMissing - startedAt: JsonField = JsonMissing.of(), - @JsonProperty("updated_at") - @ExcludeMissing - updatedAt: JsonField = JsonMissing.of(), - @JsonProperty("workflow_id") - @ExcludeMissing - workflowId: JsonField = JsonMissing.of(), - ) : this( - id, - jobType, - projectId, - status, - totalItems, - completedAt, - createdAt, - directoryId, - effectiveAt, - errorMessage, - failedItems, - jobRecordId, - processedItems, - skippedItems, - startedAt, - updatedAt, - workflowId, - mutableMapOf(), - ) - - /** - * Unique identifier for the batch 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") - - /** - * Type of processing operation (parse or classify) - * - * @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 jobType(): JobType = jobType.getRequired("job_type") - - /** - * Project this job 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") - - /** - * Current 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(): Status = status.getRequired("status") - - /** - * Total number of items in the 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 totalItems(): Long = totalItems.getRequired("total_items") - - /** - * Timestamp when job completed - * - * @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") - - /** - * Creation datetime - * - * @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") - - /** - * Directory being processed - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun directoryId(): Optional = directoryId.getOptional("directory_id") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun effectiveAt(): Optional = effectiveAt.getOptional("effective_at") - - /** - * Error message for the latest job attempt, 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") - - /** - * Number of items that failed processing - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun failedItems(): Optional = failedItems.getOptional("failed_items") - - /** - * The job record ID associated with this status, if any. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun jobRecordId(): Optional = jobRecordId.getOptional("job_record_id") - - /** - * Number of items processed so far - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun processedItems(): Optional = processedItems.getOptional("processed_items") - - /** - * Number of items skipped (already processed or size limit) - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun skippedItems(): Optional = skippedItems.getOptional("skipped_items") - - /** - * Timestamp when job processing started - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun startedAt(): Optional = startedAt.getOptional("started_at") - - /** - * Update datetime - * - * @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") - - /** - * Async job tracking ID - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun workflowId(): Optional = workflowId.getOptional("workflow_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 [jobType]. - * - * Unlike [jobType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("job_type") @ExcludeMissing fun _jobType(): JsonField = jobType - - /** - * 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 [totalItems]. - * - * Unlike [totalItems], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("total_items") @ExcludeMissing fun _totalItems(): JsonField = totalItems - - /** - * 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 [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 [directoryId]. - * - * Unlike [directoryId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("directory_id") - @ExcludeMissing - fun _directoryId(): JsonField = directoryId - - /** - * Returns the raw JSON value of [effectiveAt]. - * - * Unlike [effectiveAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("effective_at") - @ExcludeMissing - fun _effectiveAt(): JsonField = effectiveAt - - /** - * 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 [failedItems]. - * - * Unlike [failedItems], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("failed_items") - @ExcludeMissing - fun _failedItems(): JsonField = failedItems - - /** - * Returns the raw JSON value of [jobRecordId]. - * - * Unlike [jobRecordId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("job_record_id") - @ExcludeMissing - fun _jobRecordId(): JsonField = jobRecordId - - /** - * Returns the raw JSON value of [processedItems]. - * - * Unlike [processedItems], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("processed_items") - @ExcludeMissing - fun _processedItems(): JsonField = processedItems - - /** - * Returns the raw JSON value of [skippedItems]. - * - * Unlike [skippedItems], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("skipped_items") - @ExcludeMissing - fun _skippedItems(): JsonField = skippedItems - - /** - * Returns the raw JSON value of [startedAt]. - * - * Unlike [startedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("started_at") - @ExcludeMissing - fun _startedAt(): JsonField = startedAt - - /** - * 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 [workflowId]. - * - * Unlike [workflowId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("workflow_id") - @ExcludeMissing - fun _workflowId(): JsonField = workflowId - - @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 [Job]. - * - * The following fields are required: - * ```java - * .id() - * .jobType() - * .projectId() - * .status() - * .totalItems() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Job]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var jobType: JsonField? = null - private var projectId: JsonField? = null - private var status: JsonField? = null - private var totalItems: JsonField? = null - private var completedAt: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var directoryId: JsonField = JsonMissing.of() - private var effectiveAt: JsonField = JsonMissing.of() - private var errorMessage: JsonField = JsonMissing.of() - private var failedItems: JsonField = JsonMissing.of() - private var jobRecordId: JsonField = JsonMissing.of() - private var processedItems: JsonField = JsonMissing.of() - private var skippedItems: JsonField = JsonMissing.of() - private var startedAt: JsonField = JsonMissing.of() - private var updatedAt: JsonField = JsonMissing.of() - private var workflowId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(job: Job) = apply { - id = job.id - jobType = job.jobType - projectId = job.projectId - status = job.status - totalItems = job.totalItems - completedAt = job.completedAt - createdAt = job.createdAt - directoryId = job.directoryId - effectiveAt = job.effectiveAt - errorMessage = job.errorMessage - failedItems = job.failedItems - jobRecordId = job.jobRecordId - processedItems = job.processedItems - skippedItems = job.skippedItems - startedAt = job.startedAt - updatedAt = job.updatedAt - workflowId = job.workflowId - additionalProperties = job.additionalProperties.toMutableMap() - } - - /** Unique identifier for the batch 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 } - - /** Type of processing operation (parse or classify) */ - fun jobType(jobType: JobType) = jobType(JsonField.of(jobType)) - - /** - * Sets [Builder.jobType] to an arbitrary JSON value. - * - * You should usually call [Builder.jobType] with a well-typed [JobType] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun jobType(jobType: JsonField) = apply { this.jobType = jobType } - - /** Project this job 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 } - - /** Current job status */ - fun status(status: Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - /** Total number of items in the job */ - fun totalItems(totalItems: Long) = totalItems(JsonField.of(totalItems)) - - /** - * Sets [Builder.totalItems] to an arbitrary JSON value. - * - * You should usually call [Builder.totalItems] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun totalItems(totalItems: JsonField) = apply { this.totalItems = totalItems } - - /** Timestamp when job completed */ - 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 - } - - /** Creation datetime */ - 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 - } - - /** Directory being processed */ - fun directoryId(directoryId: String?) = directoryId(JsonField.ofNullable(directoryId)) - - /** Alias for calling [Builder.directoryId] with `directoryId.orElse(null)`. */ - fun directoryId(directoryId: Optional) = directoryId(directoryId.getOrNull()) - - /** - * Sets [Builder.directoryId] to an arbitrary JSON value. - * - * You should usually call [Builder.directoryId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun directoryId(directoryId: JsonField) = apply { - this.directoryId = directoryId - } - - fun effectiveAt(effectiveAt: OffsetDateTime) = effectiveAt(JsonField.of(effectiveAt)) - - /** - * Sets [Builder.effectiveAt] to an arbitrary JSON value. - * - * You should usually call [Builder.effectiveAt] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun effectiveAt(effectiveAt: JsonField) = apply { - this.effectiveAt = effectiveAt - } - - /** Error message for the latest job attempt, 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 - } - - /** Number of items that failed processing */ - fun failedItems(failedItems: Long) = failedItems(JsonField.of(failedItems)) - - /** - * Sets [Builder.failedItems] to an arbitrary JSON value. - * - * You should usually call [Builder.failedItems] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun failedItems(failedItems: JsonField) = apply { this.failedItems = failedItems } - - /** The job record ID associated with this status, if any. */ - fun jobRecordId(jobRecordId: String?) = jobRecordId(JsonField.ofNullable(jobRecordId)) - - /** Alias for calling [Builder.jobRecordId] with `jobRecordId.orElse(null)`. */ - fun jobRecordId(jobRecordId: Optional) = jobRecordId(jobRecordId.getOrNull()) - - /** - * Sets [Builder.jobRecordId] to an arbitrary JSON value. - * - * You should usually call [Builder.jobRecordId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun jobRecordId(jobRecordId: JsonField) = apply { - this.jobRecordId = jobRecordId - } - - /** Number of items processed so far */ - fun processedItems(processedItems: Long) = processedItems(JsonField.of(processedItems)) - - /** - * Sets [Builder.processedItems] to an arbitrary JSON value. - * - * You should usually call [Builder.processedItems] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun processedItems(processedItems: JsonField) = apply { - this.processedItems = processedItems - } - - /** Number of items skipped (already processed or size limit) */ - fun skippedItems(skippedItems: Long) = skippedItems(JsonField.of(skippedItems)) - - /** - * Sets [Builder.skippedItems] to an arbitrary JSON value. - * - * You should usually call [Builder.skippedItems] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun skippedItems(skippedItems: JsonField) = apply { - this.skippedItems = skippedItems - } - - /** Timestamp when job processing started */ - fun startedAt(startedAt: OffsetDateTime?) = startedAt(JsonField.ofNullable(startedAt)) - - /** Alias for calling [Builder.startedAt] with `startedAt.orElse(null)`. */ - fun startedAt(startedAt: Optional) = startedAt(startedAt.getOrNull()) - - /** - * Sets [Builder.startedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startedAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun startedAt(startedAt: JsonField) = apply { - this.startedAt = startedAt - } - - /** Update datetime */ - 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 - } - - /** Async job tracking ID */ - fun workflowId(workflowId: String?) = workflowId(JsonField.ofNullable(workflowId)) - - /** Alias for calling [Builder.workflowId] with `workflowId.orElse(null)`. */ - fun workflowId(workflowId: Optional) = workflowId(workflowId.getOrNull()) - - /** - * Sets [Builder.workflowId] to an arbitrary JSON value. - * - * You should usually call [Builder.workflowId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun workflowId(workflowId: JsonField) = apply { this.workflowId = workflowId } - - 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 [Job]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .jobType() - * .projectId() - * .status() - * .totalItems() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Job = - Job( - checkRequired("id", id), - checkRequired("jobType", jobType), - checkRequired("projectId", projectId), - checkRequired("status", status), - checkRequired("totalItems", totalItems), - completedAt, - createdAt, - directoryId, - effectiveAt, - errorMessage, - failedItems, - jobRecordId, - processedItems, - skippedItems, - startedAt, - updatedAt, - workflowId, - 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(): Job = apply { - if (validated) { - return@apply - } - - id() - jobType().validate() - projectId() - status().validate() - totalItems() - completedAt() - createdAt() - directoryId() - effectiveAt() - errorMessage() - failedItems() - jobRecordId() - processedItems() - skippedItems() - startedAt() - updatedAt() - workflowId() - 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) + - (jobType.asKnown().getOrNull()?.validity() ?: 0) + - (if (projectId.asKnown().isPresent) 1 else 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) + - (if (totalItems.asKnown().isPresent) 1 else 0) + - (if (completedAt.asKnown().isPresent) 1 else 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (if (directoryId.asKnown().isPresent) 1 else 0) + - (if (effectiveAt.asKnown().isPresent) 1 else 0) + - (if (errorMessage.asKnown().isPresent) 1 else 0) + - (if (failedItems.asKnown().isPresent) 1 else 0) + - (if (jobRecordId.asKnown().isPresent) 1 else 0) + - (if (processedItems.asKnown().isPresent) 1 else 0) + - (if (skippedItems.asKnown().isPresent) 1 else 0) + - (if (startedAt.asKnown().isPresent) 1 else 0) + - (if (updatedAt.asKnown().isPresent) 1 else 0) + - (if (workflowId.asKnown().isPresent) 1 else 0) - - /** Type of processing operation (parse or classify) */ - 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() - } - - /** Current job status */ - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CANCELLED = of("cancelled") - - @JvmField val COMPLETED = of("completed") - - @JvmField val DISPATCHED = of("dispatched") - - @JvmField val FAILED = of("failed") - - @JvmField val PENDING = of("pending") - - @JvmField val RUNNING = of("running") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - CANCELLED, - COMPLETED, - DISPATCHED, - FAILED, - PENDING, - RUNNING, - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CANCELLED, - COMPLETED, - DISPATCHED, - FAILED, - PENDING, - RUNNING, - /** - * An enum member indicating that [Status] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CANCELLED -> Value.CANCELLED - COMPLETED -> Value.COMPLETED - DISPATCHED -> Value.DISPATCHED - FAILED -> Value.FAILED - PENDING -> Value.PENDING - RUNNING -> Value.RUNNING - 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) { - CANCELLED -> Known.CANCELLED - COMPLETED -> Known.COMPLETED - DISPATCHED -> Known.DISPATCHED - FAILED -> Known.FAILED - PENDING -> Known.PENDING - RUNNING -> Known.RUNNING - else -> throw LlamaCloudInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws 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(): Status = 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 Status && 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 Job && - id == other.id && - jobType == other.jobType && - projectId == other.projectId && - status == other.status && - totalItems == other.totalItems && - completedAt == other.completedAt && - createdAt == other.createdAt && - directoryId == other.directoryId && - effectiveAt == other.effectiveAt && - errorMessage == other.errorMessage && - failedItems == other.failedItems && - jobRecordId == other.jobRecordId && - processedItems == other.processedItems && - skippedItems == other.skippedItems && - startedAt == other.startedAt && - updatedAt == other.updatedAt && - workflowId == other.workflowId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - jobType, - projectId, - status, - totalItems, - completedAt, - createdAt, - directoryId, - effectiveAt, - errorMessage, - failedItems, - jobRecordId, - processedItems, - skippedItems, - startedAt, - updatedAt, - workflowId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Job{id=$id, jobType=$jobType, projectId=$projectId, status=$status, totalItems=$totalItems, completedAt=$completedAt, createdAt=$createdAt, directoryId=$directoryId, effectiveAt=$effectiveAt, errorMessage=$errorMessage, failedItems=$failedItems, jobRecordId=$jobRecordId, processedItems=$processedItems, skippedItems=$skippedItems, startedAt=$startedAt, updatedAt=$updatedAt, workflowId=$workflowId, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BatchGetStatusResponse && - job == other.job && - progressPercentage == other.progressPercentage && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(job, progressPercentage, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BatchGetStatusResponse{job=$job, progressPercentage=$progressPercentage, additionalProperties=$additionalProperties}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListPage.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListPage.kt deleted file mode 100644 index b6541f5..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListPage.kt +++ /dev/null @@ -1,137 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch - -import ai.llamaindex.llamacloud.core.AutoPager -import ai.llamaindex.llamacloud.core.Page -import ai.llamaindex.llamacloud.core.checkRequired -import ai.llamaindex.llamacloud.services.blocking.beta.BatchService -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrDefault -import kotlin.jvm.optionals.getOrNull - -/** @see BatchService.list */ -class BatchListPage -private constructor( - private val service: BatchService, - private val params: BatchListParams, - private val response: BatchListPageResponse, -) : Page { - - /** - * Delegates to [BatchListPageResponse], but gracefully handles missing data. - * - * @see BatchListPageResponse.items - */ - override fun items(): List = - response._items().getOptional("items").getOrNull() ?: emptyList() - - /** - * Delegates to [BatchListPageResponse], but gracefully handles missing data. - * - * @see BatchListPageResponse.totalSize - */ - fun totalSize(): Optional = response._totalSize().getOptional("total_size") - - override fun hasNextPage(): Boolean { - if (items().isEmpty()) { - return false - } - - val offset = params.offset().getOrDefault(0) - val totalCount = totalSize().getOrNull() - return totalCount == null || offset + items().size < totalCount - } - - fun nextPageParams(): BatchListParams { - val offset = params.offset().getOrDefault(0) - return params.toBuilder().offset(offset + items().size).build() - } - - override fun nextPage(): BatchListPage = service.list(nextPageParams()) - - fun autoPager(): AutoPager = AutoPager.from(this) - - /** The parameters that were used to request this page. */ - fun params(): BatchListParams = params - - /** The response that this page was parsed from. */ - fun response(): BatchListPageResponse = response - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BatchListPage]. - * - * The following fields are required: - * ```java - * .service() - * .params() - * .response() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchListPage]. */ - class Builder internal constructor() { - - private var service: BatchService? = null - private var params: BatchListParams? = null - private var response: BatchListPageResponse? = null - - @JvmSynthetic - internal fun from(batchListPage: BatchListPage) = apply { - service = batchListPage.service - params = batchListPage.params - response = batchListPage.response - } - - fun service(service: BatchService) = apply { this.service = service } - - /** The parameters that were used to request this page. */ - fun params(params: BatchListParams) = apply { this.params = params } - - /** The response that this page was parsed from. */ - fun response(response: BatchListPageResponse) = apply { this.response = response } - - /** - * Returns an immutable instance of [BatchListPage]. - * - * 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(): BatchListPage = - BatchListPage( - checkRequired("service", service), - checkRequired("params", params), - checkRequired("response", response), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BatchListPage && - service == other.service && - params == other.params && - response == other.response - } - - override fun hashCode(): Int = Objects.hash(service, params, response) - - override fun toString() = "BatchListPage{service=$service, params=$params, response=$response}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListPageAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListPageAsync.kt deleted file mode 100644 index 0eaf790..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListPageAsync.kt +++ /dev/null @@ -1,152 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch - -import ai.llamaindex.llamacloud.core.AutoPagerAsync -import ai.llamaindex.llamacloud.core.PageAsync -import ai.llamaindex.llamacloud.core.checkRequired -import ai.llamaindex.llamacloud.services.async.beta.BatchServiceAsync -import java.util.Objects -import java.util.Optional -import java.util.concurrent.CompletableFuture -import java.util.concurrent.Executor -import kotlin.jvm.optionals.getOrDefault -import kotlin.jvm.optionals.getOrNull - -/** @see BatchServiceAsync.list */ -class BatchListPageAsync -private constructor( - private val service: BatchServiceAsync, - private val streamHandlerExecutor: Executor, - private val params: BatchListParams, - private val response: BatchListPageResponse, -) : PageAsync { - - /** - * Delegates to [BatchListPageResponse], but gracefully handles missing data. - * - * @see BatchListPageResponse.items - */ - override fun items(): List = - response._items().getOptional("items").getOrNull() ?: emptyList() - - /** - * Delegates to [BatchListPageResponse], but gracefully handles missing data. - * - * @see BatchListPageResponse.totalSize - */ - fun totalSize(): Optional = response._totalSize().getOptional("total_size") - - override fun hasNextPage(): Boolean { - if (items().isEmpty()) { - return false - } - - val offset = params.offset().getOrDefault(0) - val totalCount = totalSize().getOrNull() - return totalCount == null || offset + items().size < totalCount - } - - fun nextPageParams(): BatchListParams { - val offset = params.offset().getOrDefault(0) - return params.toBuilder().offset(offset + items().size).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(): BatchListParams = params - - /** The response that this page was parsed from. */ - fun response(): BatchListPageResponse = response - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BatchListPageAsync]. - * - * The following fields are required: - * ```java - * .service() - * .streamHandlerExecutor() - * .params() - * .response() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchListPageAsync]. */ - class Builder internal constructor() { - - private var service: BatchServiceAsync? = null - private var streamHandlerExecutor: Executor? = null - private var params: BatchListParams? = null - private var response: BatchListPageResponse? = null - - @JvmSynthetic - internal fun from(batchListPageAsync: BatchListPageAsync) = apply { - service = batchListPageAsync.service - streamHandlerExecutor = batchListPageAsync.streamHandlerExecutor - params = batchListPageAsync.params - response = batchListPageAsync.response - } - - fun service(service: BatchServiceAsync) = apply { this.service = service } - - fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { - this.streamHandlerExecutor = streamHandlerExecutor - } - - /** The parameters that were used to request this page. */ - fun params(params: BatchListParams) = apply { this.params = params } - - /** The response that this page was parsed from. */ - fun response(response: BatchListPageResponse) = apply { this.response = response } - - /** - * Returns an immutable instance of [BatchListPageAsync]. - * - * 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(): BatchListPageAsync = - BatchListPageAsync( - 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 BatchListPageAsync && - 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() = - "BatchListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListPageResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListPageResponse.kt deleted file mode 100644 index dc689dc..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListPageResponse.kt +++ /dev/null @@ -1,303 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch - -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 - -/** Response schema for paginated batch job queries. */ -class BatchListPageResponse -@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 [BatchListPageResponse]. - * - * The following fields are required: - * ```java - * .items() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchListPageResponse]. */ - 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(batchListPageResponse: BatchListPageResponse) = apply { - items = batchListPageResponse.items.map { it.toMutableList() } - nextPageToken = batchListPageResponse.nextPageToken - totalSize = batchListPageResponse.totalSize - additionalProperties = batchListPageResponse.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 [BatchListResponse] to [items]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addItem(item: BatchListResponse) = 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 [BatchListPageResponse]. - * - * 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(): BatchListPageResponse = - BatchListPageResponse( - 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(): BatchListPageResponse = 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 BatchListPageResponse && - 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() = - "BatchListPageResponse{items=$items, nextPageToken=$nextPageToken, totalSize=$totalSize, additionalProperties=$additionalProperties}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListParams.kt deleted file mode 100644 index 319ce4c..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListParams.kt +++ /dev/null @@ -1,620 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch - -import ai.llamaindex.llamacloud.core.Enum -import ai.llamaindex.llamacloud.core.JsonField -import ai.llamaindex.llamacloud.core.Params -import ai.llamaindex.llamacloud.core.http.Headers -import ai.llamaindex.llamacloud.core.http.QueryParams -import ai.llamaindex.llamacloud.errors.LlamaCloudInvalidDataException -import com.fasterxml.jackson.annotation.JsonCreator -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * List batch processing jobs with optional filtering. - * - * Filter by `directory_id`, `job_type`, or `status`. Results are paginated with configurable - * `limit` and `offset`. - */ -class BatchListParams -private constructor( - private val directoryId: String?, - private val jobType: JobType?, - private val limit: Long?, - private val offset: Long?, - private val organizationId: String?, - private val projectId: String?, - private val status: Status?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - /** Filter by directory ID */ - fun directoryId(): Optional = Optional.ofNullable(directoryId) - - /** Filter by job type (PARSE, EXTRACT, CLASSIFY) */ - fun jobType(): Optional = Optional.ofNullable(jobType) - - /** Maximum number of jobs to return */ - fun limit(): Optional = Optional.ofNullable(limit) - - /** Number of jobs to skip for pagination */ - fun offset(): Optional = Optional.ofNullable(offset) - - fun organizationId(): Optional = Optional.ofNullable(organizationId) - - fun projectId(): Optional = Optional.ofNullable(projectId) - - /** Filter by job status (PENDING, RUNNING, COMPLETED, FAILED, CANCELLED) */ - 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 { - - @JvmStatic fun none(): BatchListParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [BatchListParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchListParams]. */ - class Builder internal constructor() { - - private var directoryId: String? = null - private var jobType: JobType? = null - private var limit: Long? = null - private var offset: Long? = null - private var organizationId: String? = null - private var projectId: String? = null - private var status: Status? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(batchListParams: BatchListParams) = apply { - directoryId = batchListParams.directoryId - jobType = batchListParams.jobType - limit = batchListParams.limit - offset = batchListParams.offset - organizationId = batchListParams.organizationId - projectId = batchListParams.projectId - status = batchListParams.status - additionalHeaders = batchListParams.additionalHeaders.toBuilder() - additionalQueryParams = batchListParams.additionalQueryParams.toBuilder() - } - - /** Filter by directory ID */ - fun directoryId(directoryId: String?) = apply { this.directoryId = directoryId } - - /** Alias for calling [Builder.directoryId] with `directoryId.orElse(null)`. */ - fun directoryId(directoryId: Optional) = directoryId(directoryId.getOrNull()) - - /** Filter by job type (PARSE, EXTRACT, CLASSIFY) */ - fun jobType(jobType: JobType?) = apply { this.jobType = jobType } - - /** Alias for calling [Builder.jobType] with `jobType.orElse(null)`. */ - fun jobType(jobType: Optional) = jobType(jobType.getOrNull()) - - /** Maximum number of jobs to return */ - fun limit(limit: Long?) = apply { this.limit = limit } - - /** - * Alias for [Builder.limit]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun limit(limit: Long) = limit(limit as Long?) - - /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ - fun limit(limit: Optional) = limit(limit.getOrNull()) - - /** Number of jobs to skip for pagination */ - fun offset(offset: Long?) = apply { this.offset = offset } - - /** - * Alias for [Builder.offset]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun offset(offset: Long) = offset(offset as Long?) - - /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ - fun offset(offset: Optional) = offset(offset.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()) - - /** Filter by job status (PENDING, RUNNING, COMPLETED, FAILED, CANCELLED) */ - fun status(status: Status?) = apply { this.status = status } - - /** Alias for calling [Builder.status] with `status.orElse(null)`. */ - fun status(status: Optional) = status(status.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 [BatchListParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BatchListParams = - BatchListParams( - directoryId, - jobType, - limit, - offset, - organizationId, - projectId, - status, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - directoryId?.let { put("directory_id", it) } - jobType?.let { put("job_type", it.toString()) } - limit?.let { put("limit", it.toString()) } - offset?.let { put("offset", it.toString()) } - organizationId?.let { put("organization_id", it) } - projectId?.let { put("project_id", it) } - status?.let { put("status", it.toString()) } - putAll(additionalQueryParams) - } - .build() - - /** Filter by job type (PARSE, EXTRACT, CLASSIFY) */ - 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() - } - - /** Filter by job status (PENDING, RUNNING, COMPLETED, FAILED, CANCELLED) */ - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CANCELLED = of("cancelled") - - @JvmField val COMPLETED = of("completed") - - @JvmField val DISPATCHED = of("dispatched") - - @JvmField val FAILED = of("failed") - - @JvmField val PENDING = of("pending") - - @JvmField val RUNNING = of("running") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - CANCELLED, - COMPLETED, - DISPATCHED, - FAILED, - PENDING, - RUNNING, - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CANCELLED, - COMPLETED, - DISPATCHED, - FAILED, - PENDING, - RUNNING, - /** An enum member indicating that [Status] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CANCELLED -> Value.CANCELLED - COMPLETED -> Value.COMPLETED - DISPATCHED -> Value.DISPATCHED - FAILED -> Value.FAILED - PENDING -> Value.PENDING - RUNNING -> Value.RUNNING - 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) { - CANCELLED -> Known.CANCELLED - COMPLETED -> Known.COMPLETED - DISPATCHED -> Known.DISPATCHED - FAILED -> Known.FAILED - PENDING -> Known.PENDING - RUNNING -> Known.RUNNING - else -> throw LlamaCloudInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws 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(): Status = 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 Status && 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 BatchListParams && - directoryId == other.directoryId && - jobType == other.jobType && - limit == other.limit && - offset == other.offset && - organizationId == other.organizationId && - projectId == other.projectId && - status == other.status && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash( - directoryId, - jobType, - limit, - offset, - organizationId, - projectId, - status, - additionalHeaders, - additionalQueryParams, - ) - - override fun toString() = - "BatchListParams{directoryId=$directoryId, jobType=$jobType, limit=$limit, offset=$offset, organizationId=$organizationId, projectId=$projectId, status=$status, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListResponse.kt deleted file mode 100644 index 085bc1f..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListResponse.kt +++ /dev/null @@ -1,1172 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch - -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.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 - -/** Response schema for a batch processing job. */ -class BatchListResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val id: JsonField, - private val jobType: JsonField, - private val projectId: JsonField, - private val status: JsonField, - private val totalItems: JsonField, - private val completedAt: JsonField, - private val createdAt: JsonField, - private val directoryId: JsonField, - private val effectiveAt: JsonField, - private val errorMessage: JsonField, - private val failedItems: JsonField, - private val jobRecordId: JsonField, - private val processedItems: JsonField, - private val skippedItems: JsonField, - private val startedAt: JsonField, - private val updatedAt: JsonField, - private val workflowId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), - @JsonProperty("job_type") @ExcludeMissing jobType: JsonField = JsonMissing.of(), - @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), - @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("total_items") @ExcludeMissing totalItems: JsonField = JsonMissing.of(), - @JsonProperty("completed_at") - @ExcludeMissing - completedAt: JsonField = JsonMissing.of(), - @JsonProperty("created_at") - @ExcludeMissing - createdAt: JsonField = JsonMissing.of(), - @JsonProperty("directory_id") - @ExcludeMissing - directoryId: JsonField = JsonMissing.of(), - @JsonProperty("effective_at") - @ExcludeMissing - effectiveAt: JsonField = JsonMissing.of(), - @JsonProperty("error_message") - @ExcludeMissing - errorMessage: JsonField = JsonMissing.of(), - @JsonProperty("failed_items") - @ExcludeMissing - failedItems: JsonField = JsonMissing.of(), - @JsonProperty("job_record_id") - @ExcludeMissing - jobRecordId: JsonField = JsonMissing.of(), - @JsonProperty("processed_items") - @ExcludeMissing - processedItems: JsonField = JsonMissing.of(), - @JsonProperty("skipped_items") - @ExcludeMissing - skippedItems: JsonField = JsonMissing.of(), - @JsonProperty("started_at") - @ExcludeMissing - startedAt: JsonField = JsonMissing.of(), - @JsonProperty("updated_at") - @ExcludeMissing - updatedAt: JsonField = JsonMissing.of(), - @JsonProperty("workflow_id") - @ExcludeMissing - workflowId: JsonField = JsonMissing.of(), - ) : this( - id, - jobType, - projectId, - status, - totalItems, - completedAt, - createdAt, - directoryId, - effectiveAt, - errorMessage, - failedItems, - jobRecordId, - processedItems, - skippedItems, - startedAt, - updatedAt, - workflowId, - mutableMapOf(), - ) - - /** - * Unique identifier for the batch 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") - - /** - * Type of processing operation (parse or classify) - * - * @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 jobType(): JobType = jobType.getRequired("job_type") - - /** - * Project this job 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") - - /** - * Current 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(): Status = status.getRequired("status") - - /** - * Total number of items in the 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 totalItems(): Long = totalItems.getRequired("total_items") - - /** - * Timestamp when job completed - * - * @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") - - /** - * Creation datetime - * - * @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") - - /** - * Directory being processed - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun directoryId(): Optional = directoryId.getOptional("directory_id") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun effectiveAt(): Optional = effectiveAt.getOptional("effective_at") - - /** - * Error message for the latest job attempt, 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") - - /** - * Number of items that failed processing - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun failedItems(): Optional = failedItems.getOptional("failed_items") - - /** - * The job record ID associated with this status, if any. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun jobRecordId(): Optional = jobRecordId.getOptional("job_record_id") - - /** - * Number of items processed so far - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun processedItems(): Optional = processedItems.getOptional("processed_items") - - /** - * Number of items skipped (already processed or size limit) - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun skippedItems(): Optional = skippedItems.getOptional("skipped_items") - - /** - * Timestamp when job processing started - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun startedAt(): Optional = startedAt.getOptional("started_at") - - /** - * Update datetime - * - * @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") - - /** - * Async job tracking ID - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun workflowId(): Optional = workflowId.getOptional("workflow_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 [jobType]. - * - * Unlike [jobType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("job_type") @ExcludeMissing fun _jobType(): JsonField = jobType - - /** - * 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 [totalItems]. - * - * Unlike [totalItems], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("total_items") @ExcludeMissing fun _totalItems(): JsonField = totalItems - - /** - * 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 [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 [directoryId]. - * - * Unlike [directoryId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("directory_id") - @ExcludeMissing - fun _directoryId(): JsonField = directoryId - - /** - * Returns the raw JSON value of [effectiveAt]. - * - * Unlike [effectiveAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("effective_at") - @ExcludeMissing - fun _effectiveAt(): JsonField = effectiveAt - - /** - * 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 [failedItems]. - * - * Unlike [failedItems], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("failed_items") @ExcludeMissing fun _failedItems(): JsonField = failedItems - - /** - * Returns the raw JSON value of [jobRecordId]. - * - * Unlike [jobRecordId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("job_record_id") - @ExcludeMissing - fun _jobRecordId(): JsonField = jobRecordId - - /** - * Returns the raw JSON value of [processedItems]. - * - * Unlike [processedItems], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("processed_items") - @ExcludeMissing - fun _processedItems(): JsonField = processedItems - - /** - * Returns the raw JSON value of [skippedItems]. - * - * Unlike [skippedItems], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("skipped_items") - @ExcludeMissing - fun _skippedItems(): JsonField = skippedItems - - /** - * Returns the raw JSON value of [startedAt]. - * - * Unlike [startedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("started_at") - @ExcludeMissing - fun _startedAt(): JsonField = startedAt - - /** - * 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 [workflowId]. - * - * Unlike [workflowId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("workflow_id") @ExcludeMissing fun _workflowId(): JsonField = workflowId - - @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 [BatchListResponse]. - * - * The following fields are required: - * ```java - * .id() - * .jobType() - * .projectId() - * .status() - * .totalItems() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchListResponse]. */ - class Builder internal constructor() { - - private var id: JsonField? = null - private var jobType: JsonField? = null - private var projectId: JsonField? = null - private var status: JsonField? = null - private var totalItems: JsonField? = null - private var completedAt: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var directoryId: JsonField = JsonMissing.of() - private var effectiveAt: JsonField = JsonMissing.of() - private var errorMessage: JsonField = JsonMissing.of() - private var failedItems: JsonField = JsonMissing.of() - private var jobRecordId: JsonField = JsonMissing.of() - private var processedItems: JsonField = JsonMissing.of() - private var skippedItems: JsonField = JsonMissing.of() - private var startedAt: JsonField = JsonMissing.of() - private var updatedAt: JsonField = JsonMissing.of() - private var workflowId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(batchListResponse: BatchListResponse) = apply { - id = batchListResponse.id - jobType = batchListResponse.jobType - projectId = batchListResponse.projectId - status = batchListResponse.status - totalItems = batchListResponse.totalItems - completedAt = batchListResponse.completedAt - createdAt = batchListResponse.createdAt - directoryId = batchListResponse.directoryId - effectiveAt = batchListResponse.effectiveAt - errorMessage = batchListResponse.errorMessage - failedItems = batchListResponse.failedItems - jobRecordId = batchListResponse.jobRecordId - processedItems = batchListResponse.processedItems - skippedItems = batchListResponse.skippedItems - startedAt = batchListResponse.startedAt - updatedAt = batchListResponse.updatedAt - workflowId = batchListResponse.workflowId - additionalProperties = batchListResponse.additionalProperties.toMutableMap() - } - - /** Unique identifier for the batch 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 } - - /** Type of processing operation (parse or classify) */ - fun jobType(jobType: JobType) = jobType(JsonField.of(jobType)) - - /** - * Sets [Builder.jobType] to an arbitrary JSON value. - * - * You should usually call [Builder.jobType] with a well-typed [JobType] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun jobType(jobType: JsonField) = apply { this.jobType = jobType } - - /** Project this job 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 } - - /** Current job status */ - fun status(status: Status) = status(JsonField.of(status)) - - /** - * Sets [Builder.status] to an arbitrary JSON value. - * - * You should usually call [Builder.status] with a well-typed [Status] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun status(status: JsonField) = apply { this.status = status } - - /** Total number of items in the job */ - fun totalItems(totalItems: Long) = totalItems(JsonField.of(totalItems)) - - /** - * Sets [Builder.totalItems] to an arbitrary JSON value. - * - * You should usually call [Builder.totalItems] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun totalItems(totalItems: JsonField) = apply { this.totalItems = totalItems } - - /** Timestamp when job completed */ - 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 - } - - /** Creation datetime */ - 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 } - - /** Directory being processed */ - fun directoryId(directoryId: String?) = directoryId(JsonField.ofNullable(directoryId)) - - /** Alias for calling [Builder.directoryId] with `directoryId.orElse(null)`. */ - fun directoryId(directoryId: Optional) = directoryId(directoryId.getOrNull()) - - /** - * Sets [Builder.directoryId] to an arbitrary JSON value. - * - * You should usually call [Builder.directoryId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun directoryId(directoryId: JsonField) = apply { this.directoryId = directoryId } - - fun effectiveAt(effectiveAt: OffsetDateTime) = effectiveAt(JsonField.of(effectiveAt)) - - /** - * Sets [Builder.effectiveAt] to an arbitrary JSON value. - * - * You should usually call [Builder.effectiveAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun effectiveAt(effectiveAt: JsonField) = apply { - this.effectiveAt = effectiveAt - } - - /** Error message for the latest job attempt, 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 - } - - /** Number of items that failed processing */ - fun failedItems(failedItems: Long) = failedItems(JsonField.of(failedItems)) - - /** - * Sets [Builder.failedItems] to an arbitrary JSON value. - * - * You should usually call [Builder.failedItems] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun failedItems(failedItems: JsonField) = apply { this.failedItems = failedItems } - - /** The job record ID associated with this status, if any. */ - fun jobRecordId(jobRecordId: String?) = jobRecordId(JsonField.ofNullable(jobRecordId)) - - /** Alias for calling [Builder.jobRecordId] with `jobRecordId.orElse(null)`. */ - fun jobRecordId(jobRecordId: Optional) = jobRecordId(jobRecordId.getOrNull()) - - /** - * Sets [Builder.jobRecordId] to an arbitrary JSON value. - * - * You should usually call [Builder.jobRecordId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun jobRecordId(jobRecordId: JsonField) = apply { this.jobRecordId = jobRecordId } - - /** Number of items processed so far */ - fun processedItems(processedItems: Long) = processedItems(JsonField.of(processedItems)) - - /** - * Sets [Builder.processedItems] to an arbitrary JSON value. - * - * You should usually call [Builder.processedItems] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun processedItems(processedItems: JsonField) = apply { - this.processedItems = processedItems - } - - /** Number of items skipped (already processed or size limit) */ - fun skippedItems(skippedItems: Long) = skippedItems(JsonField.of(skippedItems)) - - /** - * Sets [Builder.skippedItems] to an arbitrary JSON value. - * - * You should usually call [Builder.skippedItems] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun skippedItems(skippedItems: JsonField) = apply { this.skippedItems = skippedItems } - - /** Timestamp when job processing started */ - fun startedAt(startedAt: OffsetDateTime?) = startedAt(JsonField.ofNullable(startedAt)) - - /** Alias for calling [Builder.startedAt] with `startedAt.orElse(null)`. */ - fun startedAt(startedAt: Optional) = startedAt(startedAt.getOrNull()) - - /** - * Sets [Builder.startedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.startedAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun startedAt(startedAt: JsonField) = apply { this.startedAt = startedAt } - - /** Update datetime */ - 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 } - - /** Async job tracking ID */ - fun workflowId(workflowId: String?) = workflowId(JsonField.ofNullable(workflowId)) - - /** Alias for calling [Builder.workflowId] with `workflowId.orElse(null)`. */ - fun workflowId(workflowId: Optional) = workflowId(workflowId.getOrNull()) - - /** - * Sets [Builder.workflowId] to an arbitrary JSON value. - * - * You should usually call [Builder.workflowId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun workflowId(workflowId: JsonField) = apply { this.workflowId = workflowId } - - 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 [BatchListResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * .jobType() - * .projectId() - * .status() - * .totalItems() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BatchListResponse = - BatchListResponse( - checkRequired("id", id), - checkRequired("jobType", jobType), - checkRequired("projectId", projectId), - checkRequired("status", status), - checkRequired("totalItems", totalItems), - completedAt, - createdAt, - directoryId, - effectiveAt, - errorMessage, - failedItems, - jobRecordId, - processedItems, - skippedItems, - startedAt, - updatedAt, - workflowId, - 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(): BatchListResponse = apply { - if (validated) { - return@apply - } - - id() - jobType().validate() - projectId() - status().validate() - totalItems() - completedAt() - createdAt() - directoryId() - effectiveAt() - errorMessage() - failedItems() - jobRecordId() - processedItems() - skippedItems() - startedAt() - updatedAt() - workflowId() - 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) + - (jobType.asKnown().getOrNull()?.validity() ?: 0) + - (if (projectId.asKnown().isPresent) 1 else 0) + - (status.asKnown().getOrNull()?.validity() ?: 0) + - (if (totalItems.asKnown().isPresent) 1 else 0) + - (if (completedAt.asKnown().isPresent) 1 else 0) + - (if (createdAt.asKnown().isPresent) 1 else 0) + - (if (directoryId.asKnown().isPresent) 1 else 0) + - (if (effectiveAt.asKnown().isPresent) 1 else 0) + - (if (errorMessage.asKnown().isPresent) 1 else 0) + - (if (failedItems.asKnown().isPresent) 1 else 0) + - (if (jobRecordId.asKnown().isPresent) 1 else 0) + - (if (processedItems.asKnown().isPresent) 1 else 0) + - (if (skippedItems.asKnown().isPresent) 1 else 0) + - (if (startedAt.asKnown().isPresent) 1 else 0) + - (if (updatedAt.asKnown().isPresent) 1 else 0) + - (if (workflowId.asKnown().isPresent) 1 else 0) - - /** Type of processing operation (parse or classify) */ - 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() - } - - /** Current job status */ - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CANCELLED = of("cancelled") - - @JvmField val COMPLETED = of("completed") - - @JvmField val DISPATCHED = of("dispatched") - - @JvmField val FAILED = of("failed") - - @JvmField val PENDING = of("pending") - - @JvmField val RUNNING = of("running") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - CANCELLED, - COMPLETED, - DISPATCHED, - FAILED, - PENDING, - RUNNING, - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CANCELLED, - COMPLETED, - DISPATCHED, - FAILED, - PENDING, - RUNNING, - /** An enum member indicating that [Status] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CANCELLED -> Value.CANCELLED - COMPLETED -> Value.COMPLETED - DISPATCHED -> Value.DISPATCHED - FAILED -> Value.FAILED - PENDING -> Value.PENDING - RUNNING -> Value.RUNNING - 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) { - CANCELLED -> Known.CANCELLED - COMPLETED -> Known.COMPLETED - DISPATCHED -> Known.DISPATCHED - FAILED -> Known.FAILED - PENDING -> Known.PENDING - RUNNING -> Known.RUNNING - else -> throw LlamaCloudInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws 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(): Status = 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 Status && 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 BatchListResponse && - id == other.id && - jobType == other.jobType && - projectId == other.projectId && - status == other.status && - totalItems == other.totalItems && - completedAt == other.completedAt && - createdAt == other.createdAt && - directoryId == other.directoryId && - effectiveAt == other.effectiveAt && - errorMessage == other.errorMessage && - failedItems == other.failedItems && - jobRecordId == other.jobRecordId && - processedItems == other.processedItems && - skippedItems == other.skippedItems && - startedAt == other.startedAt && - updatedAt == other.updatedAt && - workflowId == other.workflowId && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - id, - jobType, - projectId, - status, - totalItems, - completedAt, - createdAt, - directoryId, - effectiveAt, - errorMessage, - failedItems, - jobRecordId, - processedItems, - skippedItems, - startedAt, - updatedAt, - workflowId, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BatchListResponse{id=$id, jobType=$jobType, projectId=$projectId, status=$status, totalItems=$totalItems, completedAt=$completedAt, createdAt=$createdAt, directoryId=$directoryId, effectiveAt=$effectiveAt, errorMessage=$errorMessage, failedItems=$failedItems, jobRecordId=$jobRecordId, processedItems=$processedItems, skippedItems=$skippedItems, startedAt=$startedAt, updatedAt=$updatedAt, workflowId=$workflowId, additionalProperties=$additionalProperties}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsParams.kt deleted file mode 100644 index 58f3bf7..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsParams.kt +++ /dev/null @@ -1,405 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch.jobitems - -import ai.llamaindex.llamacloud.core.Enum -import ai.llamaindex.llamacloud.core.JsonField -import ai.llamaindex.llamacloud.core.Params -import ai.llamaindex.llamacloud.core.http.Headers -import ai.llamaindex.llamacloud.core.http.QueryParams -import ai.llamaindex.llamacloud.errors.LlamaCloudInvalidDataException -import com.fasterxml.jackson.annotation.JsonCreator -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * Get all processing results for a specific item. - * - * Returns the complete processing history for an item including what operations were performed, - * parameters used, and where outputs are stored. Optionally filter by `job_type`. - */ -class JobItemGetProcessingResultsParams -private constructor( - private val itemId: String?, - private val jobType: JobType?, - private val organizationId: String?, - private val projectId: String?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun itemId(): Optional = Optional.ofNullable(itemId) - - /** Filter results by job type */ - fun jobType(): Optional = Optional.ofNullable(jobType) - - 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 { - - @JvmStatic fun none(): JobItemGetProcessingResultsParams = builder().build() - - /** - * Returns a mutable builder for constructing an instance of - * [JobItemGetProcessingResultsParams]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [JobItemGetProcessingResultsParams]. */ - class Builder internal constructor() { - - private var itemId: String? = null - private var jobType: JobType? = 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(jobItemGetProcessingResultsParams: JobItemGetProcessingResultsParams) = - apply { - itemId = jobItemGetProcessingResultsParams.itemId - jobType = jobItemGetProcessingResultsParams.jobType - organizationId = jobItemGetProcessingResultsParams.organizationId - projectId = jobItemGetProcessingResultsParams.projectId - additionalHeaders = jobItemGetProcessingResultsParams.additionalHeaders.toBuilder() - additionalQueryParams = - jobItemGetProcessingResultsParams.additionalQueryParams.toBuilder() - } - - fun itemId(itemId: String?) = apply { this.itemId = itemId } - - /** Alias for calling [Builder.itemId] with `itemId.orElse(null)`. */ - fun itemId(itemId: Optional) = itemId(itemId.getOrNull()) - - /** Filter results by job type */ - fun jobType(jobType: JobType?) = apply { this.jobType = jobType } - - /** Alias for calling [Builder.jobType] with `jobType.orElse(null)`. */ - fun jobType(jobType: Optional) = jobType(jobType.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) - } - - /** - * Returns an immutable instance of [JobItemGetProcessingResultsParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): JobItemGetProcessingResultsParams = - JobItemGetProcessingResultsParams( - itemId, - jobType, - organizationId, - projectId, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> itemId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - jobType?.let { put("job_type", it.toString()) } - organizationId?.let { put("organization_id", it) } - projectId?.let { put("project_id", it) } - putAll(additionalQueryParams) - } - .build() - - /** Filter results by job type */ - 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 JobItemGetProcessingResultsParams && - itemId == other.itemId && - jobType == other.jobType && - organizationId == other.organizationId && - projectId == other.projectId && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash( - itemId, - jobType, - organizationId, - projectId, - additionalHeaders, - additionalQueryParams, - ) - - override fun toString() = - "JobItemGetProcessingResultsParams{itemId=$itemId, jobType=$jobType, organizationId=$organizationId, projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsResponse.kt deleted file mode 100644 index 47f98f9..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsResponse.kt +++ /dev/null @@ -1,11091 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch.jobitems - -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 -import ai.llamaindex.llamacloud.core.JsonValue -import ai.llamaindex.llamacloud.core.allMaxBy -import ai.llamaindex.llamacloud.core.checkKnown -import ai.llamaindex.llamacloud.core.checkRequired -import ai.llamaindex.llamacloud.core.getOrThrow -import ai.llamaindex.llamacloud.core.toImmutable -import ai.llamaindex.llamacloud.errors.LlamaCloudInvalidDataException -import ai.llamaindex.llamacloud.models.classifier.jobs.ClassifyJob -import ai.llamaindex.llamacloud.models.parsing.FailPageMode -import ai.llamaindex.llamacloud.models.parsing.ParsingLanguages -import ai.llamaindex.llamacloud.models.parsing.ParsingMode -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.OffsetDateTime -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** Response containing all processing results for an item. */ -class JobItemGetProcessingResultsResponse -@JsonCreator(mode = JsonCreator.Mode.DISABLED) -private constructor( - private val itemId: JsonField, - private val itemName: JsonField, - private val processingResults: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("item_name") @ExcludeMissing itemName: JsonField = JsonMissing.of(), - @JsonProperty("processing_results") - @ExcludeMissing - processingResults: JsonField> = JsonMissing.of(), - ) : this(itemId, itemName, processingResults, mutableMapOf()) - - /** - * ID of the source item - * - * @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 itemId(): String = itemId.getRequired("item_id") - - /** - * Name of the source item - * - * @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 itemName(): String = itemName.getRequired("item_name") - - /** - * List of all processing operations performed on this item - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun processingResults(): Optional> = - processingResults.getOptional("processing_results") - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [itemName]. - * - * Unlike [itemName], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item_name") @ExcludeMissing fun _itemName(): JsonField = itemName - - /** - * Returns the raw JSON value of [processingResults]. - * - * Unlike [processingResults], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("processing_results") - @ExcludeMissing - fun _processingResults(): JsonField> = processingResults - - @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 - * [JobItemGetProcessingResultsResponse]. - * - * The following fields are required: - * ```java - * .itemId() - * .itemName() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [JobItemGetProcessingResultsResponse]. */ - class Builder internal constructor() { - - private var itemId: JsonField? = null - private var itemName: JsonField? = null - private var processingResults: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - jobItemGetProcessingResultsResponse: JobItemGetProcessingResultsResponse - ) = apply { - itemId = jobItemGetProcessingResultsResponse.itemId - itemName = jobItemGetProcessingResultsResponse.itemName - processingResults = - jobItemGetProcessingResultsResponse.processingResults.map { it.toMutableList() } - additionalProperties = - jobItemGetProcessingResultsResponse.additionalProperties.toMutableMap() - } - - /** ID of the source item */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** Name of the source item */ - fun itemName(itemName: String) = itemName(JsonField.of(itemName)) - - /** - * Sets [Builder.itemName] to an arbitrary JSON value. - * - * You should usually call [Builder.itemName] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun itemName(itemName: JsonField) = apply { this.itemName = itemName } - - /** List of all processing operations performed on this item */ - fun processingResults(processingResults: List) = - processingResults(JsonField.of(processingResults)) - - /** - * Sets [Builder.processingResults] to an arbitrary JSON value. - * - * You should usually call [Builder.processingResults] with a well-typed - * `List` value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun processingResults(processingResults: JsonField>) = apply { - this.processingResults = processingResults.map { it.toMutableList() } - } - - /** - * Adds a single [ProcessingResult] to [processingResults]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addProcessingResult(processingResult: ProcessingResult) = apply { - processingResults = - (processingResults ?: JsonField.of(mutableListOf())).also { - checkKnown("processingResults", it).add(processingResult) - } - } - - 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 [JobItemGetProcessingResultsResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .itemId() - * .itemName() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): JobItemGetProcessingResultsResponse = - JobItemGetProcessingResultsResponse( - checkRequired("itemId", itemId), - checkRequired("itemName", itemName), - (processingResults ?: JsonMissing.of()).map { it.toImmutable() }, - 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(): JobItemGetProcessingResultsResponse = apply { - if (validated) { - return@apply - } - - itemId() - itemName() - processingResults().ifPresent { it.forEach { 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 (itemId.asKnown().isPresent) 1 else 0) + - (if (itemName.asKnown().isPresent) 1 else 0) + - (processingResults.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - /** A processing result with lineage information. */ - class ProcessingResult - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val itemId: JsonField, - private val jobConfig: JsonField, - private val jobType: JsonField, - private val outputS3Path: JsonField, - private val parametersHash: JsonField, - private val processedAt: JsonField, - private val resultId: JsonField, - private val outputMetadata: JsonValue, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("job_config") - @ExcludeMissing - jobConfig: JsonField = JsonMissing.of(), - @JsonProperty("job_type") - @ExcludeMissing - jobType: JsonField = JsonMissing.of(), - @JsonProperty("output_s3_path") - @ExcludeMissing - outputS3Path: JsonField = JsonMissing.of(), - @JsonProperty("parameters_hash") - @ExcludeMissing - parametersHash: JsonField = JsonMissing.of(), - @JsonProperty("processed_at") - @ExcludeMissing - processedAt: JsonField = JsonMissing.of(), - @JsonProperty("result_id") - @ExcludeMissing - resultId: JsonField = JsonMissing.of(), - @JsonProperty("output_metadata") - @ExcludeMissing - outputMetadata: JsonValue = JsonMissing.of(), - ) : this( - itemId, - jobConfig, - jobType, - outputS3Path, - parametersHash, - processedAt, - resultId, - outputMetadata, - mutableMapOf(), - ) - - /** - * Source item that was processed - * - * @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 itemId(): String = itemId.getRequired("item_id") - - /** - * Job configuration used for processing - * - * @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 jobConfig(): JobConfig = jobConfig.getRequired("job_config") - - /** - * Type of processing performed - * - * @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 jobType(): JobType = jobType.getRequired("job_type") - - /** - * Location of the processing output - * - * @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 outputS3Path(): String = outputS3Path.getRequired("output_s3_path") - - /** - * Content hash of the job configuration for dedup - * - * @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 parametersHash(): String = parametersHash.getRequired("parameters_hash") - - /** - * When this processing occurred - * - * @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 processedAt(): OffsetDateTime = processedAt.getRequired("processed_at") - - /** - * Unique identifier for this result - * - * @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 resultId(): String = resultId.getRequired("result_id") - - /** - * Metadata about processing output. - * - * Currently empty - will be populated with job-type-specific metadata fields in the future. - * - * This arbitrary value can be deserialized into a custom type using the `convert` method: - * ```java - * MyClass myObject = processingResult.outputMetadata().convert(MyClass.class); - * ``` - */ - @JsonProperty("output_metadata") - @ExcludeMissing - fun _outputMetadata(): JsonValue = outputMetadata - - /** - * Returns the raw JSON value of [itemId]. - * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - - /** - * Returns the raw JSON value of [jobConfig]. - * - * Unlike [jobConfig], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("job_config") - @ExcludeMissing - fun _jobConfig(): JsonField = jobConfig - - /** - * Returns the raw JSON value of [jobType]. - * - * Unlike [jobType], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("job_type") @ExcludeMissing fun _jobType(): JsonField = jobType - - /** - * Returns the raw JSON value of [outputS3Path]. - * - * Unlike [outputS3Path], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("output_s3_path") - @ExcludeMissing - fun _outputS3Path(): JsonField = outputS3Path - - /** - * Returns the raw JSON value of [parametersHash]. - * - * Unlike [parametersHash], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("parameters_hash") - @ExcludeMissing - fun _parametersHash(): JsonField = parametersHash - - /** - * Returns the raw JSON value of [processedAt]. - * - * Unlike [processedAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("processed_at") - @ExcludeMissing - fun _processedAt(): JsonField = processedAt - - /** - * Returns the raw JSON value of [resultId]. - * - * Unlike [resultId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("result_id") @ExcludeMissing fun _resultId(): JsonField = resultId - - @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 [ProcessingResult]. - * - * The following fields are required: - * ```java - * .itemId() - * .jobConfig() - * .jobType() - * .outputS3Path() - * .parametersHash() - * .processedAt() - * .resultId() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ProcessingResult]. */ - class Builder internal constructor() { - - private var itemId: JsonField? = null - private var jobConfig: JsonField? = null - private var jobType: JsonField? = null - private var outputS3Path: JsonField? = null - private var parametersHash: JsonField? = null - private var processedAt: JsonField? = null - private var resultId: JsonField? = null - private var outputMetadata: JsonValue = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(processingResult: ProcessingResult) = apply { - itemId = processingResult.itemId - jobConfig = processingResult.jobConfig - jobType = processingResult.jobType - outputS3Path = processingResult.outputS3Path - parametersHash = processingResult.parametersHash - processedAt = processingResult.processedAt - resultId = processingResult.resultId - outputMetadata = processingResult.outputMetadata - additionalProperties = processingResult.additionalProperties.toMutableMap() - } - - /** Source item that was processed */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - - /** - * Sets [Builder.itemId] to an arbitrary JSON value. - * - * You should usually call [Builder.itemId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - - /** Job configuration used for processing */ - fun jobConfig(jobConfig: JobConfig) = jobConfig(JsonField.of(jobConfig)) - - /** - * Sets [Builder.jobConfig] to an arbitrary JSON value. - * - * You should usually call [Builder.jobConfig] with a well-typed [JobConfig] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun jobConfig(jobConfig: JsonField) = apply { this.jobConfig = jobConfig } - - /** - * Alias for calling [jobConfig] with - * `JobConfig.ofBatchParseJobRecordCreate(batchParseJobRecordCreate)`. - */ - fun jobConfig(batchParseJobRecordCreate: JobConfig.BatchParseJobRecordCreate) = - jobConfig(JobConfig.ofBatchParseJobRecordCreate(batchParseJobRecordCreate)) - - /** Alias for calling [jobConfig] with `JobConfig.ofClassifyJob(classifyJob)`. */ - fun jobConfig(classifyJob: ClassifyJob) = - jobConfig(JobConfig.ofClassifyJob(classifyJob)) - - /** Type of processing performed */ - fun jobType(jobType: JobType) = jobType(JsonField.of(jobType)) - - /** - * Sets [Builder.jobType] to an arbitrary JSON value. - * - * You should usually call [Builder.jobType] with a well-typed [JobType] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun jobType(jobType: JsonField) = apply { this.jobType = jobType } - - /** Location of the processing output */ - fun outputS3Path(outputS3Path: String) = outputS3Path(JsonField.of(outputS3Path)) - - /** - * Sets [Builder.outputS3Path] to an arbitrary JSON value. - * - * You should usually call [Builder.outputS3Path] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun outputS3Path(outputS3Path: JsonField) = apply { - this.outputS3Path = outputS3Path - } - - /** Content hash of the job configuration for dedup */ - fun parametersHash(parametersHash: String) = - parametersHash(JsonField.of(parametersHash)) - - /** - * Sets [Builder.parametersHash] to an arbitrary JSON value. - * - * You should usually call [Builder.parametersHash] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun parametersHash(parametersHash: JsonField) = apply { - this.parametersHash = parametersHash - } - - /** When this processing occurred */ - fun processedAt(processedAt: OffsetDateTime) = processedAt(JsonField.of(processedAt)) - - /** - * Sets [Builder.processedAt] to an arbitrary JSON value. - * - * You should usually call [Builder.processedAt] with a well-typed [OffsetDateTime] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun processedAt(processedAt: JsonField) = apply { - this.processedAt = processedAt - } - - /** Unique identifier for this result */ - fun resultId(resultId: String) = resultId(JsonField.of(resultId)) - - /** - * Sets [Builder.resultId] to an arbitrary JSON value. - * - * You should usually call [Builder.resultId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun resultId(resultId: JsonField) = apply { this.resultId = resultId } - - /** - * Metadata about processing output. - * - * Currently empty - will be populated with job-type-specific metadata fields in the - * future. - */ - fun outputMetadata(outputMetadata: JsonValue) = apply { - this.outputMetadata = outputMetadata - } - - 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 [ProcessingResult]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .itemId() - * .jobConfig() - * .jobType() - * .outputS3Path() - * .parametersHash() - * .processedAt() - * .resultId() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): ProcessingResult = - ProcessingResult( - checkRequired("itemId", itemId), - checkRequired("jobConfig", jobConfig), - checkRequired("jobType", jobType), - checkRequired("outputS3Path", outputS3Path), - checkRequired("parametersHash", parametersHash), - checkRequired("processedAt", processedAt), - checkRequired("resultId", resultId), - outputMetadata, - 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(): ProcessingResult = apply { - if (validated) { - return@apply - } - - itemId() - jobConfig().validate() - jobType().validate() - outputS3Path() - parametersHash() - processedAt() - resultId() - 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 (itemId.asKnown().isPresent) 1 else 0) + - (jobConfig.asKnown().getOrNull()?.validity() ?: 0) + - (jobType.asKnown().getOrNull()?.validity() ?: 0) + - (if (outputS3Path.asKnown().isPresent) 1 else 0) + - (if (parametersHash.asKnown().isPresent) 1 else 0) + - (if (processedAt.asKnown().isPresent) 1 else 0) + - (if (resultId.asKnown().isPresent) 1 else 0) - - /** Job configuration used for processing */ - @JsonDeserialize(using = JobConfig.Deserializer::class) - @JsonSerialize(using = JobConfig.Serializer::class) - class JobConfig - private constructor( - private val batchParseJobRecordCreate: BatchParseJobRecordCreate? = null, - private val classifyJob: ClassifyJob? = null, - private val _json: JsonValue? = null, - ) { - - /** - * Batch-specific parse job record for batch processing. - * - * This model contains the metadata and configuration for a batch parse job, but - * excludes file-specific information. It's used as input to the batch parent workflow - * and combined with DirectoryFile data to create full ParseJobRecordCreate instances - * for each file. - * - * Attributes: job_name: Must be PARSE_RAW_FILE partitions: Partitions for job output - * location parameters: Generic parse configuration (BatchParseJobConfig) session_id: - * Upstream request ID for tracking correlation_id: Correlation ID for cross-service - * tracking parent_job_execution_id: Parent job execution ID if nested user_id: User who - * created the job project_id: Project this job belongs to webhook_url: Optional webhook - * URL for job completion notifications - */ - fun batchParseJobRecordCreate(): Optional = - Optional.ofNullable(batchParseJobRecordCreate) - - /** A classify job. */ - fun classifyJob(): Optional = Optional.ofNullable(classifyJob) - - fun isBatchParseJobRecordCreate(): Boolean = batchParseJobRecordCreate != null - - fun isClassifyJob(): Boolean = classifyJob != null - - /** - * Batch-specific parse job record for batch processing. - * - * This model contains the metadata and configuration for a batch parse job, but - * excludes file-specific information. It's used as input to the batch parent workflow - * and combined with DirectoryFile data to create full ParseJobRecordCreate instances - * for each file. - * - * Attributes: job_name: Must be PARSE_RAW_FILE partitions: Partitions for job output - * location parameters: Generic parse configuration (BatchParseJobConfig) session_id: - * Upstream request ID for tracking correlation_id: Correlation ID for cross-service - * tracking parent_job_execution_id: Parent job execution ID if nested user_id: User who - * created the job project_id: Project this job belongs to webhook_url: Optional webhook - * URL for job completion notifications - */ - fun asBatchParseJobRecordCreate(): BatchParseJobRecordCreate = - batchParseJobRecordCreate.getOrThrow("batchParseJobRecordCreate") - - /** A classify job. */ - fun asClassifyJob(): ClassifyJob = classifyJob.getOrThrow("classifyJob") - - fun _json(): Optional = Optional.ofNullable(_json) - - /** - * Maps this instance's current variant to a value of type [T] using the given - * [visitor]. - * - * Note that this method is _not_ forwards compatible with new variants from the API, - * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this - * version of the SDK gracefully, consider overriding [Visitor.unknown]: - * ```java - * import ai.llamaindex.llamacloud.core.JsonValue; - * import java.util.Optional; - * - * Optional result = jobConfig.accept(new JobConfig.Visitor>() { - * @Override - * public Optional visitBatchParseJobRecordCreate(BatchParseJobRecordCreate batchParseJobRecordCreate) { - * return Optional.of(batchParseJobRecordCreate.toString()); - * } - * - * // ... - * - * @Override - * public Optional unknown(JsonValue json) { - * // Or inspect the `json`. - * return Optional.empty(); - * } - * }); - * ``` - * - * @throws LlamaCloudInvalidDataException if [Visitor.unknown] is not overridden in - * [visitor] and the current variant is unknown. - */ - fun accept(visitor: Visitor): T = - when { - batchParseJobRecordCreate != null -> - visitor.visitBatchParseJobRecordCreate(batchParseJobRecordCreate) - classifyJob != null -> visitor.visitClassifyJob(classifyJob) - else -> visitor.unknown(_json) - } - - private var validated: Boolean = false - - /** - * Validates that the types of all values in this object match their expected types - * recursively. - * - * This method is _not_ forwards compatible with new types from the API for existing - * fields. - * - * @throws LlamaCloudInvalidDataException if any value type in this object doesn't match - * its expected type. - */ - fun validate(): JobConfig = apply { - if (validated) { - return@apply - } - - accept( - object : Visitor { - override fun visitBatchParseJobRecordCreate( - batchParseJobRecordCreate: BatchParseJobRecordCreate - ) { - batchParseJobRecordCreate.validate() - } - - override fun visitClassifyJob(classifyJob: ClassifyJob) { - classifyJob.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 = - accept( - object : Visitor { - override fun visitBatchParseJobRecordCreate( - batchParseJobRecordCreate: BatchParseJobRecordCreate - ) = batchParseJobRecordCreate.validity() - - override fun visitClassifyJob(classifyJob: ClassifyJob) = - classifyJob.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is JobConfig && - batchParseJobRecordCreate == other.batchParseJobRecordCreate && - classifyJob == other.classifyJob - } - - override fun hashCode(): Int = Objects.hash(batchParseJobRecordCreate, classifyJob) - - override fun toString(): String = - when { - batchParseJobRecordCreate != null -> - "JobConfig{batchParseJobRecordCreate=$batchParseJobRecordCreate}" - classifyJob != null -> "JobConfig{classifyJob=$classifyJob}" - _json != null -> "JobConfig{_unknown=$_json}" - else -> throw IllegalStateException("Invalid JobConfig") - } - - companion object { - - /** - * Batch-specific parse job record for batch processing. - * - * This model contains the metadata and configuration for a batch parse job, but - * excludes file-specific information. It's used as input to the batch parent - * workflow and combined with DirectoryFile data to create full ParseJobRecordCreate - * instances for each file. - * - * Attributes: job_name: Must be PARSE_RAW_FILE partitions: Partitions for job - * output location parameters: Generic parse configuration (BatchParseJobConfig) - * session_id: Upstream request ID for tracking correlation_id: Correlation ID for - * cross-service tracking parent_job_execution_id: Parent job execution ID if nested - * user_id: User who created the job project_id: Project this job belongs to - * webhook_url: Optional webhook URL for job completion notifications - */ - @JvmStatic - fun ofBatchParseJobRecordCreate( - batchParseJobRecordCreate: BatchParseJobRecordCreate - ) = JobConfig(batchParseJobRecordCreate = batchParseJobRecordCreate) - - /** A classify job. */ - @JvmStatic - fun ofClassifyJob(classifyJob: ClassifyJob) = JobConfig(classifyJob = classifyJob) - } - - /** - * An interface that defines how to map each variant of [JobConfig] to a value of type - * [T]. - */ - interface Visitor { - - /** - * Batch-specific parse job record for batch processing. - * - * This model contains the metadata and configuration for a batch parse job, but - * excludes file-specific information. It's used as input to the batch parent - * workflow and combined with DirectoryFile data to create full ParseJobRecordCreate - * instances for each file. - * - * Attributes: job_name: Must be PARSE_RAW_FILE partitions: Partitions for job - * output location parameters: Generic parse configuration (BatchParseJobConfig) - * session_id: Upstream request ID for tracking correlation_id: Correlation ID for - * cross-service tracking parent_job_execution_id: Parent job execution ID if nested - * user_id: User who created the job project_id: Project this job belongs to - * webhook_url: Optional webhook URL for job completion notifications - */ - fun visitBatchParseJobRecordCreate( - batchParseJobRecordCreate: BatchParseJobRecordCreate - ): T - - /** A classify job. */ - fun visitClassifyJob(classifyJob: ClassifyJob): T - - /** - * Maps an unknown variant of [JobConfig] to a value of type [T]. - * - * An instance of [JobConfig] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on an - * older version than the API, then the API may respond with new variants that the - * SDK is unaware of. - * - * @throws LlamaCloudInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw LlamaCloudInvalidDataException("Unknown JobConfig: $json") - } - } - - internal class Deserializer : BaseDeserializer(JobConfig::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): JobConfig { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef()) - ?.let { - JobConfig(batchParseJobRecordCreate = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - JobConfig(classifyJob = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible - // with all the possible variants (e.g. deserializing from boolean). - 0 -> JobConfig(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the - // first completely valid match, or simply the first match if none are - // completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(JobConfig::class) { - - override fun serialize( - value: JobConfig, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.batchParseJobRecordCreate != null -> - generator.writeObject(value.batchParseJobRecordCreate) - value.classifyJob != null -> generator.writeObject(value.classifyJob) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid JobConfig") - } - } - } - - /** - * Batch-specific parse job record for batch processing. - * - * This model contains the metadata and configuration for a batch parse job, but - * excludes file-specific information. It's used as input to the batch parent workflow - * and combined with DirectoryFile data to create full ParseJobRecordCreate instances - * for each file. - * - * Attributes: job_name: Must be PARSE_RAW_FILE partitions: Partitions for job output - * location parameters: Generic parse configuration (BatchParseJobConfig) session_id: - * Upstream request ID for tracking correlation_id: Correlation ID for cross-service - * tracking parent_job_execution_id: Parent job execution ID if nested user_id: User who - * created the job project_id: Project this job belongs to webhook_url: Optional webhook - * URL for job completion notifications - */ - class BatchParseJobRecordCreate - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val correlationId: JsonField, - private val jobName: JsonField, - private val parameters: JsonField, - private val parentJobExecutionId: JsonField, - private val partitions: JsonField, - private val projectId: JsonField, - private val sessionId: JsonField, - private val userId: JsonField, - private val webhookUrl: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("correlation_id") - @ExcludeMissing - correlationId: JsonField = JsonMissing.of(), - @JsonProperty("job_name") - @ExcludeMissing - jobName: JsonField = JsonMissing.of(), - @JsonProperty("parameters") - @ExcludeMissing - parameters: JsonField = JsonMissing.of(), - @JsonProperty("parent_job_execution_id") - @ExcludeMissing - parentJobExecutionId: JsonField = JsonMissing.of(), - @JsonProperty("partitions") - @ExcludeMissing - partitions: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - projectId: JsonField = JsonMissing.of(), - @JsonProperty("session_id") - @ExcludeMissing - sessionId: JsonField = JsonMissing.of(), - @JsonProperty("user_id") - @ExcludeMissing - userId: JsonField = JsonMissing.of(), - @JsonProperty("webhook_url") - @ExcludeMissing - webhookUrl: JsonField = JsonMissing.of(), - ) : this( - correlationId, - jobName, - parameters, - parentJobExecutionId, - partitions, - projectId, - sessionId, - userId, - webhookUrl, - mutableMapOf(), - ) - - /** - * The correlation ID for this job. Used for tracking the job across services. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun correlationId(): Optional = correlationId.getOptional("correlation_id") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun jobName(): Optional = jobName.getOptional("job_name") - - /** - * Generic parse job configuration for batch processing. - * - * This model contains the parsing configuration that applies to all files in a - * batch, but excludes file-specific fields like file_name, file_id, etc. Those - * file-specific fields are populated from DirectoryFile data when creating - * individual ParseJobRecordCreate instances for each file. - * - * The fields in this model should be generic settings that apply uniformly to all - * files being processed in the batch. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun parameters(): Optional = parameters.getOptional("parameters") - - /** - * The ID of the parent job execution. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun parentJobExecutionId(): Optional = - parentJobExecutionId.getOptional("parent_job_execution_id") - - /** - * The partitions for this execution. Used for determining where to save job output. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun partitions(): Optional = partitions.getOptional("partitions") - - /** - * The ID of the project this job belongs 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") - - /** - * The upstream request ID that created this job. Used for tracking the job across - * services. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun sessionId(): Optional = sessionId.getOptional("session_id") - - /** - * The ID of the user that created this job - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun userId(): Optional = userId.getOptional("user_id") - - /** - * The URL that needs to be called at the end of the parsing job. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun webhookUrl(): Optional = webhookUrl.getOptional("webhook_url") - - /** - * Returns the raw JSON value of [correlationId]. - * - * Unlike [correlationId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("correlation_id") - @ExcludeMissing - fun _correlationId(): JsonField = correlationId - - /** - * Returns the raw JSON value of [jobName]. - * - * Unlike [jobName], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("job_name") - @ExcludeMissing - fun _jobName(): JsonField = jobName - - /** - * Returns the raw JSON value of [parameters]. - * - * Unlike [parameters], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("parameters") - @ExcludeMissing - fun _parameters(): JsonField = parameters - - /** - * Returns the raw JSON value of [parentJobExecutionId]. - * - * Unlike [parentJobExecutionId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("parent_job_execution_id") - @ExcludeMissing - fun _parentJobExecutionId(): JsonField = parentJobExecutionId - - /** - * Returns the raw JSON value of [partitions]. - * - * Unlike [partitions], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("partitions") - @ExcludeMissing - fun _partitions(): JsonField = partitions - - /** - * 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 [sessionId]. - * - * Unlike [sessionId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("session_id") - @ExcludeMissing - fun _sessionId(): JsonField = sessionId - - /** - * Returns the raw JSON value of [userId]. - * - * Unlike [userId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId - - /** - * Returns the raw JSON value of [webhookUrl]. - * - * Unlike [webhookUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("webhook_url") - @ExcludeMissing - fun _webhookUrl(): JsonField = webhookUrl - - @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 - * [BatchParseJobRecordCreate]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchParseJobRecordCreate]. */ - class Builder internal constructor() { - - private var correlationId: JsonField = JsonMissing.of() - private var jobName: JsonField = JsonMissing.of() - private var parameters: JsonField = JsonMissing.of() - private var parentJobExecutionId: JsonField = JsonMissing.of() - private var partitions: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var sessionId: JsonField = JsonMissing.of() - private var userId: JsonField = JsonMissing.of() - private var webhookUrl: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(batchParseJobRecordCreate: BatchParseJobRecordCreate) = - apply { - correlationId = batchParseJobRecordCreate.correlationId - jobName = batchParseJobRecordCreate.jobName - parameters = batchParseJobRecordCreate.parameters - parentJobExecutionId = batchParseJobRecordCreate.parentJobExecutionId - partitions = batchParseJobRecordCreate.partitions - projectId = batchParseJobRecordCreate.projectId - sessionId = batchParseJobRecordCreate.sessionId - userId = batchParseJobRecordCreate.userId - webhookUrl = batchParseJobRecordCreate.webhookUrl - additionalProperties = - batchParseJobRecordCreate.additionalProperties.toMutableMap() - } - - /** - * The correlation ID for this job. Used for tracking the job across services. - */ - fun correlationId(correlationId: String?) = - correlationId(JsonField.ofNullable(correlationId)) - - /** - * Alias for calling [Builder.correlationId] with `correlationId.orElse(null)`. - */ - fun correlationId(correlationId: Optional) = - correlationId(correlationId.getOrNull()) - - /** - * Sets [Builder.correlationId] to an arbitrary JSON value. - * - * You should usually call [Builder.correlationId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun correlationId(correlationId: JsonField) = apply { - this.correlationId = correlationId - } - - fun jobName(jobName: JobName) = jobName(JsonField.of(jobName)) - - /** - * Sets [Builder.jobName] to an arbitrary JSON value. - * - * You should usually call [Builder.jobName] with a well-typed [JobName] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun jobName(jobName: JsonField) = apply { this.jobName = jobName } - - /** - * Generic parse job configuration for batch processing. - * - * This model contains the parsing configuration that applies to all files in a - * batch, but excludes file-specific fields like file_name, file_id, etc. Those - * file-specific fields are populated from DirectoryFile data when creating - * individual ParseJobRecordCreate instances for each file. - * - * The fields in this model should be generic settings that apply uniformly to - * all files being processed in the batch. - */ - fun parameters(parameters: Parameters?) = - parameters(JsonField.ofNullable(parameters)) - - /** Alias for calling [Builder.parameters] with `parameters.orElse(null)`. */ - fun parameters(parameters: Optional) = - parameters(parameters.getOrNull()) - - /** - * Sets [Builder.parameters] to an arbitrary JSON value. - * - * You should usually call [Builder.parameters] with a well-typed [Parameters] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun parameters(parameters: JsonField) = apply { - this.parameters = parameters - } - - /** The ID of the parent job execution. */ - fun parentJobExecutionId(parentJobExecutionId: String?) = - parentJobExecutionId(JsonField.ofNullable(parentJobExecutionId)) - - /** - * Alias for calling [Builder.parentJobExecutionId] with - * `parentJobExecutionId.orElse(null)`. - */ - fun parentJobExecutionId(parentJobExecutionId: Optional) = - parentJobExecutionId(parentJobExecutionId.getOrNull()) - - /** - * Sets [Builder.parentJobExecutionId] to an arbitrary JSON value. - * - * You should usually call [Builder.parentJobExecutionId] with a well-typed - * [String] value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun parentJobExecutionId(parentJobExecutionId: JsonField) = apply { - this.parentJobExecutionId = parentJobExecutionId - } - - /** - * The partitions for this execution. Used for determining where to save job - * output. - */ - fun partitions(partitions: Partitions) = partitions(JsonField.of(partitions)) - - /** - * Sets [Builder.partitions] to an arbitrary JSON value. - * - * You should usually call [Builder.partitions] with a well-typed [Partitions] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun partitions(partitions: JsonField) = apply { - this.partitions = partitions - } - - /** The ID of the project this job belongs 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 - } - - /** - * The upstream request ID that created this job. Used for tracking the job - * across services. - */ - fun sessionId(sessionId: String?) = sessionId(JsonField.ofNullable(sessionId)) - - /** Alias for calling [Builder.sessionId] with `sessionId.orElse(null)`. */ - fun sessionId(sessionId: Optional) = sessionId(sessionId.getOrNull()) - - /** - * Sets [Builder.sessionId] to an arbitrary JSON value. - * - * You should usually call [Builder.sessionId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun sessionId(sessionId: JsonField) = apply { - this.sessionId = sessionId - } - - /** The ID of the user that created this job */ - fun userId(userId: String?) = userId(JsonField.ofNullable(userId)) - - /** Alias for calling [Builder.userId] with `userId.orElse(null)`. */ - fun userId(userId: Optional) = userId(userId.getOrNull()) - - /** - * Sets [Builder.userId] to an arbitrary JSON value. - * - * You should usually call [Builder.userId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun userId(userId: JsonField) = apply { this.userId = userId } - - /** The URL that needs to be called at the end of the parsing job. */ - fun webhookUrl(webhookUrl: String?) = - webhookUrl(JsonField.ofNullable(webhookUrl)) - - /** Alias for calling [Builder.webhookUrl] with `webhookUrl.orElse(null)`. */ - fun webhookUrl(webhookUrl: Optional) = - webhookUrl(webhookUrl.getOrNull()) - - /** - * Sets [Builder.webhookUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookUrl] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun webhookUrl(webhookUrl: JsonField) = apply { - this.webhookUrl = webhookUrl - } - - 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 [BatchParseJobRecordCreate]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BatchParseJobRecordCreate = - BatchParseJobRecordCreate( - correlationId, - jobName, - parameters, - parentJobExecutionId, - partitions, - projectId, - sessionId, - userId, - webhookUrl, - 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(): BatchParseJobRecordCreate = apply { - if (validated) { - return@apply - } - - correlationId() - jobName().ifPresent { it.validate() } - parameters().ifPresent { it.validate() } - parentJobExecutionId() - partitions().ifPresent { it.validate() } - projectId() - sessionId() - userId() - webhookUrl() - 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 (correlationId.asKnown().isPresent) 1 else 0) + - (jobName.asKnown().getOrNull()?.validity() ?: 0) + - (parameters.asKnown().getOrNull()?.validity() ?: 0) + - (if (parentJobExecutionId.asKnown().isPresent) 1 else 0) + - (partitions.asKnown().getOrNull()?.validity() ?: 0) + - (if (projectId.asKnown().isPresent) 1 else 0) + - (if (sessionId.asKnown().isPresent) 1 else 0) + - (if (userId.asKnown().isPresent) 1 else 0) + - (if (webhookUrl.asKnown().isPresent) 1 else 0) - - class JobName - @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 PARSE_RAW_FILE_JOB = of("parse_raw_file_job") - - @JvmStatic fun of(value: String) = JobName(JsonField.of(value)) - } - - /** An enum containing [JobName]'s known values. */ - enum class Known { - PARSE_RAW_FILE_JOB - } - - /** - * An enum containing [JobName]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [JobName] 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 { - PARSE_RAW_FILE_JOB, - /** - * An enum member indicating that [JobName] 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) { - PARSE_RAW_FILE_JOB -> Value.PARSE_RAW_FILE_JOB - 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) { - PARSE_RAW_FILE_JOB -> Known.PARSE_RAW_FILE_JOB - else -> throw LlamaCloudInvalidDataException("Unknown JobName: $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(): JobName = 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 JobName && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** - * Generic parse job configuration for batch processing. - * - * This model contains the parsing configuration that applies to all files in a - * batch, but excludes file-specific fields like file_name, file_id, etc. Those - * file-specific fields are populated from DirectoryFile data when creating - * individual ParseJobRecordCreate instances for each file. - * - * The fields in this model should be generic settings that apply uniformly to all - * files being processed in the batch. - */ - class Parameters - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val adaptiveLongTable: JsonField, - private val aggressiveTableExtraction: JsonField, - private val annotateLinks: JsonField, - private val annotateRevisions: JsonField, - private val autoMode: JsonField, - private val autoModeConfigurationJson: JsonField, - private val autoModeTriggerOnImageInPage: JsonField, - private val autoModeTriggerOnRegexpInPage: JsonField, - private val autoModeTriggerOnTableInPage: JsonField, - private val autoModeTriggerOnTextInPage: JsonField, - private val azureOpenAIApiVersion: JsonField, - private val azureOpenAIDeploymentName: JsonField, - private val azureOpenAIEndpoint: JsonField, - private val azureOpenAIKey: JsonField, - private val bboxBottom: JsonField, - private val bboxLeft: JsonField, - private val bboxRight: JsonField, - private val bboxTop: JsonField, - private val boundingBox: JsonField, - private val compactMarkdownTable: JsonField, - private val complementalFormattingInstruction: JsonField, - private val confidenceScoreEffort: JsonField, - private val contentGuidelineInstruction: JsonField, - private val continuousMode: JsonField, - private val customMetadata: JsonField, - private val disableImageExtraction: JsonField, - private val disableOcr: JsonField, - private val disableReconstruction: JsonField, - private val doNotCache: JsonField, - private val doNotUnrollColumns: JsonField, - private val enableCostOptimizer: JsonField, - private val extractCharts: JsonField, - private val extractLayout: JsonField, - private val extractPrintedPageNumber: JsonField, - private val fastMode: JsonField, - private val formattingInstruction: JsonField, - private val gpt4oApiKey: JsonField, - private val gpt4oMode: JsonField, - private val guessXlsxSheetName: JsonField, - private val hideFooters: JsonField, - private val hideHeaders: JsonField, - private val highResOcr: JsonField, - private val htmlMakeAllElementsVisible: JsonField, - private val htmlRemoveFixedElements: JsonField, - private val htmlRemoveNavigationElements: JsonField, - private val httpProxy: JsonField, - private val ignoreDocumentElementsForLayoutDetection: JsonField, - private val imagesToSave: JsonField>, - private val inlineImagesInMarkdown: JsonField, - private val inputS3Path: JsonField, - private val inputS3Region: JsonField, - private val inputUrl: JsonField, - private val internalIsScreenshotJob: JsonField, - private val invalidateCache: JsonField, - private val isFormattingInstruction: JsonField, - private val jobTimeoutExtraTimePerPageInSeconds: JsonField, - private val jobTimeoutInSeconds: JsonField, - private val keepPageSeparatorWhenMergingTables: JsonField, - private val lang: JsonField, - private val languages: JsonField>, - private val layoutAware: JsonField, - private val lineLevelBoundingBox: JsonField, - private val markdownTableMultilineHeaderSeparator: JsonField, - private val maxPages: JsonField, - private val maxPagesEnforced: JsonField, - private val mergeTablesAcrossPagesInMarkdown: JsonField, - private val model: JsonField, - private val outlinedTableExtraction: JsonField, - private val outputPdfOfDocument: JsonField, - private val outputS3PathPrefix: JsonField, - private val outputS3Region: JsonField, - private val outputTablesAsHtml: JsonField, - private val outputBucket: JsonField, - private val pageErrorTolerance: JsonField, - private val pageFooterPrefix: JsonField, - private val pageFooterSuffix: JsonField, - private val pageHeaderPrefix: JsonField, - private val pageHeaderSuffix: JsonField, - private val pagePrefix: JsonField, - private val pageSeparator: JsonField, - private val pageSuffix: JsonField, - private val parseMode: JsonField, - private val parsingInstruction: JsonField, - private val pipelineId: JsonField, - private val preciseBoundingBox: JsonField, - private val premiumMode: JsonField, - private val presentationOutOfBoundsContent: JsonField, - private val presentationSkipEmbeddedData: JsonField, - private val preserveLayoutAlignmentAcrossPages: JsonField, - private val preserveVerySmallText: JsonField, - private val preset: JsonField, - private val priority: JsonField, - private val projectId: JsonField, - private val removeHiddenText: JsonField, - private val replaceFailedPageMode: JsonField, - private val replaceFailedPageWithErrorMessagePrefix: JsonField, - private val replaceFailedPageWithErrorMessageSuffix: JsonField, - private val resourceInfo: JsonField, - private val saveImages: JsonField, - private val skipDiagonalText: JsonField, - private val specializedChartParsingAgentic: JsonField, - private val specializedChartParsingEfficient: JsonField, - private val specializedChartParsingPlus: JsonField, - private val specializedImageParsing: JsonField, - private val spreadsheetExtractSubTables: JsonField, - private val spreadsheetForceFormulaComputation: JsonField, - private val spreadsheetIncludeHiddenSheets: JsonField, - private val strictModeBuggyFont: JsonField, - private val strictModeImageExtraction: JsonField, - private val strictModeImageOcr: JsonField, - private val strictModeReconstruction: JsonField, - private val structuredOutput: JsonField, - private val structuredOutputJsonSchema: JsonField, - private val structuredOutputJsonSchemaName: JsonField, - private val systemPrompt: JsonField, - private val systemPromptAppend: JsonField, - private val takeScreenshot: JsonField, - private val targetPages: JsonField, - private val tier: JsonField, - private val type: JsonField, - private val useVendorMultimodalModel: JsonField, - private val userPrompt: JsonField, - private val vendorMultimodalApiKey: JsonField, - private val vendorMultimodalModelName: JsonField, - private val version: JsonField, - private val webhookConfigurations: JsonField>, - private val webhookUrl: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("adaptive_long_table") - @ExcludeMissing - adaptiveLongTable: JsonField = JsonMissing.of(), - @JsonProperty("aggressive_table_extraction") - @ExcludeMissing - aggressiveTableExtraction: JsonField = JsonMissing.of(), - @JsonProperty("annotate_links") - @ExcludeMissing - annotateLinks: JsonField = JsonMissing.of(), - @JsonProperty("annotate_revisions") - @ExcludeMissing - annotateRevisions: JsonField = JsonMissing.of(), - @JsonProperty("auto_mode") - @ExcludeMissing - autoMode: JsonField = JsonMissing.of(), - @JsonProperty("auto_mode_configuration_json") - @ExcludeMissing - autoModeConfigurationJson: JsonField = JsonMissing.of(), - @JsonProperty("auto_mode_trigger_on_image_in_page") - @ExcludeMissing - autoModeTriggerOnImageInPage: JsonField = JsonMissing.of(), - @JsonProperty("auto_mode_trigger_on_regexp_in_page") - @ExcludeMissing - autoModeTriggerOnRegexpInPage: JsonField = JsonMissing.of(), - @JsonProperty("auto_mode_trigger_on_table_in_page") - @ExcludeMissing - autoModeTriggerOnTableInPage: JsonField = JsonMissing.of(), - @JsonProperty("auto_mode_trigger_on_text_in_page") - @ExcludeMissing - autoModeTriggerOnTextInPage: JsonField = JsonMissing.of(), - @JsonProperty("azure_openai_api_version") - @ExcludeMissing - azureOpenAIApiVersion: JsonField = JsonMissing.of(), - @JsonProperty("azure_openai_deployment_name") - @ExcludeMissing - azureOpenAIDeploymentName: JsonField = JsonMissing.of(), - @JsonProperty("azure_openai_endpoint") - @ExcludeMissing - azureOpenAIEndpoint: JsonField = JsonMissing.of(), - @JsonProperty("azure_openai_key") - @ExcludeMissing - azureOpenAIKey: JsonField = JsonMissing.of(), - @JsonProperty("bbox_bottom") - @ExcludeMissing - bboxBottom: JsonField = JsonMissing.of(), - @JsonProperty("bbox_left") - @ExcludeMissing - bboxLeft: JsonField = JsonMissing.of(), - @JsonProperty("bbox_right") - @ExcludeMissing - bboxRight: JsonField = JsonMissing.of(), - @JsonProperty("bbox_top") - @ExcludeMissing - bboxTop: JsonField = JsonMissing.of(), - @JsonProperty("bounding_box") - @ExcludeMissing - boundingBox: JsonField = JsonMissing.of(), - @JsonProperty("compact_markdown_table") - @ExcludeMissing - compactMarkdownTable: JsonField = JsonMissing.of(), - @JsonProperty("complemental_formatting_instruction") - @ExcludeMissing - complementalFormattingInstruction: JsonField = JsonMissing.of(), - @JsonProperty("confidence_score_effort") - @ExcludeMissing - confidenceScoreEffort: JsonField = JsonMissing.of(), - @JsonProperty("content_guideline_instruction") - @ExcludeMissing - contentGuidelineInstruction: JsonField = JsonMissing.of(), - @JsonProperty("continuous_mode") - @ExcludeMissing - continuousMode: JsonField = JsonMissing.of(), - @JsonProperty("custom_metadata") - @ExcludeMissing - customMetadata: JsonField = JsonMissing.of(), - @JsonProperty("disable_image_extraction") - @ExcludeMissing - disableImageExtraction: JsonField = JsonMissing.of(), - @JsonProperty("disable_ocr") - @ExcludeMissing - disableOcr: JsonField = JsonMissing.of(), - @JsonProperty("disable_reconstruction") - @ExcludeMissing - disableReconstruction: JsonField = JsonMissing.of(), - @JsonProperty("do_not_cache") - @ExcludeMissing - doNotCache: JsonField = JsonMissing.of(), - @JsonProperty("do_not_unroll_columns") - @ExcludeMissing - doNotUnrollColumns: JsonField = JsonMissing.of(), - @JsonProperty("enable_cost_optimizer") - @ExcludeMissing - enableCostOptimizer: JsonField = JsonMissing.of(), - @JsonProperty("extract_charts") - @ExcludeMissing - extractCharts: JsonField = JsonMissing.of(), - @JsonProperty("extract_layout") - @ExcludeMissing - extractLayout: JsonField = JsonMissing.of(), - @JsonProperty("extract_printed_page_number") - @ExcludeMissing - extractPrintedPageNumber: JsonField = JsonMissing.of(), - @JsonProperty("fast_mode") - @ExcludeMissing - fastMode: JsonField = JsonMissing.of(), - @JsonProperty("formatting_instruction") - @ExcludeMissing - formattingInstruction: JsonField = JsonMissing.of(), - @JsonProperty("gpt4o_api_key") - @ExcludeMissing - gpt4oApiKey: JsonField = JsonMissing.of(), - @JsonProperty("gpt4o_mode") - @ExcludeMissing - gpt4oMode: JsonField = JsonMissing.of(), - @JsonProperty("guess_xlsx_sheet_name") - @ExcludeMissing - guessXlsxSheetName: JsonField = JsonMissing.of(), - @JsonProperty("hide_footers") - @ExcludeMissing - hideFooters: JsonField = JsonMissing.of(), - @JsonProperty("hide_headers") - @ExcludeMissing - hideHeaders: JsonField = JsonMissing.of(), - @JsonProperty("high_res_ocr") - @ExcludeMissing - highResOcr: JsonField = JsonMissing.of(), - @JsonProperty("html_make_all_elements_visible") - @ExcludeMissing - htmlMakeAllElementsVisible: JsonField = JsonMissing.of(), - @JsonProperty("html_remove_fixed_elements") - @ExcludeMissing - htmlRemoveFixedElements: JsonField = JsonMissing.of(), - @JsonProperty("html_remove_navigation_elements") - @ExcludeMissing - htmlRemoveNavigationElements: JsonField = JsonMissing.of(), - @JsonProperty("http_proxy") - @ExcludeMissing - httpProxy: JsonField = JsonMissing.of(), - @JsonProperty("ignore_document_elements_for_layout_detection") - @ExcludeMissing - ignoreDocumentElementsForLayoutDetection: JsonField = - JsonMissing.of(), - @JsonProperty("images_to_save") - @ExcludeMissing - imagesToSave: JsonField> = JsonMissing.of(), - @JsonProperty("inline_images_in_markdown") - @ExcludeMissing - inlineImagesInMarkdown: JsonField = JsonMissing.of(), - @JsonProperty("input_s3_path") - @ExcludeMissing - inputS3Path: JsonField = JsonMissing.of(), - @JsonProperty("input_s3_region") - @ExcludeMissing - inputS3Region: JsonField = JsonMissing.of(), - @JsonProperty("input_url") - @ExcludeMissing - inputUrl: JsonField = JsonMissing.of(), - @JsonProperty("internal_is_screenshot_job") - @ExcludeMissing - internalIsScreenshotJob: JsonField = JsonMissing.of(), - @JsonProperty("invalidate_cache") - @ExcludeMissing - invalidateCache: JsonField = JsonMissing.of(), - @JsonProperty("is_formatting_instruction") - @ExcludeMissing - isFormattingInstruction: JsonField = JsonMissing.of(), - @JsonProperty("job_timeout_extra_time_per_page_in_seconds") - @ExcludeMissing - jobTimeoutExtraTimePerPageInSeconds: JsonField = JsonMissing.of(), - @JsonProperty("job_timeout_in_seconds") - @ExcludeMissing - jobTimeoutInSeconds: JsonField = JsonMissing.of(), - @JsonProperty("keep_page_separator_when_merging_tables") - @ExcludeMissing - keepPageSeparatorWhenMergingTables: JsonField = JsonMissing.of(), - @JsonProperty("lang") - @ExcludeMissing - lang: JsonField = JsonMissing.of(), - @JsonProperty("languages") - @ExcludeMissing - languages: JsonField> = JsonMissing.of(), - @JsonProperty("layout_aware") - @ExcludeMissing - layoutAware: JsonField = JsonMissing.of(), - @JsonProperty("line_level_bounding_box") - @ExcludeMissing - lineLevelBoundingBox: JsonField = JsonMissing.of(), - @JsonProperty("markdown_table_multiline_header_separator") - @ExcludeMissing - markdownTableMultilineHeaderSeparator: JsonField = JsonMissing.of(), - @JsonProperty("max_pages") - @ExcludeMissing - maxPages: JsonField = JsonMissing.of(), - @JsonProperty("max_pages_enforced") - @ExcludeMissing - maxPagesEnforced: JsonField = JsonMissing.of(), - @JsonProperty("merge_tables_across_pages_in_markdown") - @ExcludeMissing - mergeTablesAcrossPagesInMarkdown: JsonField = JsonMissing.of(), - @JsonProperty("model") - @ExcludeMissing - model: JsonField = JsonMissing.of(), - @JsonProperty("outlined_table_extraction") - @ExcludeMissing - outlinedTableExtraction: JsonField = JsonMissing.of(), - @JsonProperty("output_pdf_of_document") - @ExcludeMissing - outputPdfOfDocument: JsonField = JsonMissing.of(), - @JsonProperty("output_s3_path_prefix") - @ExcludeMissing - outputS3PathPrefix: JsonField = JsonMissing.of(), - @JsonProperty("output_s3_region") - @ExcludeMissing - outputS3Region: JsonField = JsonMissing.of(), - @JsonProperty("output_tables_as_HTML") - @ExcludeMissing - outputTablesAsHtml: JsonField = JsonMissing.of(), - @JsonProperty("outputBucket") - @ExcludeMissing - outputBucket: JsonField = JsonMissing.of(), - @JsonProperty("page_error_tolerance") - @ExcludeMissing - pageErrorTolerance: JsonField = JsonMissing.of(), - @JsonProperty("page_footer_prefix") - @ExcludeMissing - pageFooterPrefix: JsonField = JsonMissing.of(), - @JsonProperty("page_footer_suffix") - @ExcludeMissing - pageFooterSuffix: JsonField = JsonMissing.of(), - @JsonProperty("page_header_prefix") - @ExcludeMissing - pageHeaderPrefix: JsonField = JsonMissing.of(), - @JsonProperty("page_header_suffix") - @ExcludeMissing - pageHeaderSuffix: JsonField = JsonMissing.of(), - @JsonProperty("page_prefix") - @ExcludeMissing - pagePrefix: JsonField = JsonMissing.of(), - @JsonProperty("page_separator") - @ExcludeMissing - pageSeparator: JsonField = JsonMissing.of(), - @JsonProperty("page_suffix") - @ExcludeMissing - pageSuffix: JsonField = JsonMissing.of(), - @JsonProperty("parse_mode") - @ExcludeMissing - parseMode: JsonField = JsonMissing.of(), - @JsonProperty("parsing_instruction") - @ExcludeMissing - parsingInstruction: JsonField = JsonMissing.of(), - @JsonProperty("pipeline_id") - @ExcludeMissing - pipelineId: JsonField = JsonMissing.of(), - @JsonProperty("precise_bounding_box") - @ExcludeMissing - preciseBoundingBox: JsonField = JsonMissing.of(), - @JsonProperty("premium_mode") - @ExcludeMissing - premiumMode: JsonField = JsonMissing.of(), - @JsonProperty("presentation_out_of_bounds_content") - @ExcludeMissing - presentationOutOfBoundsContent: JsonField = JsonMissing.of(), - @JsonProperty("presentation_skip_embedded_data") - @ExcludeMissing - presentationSkipEmbeddedData: JsonField = JsonMissing.of(), - @JsonProperty("preserve_layout_alignment_across_pages") - @ExcludeMissing - preserveLayoutAlignmentAcrossPages: JsonField = JsonMissing.of(), - @JsonProperty("preserve_very_small_text") - @ExcludeMissing - preserveVerySmallText: JsonField = JsonMissing.of(), - @JsonProperty("preset") - @ExcludeMissing - preset: JsonField = JsonMissing.of(), - @JsonProperty("priority") - @ExcludeMissing - priority: JsonField = JsonMissing.of(), - @JsonProperty("project_id") - @ExcludeMissing - projectId: JsonField = JsonMissing.of(), - @JsonProperty("remove_hidden_text") - @ExcludeMissing - removeHiddenText: JsonField = JsonMissing.of(), - @JsonProperty("replace_failed_page_mode") - @ExcludeMissing - replaceFailedPageMode: JsonField = JsonMissing.of(), - @JsonProperty("replace_failed_page_with_error_message_prefix") - @ExcludeMissing - replaceFailedPageWithErrorMessagePrefix: JsonField = - JsonMissing.of(), - @JsonProperty("replace_failed_page_with_error_message_suffix") - @ExcludeMissing - replaceFailedPageWithErrorMessageSuffix: JsonField = - JsonMissing.of(), - @JsonProperty("resource_info") - @ExcludeMissing - resourceInfo: JsonField = JsonMissing.of(), - @JsonProperty("save_images") - @ExcludeMissing - saveImages: JsonField = JsonMissing.of(), - @JsonProperty("skip_diagonal_text") - @ExcludeMissing - skipDiagonalText: JsonField = JsonMissing.of(), - @JsonProperty("specialized_chart_parsing_agentic") - @ExcludeMissing - specializedChartParsingAgentic: JsonField = JsonMissing.of(), - @JsonProperty("specialized_chart_parsing_efficient") - @ExcludeMissing - specializedChartParsingEfficient: JsonField = JsonMissing.of(), - @JsonProperty("specialized_chart_parsing_plus") - @ExcludeMissing - specializedChartParsingPlus: JsonField = JsonMissing.of(), - @JsonProperty("specialized_image_parsing") - @ExcludeMissing - specializedImageParsing: JsonField = JsonMissing.of(), - @JsonProperty("spreadsheet_extract_sub_tables") - @ExcludeMissing - spreadsheetExtractSubTables: JsonField = JsonMissing.of(), - @JsonProperty("spreadsheet_force_formula_computation") - @ExcludeMissing - spreadsheetForceFormulaComputation: JsonField = JsonMissing.of(), - @JsonProperty("spreadsheet_include_hidden_sheets") - @ExcludeMissing - spreadsheetIncludeHiddenSheets: JsonField = JsonMissing.of(), - @JsonProperty("strict_mode_buggy_font") - @ExcludeMissing - strictModeBuggyFont: JsonField = JsonMissing.of(), - @JsonProperty("strict_mode_image_extraction") - @ExcludeMissing - strictModeImageExtraction: JsonField = JsonMissing.of(), - @JsonProperty("strict_mode_image_ocr") - @ExcludeMissing - strictModeImageOcr: JsonField = JsonMissing.of(), - @JsonProperty("strict_mode_reconstruction") - @ExcludeMissing - strictModeReconstruction: JsonField = JsonMissing.of(), - @JsonProperty("structured_output") - @ExcludeMissing - structuredOutput: JsonField = JsonMissing.of(), - @JsonProperty("structured_output_json_schema") - @ExcludeMissing - structuredOutputJsonSchema: JsonField = JsonMissing.of(), - @JsonProperty("structured_output_json_schema_name") - @ExcludeMissing - structuredOutputJsonSchemaName: JsonField = JsonMissing.of(), - @JsonProperty("system_prompt") - @ExcludeMissing - systemPrompt: JsonField = JsonMissing.of(), - @JsonProperty("system_prompt_append") - @ExcludeMissing - systemPromptAppend: JsonField = JsonMissing.of(), - @JsonProperty("take_screenshot") - @ExcludeMissing - takeScreenshot: JsonField = JsonMissing.of(), - @JsonProperty("target_pages") - @ExcludeMissing - targetPages: JsonField = JsonMissing.of(), - @JsonProperty("tier") - @ExcludeMissing - tier: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), - @JsonProperty("use_vendor_multimodal_model") - @ExcludeMissing - useVendorMultimodalModel: JsonField = JsonMissing.of(), - @JsonProperty("user_prompt") - @ExcludeMissing - userPrompt: JsonField = JsonMissing.of(), - @JsonProperty("vendor_multimodal_api_key") - @ExcludeMissing - vendorMultimodalApiKey: JsonField = JsonMissing.of(), - @JsonProperty("vendor_multimodal_model_name") - @ExcludeMissing - vendorMultimodalModelName: JsonField = JsonMissing.of(), - @JsonProperty("version") - @ExcludeMissing - version: JsonField = JsonMissing.of(), - @JsonProperty("webhook_configurations") - @ExcludeMissing - webhookConfigurations: JsonField> = - JsonMissing.of(), - @JsonProperty("webhook_url") - @ExcludeMissing - webhookUrl: JsonField = JsonMissing.of(), - ) : this( - adaptiveLongTable, - aggressiveTableExtraction, - annotateLinks, - annotateRevisions, - autoMode, - autoModeConfigurationJson, - autoModeTriggerOnImageInPage, - autoModeTriggerOnRegexpInPage, - autoModeTriggerOnTableInPage, - autoModeTriggerOnTextInPage, - azureOpenAIApiVersion, - azureOpenAIDeploymentName, - azureOpenAIEndpoint, - azureOpenAIKey, - bboxBottom, - bboxLeft, - bboxRight, - bboxTop, - boundingBox, - compactMarkdownTable, - complementalFormattingInstruction, - confidenceScoreEffort, - contentGuidelineInstruction, - continuousMode, - customMetadata, - disableImageExtraction, - disableOcr, - disableReconstruction, - doNotCache, - doNotUnrollColumns, - enableCostOptimizer, - extractCharts, - extractLayout, - extractPrintedPageNumber, - fastMode, - formattingInstruction, - gpt4oApiKey, - gpt4oMode, - guessXlsxSheetName, - hideFooters, - hideHeaders, - highResOcr, - htmlMakeAllElementsVisible, - htmlRemoveFixedElements, - htmlRemoveNavigationElements, - httpProxy, - ignoreDocumentElementsForLayoutDetection, - imagesToSave, - inlineImagesInMarkdown, - inputS3Path, - inputS3Region, - inputUrl, - internalIsScreenshotJob, - invalidateCache, - isFormattingInstruction, - jobTimeoutExtraTimePerPageInSeconds, - jobTimeoutInSeconds, - keepPageSeparatorWhenMergingTables, - lang, - languages, - layoutAware, - lineLevelBoundingBox, - markdownTableMultilineHeaderSeparator, - maxPages, - maxPagesEnforced, - mergeTablesAcrossPagesInMarkdown, - model, - outlinedTableExtraction, - outputPdfOfDocument, - outputS3PathPrefix, - outputS3Region, - outputTablesAsHtml, - outputBucket, - pageErrorTolerance, - pageFooterPrefix, - pageFooterSuffix, - pageHeaderPrefix, - pageHeaderSuffix, - pagePrefix, - pageSeparator, - pageSuffix, - parseMode, - parsingInstruction, - pipelineId, - preciseBoundingBox, - premiumMode, - presentationOutOfBoundsContent, - presentationSkipEmbeddedData, - preserveLayoutAlignmentAcrossPages, - preserveVerySmallText, - preset, - priority, - projectId, - removeHiddenText, - replaceFailedPageMode, - replaceFailedPageWithErrorMessagePrefix, - replaceFailedPageWithErrorMessageSuffix, - resourceInfo, - saveImages, - skipDiagonalText, - specializedChartParsingAgentic, - specializedChartParsingEfficient, - specializedChartParsingPlus, - specializedImageParsing, - spreadsheetExtractSubTables, - spreadsheetForceFormulaComputation, - spreadsheetIncludeHiddenSheets, - strictModeBuggyFont, - strictModeImageExtraction, - strictModeImageOcr, - strictModeReconstruction, - structuredOutput, - structuredOutputJsonSchema, - structuredOutputJsonSchemaName, - systemPrompt, - systemPromptAppend, - takeScreenshot, - targetPages, - tier, - type, - useVendorMultimodalModel, - userPrompt, - vendorMultimodalApiKey, - vendorMultimodalModelName, - version, - webhookConfigurations, - webhookUrl, - mutableMapOf(), - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun adaptiveLongTable(): Optional = - adaptiveLongTable.getOptional("adaptive_long_table") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun aggressiveTableExtraction(): Optional = - aggressiveTableExtraction.getOptional("aggressive_table_extraction") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun annotateLinks(): Optional = - annotateLinks.getOptional("annotate_links") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun annotateRevisions(): Optional = - annotateRevisions.getOptional("annotate_revisions") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun autoMode(): Optional = autoMode.getOptional("auto_mode") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun autoModeConfigurationJson(): Optional = - autoModeConfigurationJson.getOptional("auto_mode_configuration_json") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun autoModeTriggerOnImageInPage(): Optional = - autoModeTriggerOnImageInPage.getOptional( - "auto_mode_trigger_on_image_in_page" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun autoModeTriggerOnRegexpInPage(): Optional = - autoModeTriggerOnRegexpInPage.getOptional( - "auto_mode_trigger_on_regexp_in_page" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun autoModeTriggerOnTableInPage(): Optional = - autoModeTriggerOnTableInPage.getOptional( - "auto_mode_trigger_on_table_in_page" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun autoModeTriggerOnTextInPage(): Optional = - autoModeTriggerOnTextInPage.getOptional("auto_mode_trigger_on_text_in_page") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun azureOpenAIApiVersion(): Optional = - azureOpenAIApiVersion.getOptional("azure_openai_api_version") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun azureOpenAIDeploymentName(): Optional = - azureOpenAIDeploymentName.getOptional("azure_openai_deployment_name") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun azureOpenAIEndpoint(): Optional = - azureOpenAIEndpoint.getOptional("azure_openai_endpoint") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun azureOpenAIKey(): Optional = - azureOpenAIKey.getOptional("azure_openai_key") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun bboxBottom(): Optional = bboxBottom.getOptional("bbox_bottom") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun bboxLeft(): Optional = bboxLeft.getOptional("bbox_left") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun bboxRight(): Optional = bboxRight.getOptional("bbox_right") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun bboxTop(): Optional = bboxTop.getOptional("bbox_top") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun boundingBox(): Optional = boundingBox.getOptional("bounding_box") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun compactMarkdownTable(): Optional = - compactMarkdownTable.getOptional("compact_markdown_table") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun complementalFormattingInstruction(): Optional = - complementalFormattingInstruction.getOptional( - "complemental_formatting_instruction" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun confidenceScoreEffort(): Optional = - confidenceScoreEffort.getOptional("confidence_score_effort") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun contentGuidelineInstruction(): Optional = - contentGuidelineInstruction.getOptional("content_guideline_instruction") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun continuousMode(): Optional = - continuousMode.getOptional("continuous_mode") - - /** - * The custom metadata to attach to the documents. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun customMetadata(): Optional = - customMetadata.getOptional("custom_metadata") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun disableImageExtraction(): Optional = - disableImageExtraction.getOptional("disable_image_extraction") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun disableOcr(): Optional = disableOcr.getOptional("disable_ocr") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun disableReconstruction(): Optional = - disableReconstruction.getOptional("disable_reconstruction") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun doNotCache(): Optional = doNotCache.getOptional("do_not_cache") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun doNotUnrollColumns(): Optional = - doNotUnrollColumns.getOptional("do_not_unroll_columns") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun enableCostOptimizer(): Optional = - enableCostOptimizer.getOptional("enable_cost_optimizer") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun extractCharts(): Optional = - extractCharts.getOptional("extract_charts") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun extractLayout(): Optional = - extractLayout.getOptional("extract_layout") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun extractPrintedPageNumber(): Optional = - extractPrintedPageNumber.getOptional("extract_printed_page_number") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun fastMode(): Optional = fastMode.getOptional("fast_mode") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun formattingInstruction(): Optional = - formattingInstruction.getOptional("formatting_instruction") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun gpt4oApiKey(): Optional = gpt4oApiKey.getOptional("gpt4o_api_key") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun gpt4oMode(): Optional = gpt4oMode.getOptional("gpt4o_mode") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun guessXlsxSheetName(): Optional = - guessXlsxSheetName.getOptional("guess_xlsx_sheet_name") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun hideFooters(): Optional = hideFooters.getOptional("hide_footers") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun hideHeaders(): Optional = hideHeaders.getOptional("hide_headers") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun highResOcr(): Optional = highResOcr.getOptional("high_res_ocr") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun htmlMakeAllElementsVisible(): Optional = - htmlMakeAllElementsVisible.getOptional("html_make_all_elements_visible") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun htmlRemoveFixedElements(): Optional = - htmlRemoveFixedElements.getOptional("html_remove_fixed_elements") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun htmlRemoveNavigationElements(): Optional = - htmlRemoveNavigationElements.getOptional("html_remove_navigation_elements") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun httpProxy(): Optional = httpProxy.getOptional("http_proxy") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun ignoreDocumentElementsForLayoutDetection(): Optional = - ignoreDocumentElementsForLayoutDetection.getOptional( - "ignore_document_elements_for_layout_detection" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun imagesToSave(): Optional> = - imagesToSave.getOptional("images_to_save") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun inlineImagesInMarkdown(): Optional = - inlineImagesInMarkdown.getOptional("inline_images_in_markdown") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun inputS3Path(): Optional = inputS3Path.getOptional("input_s3_path") - - /** - * The region for the input S3 bucket. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun inputS3Region(): Optional = - inputS3Region.getOptional("input_s3_region") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun inputUrl(): Optional = inputUrl.getOptional("input_url") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun internalIsScreenshotJob(): Optional = - internalIsScreenshotJob.getOptional("internal_is_screenshot_job") - - /** - * @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") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun isFormattingInstruction(): Optional = - isFormattingInstruction.getOptional("is_formatting_instruction") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun jobTimeoutExtraTimePerPageInSeconds(): Optional = - jobTimeoutExtraTimePerPageInSeconds.getOptional( - "job_timeout_extra_time_per_page_in_seconds" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun jobTimeoutInSeconds(): Optional = - jobTimeoutInSeconds.getOptional("job_timeout_in_seconds") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun keepPageSeparatorWhenMergingTables(): Optional = - keepPageSeparatorWhenMergingTables.getOptional( - "keep_page_separator_when_merging_tables" - ) - - /** - * The language. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun lang(): Optional = lang.getOptional("lang") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun languages(): Optional> = - languages.getOptional("languages") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun layoutAware(): Optional = layoutAware.getOptional("layout_aware") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun lineLevelBoundingBox(): Optional = - lineLevelBoundingBox.getOptional("line_level_bounding_box") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun markdownTableMultilineHeaderSeparator(): Optional = - markdownTableMultilineHeaderSeparator.getOptional( - "markdown_table_multiline_header_separator" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun maxPages(): Optional = maxPages.getOptional("max_pages") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun maxPagesEnforced(): Optional = - maxPagesEnforced.getOptional("max_pages_enforced") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun mergeTablesAcrossPagesInMarkdown(): Optional = - mergeTablesAcrossPagesInMarkdown.getOptional( - "merge_tables_across_pages_in_markdown" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun model(): Optional = model.getOptional("model") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun outlinedTableExtraction(): Optional = - outlinedTableExtraction.getOptional("outlined_table_extraction") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun outputPdfOfDocument(): Optional = - outputPdfOfDocument.getOptional("output_pdf_of_document") - - /** - * If specified, llamaParse will save the output to the specified path. All - * output file will use this 'prefix' should be a valid s3:// url - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun outputS3PathPrefix(): Optional = - outputS3PathPrefix.getOptional("output_s3_path_prefix") - - /** - * The region for the output S3 bucket. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun outputS3Region(): Optional = - outputS3Region.getOptional("output_s3_region") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun outputTablesAsHtml(): Optional = - outputTablesAsHtml.getOptional("output_tables_as_HTML") - - /** - * The output bucket. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun outputBucket(): Optional = outputBucket.getOptional("outputBucket") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun pageErrorTolerance(): Optional = - pageErrorTolerance.getOptional("page_error_tolerance") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun pageFooterPrefix(): Optional = - pageFooterPrefix.getOptional("page_footer_prefix") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun pageFooterSuffix(): Optional = - pageFooterSuffix.getOptional("page_footer_suffix") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun pageHeaderPrefix(): Optional = - pageHeaderPrefix.getOptional("page_header_prefix") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun pageHeaderSuffix(): Optional = - pageHeaderSuffix.getOptional("page_header_suffix") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun pagePrefix(): Optional = pagePrefix.getOptional("page_prefix") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun pageSeparator(): Optional = - pageSeparator.getOptional("page_separator") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun pageSuffix(): Optional = pageSuffix.getOptional("page_suffix") - - /** - * Enum for representing the mode of parsing to be used. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun parseMode(): Optional = parseMode.getOptional("parse_mode") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun parsingInstruction(): Optional = - parsingInstruction.getOptional("parsing_instruction") - - /** - * The pipeline ID. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun pipelineId(): Optional = pipelineId.getOptional("pipeline_id") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun preciseBoundingBox(): Optional = - preciseBoundingBox.getOptional("precise_bounding_box") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun premiumMode(): Optional = premiumMode.getOptional("premium_mode") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun presentationOutOfBoundsContent(): Optional = - presentationOutOfBoundsContent.getOptional( - "presentation_out_of_bounds_content" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun presentationSkipEmbeddedData(): Optional = - presentationSkipEmbeddedData.getOptional("presentation_skip_embedded_data") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun preserveLayoutAlignmentAcrossPages(): Optional = - preserveLayoutAlignmentAcrossPages.getOptional( - "preserve_layout_alignment_across_pages" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun preserveVerySmallText(): Optional = - preserveVerySmallText.getOptional("preserve_very_small_text") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun preset(): Optional = preset.getOptional("preset") - - /** - * 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") - - /** - * @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") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun removeHiddenText(): Optional = - removeHiddenText.getOptional("remove_hidden_text") - - /** - * Enum for representing the different available page error handling modes. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun replaceFailedPageMode(): Optional = - replaceFailedPageMode.getOptional("replace_failed_page_mode") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun replaceFailedPageWithErrorMessagePrefix(): Optional = - replaceFailedPageWithErrorMessagePrefix.getOptional( - "replace_failed_page_with_error_message_prefix" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun replaceFailedPageWithErrorMessageSuffix(): Optional = - replaceFailedPageWithErrorMessageSuffix.getOptional( - "replace_failed_page_with_error_message_suffix" - ) - - /** - * The resource info about the file - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun resourceInfo(): Optional = - resourceInfo.getOptional("resource_info") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun saveImages(): Optional = saveImages.getOptional("save_images") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun skipDiagonalText(): Optional = - skipDiagonalText.getOptional("skip_diagonal_text") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun specializedChartParsingAgentic(): Optional = - specializedChartParsingAgentic.getOptional( - "specialized_chart_parsing_agentic" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun specializedChartParsingEfficient(): Optional = - specializedChartParsingEfficient.getOptional( - "specialized_chart_parsing_efficient" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun specializedChartParsingPlus(): Optional = - specializedChartParsingPlus.getOptional("specialized_chart_parsing_plus") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun specializedImageParsing(): Optional = - specializedImageParsing.getOptional("specialized_image_parsing") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun spreadsheetExtractSubTables(): Optional = - spreadsheetExtractSubTables.getOptional("spreadsheet_extract_sub_tables") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun spreadsheetForceFormulaComputation(): Optional = - spreadsheetForceFormulaComputation.getOptional( - "spreadsheet_force_formula_computation" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun spreadsheetIncludeHiddenSheets(): Optional = - spreadsheetIncludeHiddenSheets.getOptional( - "spreadsheet_include_hidden_sheets" - ) - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun strictModeBuggyFont(): Optional = - strictModeBuggyFont.getOptional("strict_mode_buggy_font") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun strictModeImageExtraction(): Optional = - strictModeImageExtraction.getOptional("strict_mode_image_extraction") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun strictModeImageOcr(): Optional = - strictModeImageOcr.getOptional("strict_mode_image_ocr") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun strictModeReconstruction(): Optional = - strictModeReconstruction.getOptional("strict_mode_reconstruction") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun structuredOutput(): Optional = - structuredOutput.getOptional("structured_output") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun structuredOutputJsonSchema(): Optional = - structuredOutputJsonSchema.getOptional("structured_output_json_schema") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun structuredOutputJsonSchemaName(): Optional = - structuredOutputJsonSchemaName.getOptional( - "structured_output_json_schema_name" - ) - - /** - * @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") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun systemPromptAppend(): Optional = - systemPromptAppend.getOptional("system_prompt_append") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun takeScreenshot(): Optional = - takeScreenshot.getOptional("take_screenshot") - - /** - * @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") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun tier(): Optional = tier.getOptional("tier") - - /** - * @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") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun useVendorMultimodalModel(): Optional = - useVendorMultimodalModel.getOptional("use_vendor_multimodal_model") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun userPrompt(): Optional = userPrompt.getOptional("user_prompt") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun vendorMultimodalApiKey(): Optional = - vendorMultimodalApiKey.getOptional("vendor_multimodal_api_key") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun vendorMultimodalModelName(): Optional = - vendorMultimodalModelName.getOptional("vendor_multimodal_model_name") - - /** - * @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") - - /** - * Outbound webhook endpoints to notify on job status changes - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun webhookConfigurations(): Optional> = - webhookConfigurations.getOptional("webhook_configurations") - - /** - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected - * type (e.g. if the server responded with an unexpected value). - */ - fun webhookUrl(): Optional = webhookUrl.getOptional("webhook_url") - - /** - * Returns the raw JSON value of [adaptiveLongTable]. - * - * Unlike [adaptiveLongTable], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("adaptive_long_table") - @ExcludeMissing - fun _adaptiveLongTable(): JsonField = adaptiveLongTable - - /** - * Returns the raw JSON value of [aggressiveTableExtraction]. - * - * Unlike [aggressiveTableExtraction], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("aggressive_table_extraction") - @ExcludeMissing - fun _aggressiveTableExtraction(): JsonField = aggressiveTableExtraction - - /** - * Returns the raw JSON value of [annotateLinks]. - * - * Unlike [annotateLinks], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("annotate_links") - @ExcludeMissing - fun _annotateLinks(): JsonField = annotateLinks - - /** - * Returns the raw JSON value of [annotateRevisions]. - * - * Unlike [annotateRevisions], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("annotate_revisions") - @ExcludeMissing - fun _annotateRevisions(): JsonField = annotateRevisions - - /** - * Returns the raw JSON value of [autoMode]. - * - * Unlike [autoMode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("auto_mode") - @ExcludeMissing - fun _autoMode(): JsonField = autoMode - - /** - * Returns the raw JSON value of [autoModeConfigurationJson]. - * - * Unlike [autoModeConfigurationJson], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("auto_mode_configuration_json") - @ExcludeMissing - fun _autoModeConfigurationJson(): JsonField = autoModeConfigurationJson - - /** - * Returns the raw JSON value of [autoModeTriggerOnImageInPage]. - * - * Unlike [autoModeTriggerOnImageInPage], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("auto_mode_trigger_on_image_in_page") - @ExcludeMissing - fun _autoModeTriggerOnImageInPage(): JsonField = - autoModeTriggerOnImageInPage - - /** - * Returns the raw JSON value of [autoModeTriggerOnRegexpInPage]. - * - * Unlike [autoModeTriggerOnRegexpInPage], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("auto_mode_trigger_on_regexp_in_page") - @ExcludeMissing - fun _autoModeTriggerOnRegexpInPage(): JsonField = - autoModeTriggerOnRegexpInPage - - /** - * Returns the raw JSON value of [autoModeTriggerOnTableInPage]. - * - * Unlike [autoModeTriggerOnTableInPage], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("auto_mode_trigger_on_table_in_page") - @ExcludeMissing - fun _autoModeTriggerOnTableInPage(): JsonField = - autoModeTriggerOnTableInPage - - /** - * Returns the raw JSON value of [autoModeTriggerOnTextInPage]. - * - * Unlike [autoModeTriggerOnTextInPage], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("auto_mode_trigger_on_text_in_page") - @ExcludeMissing - fun _autoModeTriggerOnTextInPage(): JsonField = - autoModeTriggerOnTextInPage - - /** - * Returns the raw JSON value of [azureOpenAIApiVersion]. - * - * Unlike [azureOpenAIApiVersion], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("azure_openai_api_version") - @ExcludeMissing - fun _azureOpenAIApiVersion(): JsonField = azureOpenAIApiVersion - - /** - * Returns the raw JSON value of [azureOpenAIDeploymentName]. - * - * Unlike [azureOpenAIDeploymentName], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("azure_openai_deployment_name") - @ExcludeMissing - fun _azureOpenAIDeploymentName(): JsonField = azureOpenAIDeploymentName - - /** - * Returns the raw JSON value of [azureOpenAIEndpoint]. - * - * Unlike [azureOpenAIEndpoint], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("azure_openai_endpoint") - @ExcludeMissing - fun _azureOpenAIEndpoint(): JsonField = azureOpenAIEndpoint - - /** - * Returns the raw JSON value of [azureOpenAIKey]. - * - * Unlike [azureOpenAIKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("azure_openai_key") - @ExcludeMissing - fun _azureOpenAIKey(): JsonField = azureOpenAIKey - - /** - * Returns the raw JSON value of [bboxBottom]. - * - * Unlike [bboxBottom], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("bbox_bottom") - @ExcludeMissing - fun _bboxBottom(): JsonField = bboxBottom - - /** - * Returns the raw JSON value of [bboxLeft]. - * - * Unlike [bboxLeft], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("bbox_left") - @ExcludeMissing - fun _bboxLeft(): JsonField = bboxLeft - - /** - * Returns the raw JSON value of [bboxRight]. - * - * Unlike [bboxRight], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("bbox_right") - @ExcludeMissing - fun _bboxRight(): JsonField = bboxRight - - /** - * Returns the raw JSON value of [bboxTop]. - * - * Unlike [bboxTop], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("bbox_top") - @ExcludeMissing - fun _bboxTop(): JsonField = bboxTop - - /** - * Returns the raw JSON value of [boundingBox]. - * - * Unlike [boundingBox], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("bounding_box") - @ExcludeMissing - fun _boundingBox(): JsonField = boundingBox - - /** - * Returns the raw JSON value of [compactMarkdownTable]. - * - * Unlike [compactMarkdownTable], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("compact_markdown_table") - @ExcludeMissing - fun _compactMarkdownTable(): JsonField = compactMarkdownTable - - /** - * Returns the raw JSON value of [complementalFormattingInstruction]. - * - * Unlike [complementalFormattingInstruction], this method doesn't throw if the - * JSON field has an unexpected type. - */ - @JsonProperty("complemental_formatting_instruction") - @ExcludeMissing - fun _complementalFormattingInstruction(): JsonField = - complementalFormattingInstruction - - /** - * Returns the raw JSON value of [confidenceScoreEffort]. - * - * Unlike [confidenceScoreEffort], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("confidence_score_effort") - @ExcludeMissing - fun _confidenceScoreEffort(): JsonField = confidenceScoreEffort - - /** - * Returns the raw JSON value of [contentGuidelineInstruction]. - * - * Unlike [contentGuidelineInstruction], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("content_guideline_instruction") - @ExcludeMissing - fun _contentGuidelineInstruction(): JsonField = - contentGuidelineInstruction - - /** - * Returns the raw JSON value of [continuousMode]. - * - * Unlike [continuousMode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("continuous_mode") - @ExcludeMissing - fun _continuousMode(): JsonField = continuousMode - - /** - * Returns the raw JSON value of [customMetadata]. - * - * Unlike [customMetadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("custom_metadata") - @ExcludeMissing - fun _customMetadata(): JsonField = customMetadata - - /** - * Returns the raw JSON value of [disableImageExtraction]. - * - * Unlike [disableImageExtraction], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("disable_image_extraction") - @ExcludeMissing - fun _disableImageExtraction(): JsonField = disableImageExtraction - - /** - * Returns the raw JSON value of [disableOcr]. - * - * Unlike [disableOcr], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("disable_ocr") - @ExcludeMissing - fun _disableOcr(): JsonField = disableOcr - - /** - * Returns the raw JSON value of [disableReconstruction]. - * - * Unlike [disableReconstruction], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("disable_reconstruction") - @ExcludeMissing - fun _disableReconstruction(): JsonField = disableReconstruction - - /** - * Returns the raw JSON value of [doNotCache]. - * - * Unlike [doNotCache], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("do_not_cache") - @ExcludeMissing - fun _doNotCache(): JsonField = doNotCache - - /** - * Returns the raw JSON value of [doNotUnrollColumns]. - * - * Unlike [doNotUnrollColumns], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("do_not_unroll_columns") - @ExcludeMissing - fun _doNotUnrollColumns(): JsonField = doNotUnrollColumns - - /** - * Returns the raw JSON value of [enableCostOptimizer]. - * - * Unlike [enableCostOptimizer], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("enable_cost_optimizer") - @ExcludeMissing - fun _enableCostOptimizer(): JsonField = enableCostOptimizer - - /** - * Returns the raw JSON value of [extractCharts]. - * - * Unlike [extractCharts], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("extract_charts") - @ExcludeMissing - fun _extractCharts(): JsonField = extractCharts - - /** - * Returns the raw JSON value of [extractLayout]. - * - * Unlike [extractLayout], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("extract_layout") - @ExcludeMissing - fun _extractLayout(): JsonField = extractLayout - - /** - * Returns the raw JSON value of [extractPrintedPageNumber]. - * - * Unlike [extractPrintedPageNumber], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("extract_printed_page_number") - @ExcludeMissing - fun _extractPrintedPageNumber(): JsonField = extractPrintedPageNumber - - /** - * Returns the raw JSON value of [fastMode]. - * - * Unlike [fastMode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("fast_mode") - @ExcludeMissing - fun _fastMode(): JsonField = fastMode - - /** - * Returns the raw JSON value of [formattingInstruction]. - * - * Unlike [formattingInstruction], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("formatting_instruction") - @ExcludeMissing - fun _formattingInstruction(): JsonField = formattingInstruction - - /** - * Returns the raw JSON value of [gpt4oApiKey]. - * - * Unlike [gpt4oApiKey], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("gpt4o_api_key") - @ExcludeMissing - fun _gpt4oApiKey(): JsonField = gpt4oApiKey - - /** - * Returns the raw JSON value of [gpt4oMode]. - * - * Unlike [gpt4oMode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("gpt4o_mode") - @ExcludeMissing - fun _gpt4oMode(): JsonField = gpt4oMode - - /** - * Returns the raw JSON value of [guessXlsxSheetName]. - * - * Unlike [guessXlsxSheetName], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("guess_xlsx_sheet_name") - @ExcludeMissing - fun _guessXlsxSheetName(): JsonField = guessXlsxSheetName - - /** - * Returns the raw JSON value of [hideFooters]. - * - * Unlike [hideFooters], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("hide_footers") - @ExcludeMissing - fun _hideFooters(): JsonField = hideFooters - - /** - * Returns the raw JSON value of [hideHeaders]. - * - * Unlike [hideHeaders], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("hide_headers") - @ExcludeMissing - fun _hideHeaders(): JsonField = hideHeaders - - /** - * Returns the raw JSON value of [highResOcr]. - * - * Unlike [highResOcr], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("high_res_ocr") - @ExcludeMissing - fun _highResOcr(): JsonField = highResOcr - - /** - * Returns the raw JSON value of [htmlMakeAllElementsVisible]. - * - * Unlike [htmlMakeAllElementsVisible], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("html_make_all_elements_visible") - @ExcludeMissing - fun _htmlMakeAllElementsVisible(): JsonField = - htmlMakeAllElementsVisible - - /** - * Returns the raw JSON value of [htmlRemoveFixedElements]. - * - * Unlike [htmlRemoveFixedElements], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("html_remove_fixed_elements") - @ExcludeMissing - fun _htmlRemoveFixedElements(): JsonField = htmlRemoveFixedElements - - /** - * Returns the raw JSON value of [htmlRemoveNavigationElements]. - * - * Unlike [htmlRemoveNavigationElements], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("html_remove_navigation_elements") - @ExcludeMissing - fun _htmlRemoveNavigationElements(): JsonField = - htmlRemoveNavigationElements - - /** - * Returns the raw JSON value of [httpProxy]. - * - * Unlike [httpProxy], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("http_proxy") - @ExcludeMissing - fun _httpProxy(): JsonField = httpProxy - - /** - * Returns the raw JSON value of [ignoreDocumentElementsForLayoutDetection]. - * - * Unlike [ignoreDocumentElementsForLayoutDetection], this method doesn't throw - * if the JSON field has an unexpected type. - */ - @JsonProperty("ignore_document_elements_for_layout_detection") - @ExcludeMissing - fun _ignoreDocumentElementsForLayoutDetection(): JsonField = - ignoreDocumentElementsForLayoutDetection - - /** - * Returns the raw JSON value of [imagesToSave]. - * - * Unlike [imagesToSave], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("images_to_save") - @ExcludeMissing - fun _imagesToSave(): JsonField> = imagesToSave - - /** - * Returns the raw JSON value of [inlineImagesInMarkdown]. - * - * Unlike [inlineImagesInMarkdown], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("inline_images_in_markdown") - @ExcludeMissing - fun _inlineImagesInMarkdown(): JsonField = inlineImagesInMarkdown - - /** - * Returns the raw JSON value of [inputS3Path]. - * - * Unlike [inputS3Path], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("input_s3_path") - @ExcludeMissing - fun _inputS3Path(): JsonField = inputS3Path - - /** - * Returns the raw JSON value of [inputS3Region]. - * - * Unlike [inputS3Region], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("input_s3_region") - @ExcludeMissing - fun _inputS3Region(): JsonField = inputS3Region - - /** - * Returns the raw JSON value of [inputUrl]. - * - * Unlike [inputUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("input_url") - @ExcludeMissing - fun _inputUrl(): JsonField = inputUrl - - /** - * Returns the raw JSON value of [internalIsScreenshotJob]. - * - * Unlike [internalIsScreenshotJob], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("internal_is_screenshot_job") - @ExcludeMissing - fun _internalIsScreenshotJob(): JsonField = internalIsScreenshotJob - - /** - * 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 [isFormattingInstruction]. - * - * Unlike [isFormattingInstruction], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("is_formatting_instruction") - @ExcludeMissing - fun _isFormattingInstruction(): JsonField = isFormattingInstruction - - /** - * Returns the raw JSON value of [jobTimeoutExtraTimePerPageInSeconds]. - * - * Unlike [jobTimeoutExtraTimePerPageInSeconds], this method doesn't throw if - * the JSON field has an unexpected type. - */ - @JsonProperty("job_timeout_extra_time_per_page_in_seconds") - @ExcludeMissing - fun _jobTimeoutExtraTimePerPageInSeconds(): JsonField = - jobTimeoutExtraTimePerPageInSeconds - - /** - * Returns the raw JSON value of [jobTimeoutInSeconds]. - * - * Unlike [jobTimeoutInSeconds], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("job_timeout_in_seconds") - @ExcludeMissing - fun _jobTimeoutInSeconds(): JsonField = jobTimeoutInSeconds - - /** - * Returns the raw JSON value of [keepPageSeparatorWhenMergingTables]. - * - * Unlike [keepPageSeparatorWhenMergingTables], this method doesn't throw if the - * JSON field has an unexpected type. - */ - @JsonProperty("keep_page_separator_when_merging_tables") - @ExcludeMissing - fun _keepPageSeparatorWhenMergingTables(): JsonField = - keepPageSeparatorWhenMergingTables - - /** - * Returns the raw JSON value of [lang]. - * - * Unlike [lang], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("lang") @ExcludeMissing fun _lang(): JsonField = lang - - /** - * Returns the raw JSON value of [languages]. - * - * Unlike [languages], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("languages") - @ExcludeMissing - fun _languages(): JsonField> = languages - - /** - * Returns the raw JSON value of [layoutAware]. - * - * Unlike [layoutAware], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("layout_aware") - @ExcludeMissing - fun _layoutAware(): JsonField = layoutAware - - /** - * Returns the raw JSON value of [lineLevelBoundingBox]. - * - * Unlike [lineLevelBoundingBox], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("line_level_bounding_box") - @ExcludeMissing - fun _lineLevelBoundingBox(): JsonField = lineLevelBoundingBox - - /** - * Returns the raw JSON value of [markdownTableMultilineHeaderSeparator]. - * - * Unlike [markdownTableMultilineHeaderSeparator], this method doesn't throw if - * the JSON field has an unexpected type. - */ - @JsonProperty("markdown_table_multiline_header_separator") - @ExcludeMissing - fun _markdownTableMultilineHeaderSeparator(): JsonField = - markdownTableMultilineHeaderSeparator - - /** - * Returns the raw JSON value of [maxPages]. - * - * Unlike [maxPages], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("max_pages") - @ExcludeMissing - fun _maxPages(): JsonField = maxPages - - /** - * Returns the raw JSON value of [maxPagesEnforced]. - * - * Unlike [maxPagesEnforced], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("max_pages_enforced") - @ExcludeMissing - fun _maxPagesEnforced(): JsonField = maxPagesEnforced - - /** - * Returns the raw JSON value of [mergeTablesAcrossPagesInMarkdown]. - * - * Unlike [mergeTablesAcrossPagesInMarkdown], this method doesn't throw if the - * JSON field has an unexpected type. - */ - @JsonProperty("merge_tables_across_pages_in_markdown") - @ExcludeMissing - fun _mergeTablesAcrossPagesInMarkdown(): JsonField = - mergeTablesAcrossPagesInMarkdown - - /** - * Returns the raw JSON value of [model]. - * - * Unlike [model], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("model") @ExcludeMissing fun _model(): JsonField = model - - /** - * Returns the raw JSON value of [outlinedTableExtraction]. - * - * Unlike [outlinedTableExtraction], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("outlined_table_extraction") - @ExcludeMissing - fun _outlinedTableExtraction(): JsonField = outlinedTableExtraction - - /** - * Returns the raw JSON value of [outputPdfOfDocument]. - * - * Unlike [outputPdfOfDocument], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("output_pdf_of_document") - @ExcludeMissing - fun _outputPdfOfDocument(): JsonField = outputPdfOfDocument - - /** - * Returns the raw JSON value of [outputS3PathPrefix]. - * - * Unlike [outputS3PathPrefix], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("output_s3_path_prefix") - @ExcludeMissing - fun _outputS3PathPrefix(): JsonField = outputS3PathPrefix - - /** - * Returns the raw JSON value of [outputS3Region]. - * - * Unlike [outputS3Region], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("output_s3_region") - @ExcludeMissing - fun _outputS3Region(): JsonField = outputS3Region - - /** - * Returns the raw JSON value of [outputTablesAsHtml]. - * - * Unlike [outputTablesAsHtml], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("output_tables_as_HTML") - @ExcludeMissing - fun _outputTablesAsHtml(): JsonField = outputTablesAsHtml - - /** - * Returns the raw JSON value of [outputBucket]. - * - * Unlike [outputBucket], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("outputBucket") - @ExcludeMissing - fun _outputBucket(): JsonField = outputBucket - - /** - * Returns the raw JSON value of [pageErrorTolerance]. - * - * Unlike [pageErrorTolerance], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("page_error_tolerance") - @ExcludeMissing - fun _pageErrorTolerance(): JsonField = pageErrorTolerance - - /** - * Returns the raw JSON value of [pageFooterPrefix]. - * - * Unlike [pageFooterPrefix], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("page_footer_prefix") - @ExcludeMissing - fun _pageFooterPrefix(): JsonField = pageFooterPrefix - - /** - * Returns the raw JSON value of [pageFooterSuffix]. - * - * Unlike [pageFooterSuffix], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("page_footer_suffix") - @ExcludeMissing - fun _pageFooterSuffix(): JsonField = pageFooterSuffix - - /** - * Returns the raw JSON value of [pageHeaderPrefix]. - * - * Unlike [pageHeaderPrefix], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("page_header_prefix") - @ExcludeMissing - fun _pageHeaderPrefix(): JsonField = pageHeaderPrefix - - /** - * Returns the raw JSON value of [pageHeaderSuffix]. - * - * Unlike [pageHeaderSuffix], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("page_header_suffix") - @ExcludeMissing - fun _pageHeaderSuffix(): JsonField = pageHeaderSuffix - - /** - * Returns the raw JSON value of [pagePrefix]. - * - * Unlike [pagePrefix], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("page_prefix") - @ExcludeMissing - fun _pagePrefix(): JsonField = pagePrefix - - /** - * Returns the raw JSON value of [pageSeparator]. - * - * Unlike [pageSeparator], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("page_separator") - @ExcludeMissing - fun _pageSeparator(): JsonField = pageSeparator - - /** - * Returns the raw JSON value of [pageSuffix]. - * - * Unlike [pageSuffix], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("page_suffix") - @ExcludeMissing - fun _pageSuffix(): JsonField = pageSuffix - - /** - * Returns the raw JSON value of [parseMode]. - * - * Unlike [parseMode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("parse_mode") - @ExcludeMissing - fun _parseMode(): JsonField = parseMode - - /** - * Returns the raw JSON value of [parsingInstruction]. - * - * Unlike [parsingInstruction], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("parsing_instruction") - @ExcludeMissing - fun _parsingInstruction(): JsonField = parsingInstruction - - /** - * Returns the raw JSON value of [pipelineId]. - * - * Unlike [pipelineId], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("pipeline_id") - @ExcludeMissing - fun _pipelineId(): JsonField = pipelineId - - /** - * Returns the raw JSON value of [preciseBoundingBox]. - * - * Unlike [preciseBoundingBox], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("precise_bounding_box") - @ExcludeMissing - fun _preciseBoundingBox(): JsonField = preciseBoundingBox - - /** - * Returns the raw JSON value of [premiumMode]. - * - * Unlike [premiumMode], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("premium_mode") - @ExcludeMissing - fun _premiumMode(): JsonField = premiumMode - - /** - * Returns the raw JSON value of [presentationOutOfBoundsContent]. - * - * Unlike [presentationOutOfBoundsContent], this method doesn't throw if the - * JSON field has an unexpected type. - */ - @JsonProperty("presentation_out_of_bounds_content") - @ExcludeMissing - fun _presentationOutOfBoundsContent(): JsonField = - presentationOutOfBoundsContent - - /** - * Returns the raw JSON value of [presentationSkipEmbeddedData]. - * - * Unlike [presentationSkipEmbeddedData], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("presentation_skip_embedded_data") - @ExcludeMissing - fun _presentationSkipEmbeddedData(): JsonField = - presentationSkipEmbeddedData - - /** - * Returns the raw JSON value of [preserveLayoutAlignmentAcrossPages]. - * - * Unlike [preserveLayoutAlignmentAcrossPages], this method doesn't throw if the - * JSON field has an unexpected type. - */ - @JsonProperty("preserve_layout_alignment_across_pages") - @ExcludeMissing - fun _preserveLayoutAlignmentAcrossPages(): JsonField = - preserveLayoutAlignmentAcrossPages - - /** - * Returns the raw JSON value of [preserveVerySmallText]. - * - * Unlike [preserveVerySmallText], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("preserve_very_small_text") - @ExcludeMissing - fun _preserveVerySmallText(): JsonField = preserveVerySmallText - - /** - * Returns the raw JSON value of [preset]. - * - * Unlike [preset], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("preset") - @ExcludeMissing - fun _preset(): JsonField = preset - - /** - * 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 [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 [removeHiddenText]. - * - * Unlike [removeHiddenText], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("remove_hidden_text") - @ExcludeMissing - fun _removeHiddenText(): JsonField = removeHiddenText - - /** - * Returns the raw JSON value of [replaceFailedPageMode]. - * - * Unlike [replaceFailedPageMode], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("replace_failed_page_mode") - @ExcludeMissing - fun _replaceFailedPageMode(): JsonField = replaceFailedPageMode - - /** - * Returns the raw JSON value of [replaceFailedPageWithErrorMessagePrefix]. - * - * Unlike [replaceFailedPageWithErrorMessagePrefix], this method doesn't throw - * if the JSON field has an unexpected type. - */ - @JsonProperty("replace_failed_page_with_error_message_prefix") - @ExcludeMissing - fun _replaceFailedPageWithErrorMessagePrefix(): JsonField = - replaceFailedPageWithErrorMessagePrefix - - /** - * Returns the raw JSON value of [replaceFailedPageWithErrorMessageSuffix]. - * - * Unlike [replaceFailedPageWithErrorMessageSuffix], this method doesn't throw - * if the JSON field has an unexpected type. - */ - @JsonProperty("replace_failed_page_with_error_message_suffix") - @ExcludeMissing - fun _replaceFailedPageWithErrorMessageSuffix(): JsonField = - replaceFailedPageWithErrorMessageSuffix - - /** - * Returns the raw JSON value of [resourceInfo]. - * - * Unlike [resourceInfo], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("resource_info") - @ExcludeMissing - fun _resourceInfo(): JsonField = resourceInfo - - /** - * Returns the raw JSON value of [saveImages]. - * - * Unlike [saveImages], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("save_images") - @ExcludeMissing - fun _saveImages(): JsonField = saveImages - - /** - * Returns the raw JSON value of [skipDiagonalText]. - * - * Unlike [skipDiagonalText], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("skip_diagonal_text") - @ExcludeMissing - fun _skipDiagonalText(): JsonField = skipDiagonalText - - /** - * Returns the raw JSON value of [specializedChartParsingAgentic]. - * - * Unlike [specializedChartParsingAgentic], this method doesn't throw if the - * JSON field has an unexpected type. - */ - @JsonProperty("specialized_chart_parsing_agentic") - @ExcludeMissing - fun _specializedChartParsingAgentic(): JsonField = - specializedChartParsingAgentic - - /** - * Returns the raw JSON value of [specializedChartParsingEfficient]. - * - * Unlike [specializedChartParsingEfficient], this method doesn't throw if the - * JSON field has an unexpected type. - */ - @JsonProperty("specialized_chart_parsing_efficient") - @ExcludeMissing - fun _specializedChartParsingEfficient(): JsonField = - specializedChartParsingEfficient - - /** - * Returns the raw JSON value of [specializedChartParsingPlus]. - * - * Unlike [specializedChartParsingPlus], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("specialized_chart_parsing_plus") - @ExcludeMissing - fun _specializedChartParsingPlus(): JsonField = - specializedChartParsingPlus - - /** - * Returns the raw JSON value of [specializedImageParsing]. - * - * Unlike [specializedImageParsing], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("specialized_image_parsing") - @ExcludeMissing - fun _specializedImageParsing(): JsonField = specializedImageParsing - - /** - * Returns the raw JSON value of [spreadsheetExtractSubTables]. - * - * Unlike [spreadsheetExtractSubTables], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("spreadsheet_extract_sub_tables") - @ExcludeMissing - fun _spreadsheetExtractSubTables(): JsonField = - spreadsheetExtractSubTables - - /** - * Returns the raw JSON value of [spreadsheetForceFormulaComputation]. - * - * Unlike [spreadsheetForceFormulaComputation], this method doesn't throw if the - * JSON field has an unexpected type. - */ - @JsonProperty("spreadsheet_force_formula_computation") - @ExcludeMissing - fun _spreadsheetForceFormulaComputation(): JsonField = - spreadsheetForceFormulaComputation - - /** - * Returns the raw JSON value of [spreadsheetIncludeHiddenSheets]. - * - * Unlike [spreadsheetIncludeHiddenSheets], this method doesn't throw if the - * JSON field has an unexpected type. - */ - @JsonProperty("spreadsheet_include_hidden_sheets") - @ExcludeMissing - fun _spreadsheetIncludeHiddenSheets(): JsonField = - spreadsheetIncludeHiddenSheets - - /** - * Returns the raw JSON value of [strictModeBuggyFont]. - * - * Unlike [strictModeBuggyFont], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("strict_mode_buggy_font") - @ExcludeMissing - fun _strictModeBuggyFont(): JsonField = strictModeBuggyFont - - /** - * Returns the raw JSON value of [strictModeImageExtraction]. - * - * Unlike [strictModeImageExtraction], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("strict_mode_image_extraction") - @ExcludeMissing - fun _strictModeImageExtraction(): JsonField = strictModeImageExtraction - - /** - * Returns the raw JSON value of [strictModeImageOcr]. - * - * Unlike [strictModeImageOcr], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("strict_mode_image_ocr") - @ExcludeMissing - fun _strictModeImageOcr(): JsonField = strictModeImageOcr - - /** - * Returns the raw JSON value of [strictModeReconstruction]. - * - * Unlike [strictModeReconstruction], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("strict_mode_reconstruction") - @ExcludeMissing - fun _strictModeReconstruction(): JsonField = strictModeReconstruction - - /** - * Returns the raw JSON value of [structuredOutput]. - * - * Unlike [structuredOutput], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("structured_output") - @ExcludeMissing - fun _structuredOutput(): JsonField = structuredOutput - - /** - * Returns the raw JSON value of [structuredOutputJsonSchema]. - * - * Unlike [structuredOutputJsonSchema], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("structured_output_json_schema") - @ExcludeMissing - fun _structuredOutputJsonSchema(): JsonField = - structuredOutputJsonSchema - - /** - * Returns the raw JSON value of [structuredOutputJsonSchemaName]. - * - * Unlike [structuredOutputJsonSchemaName], this method doesn't throw if the - * JSON field has an unexpected type. - */ - @JsonProperty("structured_output_json_schema_name") - @ExcludeMissing - fun _structuredOutputJsonSchemaName(): JsonField = - structuredOutputJsonSchemaName - - /** - * 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 [systemPromptAppend]. - * - * Unlike [systemPromptAppend], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("system_prompt_append") - @ExcludeMissing - fun _systemPromptAppend(): JsonField = systemPromptAppend - - /** - * Returns the raw JSON value of [takeScreenshot]. - * - * Unlike [takeScreenshot], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("take_screenshot") - @ExcludeMissing - fun _takeScreenshot(): JsonField = takeScreenshot - - /** - * 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 [tier]. - * - * Unlike [tier], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("tier") @ExcludeMissing fun _tier(): JsonField = tier - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [useVendorMultimodalModel]. - * - * Unlike [useVendorMultimodalModel], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("use_vendor_multimodal_model") - @ExcludeMissing - fun _useVendorMultimodalModel(): JsonField = useVendorMultimodalModel - - /** - * Returns the raw JSON value of [userPrompt]. - * - * Unlike [userPrompt], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("user_prompt") - @ExcludeMissing - fun _userPrompt(): JsonField = userPrompt - - /** - * Returns the raw JSON value of [vendorMultimodalApiKey]. - * - * Unlike [vendorMultimodalApiKey], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("vendor_multimodal_api_key") - @ExcludeMissing - fun _vendorMultimodalApiKey(): JsonField = vendorMultimodalApiKey - - /** - * Returns the raw JSON value of [vendorMultimodalModelName]. - * - * Unlike [vendorMultimodalModelName], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("vendor_multimodal_model_name") - @ExcludeMissing - fun _vendorMultimodalModelName(): JsonField = vendorMultimodalModelName - - /** - * 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 - - /** - * Returns the raw JSON value of [webhookConfigurations]. - * - * Unlike [webhookConfigurations], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("webhook_configurations") - @ExcludeMissing - fun _webhookConfigurations(): JsonField> = - webhookConfigurations - - /** - * Returns the raw JSON value of [webhookUrl]. - * - * Unlike [webhookUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("webhook_url") - @ExcludeMissing - fun _webhookUrl(): JsonField = webhookUrl - - @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 [Parameters]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Parameters]. */ - class Builder internal constructor() { - - private var adaptiveLongTable: JsonField = JsonMissing.of() - private var aggressiveTableExtraction: JsonField = JsonMissing.of() - private var annotateLinks: JsonField = JsonMissing.of() - private var annotateRevisions: JsonField = JsonMissing.of() - private var autoMode: JsonField = JsonMissing.of() - private var autoModeConfigurationJson: JsonField = JsonMissing.of() - private var autoModeTriggerOnImageInPage: JsonField = - JsonMissing.of() - private var autoModeTriggerOnRegexpInPage: JsonField = - JsonMissing.of() - private var autoModeTriggerOnTableInPage: JsonField = - JsonMissing.of() - private var autoModeTriggerOnTextInPage: JsonField = - JsonMissing.of() - private var azureOpenAIApiVersion: JsonField = JsonMissing.of() - private var azureOpenAIDeploymentName: JsonField = JsonMissing.of() - private var azureOpenAIEndpoint: JsonField = JsonMissing.of() - private var azureOpenAIKey: JsonField = JsonMissing.of() - private var bboxBottom: JsonField = JsonMissing.of() - private var bboxLeft: JsonField = JsonMissing.of() - private var bboxRight: JsonField = JsonMissing.of() - private var bboxTop: JsonField = JsonMissing.of() - private var boundingBox: JsonField = JsonMissing.of() - private var compactMarkdownTable: JsonField = JsonMissing.of() - private var complementalFormattingInstruction: JsonField = - JsonMissing.of() - private var confidenceScoreEffort: JsonField = JsonMissing.of() - private var contentGuidelineInstruction: JsonField = - JsonMissing.of() - private var continuousMode: JsonField = JsonMissing.of() - private var customMetadata: JsonField = JsonMissing.of() - private var disableImageExtraction: JsonField = JsonMissing.of() - private var disableOcr: JsonField = JsonMissing.of() - private var disableReconstruction: JsonField = JsonMissing.of() - private var doNotCache: JsonField = JsonMissing.of() - private var doNotUnrollColumns: JsonField = JsonMissing.of() - private var enableCostOptimizer: JsonField = JsonMissing.of() - private var extractCharts: JsonField = JsonMissing.of() - private var extractLayout: JsonField = JsonMissing.of() - private var extractPrintedPageNumber: JsonField = JsonMissing.of() - private var fastMode: JsonField = JsonMissing.of() - private var formattingInstruction: JsonField = JsonMissing.of() - private var gpt4oApiKey: JsonField = JsonMissing.of() - private var gpt4oMode: JsonField = JsonMissing.of() - private var guessXlsxSheetName: JsonField = JsonMissing.of() - private var hideFooters: JsonField = JsonMissing.of() - private var hideHeaders: JsonField = JsonMissing.of() - private var highResOcr: JsonField = JsonMissing.of() - private var htmlMakeAllElementsVisible: JsonField = - JsonMissing.of() - private var htmlRemoveFixedElements: JsonField = JsonMissing.of() - private var htmlRemoveNavigationElements: JsonField = - JsonMissing.of() - private var httpProxy: JsonField = JsonMissing.of() - private var ignoreDocumentElementsForLayoutDetection: JsonField = - JsonMissing.of() - private var imagesToSave: JsonField>? = null - private var inlineImagesInMarkdown: JsonField = JsonMissing.of() - private var inputS3Path: JsonField = JsonMissing.of() - private var inputS3Region: JsonField = JsonMissing.of() - private var inputUrl: JsonField = JsonMissing.of() - private var internalIsScreenshotJob: JsonField = JsonMissing.of() - private var invalidateCache: JsonField = JsonMissing.of() - private var isFormattingInstruction: JsonField = JsonMissing.of() - private var jobTimeoutExtraTimePerPageInSeconds: JsonField = - JsonMissing.of() - private var jobTimeoutInSeconds: JsonField = JsonMissing.of() - private var keepPageSeparatorWhenMergingTables: JsonField = - JsonMissing.of() - private var lang: JsonField = JsonMissing.of() - private var languages: JsonField>? = null - private var layoutAware: JsonField = JsonMissing.of() - private var lineLevelBoundingBox: JsonField = JsonMissing.of() - private var markdownTableMultilineHeaderSeparator: JsonField = - JsonMissing.of() - private var maxPages: JsonField = JsonMissing.of() - private var maxPagesEnforced: JsonField = JsonMissing.of() - private var mergeTablesAcrossPagesInMarkdown: JsonField = - JsonMissing.of() - private var model: JsonField = JsonMissing.of() - private var outlinedTableExtraction: JsonField = JsonMissing.of() - private var outputPdfOfDocument: JsonField = JsonMissing.of() - private var outputS3PathPrefix: JsonField = JsonMissing.of() - private var outputS3Region: JsonField = JsonMissing.of() - private var outputTablesAsHtml: JsonField = JsonMissing.of() - private var outputBucket: JsonField = JsonMissing.of() - private var pageErrorTolerance: JsonField = JsonMissing.of() - private var pageFooterPrefix: JsonField = JsonMissing.of() - private var pageFooterSuffix: JsonField = JsonMissing.of() - private var pageHeaderPrefix: JsonField = JsonMissing.of() - private var pageHeaderSuffix: JsonField = JsonMissing.of() - private var pagePrefix: JsonField = JsonMissing.of() - private var pageSeparator: JsonField = JsonMissing.of() - private var pageSuffix: JsonField = JsonMissing.of() - private var parseMode: JsonField = JsonMissing.of() - private var parsingInstruction: JsonField = JsonMissing.of() - private var pipelineId: JsonField = JsonMissing.of() - private var preciseBoundingBox: JsonField = JsonMissing.of() - private var premiumMode: JsonField = JsonMissing.of() - private var presentationOutOfBoundsContent: JsonField = - JsonMissing.of() - private var presentationSkipEmbeddedData: JsonField = - JsonMissing.of() - private var preserveLayoutAlignmentAcrossPages: JsonField = - JsonMissing.of() - private var preserveVerySmallText: JsonField = JsonMissing.of() - private var preset: JsonField = JsonMissing.of() - private var priority: JsonField = JsonMissing.of() - private var projectId: JsonField = JsonMissing.of() - private var removeHiddenText: JsonField = JsonMissing.of() - private var replaceFailedPageMode: JsonField = - JsonMissing.of() - private var replaceFailedPageWithErrorMessagePrefix: JsonField = - JsonMissing.of() - private var replaceFailedPageWithErrorMessageSuffix: JsonField = - JsonMissing.of() - private var resourceInfo: JsonField = JsonMissing.of() - private var saveImages: JsonField = JsonMissing.of() - private var skipDiagonalText: JsonField = JsonMissing.of() - private var specializedChartParsingAgentic: JsonField = - JsonMissing.of() - private var specializedChartParsingEfficient: JsonField = - JsonMissing.of() - private var specializedChartParsingPlus: JsonField = - JsonMissing.of() - private var specializedImageParsing: JsonField = JsonMissing.of() - private var spreadsheetExtractSubTables: JsonField = - JsonMissing.of() - private var spreadsheetForceFormulaComputation: JsonField = - JsonMissing.of() - private var spreadsheetIncludeHiddenSheets: JsonField = - JsonMissing.of() - private var strictModeBuggyFont: JsonField = JsonMissing.of() - private var strictModeImageExtraction: JsonField = JsonMissing.of() - private var strictModeImageOcr: JsonField = JsonMissing.of() - private var strictModeReconstruction: JsonField = JsonMissing.of() - private var structuredOutput: JsonField = JsonMissing.of() - private var structuredOutputJsonSchema: JsonField = JsonMissing.of() - private var structuredOutputJsonSchemaName: JsonField = - JsonMissing.of() - private var systemPrompt: JsonField = JsonMissing.of() - private var systemPromptAppend: JsonField = JsonMissing.of() - private var takeScreenshot: JsonField = JsonMissing.of() - private var targetPages: JsonField = JsonMissing.of() - private var tier: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var useVendorMultimodalModel: JsonField = JsonMissing.of() - private var userPrompt: JsonField = JsonMissing.of() - private var vendorMultimodalApiKey: JsonField = JsonMissing.of() - private var vendorMultimodalModelName: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() - private var webhookConfigurations: - JsonField>? = - null - private var webhookUrl: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(parameters: Parameters) = apply { - adaptiveLongTable = parameters.adaptiveLongTable - aggressiveTableExtraction = parameters.aggressiveTableExtraction - annotateLinks = parameters.annotateLinks - annotateRevisions = parameters.annotateRevisions - autoMode = parameters.autoMode - autoModeConfigurationJson = parameters.autoModeConfigurationJson - autoModeTriggerOnImageInPage = parameters.autoModeTriggerOnImageInPage - autoModeTriggerOnRegexpInPage = parameters.autoModeTriggerOnRegexpInPage - autoModeTriggerOnTableInPage = parameters.autoModeTriggerOnTableInPage - autoModeTriggerOnTextInPage = parameters.autoModeTriggerOnTextInPage - azureOpenAIApiVersion = parameters.azureOpenAIApiVersion - azureOpenAIDeploymentName = parameters.azureOpenAIDeploymentName - azureOpenAIEndpoint = parameters.azureOpenAIEndpoint - azureOpenAIKey = parameters.azureOpenAIKey - bboxBottom = parameters.bboxBottom - bboxLeft = parameters.bboxLeft - bboxRight = parameters.bboxRight - bboxTop = parameters.bboxTop - boundingBox = parameters.boundingBox - compactMarkdownTable = parameters.compactMarkdownTable - complementalFormattingInstruction = - parameters.complementalFormattingInstruction - confidenceScoreEffort = parameters.confidenceScoreEffort - contentGuidelineInstruction = parameters.contentGuidelineInstruction - continuousMode = parameters.continuousMode - customMetadata = parameters.customMetadata - disableImageExtraction = parameters.disableImageExtraction - disableOcr = parameters.disableOcr - disableReconstruction = parameters.disableReconstruction - doNotCache = parameters.doNotCache - doNotUnrollColumns = parameters.doNotUnrollColumns - enableCostOptimizer = parameters.enableCostOptimizer - extractCharts = parameters.extractCharts - extractLayout = parameters.extractLayout - extractPrintedPageNumber = parameters.extractPrintedPageNumber - fastMode = parameters.fastMode - formattingInstruction = parameters.formattingInstruction - gpt4oApiKey = parameters.gpt4oApiKey - gpt4oMode = parameters.gpt4oMode - guessXlsxSheetName = parameters.guessXlsxSheetName - hideFooters = parameters.hideFooters - hideHeaders = parameters.hideHeaders - highResOcr = parameters.highResOcr - htmlMakeAllElementsVisible = parameters.htmlMakeAllElementsVisible - htmlRemoveFixedElements = parameters.htmlRemoveFixedElements - htmlRemoveNavigationElements = parameters.htmlRemoveNavigationElements - httpProxy = parameters.httpProxy - ignoreDocumentElementsForLayoutDetection = - parameters.ignoreDocumentElementsForLayoutDetection - imagesToSave = parameters.imagesToSave.map { it.toMutableList() } - inlineImagesInMarkdown = parameters.inlineImagesInMarkdown - inputS3Path = parameters.inputS3Path - inputS3Region = parameters.inputS3Region - inputUrl = parameters.inputUrl - internalIsScreenshotJob = parameters.internalIsScreenshotJob - invalidateCache = parameters.invalidateCache - isFormattingInstruction = parameters.isFormattingInstruction - jobTimeoutExtraTimePerPageInSeconds = - parameters.jobTimeoutExtraTimePerPageInSeconds - jobTimeoutInSeconds = parameters.jobTimeoutInSeconds - keepPageSeparatorWhenMergingTables = - parameters.keepPageSeparatorWhenMergingTables - lang = parameters.lang - languages = parameters.languages.map { it.toMutableList() } - layoutAware = parameters.layoutAware - lineLevelBoundingBox = parameters.lineLevelBoundingBox - markdownTableMultilineHeaderSeparator = - parameters.markdownTableMultilineHeaderSeparator - maxPages = parameters.maxPages - maxPagesEnforced = parameters.maxPagesEnforced - mergeTablesAcrossPagesInMarkdown = - parameters.mergeTablesAcrossPagesInMarkdown - model = parameters.model - outlinedTableExtraction = parameters.outlinedTableExtraction - outputPdfOfDocument = parameters.outputPdfOfDocument - outputS3PathPrefix = parameters.outputS3PathPrefix - outputS3Region = parameters.outputS3Region - outputTablesAsHtml = parameters.outputTablesAsHtml - outputBucket = parameters.outputBucket - pageErrorTolerance = parameters.pageErrorTolerance - pageFooterPrefix = parameters.pageFooterPrefix - pageFooterSuffix = parameters.pageFooterSuffix - pageHeaderPrefix = parameters.pageHeaderPrefix - pageHeaderSuffix = parameters.pageHeaderSuffix - pagePrefix = parameters.pagePrefix - pageSeparator = parameters.pageSeparator - pageSuffix = parameters.pageSuffix - parseMode = parameters.parseMode - parsingInstruction = parameters.parsingInstruction - pipelineId = parameters.pipelineId - preciseBoundingBox = parameters.preciseBoundingBox - premiumMode = parameters.premiumMode - presentationOutOfBoundsContent = - parameters.presentationOutOfBoundsContent - presentationSkipEmbeddedData = parameters.presentationSkipEmbeddedData - preserveLayoutAlignmentAcrossPages = - parameters.preserveLayoutAlignmentAcrossPages - preserveVerySmallText = parameters.preserveVerySmallText - preset = parameters.preset - priority = parameters.priority - projectId = parameters.projectId - removeHiddenText = parameters.removeHiddenText - replaceFailedPageMode = parameters.replaceFailedPageMode - replaceFailedPageWithErrorMessagePrefix = - parameters.replaceFailedPageWithErrorMessagePrefix - replaceFailedPageWithErrorMessageSuffix = - parameters.replaceFailedPageWithErrorMessageSuffix - resourceInfo = parameters.resourceInfo - saveImages = parameters.saveImages - skipDiagonalText = parameters.skipDiagonalText - specializedChartParsingAgentic = - parameters.specializedChartParsingAgentic - specializedChartParsingEfficient = - parameters.specializedChartParsingEfficient - specializedChartParsingPlus = parameters.specializedChartParsingPlus - specializedImageParsing = parameters.specializedImageParsing - spreadsheetExtractSubTables = parameters.spreadsheetExtractSubTables - spreadsheetForceFormulaComputation = - parameters.spreadsheetForceFormulaComputation - spreadsheetIncludeHiddenSheets = - parameters.spreadsheetIncludeHiddenSheets - strictModeBuggyFont = parameters.strictModeBuggyFont - strictModeImageExtraction = parameters.strictModeImageExtraction - strictModeImageOcr = parameters.strictModeImageOcr - strictModeReconstruction = parameters.strictModeReconstruction - structuredOutput = parameters.structuredOutput - structuredOutputJsonSchema = parameters.structuredOutputJsonSchema - structuredOutputJsonSchemaName = - parameters.structuredOutputJsonSchemaName - systemPrompt = parameters.systemPrompt - systemPromptAppend = parameters.systemPromptAppend - takeScreenshot = parameters.takeScreenshot - targetPages = parameters.targetPages - tier = parameters.tier - type = parameters.type - useVendorMultimodalModel = parameters.useVendorMultimodalModel - userPrompt = parameters.userPrompt - vendorMultimodalApiKey = parameters.vendorMultimodalApiKey - vendorMultimodalModelName = parameters.vendorMultimodalModelName - version = parameters.version - webhookConfigurations = - parameters.webhookConfigurations.map { it.toMutableList() } - webhookUrl = parameters.webhookUrl - additionalProperties = parameters.additionalProperties.toMutableMap() - } - - fun adaptiveLongTable(adaptiveLongTable: Boolean?) = - adaptiveLongTable(JsonField.ofNullable(adaptiveLongTable)) - - /** - * Alias for [Builder.adaptiveLongTable]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun adaptiveLongTable(adaptiveLongTable: Boolean) = - adaptiveLongTable(adaptiveLongTable as Boolean?) - - /** - * Alias for calling [Builder.adaptiveLongTable] with - * `adaptiveLongTable.orElse(null)`. - */ - fun adaptiveLongTable(adaptiveLongTable: Optional) = - adaptiveLongTable(adaptiveLongTable.getOrNull()) - - /** - * Sets [Builder.adaptiveLongTable] to an arbitrary JSON value. - * - * You should usually call [Builder.adaptiveLongTable] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun adaptiveLongTable(adaptiveLongTable: JsonField) = apply { - this.adaptiveLongTable = adaptiveLongTable - } - - fun aggressiveTableExtraction(aggressiveTableExtraction: Boolean?) = - aggressiveTableExtraction( - JsonField.ofNullable(aggressiveTableExtraction) - ) - - /** - * Alias for [Builder.aggressiveTableExtraction]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun aggressiveTableExtraction(aggressiveTableExtraction: Boolean) = - aggressiveTableExtraction(aggressiveTableExtraction as Boolean?) - - /** - * Alias for calling [Builder.aggressiveTableExtraction] with - * `aggressiveTableExtraction.orElse(null)`. - */ - fun aggressiveTableExtraction( - aggressiveTableExtraction: Optional - ) = aggressiveTableExtraction(aggressiveTableExtraction.getOrNull()) - - /** - * Sets [Builder.aggressiveTableExtraction] to an arbitrary JSON value. - * - * You should usually call [Builder.aggressiveTableExtraction] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun aggressiveTableExtraction( - aggressiveTableExtraction: JsonField - ) = apply { this.aggressiveTableExtraction = aggressiveTableExtraction } - - fun annotateLinks(annotateLinks: Boolean?) = - annotateLinks(JsonField.ofNullable(annotateLinks)) - - /** - * Alias for [Builder.annotateLinks]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun annotateLinks(annotateLinks: Boolean) = - annotateLinks(annotateLinks as Boolean?) - - /** - * Alias for calling [Builder.annotateLinks] with - * `annotateLinks.orElse(null)`. - */ - fun annotateLinks(annotateLinks: Optional) = - annotateLinks(annotateLinks.getOrNull()) - - /** - * Sets [Builder.annotateLinks] to an arbitrary JSON value. - * - * You should usually call [Builder.annotateLinks] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun annotateLinks(annotateLinks: JsonField) = apply { - this.annotateLinks = annotateLinks - } - - fun annotateRevisions(annotateRevisions: Boolean?) = - annotateRevisions(JsonField.ofNullable(annotateRevisions)) - - /** - * Alias for [Builder.annotateRevisions]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun annotateRevisions(annotateRevisions: Boolean) = - annotateRevisions(annotateRevisions as Boolean?) - - /** - * Alias for calling [Builder.annotateRevisions] with - * `annotateRevisions.orElse(null)`. - */ - fun annotateRevisions(annotateRevisions: Optional) = - annotateRevisions(annotateRevisions.getOrNull()) - - /** - * Sets [Builder.annotateRevisions] to an arbitrary JSON value. - * - * You should usually call [Builder.annotateRevisions] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun annotateRevisions(annotateRevisions: JsonField) = apply { - this.annotateRevisions = annotateRevisions - } - - fun autoMode(autoMode: Boolean?) = autoMode(JsonField.ofNullable(autoMode)) - - /** - * Alias for [Builder.autoMode]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun autoMode(autoMode: Boolean) = autoMode(autoMode as Boolean?) - - /** Alias for calling [Builder.autoMode] with `autoMode.orElse(null)`. */ - fun autoMode(autoMode: Optional) = autoMode(autoMode.getOrNull()) - - /** - * Sets [Builder.autoMode] to an arbitrary JSON value. - * - * You should usually call [Builder.autoMode] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun autoMode(autoMode: JsonField) = apply { - this.autoMode = autoMode - } - - fun autoModeConfigurationJson(autoModeConfigurationJson: String?) = - autoModeConfigurationJson( - JsonField.ofNullable(autoModeConfigurationJson) - ) - - /** - * Alias for calling [Builder.autoModeConfigurationJson] with - * `autoModeConfigurationJson.orElse(null)`. - */ - fun autoModeConfigurationJson(autoModeConfigurationJson: Optional) = - autoModeConfigurationJson(autoModeConfigurationJson.getOrNull()) - - /** - * Sets [Builder.autoModeConfigurationJson] to an arbitrary JSON value. - * - * You should usually call [Builder.autoModeConfigurationJson] with a - * well-typed [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun autoModeConfigurationJson( - autoModeConfigurationJson: JsonField - ) = apply { this.autoModeConfigurationJson = autoModeConfigurationJson } - - fun autoModeTriggerOnImageInPage(autoModeTriggerOnImageInPage: Boolean?) = - autoModeTriggerOnImageInPage( - JsonField.ofNullable(autoModeTriggerOnImageInPage) - ) - - /** - * Alias for [Builder.autoModeTriggerOnImageInPage]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun autoModeTriggerOnImageInPage(autoModeTriggerOnImageInPage: Boolean) = - autoModeTriggerOnImageInPage(autoModeTriggerOnImageInPage as Boolean?) - - /** - * Alias for calling [Builder.autoModeTriggerOnImageInPage] with - * `autoModeTriggerOnImageInPage.orElse(null)`. - */ - fun autoModeTriggerOnImageInPage( - autoModeTriggerOnImageInPage: Optional - ) = autoModeTriggerOnImageInPage(autoModeTriggerOnImageInPage.getOrNull()) - - /** - * Sets [Builder.autoModeTriggerOnImageInPage] to an arbitrary JSON value. - * - * You should usually call [Builder.autoModeTriggerOnImageInPage] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun autoModeTriggerOnImageInPage( - autoModeTriggerOnImageInPage: JsonField - ) = apply { - this.autoModeTriggerOnImageInPage = autoModeTriggerOnImageInPage - } - - fun autoModeTriggerOnRegexpInPage(autoModeTriggerOnRegexpInPage: String?) = - autoModeTriggerOnRegexpInPage( - JsonField.ofNullable(autoModeTriggerOnRegexpInPage) - ) - - /** - * Alias for calling [Builder.autoModeTriggerOnRegexpInPage] with - * `autoModeTriggerOnRegexpInPage.orElse(null)`. - */ - fun autoModeTriggerOnRegexpInPage( - autoModeTriggerOnRegexpInPage: Optional - ) = autoModeTriggerOnRegexpInPage(autoModeTriggerOnRegexpInPage.getOrNull()) - - /** - * Sets [Builder.autoModeTriggerOnRegexpInPage] to an arbitrary JSON value. - * - * You should usually call [Builder.autoModeTriggerOnRegexpInPage] with a - * well-typed [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun autoModeTriggerOnRegexpInPage( - autoModeTriggerOnRegexpInPage: JsonField - ) = apply { - this.autoModeTriggerOnRegexpInPage = autoModeTriggerOnRegexpInPage - } - - fun autoModeTriggerOnTableInPage(autoModeTriggerOnTableInPage: Boolean?) = - autoModeTriggerOnTableInPage( - JsonField.ofNullable(autoModeTriggerOnTableInPage) - ) - - /** - * Alias for [Builder.autoModeTriggerOnTableInPage]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun autoModeTriggerOnTableInPage(autoModeTriggerOnTableInPage: Boolean) = - autoModeTriggerOnTableInPage(autoModeTriggerOnTableInPage as Boolean?) - - /** - * Alias for calling [Builder.autoModeTriggerOnTableInPage] with - * `autoModeTriggerOnTableInPage.orElse(null)`. - */ - fun autoModeTriggerOnTableInPage( - autoModeTriggerOnTableInPage: Optional - ) = autoModeTriggerOnTableInPage(autoModeTriggerOnTableInPage.getOrNull()) - - /** - * Sets [Builder.autoModeTriggerOnTableInPage] to an arbitrary JSON value. - * - * You should usually call [Builder.autoModeTriggerOnTableInPage] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun autoModeTriggerOnTableInPage( - autoModeTriggerOnTableInPage: JsonField - ) = apply { - this.autoModeTriggerOnTableInPage = autoModeTriggerOnTableInPage - } - - fun autoModeTriggerOnTextInPage(autoModeTriggerOnTextInPage: String?) = - autoModeTriggerOnTextInPage( - JsonField.ofNullable(autoModeTriggerOnTextInPage) - ) - - /** - * Alias for calling [Builder.autoModeTriggerOnTextInPage] with - * `autoModeTriggerOnTextInPage.orElse(null)`. - */ - fun autoModeTriggerOnTextInPage( - autoModeTriggerOnTextInPage: Optional - ) = autoModeTriggerOnTextInPage(autoModeTriggerOnTextInPage.getOrNull()) - - /** - * Sets [Builder.autoModeTriggerOnTextInPage] to an arbitrary JSON value. - * - * You should usually call [Builder.autoModeTriggerOnTextInPage] with a - * well-typed [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun autoModeTriggerOnTextInPage( - autoModeTriggerOnTextInPage: JsonField - ) = apply { this.autoModeTriggerOnTextInPage = autoModeTriggerOnTextInPage } - - fun azureOpenAIApiVersion(azureOpenAIApiVersion: String?) = - azureOpenAIApiVersion(JsonField.ofNullable(azureOpenAIApiVersion)) - - /** - * Alias for calling [Builder.azureOpenAIApiVersion] with - * `azureOpenAIApiVersion.orElse(null)`. - */ - fun azureOpenAIApiVersion(azureOpenAIApiVersion: Optional) = - azureOpenAIApiVersion(azureOpenAIApiVersion.getOrNull()) - - /** - * Sets [Builder.azureOpenAIApiVersion] to an arbitrary JSON value. - * - * You should usually call [Builder.azureOpenAIApiVersion] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun azureOpenAIApiVersion(azureOpenAIApiVersion: JsonField) = - apply { - this.azureOpenAIApiVersion = azureOpenAIApiVersion - } - - fun azureOpenAIDeploymentName(azureOpenAIDeploymentName: String?) = - azureOpenAIDeploymentName( - JsonField.ofNullable(azureOpenAIDeploymentName) - ) - - /** - * Alias for calling [Builder.azureOpenAIDeploymentName] with - * `azureOpenAIDeploymentName.orElse(null)`. - */ - fun azureOpenAIDeploymentName(azureOpenAIDeploymentName: Optional) = - azureOpenAIDeploymentName(azureOpenAIDeploymentName.getOrNull()) - - /** - * Sets [Builder.azureOpenAIDeploymentName] to an arbitrary JSON value. - * - * You should usually call [Builder.azureOpenAIDeploymentName] with a - * well-typed [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun azureOpenAIDeploymentName( - azureOpenAIDeploymentName: JsonField - ) = apply { this.azureOpenAIDeploymentName = azureOpenAIDeploymentName } - - fun azureOpenAIEndpoint(azureOpenAIEndpoint: String?) = - azureOpenAIEndpoint(JsonField.ofNullable(azureOpenAIEndpoint)) - - /** - * Alias for calling [Builder.azureOpenAIEndpoint] with - * `azureOpenAIEndpoint.orElse(null)`. - */ - fun azureOpenAIEndpoint(azureOpenAIEndpoint: Optional) = - azureOpenAIEndpoint(azureOpenAIEndpoint.getOrNull()) - - /** - * Sets [Builder.azureOpenAIEndpoint] to an arbitrary JSON value. - * - * You should usually call [Builder.azureOpenAIEndpoint] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun azureOpenAIEndpoint(azureOpenAIEndpoint: JsonField) = apply { - this.azureOpenAIEndpoint = azureOpenAIEndpoint - } - - fun azureOpenAIKey(azureOpenAIKey: String?) = - azureOpenAIKey(JsonField.ofNullable(azureOpenAIKey)) - - /** - * Alias for calling [Builder.azureOpenAIKey] with - * `azureOpenAIKey.orElse(null)`. - */ - fun azureOpenAIKey(azureOpenAIKey: Optional) = - azureOpenAIKey(azureOpenAIKey.getOrNull()) - - /** - * Sets [Builder.azureOpenAIKey] to an arbitrary JSON value. - * - * You should usually call [Builder.azureOpenAIKey] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun azureOpenAIKey(azureOpenAIKey: JsonField) = apply { - this.azureOpenAIKey = azureOpenAIKey - } - - fun bboxBottom(bboxBottom: Double?) = - bboxBottom(JsonField.ofNullable(bboxBottom)) - - /** - * Alias for [Builder.bboxBottom]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun bboxBottom(bboxBottom: Double) = bboxBottom(bboxBottom as Double?) - - /** - * Alias for calling [Builder.bboxBottom] with `bboxBottom.orElse(null)`. - */ - fun bboxBottom(bboxBottom: Optional) = - bboxBottom(bboxBottom.getOrNull()) - - /** - * Sets [Builder.bboxBottom] to an arbitrary JSON value. - * - * You should usually call [Builder.bboxBottom] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun bboxBottom(bboxBottom: JsonField) = apply { - this.bboxBottom = bboxBottom - } - - fun bboxLeft(bboxLeft: Double?) = bboxLeft(JsonField.ofNullable(bboxLeft)) - - /** - * Alias for [Builder.bboxLeft]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun bboxLeft(bboxLeft: Double) = bboxLeft(bboxLeft as Double?) - - /** Alias for calling [Builder.bboxLeft] with `bboxLeft.orElse(null)`. */ - fun bboxLeft(bboxLeft: Optional) = bboxLeft(bboxLeft.getOrNull()) - - /** - * Sets [Builder.bboxLeft] to an arbitrary JSON value. - * - * You should usually call [Builder.bboxLeft] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun bboxLeft(bboxLeft: JsonField) = apply { - this.bboxLeft = bboxLeft - } - - fun bboxRight(bboxRight: Double?) = - bboxRight(JsonField.ofNullable(bboxRight)) - - /** - * Alias for [Builder.bboxRight]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun bboxRight(bboxRight: Double) = bboxRight(bboxRight as Double?) - - /** Alias for calling [Builder.bboxRight] with `bboxRight.orElse(null)`. */ - fun bboxRight(bboxRight: Optional) = - bboxRight(bboxRight.getOrNull()) - - /** - * Sets [Builder.bboxRight] to an arbitrary JSON value. - * - * You should usually call [Builder.bboxRight] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun bboxRight(bboxRight: JsonField) = apply { - this.bboxRight = bboxRight - } - - fun bboxTop(bboxTop: Double?) = bboxTop(JsonField.ofNullable(bboxTop)) - - /** - * Alias for [Builder.bboxTop]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun bboxTop(bboxTop: Double) = bboxTop(bboxTop as Double?) - - /** Alias for calling [Builder.bboxTop] with `bboxTop.orElse(null)`. */ - fun bboxTop(bboxTop: Optional) = bboxTop(bboxTop.getOrNull()) - - /** - * Sets [Builder.bboxTop] to an arbitrary JSON value. - * - * You should usually call [Builder.bboxTop] with a well-typed [Double] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun bboxTop(bboxTop: JsonField) = apply { this.bboxTop = bboxTop } - - fun boundingBox(boundingBox: String?) = - boundingBox(JsonField.ofNullable(boundingBox)) - - /** - * Alias for calling [Builder.boundingBox] with `boundingBox.orElse(null)`. - */ - fun boundingBox(boundingBox: Optional) = - boundingBox(boundingBox.getOrNull()) - - /** - * Sets [Builder.boundingBox] to an arbitrary JSON value. - * - * You should usually call [Builder.boundingBox] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun boundingBox(boundingBox: JsonField) = apply { - this.boundingBox = boundingBox - } - - fun compactMarkdownTable(compactMarkdownTable: Boolean?) = - compactMarkdownTable(JsonField.ofNullable(compactMarkdownTable)) - - /** - * Alias for [Builder.compactMarkdownTable]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun compactMarkdownTable(compactMarkdownTable: Boolean) = - compactMarkdownTable(compactMarkdownTable as Boolean?) - - /** - * Alias for calling [Builder.compactMarkdownTable] with - * `compactMarkdownTable.orElse(null)`. - */ - fun compactMarkdownTable(compactMarkdownTable: Optional) = - compactMarkdownTable(compactMarkdownTable.getOrNull()) - - /** - * Sets [Builder.compactMarkdownTable] to an arbitrary JSON value. - * - * You should usually call [Builder.compactMarkdownTable] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun compactMarkdownTable(compactMarkdownTable: JsonField) = apply { - this.compactMarkdownTable = compactMarkdownTable - } - - fun complementalFormattingInstruction( - complementalFormattingInstruction: String? - ) = - complementalFormattingInstruction( - JsonField.ofNullable(complementalFormattingInstruction) - ) - - /** - * Alias for calling [Builder.complementalFormattingInstruction] with - * `complementalFormattingInstruction.orElse(null)`. - */ - fun complementalFormattingInstruction( - complementalFormattingInstruction: Optional - ) = - complementalFormattingInstruction( - complementalFormattingInstruction.getOrNull() - ) - - /** - * Sets [Builder.complementalFormattingInstruction] to an arbitrary JSON - * value. - * - * You should usually call [Builder.complementalFormattingInstruction] with - * a well-typed [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun complementalFormattingInstruction( - complementalFormattingInstruction: JsonField - ) = apply { - this.complementalFormattingInstruction = - complementalFormattingInstruction - } - - fun confidenceScoreEffort(confidenceScoreEffort: String?) = - confidenceScoreEffort(JsonField.ofNullable(confidenceScoreEffort)) - - /** - * Alias for calling [Builder.confidenceScoreEffort] with - * `confidenceScoreEffort.orElse(null)`. - */ - fun confidenceScoreEffort(confidenceScoreEffort: Optional) = - confidenceScoreEffort(confidenceScoreEffort.getOrNull()) - - /** - * Sets [Builder.confidenceScoreEffort] to an arbitrary JSON value. - * - * You should usually call [Builder.confidenceScoreEffort] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun confidenceScoreEffort(confidenceScoreEffort: JsonField) = - apply { - this.confidenceScoreEffort = confidenceScoreEffort - } - - fun contentGuidelineInstruction(contentGuidelineInstruction: String?) = - contentGuidelineInstruction( - JsonField.ofNullable(contentGuidelineInstruction) - ) - - /** - * Alias for calling [Builder.contentGuidelineInstruction] with - * `contentGuidelineInstruction.orElse(null)`. - */ - fun contentGuidelineInstruction( - contentGuidelineInstruction: Optional - ) = contentGuidelineInstruction(contentGuidelineInstruction.getOrNull()) - - /** - * Sets [Builder.contentGuidelineInstruction] to an arbitrary JSON value. - * - * You should usually call [Builder.contentGuidelineInstruction] with a - * well-typed [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun contentGuidelineInstruction( - contentGuidelineInstruction: JsonField - ) = apply { this.contentGuidelineInstruction = contentGuidelineInstruction } - - fun continuousMode(continuousMode: Boolean?) = - continuousMode(JsonField.ofNullable(continuousMode)) - - /** - * Alias for [Builder.continuousMode]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun continuousMode(continuousMode: Boolean) = - continuousMode(continuousMode as Boolean?) - - /** - * Alias for calling [Builder.continuousMode] with - * `continuousMode.orElse(null)`. - */ - fun continuousMode(continuousMode: Optional) = - continuousMode(continuousMode.getOrNull()) - - /** - * Sets [Builder.continuousMode] to an arbitrary JSON value. - * - * You should usually call [Builder.continuousMode] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun continuousMode(continuousMode: JsonField) = apply { - this.continuousMode = continuousMode - } - - /** The custom metadata to attach to the documents. */ - fun customMetadata(customMetadata: CustomMetadata?) = - customMetadata(JsonField.ofNullable(customMetadata)) - - /** - * Alias for calling [Builder.customMetadata] with - * `customMetadata.orElse(null)`. - */ - fun customMetadata(customMetadata: Optional) = - customMetadata(customMetadata.getOrNull()) - - /** - * Sets [Builder.customMetadata] to an arbitrary JSON value. - * - * You should usually call [Builder.customMetadata] with a well-typed - * [CustomMetadata] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun customMetadata(customMetadata: JsonField) = apply { - this.customMetadata = customMetadata - } - - fun disableImageExtraction(disableImageExtraction: Boolean?) = - disableImageExtraction(JsonField.ofNullable(disableImageExtraction)) - - /** - * Alias for [Builder.disableImageExtraction]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun disableImageExtraction(disableImageExtraction: Boolean) = - disableImageExtraction(disableImageExtraction as Boolean?) - - /** - * Alias for calling [Builder.disableImageExtraction] with - * `disableImageExtraction.orElse(null)`. - */ - fun disableImageExtraction(disableImageExtraction: Optional) = - disableImageExtraction(disableImageExtraction.getOrNull()) - - /** - * Sets [Builder.disableImageExtraction] to an arbitrary JSON value. - * - * You should usually call [Builder.disableImageExtraction] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun disableImageExtraction(disableImageExtraction: JsonField) = - apply { - this.disableImageExtraction = disableImageExtraction - } - - fun disableOcr(disableOcr: Boolean?) = - disableOcr(JsonField.ofNullable(disableOcr)) - - /** - * Alias for [Builder.disableOcr]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun disableOcr(disableOcr: Boolean) = disableOcr(disableOcr as Boolean?) - - /** - * Alias for calling [Builder.disableOcr] with `disableOcr.orElse(null)`. - */ - fun disableOcr(disableOcr: Optional) = - disableOcr(disableOcr.getOrNull()) - - /** - * Sets [Builder.disableOcr] to an arbitrary JSON value. - * - * You should usually call [Builder.disableOcr] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun disableOcr(disableOcr: JsonField) = apply { - this.disableOcr = disableOcr - } - - fun disableReconstruction(disableReconstruction: Boolean?) = - disableReconstruction(JsonField.ofNullable(disableReconstruction)) - - /** - * Alias for [Builder.disableReconstruction]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun disableReconstruction(disableReconstruction: Boolean) = - disableReconstruction(disableReconstruction as Boolean?) - - /** - * Alias for calling [Builder.disableReconstruction] with - * `disableReconstruction.orElse(null)`. - */ - fun disableReconstruction(disableReconstruction: Optional) = - disableReconstruction(disableReconstruction.getOrNull()) - - /** - * Sets [Builder.disableReconstruction] to an arbitrary JSON value. - * - * You should usually call [Builder.disableReconstruction] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun disableReconstruction(disableReconstruction: JsonField) = - apply { - this.disableReconstruction = disableReconstruction - } - - fun doNotCache(doNotCache: Boolean?) = - doNotCache(JsonField.ofNullable(doNotCache)) - - /** - * Alias for [Builder.doNotCache]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun doNotCache(doNotCache: Boolean) = doNotCache(doNotCache as Boolean?) - - /** - * Alias for calling [Builder.doNotCache] with `doNotCache.orElse(null)`. - */ - fun doNotCache(doNotCache: Optional) = - doNotCache(doNotCache.getOrNull()) - - /** - * Sets [Builder.doNotCache] to an arbitrary JSON value. - * - * You should usually call [Builder.doNotCache] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun doNotCache(doNotCache: JsonField) = apply { - this.doNotCache = doNotCache - } - - fun doNotUnrollColumns(doNotUnrollColumns: Boolean?) = - doNotUnrollColumns(JsonField.ofNullable(doNotUnrollColumns)) - - /** - * Alias for [Builder.doNotUnrollColumns]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun doNotUnrollColumns(doNotUnrollColumns: Boolean) = - doNotUnrollColumns(doNotUnrollColumns as Boolean?) - - /** - * Alias for calling [Builder.doNotUnrollColumns] with - * `doNotUnrollColumns.orElse(null)`. - */ - fun doNotUnrollColumns(doNotUnrollColumns: Optional) = - doNotUnrollColumns(doNotUnrollColumns.getOrNull()) - - /** - * Sets [Builder.doNotUnrollColumns] to an arbitrary JSON value. - * - * You should usually call [Builder.doNotUnrollColumns] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun doNotUnrollColumns(doNotUnrollColumns: JsonField) = apply { - this.doNotUnrollColumns = doNotUnrollColumns - } - - fun enableCostOptimizer(enableCostOptimizer: Boolean?) = - enableCostOptimizer(JsonField.ofNullable(enableCostOptimizer)) - - /** - * Alias for [Builder.enableCostOptimizer]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun enableCostOptimizer(enableCostOptimizer: Boolean) = - enableCostOptimizer(enableCostOptimizer as Boolean?) - - /** - * Alias for calling [Builder.enableCostOptimizer] with - * `enableCostOptimizer.orElse(null)`. - */ - fun enableCostOptimizer(enableCostOptimizer: Optional) = - enableCostOptimizer(enableCostOptimizer.getOrNull()) - - /** - * Sets [Builder.enableCostOptimizer] to an arbitrary JSON value. - * - * You should usually call [Builder.enableCostOptimizer] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun enableCostOptimizer(enableCostOptimizer: JsonField) = apply { - this.enableCostOptimizer = enableCostOptimizer - } - - fun extractCharts(extractCharts: Boolean?) = - extractCharts(JsonField.ofNullable(extractCharts)) - - /** - * Alias for [Builder.extractCharts]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun extractCharts(extractCharts: Boolean) = - extractCharts(extractCharts as Boolean?) - - /** - * Alias for calling [Builder.extractCharts] with - * `extractCharts.orElse(null)`. - */ - fun extractCharts(extractCharts: Optional) = - extractCharts(extractCharts.getOrNull()) - - /** - * Sets [Builder.extractCharts] to an arbitrary JSON value. - * - * You should usually call [Builder.extractCharts] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun extractCharts(extractCharts: JsonField) = apply { - this.extractCharts = extractCharts - } - - fun extractLayout(extractLayout: Boolean?) = - extractLayout(JsonField.ofNullable(extractLayout)) - - /** - * Alias for [Builder.extractLayout]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun extractLayout(extractLayout: Boolean) = - extractLayout(extractLayout as Boolean?) - - /** - * Alias for calling [Builder.extractLayout] with - * `extractLayout.orElse(null)`. - */ - fun extractLayout(extractLayout: Optional) = - extractLayout(extractLayout.getOrNull()) - - /** - * Sets [Builder.extractLayout] to an arbitrary JSON value. - * - * You should usually call [Builder.extractLayout] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun extractLayout(extractLayout: JsonField) = apply { - this.extractLayout = extractLayout - } - - fun extractPrintedPageNumber(extractPrintedPageNumber: Boolean?) = - extractPrintedPageNumber(JsonField.ofNullable(extractPrintedPageNumber)) - - /** - * Alias for [Builder.extractPrintedPageNumber]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun extractPrintedPageNumber(extractPrintedPageNumber: Boolean) = - extractPrintedPageNumber(extractPrintedPageNumber as Boolean?) - - /** - * Alias for calling [Builder.extractPrintedPageNumber] with - * `extractPrintedPageNumber.orElse(null)`. - */ - fun extractPrintedPageNumber(extractPrintedPageNumber: Optional) = - extractPrintedPageNumber(extractPrintedPageNumber.getOrNull()) - - /** - * Sets [Builder.extractPrintedPageNumber] to an arbitrary JSON value. - * - * You should usually call [Builder.extractPrintedPageNumber] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun extractPrintedPageNumber(extractPrintedPageNumber: JsonField) = - apply { - this.extractPrintedPageNumber = extractPrintedPageNumber - } - - fun fastMode(fastMode: Boolean?) = fastMode(JsonField.ofNullable(fastMode)) - - /** - * Alias for [Builder.fastMode]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun fastMode(fastMode: Boolean) = fastMode(fastMode as Boolean?) - - /** Alias for calling [Builder.fastMode] with `fastMode.orElse(null)`. */ - fun fastMode(fastMode: Optional) = fastMode(fastMode.getOrNull()) - - /** - * Sets [Builder.fastMode] to an arbitrary JSON value. - * - * You should usually call [Builder.fastMode] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun fastMode(fastMode: JsonField) = apply { - this.fastMode = fastMode - } - - fun formattingInstruction(formattingInstruction: String?) = - formattingInstruction(JsonField.ofNullable(formattingInstruction)) - - /** - * Alias for calling [Builder.formattingInstruction] with - * `formattingInstruction.orElse(null)`. - */ - fun formattingInstruction(formattingInstruction: Optional) = - formattingInstruction(formattingInstruction.getOrNull()) - - /** - * Sets [Builder.formattingInstruction] to an arbitrary JSON value. - * - * You should usually call [Builder.formattingInstruction] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun formattingInstruction(formattingInstruction: JsonField) = - apply { - this.formattingInstruction = formattingInstruction - } - - fun gpt4oApiKey(gpt4oApiKey: String?) = - gpt4oApiKey(JsonField.ofNullable(gpt4oApiKey)) - - /** - * Alias for calling [Builder.gpt4oApiKey] with `gpt4oApiKey.orElse(null)`. - */ - fun gpt4oApiKey(gpt4oApiKey: Optional) = - gpt4oApiKey(gpt4oApiKey.getOrNull()) - - /** - * Sets [Builder.gpt4oApiKey] to an arbitrary JSON value. - * - * You should usually call [Builder.gpt4oApiKey] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun gpt4oApiKey(gpt4oApiKey: JsonField) = apply { - this.gpt4oApiKey = gpt4oApiKey - } - - fun gpt4oMode(gpt4oMode: Boolean?) = - gpt4oMode(JsonField.ofNullable(gpt4oMode)) - - /** - * Alias for [Builder.gpt4oMode]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun gpt4oMode(gpt4oMode: Boolean) = gpt4oMode(gpt4oMode as Boolean?) - - /** Alias for calling [Builder.gpt4oMode] with `gpt4oMode.orElse(null)`. */ - fun gpt4oMode(gpt4oMode: Optional) = - gpt4oMode(gpt4oMode.getOrNull()) - - /** - * Sets [Builder.gpt4oMode] to an arbitrary JSON value. - * - * You should usually call [Builder.gpt4oMode] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun gpt4oMode(gpt4oMode: JsonField) = apply { - this.gpt4oMode = gpt4oMode - } - - fun guessXlsxSheetName(guessXlsxSheetName: Boolean?) = - guessXlsxSheetName(JsonField.ofNullable(guessXlsxSheetName)) - - /** - * Alias for [Builder.guessXlsxSheetName]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun guessXlsxSheetName(guessXlsxSheetName: Boolean) = - guessXlsxSheetName(guessXlsxSheetName as Boolean?) - - /** - * Alias for calling [Builder.guessXlsxSheetName] with - * `guessXlsxSheetName.orElse(null)`. - */ - fun guessXlsxSheetName(guessXlsxSheetName: Optional) = - guessXlsxSheetName(guessXlsxSheetName.getOrNull()) - - /** - * Sets [Builder.guessXlsxSheetName] to an arbitrary JSON value. - * - * You should usually call [Builder.guessXlsxSheetName] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun guessXlsxSheetName(guessXlsxSheetName: JsonField) = apply { - this.guessXlsxSheetName = guessXlsxSheetName - } - - fun hideFooters(hideFooters: Boolean?) = - hideFooters(JsonField.ofNullable(hideFooters)) - - /** - * Alias for [Builder.hideFooters]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun hideFooters(hideFooters: Boolean) = hideFooters(hideFooters as Boolean?) - - /** - * Alias for calling [Builder.hideFooters] with `hideFooters.orElse(null)`. - */ - fun hideFooters(hideFooters: Optional) = - hideFooters(hideFooters.getOrNull()) - - /** - * Sets [Builder.hideFooters] to an arbitrary JSON value. - * - * You should usually call [Builder.hideFooters] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun hideFooters(hideFooters: JsonField) = apply { - this.hideFooters = hideFooters - } - - fun hideHeaders(hideHeaders: Boolean?) = - hideHeaders(JsonField.ofNullable(hideHeaders)) - - /** - * Alias for [Builder.hideHeaders]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun hideHeaders(hideHeaders: Boolean) = hideHeaders(hideHeaders as Boolean?) - - /** - * Alias for calling [Builder.hideHeaders] with `hideHeaders.orElse(null)`. - */ - fun hideHeaders(hideHeaders: Optional) = - hideHeaders(hideHeaders.getOrNull()) - - /** - * Sets [Builder.hideHeaders] to an arbitrary JSON value. - * - * You should usually call [Builder.hideHeaders] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun hideHeaders(hideHeaders: JsonField) = apply { - this.hideHeaders = hideHeaders - } - - fun highResOcr(highResOcr: Boolean?) = - highResOcr(JsonField.ofNullable(highResOcr)) - - /** - * Alias for [Builder.highResOcr]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun highResOcr(highResOcr: Boolean) = highResOcr(highResOcr as Boolean?) - - /** - * Alias for calling [Builder.highResOcr] with `highResOcr.orElse(null)`. - */ - fun highResOcr(highResOcr: Optional) = - highResOcr(highResOcr.getOrNull()) - - /** - * Sets [Builder.highResOcr] to an arbitrary JSON value. - * - * You should usually call [Builder.highResOcr] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun highResOcr(highResOcr: JsonField) = apply { - this.highResOcr = highResOcr - } - - fun htmlMakeAllElementsVisible(htmlMakeAllElementsVisible: Boolean?) = - htmlMakeAllElementsVisible( - JsonField.ofNullable(htmlMakeAllElementsVisible) - ) - - /** - * Alias for [Builder.htmlMakeAllElementsVisible]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun htmlMakeAllElementsVisible(htmlMakeAllElementsVisible: Boolean) = - htmlMakeAllElementsVisible(htmlMakeAllElementsVisible as Boolean?) - - /** - * Alias for calling [Builder.htmlMakeAllElementsVisible] with - * `htmlMakeAllElementsVisible.orElse(null)`. - */ - fun htmlMakeAllElementsVisible( - htmlMakeAllElementsVisible: Optional - ) = htmlMakeAllElementsVisible(htmlMakeAllElementsVisible.getOrNull()) - - /** - * Sets [Builder.htmlMakeAllElementsVisible] to an arbitrary JSON value. - * - * You should usually call [Builder.htmlMakeAllElementsVisible] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun htmlMakeAllElementsVisible( - htmlMakeAllElementsVisible: JsonField - ) = apply { this.htmlMakeAllElementsVisible = htmlMakeAllElementsVisible } - - fun htmlRemoveFixedElements(htmlRemoveFixedElements: Boolean?) = - htmlRemoveFixedElements(JsonField.ofNullable(htmlRemoveFixedElements)) - - /** - * Alias for [Builder.htmlRemoveFixedElements]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun htmlRemoveFixedElements(htmlRemoveFixedElements: Boolean) = - htmlRemoveFixedElements(htmlRemoveFixedElements as Boolean?) - - /** - * Alias for calling [Builder.htmlRemoveFixedElements] with - * `htmlRemoveFixedElements.orElse(null)`. - */ - fun htmlRemoveFixedElements(htmlRemoveFixedElements: Optional) = - htmlRemoveFixedElements(htmlRemoveFixedElements.getOrNull()) - - /** - * Sets [Builder.htmlRemoveFixedElements] to an arbitrary JSON value. - * - * You should usually call [Builder.htmlRemoveFixedElements] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun htmlRemoveFixedElements(htmlRemoveFixedElements: JsonField) = - apply { - this.htmlRemoveFixedElements = htmlRemoveFixedElements - } - - fun htmlRemoveNavigationElements(htmlRemoveNavigationElements: Boolean?) = - htmlRemoveNavigationElements( - JsonField.ofNullable(htmlRemoveNavigationElements) - ) - - /** - * Alias for [Builder.htmlRemoveNavigationElements]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun htmlRemoveNavigationElements(htmlRemoveNavigationElements: Boolean) = - htmlRemoveNavigationElements(htmlRemoveNavigationElements as Boolean?) - - /** - * Alias for calling [Builder.htmlRemoveNavigationElements] with - * `htmlRemoveNavigationElements.orElse(null)`. - */ - fun htmlRemoveNavigationElements( - htmlRemoveNavigationElements: Optional - ) = htmlRemoveNavigationElements(htmlRemoveNavigationElements.getOrNull()) - - /** - * Sets [Builder.htmlRemoveNavigationElements] to an arbitrary JSON value. - * - * You should usually call [Builder.htmlRemoveNavigationElements] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun htmlRemoveNavigationElements( - htmlRemoveNavigationElements: JsonField - ) = apply { - this.htmlRemoveNavigationElements = htmlRemoveNavigationElements - } - - fun httpProxy(httpProxy: String?) = - httpProxy(JsonField.ofNullable(httpProxy)) - - /** Alias for calling [Builder.httpProxy] with `httpProxy.orElse(null)`. */ - fun httpProxy(httpProxy: Optional) = - httpProxy(httpProxy.getOrNull()) - - /** - * Sets [Builder.httpProxy] to an arbitrary JSON value. - * - * You should usually call [Builder.httpProxy] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun httpProxy(httpProxy: JsonField) = apply { - this.httpProxy = httpProxy - } - - fun ignoreDocumentElementsForLayoutDetection( - ignoreDocumentElementsForLayoutDetection: Boolean? - ) = - ignoreDocumentElementsForLayoutDetection( - JsonField.ofNullable(ignoreDocumentElementsForLayoutDetection) - ) - - /** - * Alias for [Builder.ignoreDocumentElementsForLayoutDetection]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun ignoreDocumentElementsForLayoutDetection( - ignoreDocumentElementsForLayoutDetection: Boolean - ) = - ignoreDocumentElementsForLayoutDetection( - ignoreDocumentElementsForLayoutDetection as Boolean? - ) - - /** - * Alias for calling [Builder.ignoreDocumentElementsForLayoutDetection] with - * `ignoreDocumentElementsForLayoutDetection.orElse(null)`. - */ - fun ignoreDocumentElementsForLayoutDetection( - ignoreDocumentElementsForLayoutDetection: Optional - ) = - ignoreDocumentElementsForLayoutDetection( - ignoreDocumentElementsForLayoutDetection.getOrNull() - ) - - /** - * Sets [Builder.ignoreDocumentElementsForLayoutDetection] to an arbitrary - * JSON value. - * - * You should usually call - * [Builder.ignoreDocumentElementsForLayoutDetection] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun ignoreDocumentElementsForLayoutDetection( - ignoreDocumentElementsForLayoutDetection: JsonField - ) = apply { - this.ignoreDocumentElementsForLayoutDetection = - ignoreDocumentElementsForLayoutDetection - } - - fun imagesToSave(imagesToSave: List?) = - imagesToSave(JsonField.ofNullable(imagesToSave)) - - /** - * Alias for calling [Builder.imagesToSave] with - * `imagesToSave.orElse(null)`. - */ - fun imagesToSave(imagesToSave: Optional>) = - imagesToSave(imagesToSave.getOrNull()) - - /** - * Sets [Builder.imagesToSave] to an arbitrary JSON value. - * - * You should usually call [Builder.imagesToSave] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun imagesToSave(imagesToSave: JsonField>) = apply { - this.imagesToSave = imagesToSave.map { it.toMutableList() } - } - - /** - * Adds a single [ImagesToSave] to [Builder.imagesToSave]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addImagesToSave(imagesToSave: ImagesToSave) = apply { - this.imagesToSave = - (this.imagesToSave ?: JsonField.of(mutableListOf())).also { - checkKnown("imagesToSave", it).add(imagesToSave) - } - } - - fun inlineImagesInMarkdown(inlineImagesInMarkdown: Boolean?) = - inlineImagesInMarkdown(JsonField.ofNullable(inlineImagesInMarkdown)) - - /** - * Alias for [Builder.inlineImagesInMarkdown]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun inlineImagesInMarkdown(inlineImagesInMarkdown: Boolean) = - inlineImagesInMarkdown(inlineImagesInMarkdown as Boolean?) - - /** - * Alias for calling [Builder.inlineImagesInMarkdown] with - * `inlineImagesInMarkdown.orElse(null)`. - */ - fun inlineImagesInMarkdown(inlineImagesInMarkdown: Optional) = - inlineImagesInMarkdown(inlineImagesInMarkdown.getOrNull()) - - /** - * Sets [Builder.inlineImagesInMarkdown] to an arbitrary JSON value. - * - * You should usually call [Builder.inlineImagesInMarkdown] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun inlineImagesInMarkdown(inlineImagesInMarkdown: JsonField) = - apply { - this.inlineImagesInMarkdown = inlineImagesInMarkdown - } - - fun inputS3Path(inputS3Path: String?) = - inputS3Path(JsonField.ofNullable(inputS3Path)) - - /** - * Alias for calling [Builder.inputS3Path] with `inputS3Path.orElse(null)`. - */ - fun inputS3Path(inputS3Path: Optional) = - inputS3Path(inputS3Path.getOrNull()) - - /** - * Sets [Builder.inputS3Path] to an arbitrary JSON value. - * - * You should usually call [Builder.inputS3Path] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun inputS3Path(inputS3Path: JsonField) = apply { - this.inputS3Path = inputS3Path - } - - /** The region for the input S3 bucket. */ - fun inputS3Region(inputS3Region: String?) = - inputS3Region(JsonField.ofNullable(inputS3Region)) - - /** - * Alias for calling [Builder.inputS3Region] with - * `inputS3Region.orElse(null)`. - */ - fun inputS3Region(inputS3Region: Optional) = - inputS3Region(inputS3Region.getOrNull()) - - /** - * Sets [Builder.inputS3Region] to an arbitrary JSON value. - * - * You should usually call [Builder.inputS3Region] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun inputS3Region(inputS3Region: JsonField) = apply { - this.inputS3Region = inputS3Region - } - - fun inputUrl(inputUrl: String?) = inputUrl(JsonField.ofNullable(inputUrl)) - - /** Alias for calling [Builder.inputUrl] with `inputUrl.orElse(null)`. */ - fun inputUrl(inputUrl: Optional) = inputUrl(inputUrl.getOrNull()) - - /** - * Sets [Builder.inputUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.inputUrl] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun inputUrl(inputUrl: JsonField) = apply { - this.inputUrl = inputUrl - } - - fun internalIsScreenshotJob(internalIsScreenshotJob: Boolean?) = - internalIsScreenshotJob(JsonField.ofNullable(internalIsScreenshotJob)) - - /** - * Alias for [Builder.internalIsScreenshotJob]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun internalIsScreenshotJob(internalIsScreenshotJob: Boolean) = - internalIsScreenshotJob(internalIsScreenshotJob as Boolean?) - - /** - * Alias for calling [Builder.internalIsScreenshotJob] with - * `internalIsScreenshotJob.orElse(null)`. - */ - fun internalIsScreenshotJob(internalIsScreenshotJob: Optional) = - internalIsScreenshotJob(internalIsScreenshotJob.getOrNull()) - - /** - * Sets [Builder.internalIsScreenshotJob] to an arbitrary JSON value. - * - * You should usually call [Builder.internalIsScreenshotJob] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun internalIsScreenshotJob(internalIsScreenshotJob: JsonField) = - apply { - this.internalIsScreenshotJob = internalIsScreenshotJob - } - - fun invalidateCache(invalidateCache: Boolean?) = - invalidateCache(JsonField.ofNullable(invalidateCache)) - - /** - * Alias for [Builder.invalidateCache]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun invalidateCache(invalidateCache: Boolean) = - invalidateCache(invalidateCache as Boolean?) - - /** - * Alias for calling [Builder.invalidateCache] with - * `invalidateCache.orElse(null)`. - */ - fun invalidateCache(invalidateCache: Optional) = - invalidateCache(invalidateCache.getOrNull()) - - /** - * 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 - } - - fun isFormattingInstruction(isFormattingInstruction: Boolean?) = - isFormattingInstruction(JsonField.ofNullable(isFormattingInstruction)) - - /** - * Alias for [Builder.isFormattingInstruction]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun isFormattingInstruction(isFormattingInstruction: Boolean) = - isFormattingInstruction(isFormattingInstruction as Boolean?) - - /** - * Alias for calling [Builder.isFormattingInstruction] with - * `isFormattingInstruction.orElse(null)`. - */ - fun isFormattingInstruction(isFormattingInstruction: Optional) = - isFormattingInstruction(isFormattingInstruction.getOrNull()) - - /** - * Sets [Builder.isFormattingInstruction] to an arbitrary JSON value. - * - * You should usually call [Builder.isFormattingInstruction] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun isFormattingInstruction(isFormattingInstruction: JsonField) = - apply { - this.isFormattingInstruction = isFormattingInstruction - } - - fun jobTimeoutExtraTimePerPageInSeconds( - jobTimeoutExtraTimePerPageInSeconds: Double? - ) = - jobTimeoutExtraTimePerPageInSeconds( - JsonField.ofNullable(jobTimeoutExtraTimePerPageInSeconds) - ) - - /** - * Alias for [Builder.jobTimeoutExtraTimePerPageInSeconds]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun jobTimeoutExtraTimePerPageInSeconds( - jobTimeoutExtraTimePerPageInSeconds: Double - ) = - jobTimeoutExtraTimePerPageInSeconds( - jobTimeoutExtraTimePerPageInSeconds as Double? - ) - - /** - * Alias for calling [Builder.jobTimeoutExtraTimePerPageInSeconds] with - * `jobTimeoutExtraTimePerPageInSeconds.orElse(null)`. - */ - fun jobTimeoutExtraTimePerPageInSeconds( - jobTimeoutExtraTimePerPageInSeconds: Optional - ) = - jobTimeoutExtraTimePerPageInSeconds( - jobTimeoutExtraTimePerPageInSeconds.getOrNull() - ) - - /** - * Sets [Builder.jobTimeoutExtraTimePerPageInSeconds] to an arbitrary JSON - * value. - * - * You should usually call [Builder.jobTimeoutExtraTimePerPageInSeconds] - * with a well-typed [Double] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun jobTimeoutExtraTimePerPageInSeconds( - jobTimeoutExtraTimePerPageInSeconds: JsonField - ) = apply { - this.jobTimeoutExtraTimePerPageInSeconds = - jobTimeoutExtraTimePerPageInSeconds - } - - fun jobTimeoutInSeconds(jobTimeoutInSeconds: Double?) = - jobTimeoutInSeconds(JsonField.ofNullable(jobTimeoutInSeconds)) - - /** - * Alias for [Builder.jobTimeoutInSeconds]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun jobTimeoutInSeconds(jobTimeoutInSeconds: Double) = - jobTimeoutInSeconds(jobTimeoutInSeconds as Double?) - - /** - * Alias for calling [Builder.jobTimeoutInSeconds] with - * `jobTimeoutInSeconds.orElse(null)`. - */ - fun jobTimeoutInSeconds(jobTimeoutInSeconds: Optional) = - jobTimeoutInSeconds(jobTimeoutInSeconds.getOrNull()) - - /** - * Sets [Builder.jobTimeoutInSeconds] to an arbitrary JSON value. - * - * You should usually call [Builder.jobTimeoutInSeconds] with a well-typed - * [Double] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun jobTimeoutInSeconds(jobTimeoutInSeconds: JsonField) = apply { - this.jobTimeoutInSeconds = jobTimeoutInSeconds - } - - fun keepPageSeparatorWhenMergingTables( - keepPageSeparatorWhenMergingTables: Boolean? - ) = - keepPageSeparatorWhenMergingTables( - JsonField.ofNullable(keepPageSeparatorWhenMergingTables) - ) - - /** - * Alias for [Builder.keepPageSeparatorWhenMergingTables]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun keepPageSeparatorWhenMergingTables( - keepPageSeparatorWhenMergingTables: Boolean - ) = - keepPageSeparatorWhenMergingTables( - keepPageSeparatorWhenMergingTables as Boolean? - ) - - /** - * Alias for calling [Builder.keepPageSeparatorWhenMergingTables] with - * `keepPageSeparatorWhenMergingTables.orElse(null)`. - */ - fun keepPageSeparatorWhenMergingTables( - keepPageSeparatorWhenMergingTables: Optional - ) = - keepPageSeparatorWhenMergingTables( - keepPageSeparatorWhenMergingTables.getOrNull() - ) - - /** - * Sets [Builder.keepPageSeparatorWhenMergingTables] to an arbitrary JSON - * value. - * - * You should usually call [Builder.keepPageSeparatorWhenMergingTables] with - * a well-typed [Boolean] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun keepPageSeparatorWhenMergingTables( - keepPageSeparatorWhenMergingTables: JsonField - ) = apply { - this.keepPageSeparatorWhenMergingTables = - keepPageSeparatorWhenMergingTables - } - - /** The language. */ - fun lang(lang: String) = lang(JsonField.of(lang)) - - /** - * Sets [Builder.lang] to an arbitrary JSON value. - * - * You should usually call [Builder.lang] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun lang(lang: JsonField) = apply { this.lang = lang } - - fun languages(languages: List) = - languages(JsonField.of(languages)) - - /** - * Sets [Builder.languages] to an arbitrary JSON value. - * - * You should usually call [Builder.languages] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun languages(languages: JsonField>) = apply { - this.languages = languages.map { it.toMutableList() } - } - - /** - * Adds a single [ParsingLanguages] to [languages]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addLanguage(language: ParsingLanguages) = apply { - languages = - (languages ?: JsonField.of(mutableListOf())).also { - checkKnown("languages", it).add(language) - } - } - - fun layoutAware(layoutAware: Boolean?) = - layoutAware(JsonField.ofNullable(layoutAware)) - - /** - * Alias for [Builder.layoutAware]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun layoutAware(layoutAware: Boolean) = layoutAware(layoutAware as Boolean?) - - /** - * Alias for calling [Builder.layoutAware] with `layoutAware.orElse(null)`. - */ - fun layoutAware(layoutAware: Optional) = - layoutAware(layoutAware.getOrNull()) - - /** - * Sets [Builder.layoutAware] to an arbitrary JSON value. - * - * You should usually call [Builder.layoutAware] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun layoutAware(layoutAware: JsonField) = apply { - this.layoutAware = layoutAware - } - - fun lineLevelBoundingBox(lineLevelBoundingBox: Boolean?) = - lineLevelBoundingBox(JsonField.ofNullable(lineLevelBoundingBox)) - - /** - * Alias for [Builder.lineLevelBoundingBox]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun lineLevelBoundingBox(lineLevelBoundingBox: Boolean) = - lineLevelBoundingBox(lineLevelBoundingBox as Boolean?) - - /** - * Alias for calling [Builder.lineLevelBoundingBox] with - * `lineLevelBoundingBox.orElse(null)`. - */ - fun lineLevelBoundingBox(lineLevelBoundingBox: Optional) = - lineLevelBoundingBox(lineLevelBoundingBox.getOrNull()) - - /** - * Sets [Builder.lineLevelBoundingBox] to an arbitrary JSON value. - * - * You should usually call [Builder.lineLevelBoundingBox] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun lineLevelBoundingBox(lineLevelBoundingBox: JsonField) = apply { - this.lineLevelBoundingBox = lineLevelBoundingBox - } - - fun markdownTableMultilineHeaderSeparator( - markdownTableMultilineHeaderSeparator: String? - ) = - markdownTableMultilineHeaderSeparator( - JsonField.ofNullable(markdownTableMultilineHeaderSeparator) - ) - - /** - * Alias for calling [Builder.markdownTableMultilineHeaderSeparator] with - * `markdownTableMultilineHeaderSeparator.orElse(null)`. - */ - fun markdownTableMultilineHeaderSeparator( - markdownTableMultilineHeaderSeparator: Optional - ) = - markdownTableMultilineHeaderSeparator( - markdownTableMultilineHeaderSeparator.getOrNull() - ) - - /** - * Sets [Builder.markdownTableMultilineHeaderSeparator] to an arbitrary JSON - * value. - * - * You should usually call [Builder.markdownTableMultilineHeaderSeparator] - * with a well-typed [String] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun markdownTableMultilineHeaderSeparator( - markdownTableMultilineHeaderSeparator: JsonField - ) = apply { - this.markdownTableMultilineHeaderSeparator = - markdownTableMultilineHeaderSeparator - } - - fun maxPages(maxPages: Long?) = maxPages(JsonField.ofNullable(maxPages)) - - /** - * Alias for [Builder.maxPages]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun maxPages(maxPages: Long) = maxPages(maxPages as Long?) - - /** Alias for calling [Builder.maxPages] with `maxPages.orElse(null)`. */ - fun maxPages(maxPages: Optional) = maxPages(maxPages.getOrNull()) - - /** - * Sets [Builder.maxPages] to an arbitrary JSON value. - * - * You should usually call [Builder.maxPages] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun maxPages(maxPages: JsonField) = apply { this.maxPages = maxPages } - - fun maxPagesEnforced(maxPagesEnforced: Long?) = - maxPagesEnforced(JsonField.ofNullable(maxPagesEnforced)) - - /** - * Alias for [Builder.maxPagesEnforced]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun maxPagesEnforced(maxPagesEnforced: Long) = - maxPagesEnforced(maxPagesEnforced as Long?) - - /** - * Alias for calling [Builder.maxPagesEnforced] with - * `maxPagesEnforced.orElse(null)`. - */ - fun maxPagesEnforced(maxPagesEnforced: Optional) = - maxPagesEnforced(maxPagesEnforced.getOrNull()) - - /** - * Sets [Builder.maxPagesEnforced] to an arbitrary JSON value. - * - * You should usually call [Builder.maxPagesEnforced] with a well-typed - * [Long] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun maxPagesEnforced(maxPagesEnforced: JsonField) = apply { - this.maxPagesEnforced = maxPagesEnforced - } - - fun mergeTablesAcrossPagesInMarkdown( - mergeTablesAcrossPagesInMarkdown: Boolean? - ) = - mergeTablesAcrossPagesInMarkdown( - JsonField.ofNullable(mergeTablesAcrossPagesInMarkdown) - ) - - /** - * Alias for [Builder.mergeTablesAcrossPagesInMarkdown]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun mergeTablesAcrossPagesInMarkdown( - mergeTablesAcrossPagesInMarkdown: Boolean - ) = - mergeTablesAcrossPagesInMarkdown( - mergeTablesAcrossPagesInMarkdown as Boolean? - ) - - /** - * Alias for calling [Builder.mergeTablesAcrossPagesInMarkdown] with - * `mergeTablesAcrossPagesInMarkdown.orElse(null)`. - */ - fun mergeTablesAcrossPagesInMarkdown( - mergeTablesAcrossPagesInMarkdown: Optional - ) = - mergeTablesAcrossPagesInMarkdown( - mergeTablesAcrossPagesInMarkdown.getOrNull() - ) - - /** - * Sets [Builder.mergeTablesAcrossPagesInMarkdown] to an arbitrary JSON - * value. - * - * You should usually call [Builder.mergeTablesAcrossPagesInMarkdown] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun mergeTablesAcrossPagesInMarkdown( - mergeTablesAcrossPagesInMarkdown: JsonField - ) = apply { - this.mergeTablesAcrossPagesInMarkdown = mergeTablesAcrossPagesInMarkdown - } - - fun model(model: String?) = model(JsonField.ofNullable(model)) - - /** Alias for calling [Builder.model] with `model.orElse(null)`. */ - fun model(model: Optional) = model(model.getOrNull()) - - /** - * Sets [Builder.model] to an arbitrary JSON value. - * - * You should usually call [Builder.model] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun model(model: JsonField) = apply { this.model = model } - - fun outlinedTableExtraction(outlinedTableExtraction: Boolean?) = - outlinedTableExtraction(JsonField.ofNullable(outlinedTableExtraction)) - - /** - * Alias for [Builder.outlinedTableExtraction]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun outlinedTableExtraction(outlinedTableExtraction: Boolean) = - outlinedTableExtraction(outlinedTableExtraction as Boolean?) - - /** - * Alias for calling [Builder.outlinedTableExtraction] with - * `outlinedTableExtraction.orElse(null)`. - */ - fun outlinedTableExtraction(outlinedTableExtraction: Optional) = - outlinedTableExtraction(outlinedTableExtraction.getOrNull()) - - /** - * Sets [Builder.outlinedTableExtraction] to an arbitrary JSON value. - * - * You should usually call [Builder.outlinedTableExtraction] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun outlinedTableExtraction(outlinedTableExtraction: JsonField) = - apply { - this.outlinedTableExtraction = outlinedTableExtraction - } - - fun outputPdfOfDocument(outputPdfOfDocument: Boolean?) = - outputPdfOfDocument(JsonField.ofNullable(outputPdfOfDocument)) - - /** - * Alias for [Builder.outputPdfOfDocument]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun outputPdfOfDocument(outputPdfOfDocument: Boolean) = - outputPdfOfDocument(outputPdfOfDocument as Boolean?) - - /** - * Alias for calling [Builder.outputPdfOfDocument] with - * `outputPdfOfDocument.orElse(null)`. - */ - fun outputPdfOfDocument(outputPdfOfDocument: Optional) = - outputPdfOfDocument(outputPdfOfDocument.getOrNull()) - - /** - * Sets [Builder.outputPdfOfDocument] to an arbitrary JSON value. - * - * You should usually call [Builder.outputPdfOfDocument] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun outputPdfOfDocument(outputPdfOfDocument: JsonField) = apply { - this.outputPdfOfDocument = outputPdfOfDocument - } - - /** - * If specified, llamaParse will save the output to the specified path. All - * output file will use this 'prefix' should be a valid s3:// url - */ - fun outputS3PathPrefix(outputS3PathPrefix: String?) = - outputS3PathPrefix(JsonField.ofNullable(outputS3PathPrefix)) - - /** - * Alias for calling [Builder.outputS3PathPrefix] with - * `outputS3PathPrefix.orElse(null)`. - */ - fun outputS3PathPrefix(outputS3PathPrefix: Optional) = - outputS3PathPrefix(outputS3PathPrefix.getOrNull()) - - /** - * Sets [Builder.outputS3PathPrefix] to an arbitrary JSON value. - * - * You should usually call [Builder.outputS3PathPrefix] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun outputS3PathPrefix(outputS3PathPrefix: JsonField) = apply { - this.outputS3PathPrefix = outputS3PathPrefix - } - - /** The region for the output S3 bucket. */ - fun outputS3Region(outputS3Region: String?) = - outputS3Region(JsonField.ofNullable(outputS3Region)) - - /** - * Alias for calling [Builder.outputS3Region] with - * `outputS3Region.orElse(null)`. - */ - fun outputS3Region(outputS3Region: Optional) = - outputS3Region(outputS3Region.getOrNull()) - - /** - * Sets [Builder.outputS3Region] to an arbitrary JSON value. - * - * You should usually call [Builder.outputS3Region] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun outputS3Region(outputS3Region: JsonField) = apply { - this.outputS3Region = outputS3Region - } - - fun outputTablesAsHtml(outputTablesAsHtml: Boolean?) = - outputTablesAsHtml(JsonField.ofNullable(outputTablesAsHtml)) - - /** - * Alias for [Builder.outputTablesAsHtml]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun outputTablesAsHtml(outputTablesAsHtml: Boolean) = - outputTablesAsHtml(outputTablesAsHtml as Boolean?) - - /** - * Alias for calling [Builder.outputTablesAsHtml] with - * `outputTablesAsHtml.orElse(null)`. - */ - fun outputTablesAsHtml(outputTablesAsHtml: Optional) = - outputTablesAsHtml(outputTablesAsHtml.getOrNull()) - - /** - * Sets [Builder.outputTablesAsHtml] to an arbitrary JSON value. - * - * You should usually call [Builder.outputTablesAsHtml] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun outputTablesAsHtml(outputTablesAsHtml: JsonField) = apply { - this.outputTablesAsHtml = outputTablesAsHtml - } - - /** The output bucket. */ - fun outputBucket(outputBucket: String?) = - outputBucket(JsonField.ofNullable(outputBucket)) - - /** - * Alias for calling [Builder.outputBucket] with - * `outputBucket.orElse(null)`. - */ - fun outputBucket(outputBucket: Optional) = - outputBucket(outputBucket.getOrNull()) - - /** - * Sets [Builder.outputBucket] to an arbitrary JSON value. - * - * You should usually call [Builder.outputBucket] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun outputBucket(outputBucket: JsonField) = apply { - this.outputBucket = outputBucket - } - - fun pageErrorTolerance(pageErrorTolerance: Double?) = - pageErrorTolerance(JsonField.ofNullable(pageErrorTolerance)) - - /** - * Alias for [Builder.pageErrorTolerance]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun pageErrorTolerance(pageErrorTolerance: Double) = - pageErrorTolerance(pageErrorTolerance as Double?) - - /** - * Alias for calling [Builder.pageErrorTolerance] with - * `pageErrorTolerance.orElse(null)`. - */ - fun pageErrorTolerance(pageErrorTolerance: Optional) = - pageErrorTolerance(pageErrorTolerance.getOrNull()) - - /** - * Sets [Builder.pageErrorTolerance] to an arbitrary JSON value. - * - * You should usually call [Builder.pageErrorTolerance] with a well-typed - * [Double] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun pageErrorTolerance(pageErrorTolerance: JsonField) = apply { - this.pageErrorTolerance = pageErrorTolerance - } - - fun pageFooterPrefix(pageFooterPrefix: String?) = - pageFooterPrefix(JsonField.ofNullable(pageFooterPrefix)) - - /** - * Alias for calling [Builder.pageFooterPrefix] with - * `pageFooterPrefix.orElse(null)`. - */ - fun pageFooterPrefix(pageFooterPrefix: Optional) = - pageFooterPrefix(pageFooterPrefix.getOrNull()) - - /** - * Sets [Builder.pageFooterPrefix] to an arbitrary JSON value. - * - * You should usually call [Builder.pageFooterPrefix] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun pageFooterPrefix(pageFooterPrefix: JsonField) = apply { - this.pageFooterPrefix = pageFooterPrefix - } - - fun pageFooterSuffix(pageFooterSuffix: String?) = - pageFooterSuffix(JsonField.ofNullable(pageFooterSuffix)) - - /** - * Alias for calling [Builder.pageFooterSuffix] with - * `pageFooterSuffix.orElse(null)`. - */ - fun pageFooterSuffix(pageFooterSuffix: Optional) = - pageFooterSuffix(pageFooterSuffix.getOrNull()) - - /** - * Sets [Builder.pageFooterSuffix] to an arbitrary JSON value. - * - * You should usually call [Builder.pageFooterSuffix] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun pageFooterSuffix(pageFooterSuffix: JsonField) = apply { - this.pageFooterSuffix = pageFooterSuffix - } - - fun pageHeaderPrefix(pageHeaderPrefix: String?) = - pageHeaderPrefix(JsonField.ofNullable(pageHeaderPrefix)) - - /** - * Alias for calling [Builder.pageHeaderPrefix] with - * `pageHeaderPrefix.orElse(null)`. - */ - fun pageHeaderPrefix(pageHeaderPrefix: Optional) = - pageHeaderPrefix(pageHeaderPrefix.getOrNull()) - - /** - * Sets [Builder.pageHeaderPrefix] to an arbitrary JSON value. - * - * You should usually call [Builder.pageHeaderPrefix] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun pageHeaderPrefix(pageHeaderPrefix: JsonField) = apply { - this.pageHeaderPrefix = pageHeaderPrefix - } - - fun pageHeaderSuffix(pageHeaderSuffix: String?) = - pageHeaderSuffix(JsonField.ofNullable(pageHeaderSuffix)) - - /** - * Alias for calling [Builder.pageHeaderSuffix] with - * `pageHeaderSuffix.orElse(null)`. - */ - fun pageHeaderSuffix(pageHeaderSuffix: Optional) = - pageHeaderSuffix(pageHeaderSuffix.getOrNull()) - - /** - * Sets [Builder.pageHeaderSuffix] to an arbitrary JSON value. - * - * You should usually call [Builder.pageHeaderSuffix] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun pageHeaderSuffix(pageHeaderSuffix: JsonField) = apply { - this.pageHeaderSuffix = pageHeaderSuffix - } - - fun pagePrefix(pagePrefix: String?) = - pagePrefix(JsonField.ofNullable(pagePrefix)) - - /** - * Alias for calling [Builder.pagePrefix] with `pagePrefix.orElse(null)`. - */ - fun pagePrefix(pagePrefix: Optional) = - pagePrefix(pagePrefix.getOrNull()) - - /** - * Sets [Builder.pagePrefix] to an arbitrary JSON value. - * - * You should usually call [Builder.pagePrefix] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun pagePrefix(pagePrefix: JsonField) = apply { - this.pagePrefix = pagePrefix - } - - fun pageSeparator(pageSeparator: String?) = - pageSeparator(JsonField.ofNullable(pageSeparator)) - - /** - * Alias for calling [Builder.pageSeparator] with - * `pageSeparator.orElse(null)`. - */ - fun pageSeparator(pageSeparator: Optional) = - pageSeparator(pageSeparator.getOrNull()) - - /** - * Sets [Builder.pageSeparator] to an arbitrary JSON value. - * - * You should usually call [Builder.pageSeparator] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun pageSeparator(pageSeparator: JsonField) = apply { - this.pageSeparator = pageSeparator - } - - fun pageSuffix(pageSuffix: String?) = - pageSuffix(JsonField.ofNullable(pageSuffix)) - - /** - * Alias for calling [Builder.pageSuffix] with `pageSuffix.orElse(null)`. - */ - fun pageSuffix(pageSuffix: Optional) = - pageSuffix(pageSuffix.getOrNull()) - - /** - * Sets [Builder.pageSuffix] to an arbitrary JSON value. - * - * You should usually call [Builder.pageSuffix] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun pageSuffix(pageSuffix: JsonField) = apply { - this.pageSuffix = pageSuffix - } - - /** Enum for representing the mode of parsing to be used. */ - fun parseMode(parseMode: ParsingMode?) = - parseMode(JsonField.ofNullable(parseMode)) - - /** Alias for calling [Builder.parseMode] with `parseMode.orElse(null)`. */ - fun parseMode(parseMode: Optional) = - parseMode(parseMode.getOrNull()) - - /** - * Sets [Builder.parseMode] to an arbitrary JSON value. - * - * You should usually call [Builder.parseMode] with a well-typed - * [ParsingMode] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun parseMode(parseMode: JsonField) = apply { - this.parseMode = parseMode - } - - fun parsingInstruction(parsingInstruction: String?) = - parsingInstruction(JsonField.ofNullable(parsingInstruction)) - - /** - * Alias for calling [Builder.parsingInstruction] with - * `parsingInstruction.orElse(null)`. - */ - fun parsingInstruction(parsingInstruction: Optional) = - parsingInstruction(parsingInstruction.getOrNull()) - - /** - * Sets [Builder.parsingInstruction] to an arbitrary JSON value. - * - * You should usually call [Builder.parsingInstruction] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun parsingInstruction(parsingInstruction: JsonField) = apply { - this.parsingInstruction = parsingInstruction - } - - /** The pipeline ID. */ - fun pipelineId(pipelineId: String?) = - pipelineId(JsonField.ofNullable(pipelineId)) - - /** - * Alias for calling [Builder.pipelineId] with `pipelineId.orElse(null)`. - */ - fun pipelineId(pipelineId: Optional) = - pipelineId(pipelineId.getOrNull()) - - /** - * Sets [Builder.pipelineId] to an arbitrary JSON value. - * - * You should usually call [Builder.pipelineId] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun pipelineId(pipelineId: JsonField) = apply { - this.pipelineId = pipelineId - } - - fun preciseBoundingBox(preciseBoundingBox: Boolean?) = - preciseBoundingBox(JsonField.ofNullable(preciseBoundingBox)) - - /** - * Alias for [Builder.preciseBoundingBox]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun preciseBoundingBox(preciseBoundingBox: Boolean) = - preciseBoundingBox(preciseBoundingBox as Boolean?) - - /** - * Alias for calling [Builder.preciseBoundingBox] with - * `preciseBoundingBox.orElse(null)`. - */ - fun preciseBoundingBox(preciseBoundingBox: Optional) = - preciseBoundingBox(preciseBoundingBox.getOrNull()) - - /** - * Sets [Builder.preciseBoundingBox] to an arbitrary JSON value. - * - * You should usually call [Builder.preciseBoundingBox] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun preciseBoundingBox(preciseBoundingBox: JsonField) = apply { - this.preciseBoundingBox = preciseBoundingBox - } - - fun premiumMode(premiumMode: Boolean?) = - premiumMode(JsonField.ofNullable(premiumMode)) - - /** - * Alias for [Builder.premiumMode]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun premiumMode(premiumMode: Boolean) = premiumMode(premiumMode as Boolean?) - - /** - * Alias for calling [Builder.premiumMode] with `premiumMode.orElse(null)`. - */ - fun premiumMode(premiumMode: Optional) = - premiumMode(premiumMode.getOrNull()) - - /** - * Sets [Builder.premiumMode] to an arbitrary JSON value. - * - * You should usually call [Builder.premiumMode] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun premiumMode(premiumMode: JsonField) = apply { - this.premiumMode = premiumMode - } - - fun presentationOutOfBoundsContent( - presentationOutOfBoundsContent: Boolean? - ) = - presentationOutOfBoundsContent( - JsonField.ofNullable(presentationOutOfBoundsContent) - ) - - /** - * Alias for [Builder.presentationOutOfBoundsContent]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun presentationOutOfBoundsContent( - presentationOutOfBoundsContent: Boolean - ) = - presentationOutOfBoundsContent( - presentationOutOfBoundsContent as Boolean? - ) - - /** - * Alias for calling [Builder.presentationOutOfBoundsContent] with - * `presentationOutOfBoundsContent.orElse(null)`. - */ - fun presentationOutOfBoundsContent( - presentationOutOfBoundsContent: Optional - ) = - presentationOutOfBoundsContent( - presentationOutOfBoundsContent.getOrNull() - ) - - /** - * Sets [Builder.presentationOutOfBoundsContent] to an arbitrary JSON value. - * - * You should usually call [Builder.presentationOutOfBoundsContent] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun presentationOutOfBoundsContent( - presentationOutOfBoundsContent: JsonField - ) = apply { - this.presentationOutOfBoundsContent = presentationOutOfBoundsContent - } - - fun presentationSkipEmbeddedData(presentationSkipEmbeddedData: Boolean?) = - presentationSkipEmbeddedData( - JsonField.ofNullable(presentationSkipEmbeddedData) - ) - - /** - * Alias for [Builder.presentationSkipEmbeddedData]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun presentationSkipEmbeddedData(presentationSkipEmbeddedData: Boolean) = - presentationSkipEmbeddedData(presentationSkipEmbeddedData as Boolean?) - - /** - * Alias for calling [Builder.presentationSkipEmbeddedData] with - * `presentationSkipEmbeddedData.orElse(null)`. - */ - fun presentationSkipEmbeddedData( - presentationSkipEmbeddedData: Optional - ) = presentationSkipEmbeddedData(presentationSkipEmbeddedData.getOrNull()) - - /** - * Sets [Builder.presentationSkipEmbeddedData] to an arbitrary JSON value. - * - * You should usually call [Builder.presentationSkipEmbeddedData] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun presentationSkipEmbeddedData( - presentationSkipEmbeddedData: JsonField - ) = apply { - this.presentationSkipEmbeddedData = presentationSkipEmbeddedData - } - - fun preserveLayoutAlignmentAcrossPages( - preserveLayoutAlignmentAcrossPages: Boolean? - ) = - preserveLayoutAlignmentAcrossPages( - JsonField.ofNullable(preserveLayoutAlignmentAcrossPages) - ) - - /** - * Alias for [Builder.preserveLayoutAlignmentAcrossPages]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun preserveLayoutAlignmentAcrossPages( - preserveLayoutAlignmentAcrossPages: Boolean - ) = - preserveLayoutAlignmentAcrossPages( - preserveLayoutAlignmentAcrossPages as Boolean? - ) - - /** - * Alias for calling [Builder.preserveLayoutAlignmentAcrossPages] with - * `preserveLayoutAlignmentAcrossPages.orElse(null)`. - */ - fun preserveLayoutAlignmentAcrossPages( - preserveLayoutAlignmentAcrossPages: Optional - ) = - preserveLayoutAlignmentAcrossPages( - preserveLayoutAlignmentAcrossPages.getOrNull() - ) - - /** - * Sets [Builder.preserveLayoutAlignmentAcrossPages] to an arbitrary JSON - * value. - * - * You should usually call [Builder.preserveLayoutAlignmentAcrossPages] with - * a well-typed [Boolean] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun preserveLayoutAlignmentAcrossPages( - preserveLayoutAlignmentAcrossPages: JsonField - ) = apply { - this.preserveLayoutAlignmentAcrossPages = - preserveLayoutAlignmentAcrossPages - } - - fun preserveVerySmallText(preserveVerySmallText: Boolean?) = - preserveVerySmallText(JsonField.ofNullable(preserveVerySmallText)) - - /** - * Alias for [Builder.preserveVerySmallText]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun preserveVerySmallText(preserveVerySmallText: Boolean) = - preserveVerySmallText(preserveVerySmallText as Boolean?) - - /** - * Alias for calling [Builder.preserveVerySmallText] with - * `preserveVerySmallText.orElse(null)`. - */ - fun preserveVerySmallText(preserveVerySmallText: Optional) = - preserveVerySmallText(preserveVerySmallText.getOrNull()) - - /** - * Sets [Builder.preserveVerySmallText] to an arbitrary JSON value. - * - * You should usually call [Builder.preserveVerySmallText] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun preserveVerySmallText(preserveVerySmallText: JsonField) = - apply { - this.preserveVerySmallText = preserveVerySmallText - } - - fun preset(preset: String?) = preset(JsonField.ofNullable(preset)) - - /** Alias for calling [Builder.preset] with `preset.orElse(null)`. */ - fun preset(preset: Optional) = preset(preset.getOrNull()) - - /** - * Sets [Builder.preset] to an arbitrary JSON value. - * - * You should usually call [Builder.preset] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun preset(preset: JsonField) = apply { this.preset = preset } - - /** - * 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 - } - - 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 removeHiddenText(removeHiddenText: Boolean?) = - removeHiddenText(JsonField.ofNullable(removeHiddenText)) - - /** - * Alias for [Builder.removeHiddenText]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun removeHiddenText(removeHiddenText: Boolean) = - removeHiddenText(removeHiddenText as Boolean?) - - /** - * Alias for calling [Builder.removeHiddenText] with - * `removeHiddenText.orElse(null)`. - */ - fun removeHiddenText(removeHiddenText: Optional) = - removeHiddenText(removeHiddenText.getOrNull()) - - /** - * Sets [Builder.removeHiddenText] to an arbitrary JSON value. - * - * You should usually call [Builder.removeHiddenText] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun removeHiddenText(removeHiddenText: JsonField) = apply { - this.removeHiddenText = removeHiddenText - } - - /** - * Enum for representing the different available page error handling modes. - */ - fun replaceFailedPageMode(replaceFailedPageMode: FailPageMode?) = - replaceFailedPageMode(JsonField.ofNullable(replaceFailedPageMode)) - - /** - * Alias for calling [Builder.replaceFailedPageMode] with - * `replaceFailedPageMode.orElse(null)`. - */ - fun replaceFailedPageMode(replaceFailedPageMode: Optional) = - replaceFailedPageMode(replaceFailedPageMode.getOrNull()) - - /** - * Sets [Builder.replaceFailedPageMode] to an arbitrary JSON value. - * - * You should usually call [Builder.replaceFailedPageMode] with a well-typed - * [FailPageMode] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun replaceFailedPageMode(replaceFailedPageMode: JsonField) = - apply { - this.replaceFailedPageMode = replaceFailedPageMode - } - - fun replaceFailedPageWithErrorMessagePrefix( - replaceFailedPageWithErrorMessagePrefix: String? - ) = - replaceFailedPageWithErrorMessagePrefix( - JsonField.ofNullable(replaceFailedPageWithErrorMessagePrefix) - ) - - /** - * Alias for calling [Builder.replaceFailedPageWithErrorMessagePrefix] with - * `replaceFailedPageWithErrorMessagePrefix.orElse(null)`. - */ - fun replaceFailedPageWithErrorMessagePrefix( - replaceFailedPageWithErrorMessagePrefix: Optional - ) = - replaceFailedPageWithErrorMessagePrefix( - replaceFailedPageWithErrorMessagePrefix.getOrNull() - ) - - /** - * Sets [Builder.replaceFailedPageWithErrorMessagePrefix] to an arbitrary - * JSON value. - * - * You should usually call [Builder.replaceFailedPageWithErrorMessagePrefix] - * with a well-typed [String] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun replaceFailedPageWithErrorMessagePrefix( - replaceFailedPageWithErrorMessagePrefix: JsonField - ) = apply { - this.replaceFailedPageWithErrorMessagePrefix = - replaceFailedPageWithErrorMessagePrefix - } - - fun replaceFailedPageWithErrorMessageSuffix( - replaceFailedPageWithErrorMessageSuffix: String? - ) = - replaceFailedPageWithErrorMessageSuffix( - JsonField.ofNullable(replaceFailedPageWithErrorMessageSuffix) - ) - - /** - * Alias for calling [Builder.replaceFailedPageWithErrorMessageSuffix] with - * `replaceFailedPageWithErrorMessageSuffix.orElse(null)`. - */ - fun replaceFailedPageWithErrorMessageSuffix( - replaceFailedPageWithErrorMessageSuffix: Optional - ) = - replaceFailedPageWithErrorMessageSuffix( - replaceFailedPageWithErrorMessageSuffix.getOrNull() - ) - - /** - * Sets [Builder.replaceFailedPageWithErrorMessageSuffix] to an arbitrary - * JSON value. - * - * You should usually call [Builder.replaceFailedPageWithErrorMessageSuffix] - * with a well-typed [String] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun replaceFailedPageWithErrorMessageSuffix( - replaceFailedPageWithErrorMessageSuffix: JsonField - ) = apply { - this.replaceFailedPageWithErrorMessageSuffix = - replaceFailedPageWithErrorMessageSuffix - } - - /** The resource info about the file */ - fun resourceInfo(resourceInfo: ResourceInfo?) = - resourceInfo(JsonField.ofNullable(resourceInfo)) - - /** - * Alias for calling [Builder.resourceInfo] with - * `resourceInfo.orElse(null)`. - */ - fun resourceInfo(resourceInfo: Optional) = - resourceInfo(resourceInfo.getOrNull()) - - /** - * Sets [Builder.resourceInfo] to an arbitrary JSON value. - * - * You should usually call [Builder.resourceInfo] with a well-typed - * [ResourceInfo] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun resourceInfo(resourceInfo: JsonField) = apply { - this.resourceInfo = resourceInfo - } - - fun saveImages(saveImages: Boolean?) = - saveImages(JsonField.ofNullable(saveImages)) - - /** - * Alias for [Builder.saveImages]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun saveImages(saveImages: Boolean) = saveImages(saveImages as Boolean?) - - /** - * Alias for calling [Builder.saveImages] with `saveImages.orElse(null)`. - */ - fun saveImages(saveImages: Optional) = - saveImages(saveImages.getOrNull()) - - /** - * Sets [Builder.saveImages] to an arbitrary JSON value. - * - * You should usually call [Builder.saveImages] with a well-typed [Boolean] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun saveImages(saveImages: JsonField) = apply { - this.saveImages = saveImages - } - - fun skipDiagonalText(skipDiagonalText: Boolean?) = - skipDiagonalText(JsonField.ofNullable(skipDiagonalText)) - - /** - * Alias for [Builder.skipDiagonalText]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun skipDiagonalText(skipDiagonalText: Boolean) = - skipDiagonalText(skipDiagonalText as Boolean?) - - /** - * Alias for calling [Builder.skipDiagonalText] with - * `skipDiagonalText.orElse(null)`. - */ - fun skipDiagonalText(skipDiagonalText: Optional) = - skipDiagonalText(skipDiagonalText.getOrNull()) - - /** - * Sets [Builder.skipDiagonalText] to an arbitrary JSON value. - * - * You should usually call [Builder.skipDiagonalText] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun skipDiagonalText(skipDiagonalText: JsonField) = apply { - this.skipDiagonalText = skipDiagonalText - } - - fun specializedChartParsingAgentic( - specializedChartParsingAgentic: Boolean? - ) = - specializedChartParsingAgentic( - JsonField.ofNullable(specializedChartParsingAgentic) - ) - - /** - * Alias for [Builder.specializedChartParsingAgentic]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun specializedChartParsingAgentic( - specializedChartParsingAgentic: Boolean - ) = - specializedChartParsingAgentic( - specializedChartParsingAgentic as Boolean? - ) - - /** - * Alias for calling [Builder.specializedChartParsingAgentic] with - * `specializedChartParsingAgentic.orElse(null)`. - */ - fun specializedChartParsingAgentic( - specializedChartParsingAgentic: Optional - ) = - specializedChartParsingAgentic( - specializedChartParsingAgentic.getOrNull() - ) - - /** - * Sets [Builder.specializedChartParsingAgentic] to an arbitrary JSON value. - * - * You should usually call [Builder.specializedChartParsingAgentic] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun specializedChartParsingAgentic( - specializedChartParsingAgentic: JsonField - ) = apply { - this.specializedChartParsingAgentic = specializedChartParsingAgentic - } - - fun specializedChartParsingEfficient( - specializedChartParsingEfficient: Boolean? - ) = - specializedChartParsingEfficient( - JsonField.ofNullable(specializedChartParsingEfficient) - ) - - /** - * Alias for [Builder.specializedChartParsingEfficient]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun specializedChartParsingEfficient( - specializedChartParsingEfficient: Boolean - ) = - specializedChartParsingEfficient( - specializedChartParsingEfficient as Boolean? - ) - - /** - * Alias for calling [Builder.specializedChartParsingEfficient] with - * `specializedChartParsingEfficient.orElse(null)`. - */ - fun specializedChartParsingEfficient( - specializedChartParsingEfficient: Optional - ) = - specializedChartParsingEfficient( - specializedChartParsingEfficient.getOrNull() - ) - - /** - * Sets [Builder.specializedChartParsingEfficient] to an arbitrary JSON - * value. - * - * You should usually call [Builder.specializedChartParsingEfficient] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun specializedChartParsingEfficient( - specializedChartParsingEfficient: JsonField - ) = apply { - this.specializedChartParsingEfficient = specializedChartParsingEfficient - } - - fun specializedChartParsingPlus(specializedChartParsingPlus: Boolean?) = - specializedChartParsingPlus( - JsonField.ofNullable(specializedChartParsingPlus) - ) - - /** - * Alias for [Builder.specializedChartParsingPlus]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun specializedChartParsingPlus(specializedChartParsingPlus: Boolean) = - specializedChartParsingPlus(specializedChartParsingPlus as Boolean?) - - /** - * Alias for calling [Builder.specializedChartParsingPlus] with - * `specializedChartParsingPlus.orElse(null)`. - */ - fun specializedChartParsingPlus( - specializedChartParsingPlus: Optional - ) = specializedChartParsingPlus(specializedChartParsingPlus.getOrNull()) - - /** - * Sets [Builder.specializedChartParsingPlus] to an arbitrary JSON value. - * - * You should usually call [Builder.specializedChartParsingPlus] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun specializedChartParsingPlus( - specializedChartParsingPlus: JsonField - ) = apply { this.specializedChartParsingPlus = specializedChartParsingPlus } - - fun specializedImageParsing(specializedImageParsing: Boolean?) = - specializedImageParsing(JsonField.ofNullable(specializedImageParsing)) - - /** - * Alias for [Builder.specializedImageParsing]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun specializedImageParsing(specializedImageParsing: Boolean) = - specializedImageParsing(specializedImageParsing as Boolean?) - - /** - * Alias for calling [Builder.specializedImageParsing] with - * `specializedImageParsing.orElse(null)`. - */ - fun specializedImageParsing(specializedImageParsing: Optional) = - specializedImageParsing(specializedImageParsing.getOrNull()) - - /** - * Sets [Builder.specializedImageParsing] to an arbitrary JSON value. - * - * You should usually call [Builder.specializedImageParsing] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun specializedImageParsing(specializedImageParsing: JsonField) = - apply { - this.specializedImageParsing = specializedImageParsing - } - - fun spreadsheetExtractSubTables(spreadsheetExtractSubTables: Boolean?) = - spreadsheetExtractSubTables( - JsonField.ofNullable(spreadsheetExtractSubTables) - ) - - /** - * Alias for [Builder.spreadsheetExtractSubTables]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun spreadsheetExtractSubTables(spreadsheetExtractSubTables: Boolean) = - spreadsheetExtractSubTables(spreadsheetExtractSubTables as Boolean?) - - /** - * Alias for calling [Builder.spreadsheetExtractSubTables] with - * `spreadsheetExtractSubTables.orElse(null)`. - */ - fun spreadsheetExtractSubTables( - spreadsheetExtractSubTables: Optional - ) = spreadsheetExtractSubTables(spreadsheetExtractSubTables.getOrNull()) - - /** - * Sets [Builder.spreadsheetExtractSubTables] to an arbitrary JSON value. - * - * You should usually call [Builder.spreadsheetExtractSubTables] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun spreadsheetExtractSubTables( - spreadsheetExtractSubTables: JsonField - ) = apply { this.spreadsheetExtractSubTables = spreadsheetExtractSubTables } - - fun spreadsheetForceFormulaComputation( - spreadsheetForceFormulaComputation: Boolean? - ) = - spreadsheetForceFormulaComputation( - JsonField.ofNullable(spreadsheetForceFormulaComputation) - ) - - /** - * Alias for [Builder.spreadsheetForceFormulaComputation]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun spreadsheetForceFormulaComputation( - spreadsheetForceFormulaComputation: Boolean - ) = - spreadsheetForceFormulaComputation( - spreadsheetForceFormulaComputation as Boolean? - ) - - /** - * Alias for calling [Builder.spreadsheetForceFormulaComputation] with - * `spreadsheetForceFormulaComputation.orElse(null)`. - */ - fun spreadsheetForceFormulaComputation( - spreadsheetForceFormulaComputation: Optional - ) = - spreadsheetForceFormulaComputation( - spreadsheetForceFormulaComputation.getOrNull() - ) - - /** - * Sets [Builder.spreadsheetForceFormulaComputation] to an arbitrary JSON - * value. - * - * You should usually call [Builder.spreadsheetForceFormulaComputation] with - * a well-typed [Boolean] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun spreadsheetForceFormulaComputation( - spreadsheetForceFormulaComputation: JsonField - ) = apply { - this.spreadsheetForceFormulaComputation = - spreadsheetForceFormulaComputation - } - - fun spreadsheetIncludeHiddenSheets( - spreadsheetIncludeHiddenSheets: Boolean? - ) = - spreadsheetIncludeHiddenSheets( - JsonField.ofNullable(spreadsheetIncludeHiddenSheets) - ) - - /** - * Alias for [Builder.spreadsheetIncludeHiddenSheets]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun spreadsheetIncludeHiddenSheets( - spreadsheetIncludeHiddenSheets: Boolean - ) = - spreadsheetIncludeHiddenSheets( - spreadsheetIncludeHiddenSheets as Boolean? - ) - - /** - * Alias for calling [Builder.spreadsheetIncludeHiddenSheets] with - * `spreadsheetIncludeHiddenSheets.orElse(null)`. - */ - fun spreadsheetIncludeHiddenSheets( - spreadsheetIncludeHiddenSheets: Optional - ) = - spreadsheetIncludeHiddenSheets( - spreadsheetIncludeHiddenSheets.getOrNull() - ) - - /** - * Sets [Builder.spreadsheetIncludeHiddenSheets] to an arbitrary JSON value. - * - * You should usually call [Builder.spreadsheetIncludeHiddenSheets] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun spreadsheetIncludeHiddenSheets( - spreadsheetIncludeHiddenSheets: JsonField - ) = apply { - this.spreadsheetIncludeHiddenSheets = spreadsheetIncludeHiddenSheets - } - - fun strictModeBuggyFont(strictModeBuggyFont: Boolean?) = - strictModeBuggyFont(JsonField.ofNullable(strictModeBuggyFont)) - - /** - * Alias for [Builder.strictModeBuggyFont]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun strictModeBuggyFont(strictModeBuggyFont: Boolean) = - strictModeBuggyFont(strictModeBuggyFont as Boolean?) - - /** - * Alias for calling [Builder.strictModeBuggyFont] with - * `strictModeBuggyFont.orElse(null)`. - */ - fun strictModeBuggyFont(strictModeBuggyFont: Optional) = - strictModeBuggyFont(strictModeBuggyFont.getOrNull()) - - /** - * Sets [Builder.strictModeBuggyFont] to an arbitrary JSON value. - * - * You should usually call [Builder.strictModeBuggyFont] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun strictModeBuggyFont(strictModeBuggyFont: JsonField) = apply { - this.strictModeBuggyFont = strictModeBuggyFont - } - - fun strictModeImageExtraction(strictModeImageExtraction: Boolean?) = - strictModeImageExtraction( - JsonField.ofNullable(strictModeImageExtraction) - ) - - /** - * Alias for [Builder.strictModeImageExtraction]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun strictModeImageExtraction(strictModeImageExtraction: Boolean) = - strictModeImageExtraction(strictModeImageExtraction as Boolean?) - - /** - * Alias for calling [Builder.strictModeImageExtraction] with - * `strictModeImageExtraction.orElse(null)`. - */ - fun strictModeImageExtraction( - strictModeImageExtraction: Optional - ) = strictModeImageExtraction(strictModeImageExtraction.getOrNull()) - - /** - * Sets [Builder.strictModeImageExtraction] to an arbitrary JSON value. - * - * You should usually call [Builder.strictModeImageExtraction] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun strictModeImageExtraction( - strictModeImageExtraction: JsonField - ) = apply { this.strictModeImageExtraction = strictModeImageExtraction } - - fun strictModeImageOcr(strictModeImageOcr: Boolean?) = - strictModeImageOcr(JsonField.ofNullable(strictModeImageOcr)) - - /** - * Alias for [Builder.strictModeImageOcr]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun strictModeImageOcr(strictModeImageOcr: Boolean) = - strictModeImageOcr(strictModeImageOcr as Boolean?) - - /** - * Alias for calling [Builder.strictModeImageOcr] with - * `strictModeImageOcr.orElse(null)`. - */ - fun strictModeImageOcr(strictModeImageOcr: Optional) = - strictModeImageOcr(strictModeImageOcr.getOrNull()) - - /** - * Sets [Builder.strictModeImageOcr] to an arbitrary JSON value. - * - * You should usually call [Builder.strictModeImageOcr] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun strictModeImageOcr(strictModeImageOcr: JsonField) = apply { - this.strictModeImageOcr = strictModeImageOcr - } - - fun strictModeReconstruction(strictModeReconstruction: Boolean?) = - strictModeReconstruction(JsonField.ofNullable(strictModeReconstruction)) - - /** - * Alias for [Builder.strictModeReconstruction]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun strictModeReconstruction(strictModeReconstruction: Boolean) = - strictModeReconstruction(strictModeReconstruction as Boolean?) - - /** - * Alias for calling [Builder.strictModeReconstruction] with - * `strictModeReconstruction.orElse(null)`. - */ - fun strictModeReconstruction(strictModeReconstruction: Optional) = - strictModeReconstruction(strictModeReconstruction.getOrNull()) - - /** - * Sets [Builder.strictModeReconstruction] to an arbitrary JSON value. - * - * You should usually call [Builder.strictModeReconstruction] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun strictModeReconstruction(strictModeReconstruction: JsonField) = - apply { - this.strictModeReconstruction = strictModeReconstruction - } - - fun structuredOutput(structuredOutput: Boolean?) = - structuredOutput(JsonField.ofNullable(structuredOutput)) - - /** - * Alias for [Builder.structuredOutput]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun structuredOutput(structuredOutput: Boolean) = - structuredOutput(structuredOutput as Boolean?) - - /** - * Alias for calling [Builder.structuredOutput] with - * `structuredOutput.orElse(null)`. - */ - fun structuredOutput(structuredOutput: Optional) = - structuredOutput(structuredOutput.getOrNull()) - - /** - * Sets [Builder.structuredOutput] to an arbitrary JSON value. - * - * You should usually call [Builder.structuredOutput] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun structuredOutput(structuredOutput: JsonField) = apply { - this.structuredOutput = structuredOutput - } - - fun structuredOutputJsonSchema(structuredOutputJsonSchema: String?) = - structuredOutputJsonSchema( - JsonField.ofNullable(structuredOutputJsonSchema) - ) - - /** - * Alias for calling [Builder.structuredOutputJsonSchema] with - * `structuredOutputJsonSchema.orElse(null)`. - */ - fun structuredOutputJsonSchema( - structuredOutputJsonSchema: Optional - ) = structuredOutputJsonSchema(structuredOutputJsonSchema.getOrNull()) - - /** - * Sets [Builder.structuredOutputJsonSchema] to an arbitrary JSON value. - * - * You should usually call [Builder.structuredOutputJsonSchema] with a - * well-typed [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun structuredOutputJsonSchema( - structuredOutputJsonSchema: JsonField - ) = apply { this.structuredOutputJsonSchema = structuredOutputJsonSchema } - - fun structuredOutputJsonSchemaName( - structuredOutputJsonSchemaName: String? - ) = - structuredOutputJsonSchemaName( - JsonField.ofNullable(structuredOutputJsonSchemaName) - ) - - /** - * Alias for calling [Builder.structuredOutputJsonSchemaName] with - * `structuredOutputJsonSchemaName.orElse(null)`. - */ - fun structuredOutputJsonSchemaName( - structuredOutputJsonSchemaName: Optional - ) = - structuredOutputJsonSchemaName( - structuredOutputJsonSchemaName.getOrNull() - ) - - /** - * Sets [Builder.structuredOutputJsonSchemaName] to an arbitrary JSON value. - * - * You should usually call [Builder.structuredOutputJsonSchemaName] with a - * well-typed [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun structuredOutputJsonSchemaName( - structuredOutputJsonSchemaName: JsonField - ) = apply { - this.structuredOutputJsonSchemaName = structuredOutputJsonSchemaName - } - - 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 - } - - fun systemPromptAppend(systemPromptAppend: String?) = - systemPromptAppend(JsonField.ofNullable(systemPromptAppend)) - - /** - * Alias for calling [Builder.systemPromptAppend] with - * `systemPromptAppend.orElse(null)`. - */ - fun systemPromptAppend(systemPromptAppend: Optional) = - systemPromptAppend(systemPromptAppend.getOrNull()) - - /** - * Sets [Builder.systemPromptAppend] to an arbitrary JSON value. - * - * You should usually call [Builder.systemPromptAppend] with a well-typed - * [String] value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun systemPromptAppend(systemPromptAppend: JsonField) = apply { - this.systemPromptAppend = systemPromptAppend - } - - fun takeScreenshot(takeScreenshot: Boolean?) = - takeScreenshot(JsonField.ofNullable(takeScreenshot)) - - /** - * Alias for [Builder.takeScreenshot]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun takeScreenshot(takeScreenshot: Boolean) = - takeScreenshot(takeScreenshot as Boolean?) - - /** - * Alias for calling [Builder.takeScreenshot] with - * `takeScreenshot.orElse(null)`. - */ - fun takeScreenshot(takeScreenshot: Optional) = - takeScreenshot(takeScreenshot.getOrNull()) - - /** - * Sets [Builder.takeScreenshot] to an arbitrary JSON value. - * - * You should usually call [Builder.takeScreenshot] with a well-typed - * [Boolean] value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun takeScreenshot(takeScreenshot: JsonField) = apply { - this.takeScreenshot = takeScreenshot - } - - 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 - } - - fun tier(tier: String?) = tier(JsonField.ofNullable(tier)) - - /** Alias for calling [Builder.tier] with `tier.orElse(null)`. */ - fun tier(tier: Optional) = tier(tier.getOrNull()) - - /** - * Sets [Builder.tier] to an arbitrary JSON value. - * - * You should usually call [Builder.tier] with a well-typed [String] value - * instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun tier(tier: JsonField) = apply { this.tier = tier } - - 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 useVendorMultimodalModel(useVendorMultimodalModel: Boolean?) = - useVendorMultimodalModel(JsonField.ofNullable(useVendorMultimodalModel)) - - /** - * Alias for [Builder.useVendorMultimodalModel]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun useVendorMultimodalModel(useVendorMultimodalModel: Boolean) = - useVendorMultimodalModel(useVendorMultimodalModel as Boolean?) - - /** - * Alias for calling [Builder.useVendorMultimodalModel] with - * `useVendorMultimodalModel.orElse(null)`. - */ - fun useVendorMultimodalModel(useVendorMultimodalModel: Optional) = - useVendorMultimodalModel(useVendorMultimodalModel.getOrNull()) - - /** - * Sets [Builder.useVendorMultimodalModel] to an arbitrary JSON value. - * - * You should usually call [Builder.useVendorMultimodalModel] with a - * well-typed [Boolean] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun useVendorMultimodalModel(useVendorMultimodalModel: JsonField) = - apply { - this.useVendorMultimodalModel = useVendorMultimodalModel - } - - fun userPrompt(userPrompt: String?) = - userPrompt(JsonField.ofNullable(userPrompt)) - - /** - * Alias for calling [Builder.userPrompt] with `userPrompt.orElse(null)`. - */ - fun userPrompt(userPrompt: Optional) = - userPrompt(userPrompt.getOrNull()) - - /** - * Sets [Builder.userPrompt] to an arbitrary JSON value. - * - * You should usually call [Builder.userPrompt] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun userPrompt(userPrompt: JsonField) = apply { - this.userPrompt = userPrompt - } - - fun vendorMultimodalApiKey(vendorMultimodalApiKey: String?) = - vendorMultimodalApiKey(JsonField.ofNullable(vendorMultimodalApiKey)) - - /** - * Alias for calling [Builder.vendorMultimodalApiKey] with - * `vendorMultimodalApiKey.orElse(null)`. - */ - fun vendorMultimodalApiKey(vendorMultimodalApiKey: Optional) = - vendorMultimodalApiKey(vendorMultimodalApiKey.getOrNull()) - - /** - * Sets [Builder.vendorMultimodalApiKey] to an arbitrary JSON value. - * - * You should usually call [Builder.vendorMultimodalApiKey] with a - * well-typed [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun vendorMultimodalApiKey(vendorMultimodalApiKey: JsonField) = - apply { - this.vendorMultimodalApiKey = vendorMultimodalApiKey - } - - fun vendorMultimodalModelName(vendorMultimodalModelName: String?) = - vendorMultimodalModelName( - JsonField.ofNullable(vendorMultimodalModelName) - ) - - /** - * Alias for calling [Builder.vendorMultimodalModelName] with - * `vendorMultimodalModelName.orElse(null)`. - */ - fun vendorMultimodalModelName(vendorMultimodalModelName: Optional) = - vendorMultimodalModelName(vendorMultimodalModelName.getOrNull()) - - /** - * Sets [Builder.vendorMultimodalModelName] to an arbitrary JSON value. - * - * You should usually call [Builder.vendorMultimodalModelName] with a - * well-typed [String] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun vendorMultimodalModelName( - vendorMultimodalModelName: JsonField - ) = apply { this.vendorMultimodalModelName = vendorMultimodalModelName } - - 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 } - - /** Outbound webhook endpoints to notify on job status changes */ - fun webhookConfigurations( - webhookConfigurations: List? - ) = webhookConfigurations(JsonField.ofNullable(webhookConfigurations)) - - /** - * Alias for calling [Builder.webhookConfigurations] with - * `webhookConfigurations.orElse(null)`. - */ - fun webhookConfigurations( - webhookConfigurations: Optional> - ) = webhookConfigurations(webhookConfigurations.getOrNull()) - - /** - * Sets [Builder.webhookConfigurations] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookConfigurations] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun webhookConfigurations( - webhookConfigurations: JsonField> - ) = apply { - this.webhookConfigurations = - webhookConfigurations.map { it.toMutableList() } - } - - /** - * Adds a single [WebhookConfiguration] to [webhookConfigurations]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addWebhookConfiguration(webhookConfiguration: WebhookConfiguration) = - apply { - webhookConfigurations = - (webhookConfigurations ?: JsonField.of(mutableListOf())).also { - checkKnown("webhookConfigurations", it) - .add(webhookConfiguration) - } - } - - fun webhookUrl(webhookUrl: String?) = - webhookUrl(JsonField.ofNullable(webhookUrl)) - - /** - * Alias for calling [Builder.webhookUrl] with `webhookUrl.orElse(null)`. - */ - fun webhookUrl(webhookUrl: Optional) = - webhookUrl(webhookUrl.getOrNull()) - - /** - * Sets [Builder.webhookUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookUrl] with a well-typed [String] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun webhookUrl(webhookUrl: JsonField) = apply { - this.webhookUrl = webhookUrl - } - - 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 [Parameters]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Parameters = - Parameters( - adaptiveLongTable, - aggressiveTableExtraction, - annotateLinks, - annotateRevisions, - autoMode, - autoModeConfigurationJson, - autoModeTriggerOnImageInPage, - autoModeTriggerOnRegexpInPage, - autoModeTriggerOnTableInPage, - autoModeTriggerOnTextInPage, - azureOpenAIApiVersion, - azureOpenAIDeploymentName, - azureOpenAIEndpoint, - azureOpenAIKey, - bboxBottom, - bboxLeft, - bboxRight, - bboxTop, - boundingBox, - compactMarkdownTable, - complementalFormattingInstruction, - confidenceScoreEffort, - contentGuidelineInstruction, - continuousMode, - customMetadata, - disableImageExtraction, - disableOcr, - disableReconstruction, - doNotCache, - doNotUnrollColumns, - enableCostOptimizer, - extractCharts, - extractLayout, - extractPrintedPageNumber, - fastMode, - formattingInstruction, - gpt4oApiKey, - gpt4oMode, - guessXlsxSheetName, - hideFooters, - hideHeaders, - highResOcr, - htmlMakeAllElementsVisible, - htmlRemoveFixedElements, - htmlRemoveNavigationElements, - httpProxy, - ignoreDocumentElementsForLayoutDetection, - (imagesToSave ?: JsonMissing.of()).map { it.toImmutable() }, - inlineImagesInMarkdown, - inputS3Path, - inputS3Region, - inputUrl, - internalIsScreenshotJob, - invalidateCache, - isFormattingInstruction, - jobTimeoutExtraTimePerPageInSeconds, - jobTimeoutInSeconds, - keepPageSeparatorWhenMergingTables, - lang, - (languages ?: JsonMissing.of()).map { it.toImmutable() }, - layoutAware, - lineLevelBoundingBox, - markdownTableMultilineHeaderSeparator, - maxPages, - maxPagesEnforced, - mergeTablesAcrossPagesInMarkdown, - model, - outlinedTableExtraction, - outputPdfOfDocument, - outputS3PathPrefix, - outputS3Region, - outputTablesAsHtml, - outputBucket, - pageErrorTolerance, - pageFooterPrefix, - pageFooterSuffix, - pageHeaderPrefix, - pageHeaderSuffix, - pagePrefix, - pageSeparator, - pageSuffix, - parseMode, - parsingInstruction, - pipelineId, - preciseBoundingBox, - premiumMode, - presentationOutOfBoundsContent, - presentationSkipEmbeddedData, - preserveLayoutAlignmentAcrossPages, - preserveVerySmallText, - preset, - priority, - projectId, - removeHiddenText, - replaceFailedPageMode, - replaceFailedPageWithErrorMessagePrefix, - replaceFailedPageWithErrorMessageSuffix, - resourceInfo, - saveImages, - skipDiagonalText, - specializedChartParsingAgentic, - specializedChartParsingEfficient, - specializedChartParsingPlus, - specializedImageParsing, - spreadsheetExtractSubTables, - spreadsheetForceFormulaComputation, - spreadsheetIncludeHiddenSheets, - strictModeBuggyFont, - strictModeImageExtraction, - strictModeImageOcr, - strictModeReconstruction, - structuredOutput, - structuredOutputJsonSchema, - structuredOutputJsonSchemaName, - systemPrompt, - systemPromptAppend, - takeScreenshot, - targetPages, - tier, - type, - useVendorMultimodalModel, - userPrompt, - vendorMultimodalApiKey, - vendorMultimodalModelName, - version, - (webhookConfigurations ?: JsonMissing.of()).map { - it.toImmutable() - }, - webhookUrl, - 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(): Parameters = apply { - if (validated) { - return@apply - } - - adaptiveLongTable() - aggressiveTableExtraction() - annotateLinks() - annotateRevisions() - autoMode() - autoModeConfigurationJson() - autoModeTriggerOnImageInPage() - autoModeTriggerOnRegexpInPage() - autoModeTriggerOnTableInPage() - autoModeTriggerOnTextInPage() - azureOpenAIApiVersion() - azureOpenAIDeploymentName() - azureOpenAIEndpoint() - azureOpenAIKey() - bboxBottom() - bboxLeft() - bboxRight() - bboxTop() - boundingBox() - compactMarkdownTable() - complementalFormattingInstruction() - confidenceScoreEffort() - contentGuidelineInstruction() - continuousMode() - customMetadata().ifPresent { it.validate() } - disableImageExtraction() - disableOcr() - disableReconstruction() - doNotCache() - doNotUnrollColumns() - enableCostOptimizer() - extractCharts() - extractLayout() - extractPrintedPageNumber() - fastMode() - formattingInstruction() - gpt4oApiKey() - gpt4oMode() - guessXlsxSheetName() - hideFooters() - hideHeaders() - highResOcr() - htmlMakeAllElementsVisible() - htmlRemoveFixedElements() - htmlRemoveNavigationElements() - httpProxy() - ignoreDocumentElementsForLayoutDetection() - imagesToSave().ifPresent { it.forEach { it.validate() } } - inlineImagesInMarkdown() - inputS3Path() - inputS3Region() - inputUrl() - internalIsScreenshotJob() - invalidateCache() - isFormattingInstruction() - jobTimeoutExtraTimePerPageInSeconds() - jobTimeoutInSeconds() - keepPageSeparatorWhenMergingTables() - lang() - languages().ifPresent { it.forEach { it.validate() } } - layoutAware() - lineLevelBoundingBox() - markdownTableMultilineHeaderSeparator() - maxPages() - maxPagesEnforced() - mergeTablesAcrossPagesInMarkdown() - model() - outlinedTableExtraction() - outputPdfOfDocument() - outputS3PathPrefix() - outputS3Region() - outputTablesAsHtml() - outputBucket() - pageErrorTolerance() - pageFooterPrefix() - pageFooterSuffix() - pageHeaderPrefix() - pageHeaderSuffix() - pagePrefix() - pageSeparator() - pageSuffix() - parseMode().ifPresent { it.validate() } - parsingInstruction() - pipelineId() - preciseBoundingBox() - premiumMode() - presentationOutOfBoundsContent() - presentationSkipEmbeddedData() - preserveLayoutAlignmentAcrossPages() - preserveVerySmallText() - preset() - priority().ifPresent { it.validate() } - projectId() - removeHiddenText() - replaceFailedPageMode().ifPresent { it.validate() } - replaceFailedPageWithErrorMessagePrefix() - replaceFailedPageWithErrorMessageSuffix() - resourceInfo().ifPresent { it.validate() } - saveImages() - skipDiagonalText() - specializedChartParsingAgentic() - specializedChartParsingEfficient() - specializedChartParsingPlus() - specializedImageParsing() - spreadsheetExtractSubTables() - spreadsheetForceFormulaComputation() - spreadsheetIncludeHiddenSheets() - strictModeBuggyFont() - strictModeImageExtraction() - strictModeImageOcr() - strictModeReconstruction() - structuredOutput() - structuredOutputJsonSchema() - structuredOutputJsonSchemaName() - systemPrompt() - systemPromptAppend() - takeScreenshot() - targetPages() - tier() - type().ifPresent { it.validate() } - useVendorMultimodalModel() - userPrompt() - vendorMultimodalApiKey() - vendorMultimodalModelName() - version() - webhookConfigurations().ifPresent { it.forEach { it.validate() } } - webhookUrl() - 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 (adaptiveLongTable.asKnown().isPresent) 1 else 0) + - (if (aggressiveTableExtraction.asKnown().isPresent) 1 else 0) + - (if (annotateLinks.asKnown().isPresent) 1 else 0) + - (if (annotateRevisions.asKnown().isPresent) 1 else 0) + - (if (autoMode.asKnown().isPresent) 1 else 0) + - (if (autoModeConfigurationJson.asKnown().isPresent) 1 else 0) + - (if (autoModeTriggerOnImageInPage.asKnown().isPresent) 1 else 0) + - (if (autoModeTriggerOnRegexpInPage.asKnown().isPresent) 1 else 0) + - (if (autoModeTriggerOnTableInPage.asKnown().isPresent) 1 else 0) + - (if (autoModeTriggerOnTextInPage.asKnown().isPresent) 1 else 0) + - (if (azureOpenAIApiVersion.asKnown().isPresent) 1 else 0) + - (if (azureOpenAIDeploymentName.asKnown().isPresent) 1 else 0) + - (if (azureOpenAIEndpoint.asKnown().isPresent) 1 else 0) + - (if (azureOpenAIKey.asKnown().isPresent) 1 else 0) + - (if (bboxBottom.asKnown().isPresent) 1 else 0) + - (if (bboxLeft.asKnown().isPresent) 1 else 0) + - (if (bboxRight.asKnown().isPresent) 1 else 0) + - (if (bboxTop.asKnown().isPresent) 1 else 0) + - (if (boundingBox.asKnown().isPresent) 1 else 0) + - (if (compactMarkdownTable.asKnown().isPresent) 1 else 0) + - (if (complementalFormattingInstruction.asKnown().isPresent) 1 else 0) + - (if (confidenceScoreEffort.asKnown().isPresent) 1 else 0) + - (if (contentGuidelineInstruction.asKnown().isPresent) 1 else 0) + - (if (continuousMode.asKnown().isPresent) 1 else 0) + - (customMetadata.asKnown().getOrNull()?.validity() ?: 0) + - (if (disableImageExtraction.asKnown().isPresent) 1 else 0) + - (if (disableOcr.asKnown().isPresent) 1 else 0) + - (if (disableReconstruction.asKnown().isPresent) 1 else 0) + - (if (doNotCache.asKnown().isPresent) 1 else 0) + - (if (doNotUnrollColumns.asKnown().isPresent) 1 else 0) + - (if (enableCostOptimizer.asKnown().isPresent) 1 else 0) + - (if (extractCharts.asKnown().isPresent) 1 else 0) + - (if (extractLayout.asKnown().isPresent) 1 else 0) + - (if (extractPrintedPageNumber.asKnown().isPresent) 1 else 0) + - (if (fastMode.asKnown().isPresent) 1 else 0) + - (if (formattingInstruction.asKnown().isPresent) 1 else 0) + - (if (gpt4oApiKey.asKnown().isPresent) 1 else 0) + - (if (gpt4oMode.asKnown().isPresent) 1 else 0) + - (if (guessXlsxSheetName.asKnown().isPresent) 1 else 0) + - (if (hideFooters.asKnown().isPresent) 1 else 0) + - (if (hideHeaders.asKnown().isPresent) 1 else 0) + - (if (highResOcr.asKnown().isPresent) 1 else 0) + - (if (htmlMakeAllElementsVisible.asKnown().isPresent) 1 else 0) + - (if (htmlRemoveFixedElements.asKnown().isPresent) 1 else 0) + - (if (htmlRemoveNavigationElements.asKnown().isPresent) 1 else 0) + - (if (httpProxy.asKnown().isPresent) 1 else 0) + - (if (ignoreDocumentElementsForLayoutDetection.asKnown().isPresent) 1 - else 0) + - (imagesToSave.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (if (inlineImagesInMarkdown.asKnown().isPresent) 1 else 0) + - (if (inputS3Path.asKnown().isPresent) 1 else 0) + - (if (inputS3Region.asKnown().isPresent) 1 else 0) + - (if (inputUrl.asKnown().isPresent) 1 else 0) + - (if (internalIsScreenshotJob.asKnown().isPresent) 1 else 0) + - (if (invalidateCache.asKnown().isPresent) 1 else 0) + - (if (isFormattingInstruction.asKnown().isPresent) 1 else 0) + - (if (jobTimeoutExtraTimePerPageInSeconds.asKnown().isPresent) 1 - else 0) + - (if (jobTimeoutInSeconds.asKnown().isPresent) 1 else 0) + - (if (keepPageSeparatorWhenMergingTables.asKnown().isPresent) 1 else 0) + - (if (lang.asKnown().isPresent) 1 else 0) + - (languages.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (if (layoutAware.asKnown().isPresent) 1 else 0) + - (if (lineLevelBoundingBox.asKnown().isPresent) 1 else 0) + - (if (markdownTableMultilineHeaderSeparator.asKnown().isPresent) 1 - else 0) + - (if (maxPages.asKnown().isPresent) 1 else 0) + - (if (maxPagesEnforced.asKnown().isPresent) 1 else 0) + - (if (mergeTablesAcrossPagesInMarkdown.asKnown().isPresent) 1 else 0) + - (if (model.asKnown().isPresent) 1 else 0) + - (if (outlinedTableExtraction.asKnown().isPresent) 1 else 0) + - (if (outputPdfOfDocument.asKnown().isPresent) 1 else 0) + - (if (outputS3PathPrefix.asKnown().isPresent) 1 else 0) + - (if (outputS3Region.asKnown().isPresent) 1 else 0) + - (if (outputTablesAsHtml.asKnown().isPresent) 1 else 0) + - (if (outputBucket.asKnown().isPresent) 1 else 0) + - (if (pageErrorTolerance.asKnown().isPresent) 1 else 0) + - (if (pageFooterPrefix.asKnown().isPresent) 1 else 0) + - (if (pageFooterSuffix.asKnown().isPresent) 1 else 0) + - (if (pageHeaderPrefix.asKnown().isPresent) 1 else 0) + - (if (pageHeaderSuffix.asKnown().isPresent) 1 else 0) + - (if (pagePrefix.asKnown().isPresent) 1 else 0) + - (if (pageSeparator.asKnown().isPresent) 1 else 0) + - (if (pageSuffix.asKnown().isPresent) 1 else 0) + - (parseMode.asKnown().getOrNull()?.validity() ?: 0) + - (if (parsingInstruction.asKnown().isPresent) 1 else 0) + - (if (pipelineId.asKnown().isPresent) 1 else 0) + - (if (preciseBoundingBox.asKnown().isPresent) 1 else 0) + - (if (premiumMode.asKnown().isPresent) 1 else 0) + - (if (presentationOutOfBoundsContent.asKnown().isPresent) 1 else 0) + - (if (presentationSkipEmbeddedData.asKnown().isPresent) 1 else 0) + - (if (preserveLayoutAlignmentAcrossPages.asKnown().isPresent) 1 else 0) + - (if (preserveVerySmallText.asKnown().isPresent) 1 else 0) + - (if (preset.asKnown().isPresent) 1 else 0) + - (priority.asKnown().getOrNull()?.validity() ?: 0) + - (if (projectId.asKnown().isPresent) 1 else 0) + - (if (removeHiddenText.asKnown().isPresent) 1 else 0) + - (replaceFailedPageMode.asKnown().getOrNull()?.validity() ?: 0) + - (if (replaceFailedPageWithErrorMessagePrefix.asKnown().isPresent) 1 - else 0) + - (if (replaceFailedPageWithErrorMessageSuffix.asKnown().isPresent) 1 - else 0) + - (resourceInfo.asKnown().getOrNull()?.validity() ?: 0) + - (if (saveImages.asKnown().isPresent) 1 else 0) + - (if (skipDiagonalText.asKnown().isPresent) 1 else 0) + - (if (specializedChartParsingAgentic.asKnown().isPresent) 1 else 0) + - (if (specializedChartParsingEfficient.asKnown().isPresent) 1 else 0) + - (if (specializedChartParsingPlus.asKnown().isPresent) 1 else 0) + - (if (specializedImageParsing.asKnown().isPresent) 1 else 0) + - (if (spreadsheetExtractSubTables.asKnown().isPresent) 1 else 0) + - (if (spreadsheetForceFormulaComputation.asKnown().isPresent) 1 else 0) + - (if (spreadsheetIncludeHiddenSheets.asKnown().isPresent) 1 else 0) + - (if (strictModeBuggyFont.asKnown().isPresent) 1 else 0) + - (if (strictModeImageExtraction.asKnown().isPresent) 1 else 0) + - (if (strictModeImageOcr.asKnown().isPresent) 1 else 0) + - (if (strictModeReconstruction.asKnown().isPresent) 1 else 0) + - (if (structuredOutput.asKnown().isPresent) 1 else 0) + - (if (structuredOutputJsonSchema.asKnown().isPresent) 1 else 0) + - (if (structuredOutputJsonSchemaName.asKnown().isPresent) 1 else 0) + - (if (systemPrompt.asKnown().isPresent) 1 else 0) + - (if (systemPromptAppend.asKnown().isPresent) 1 else 0) + - (if (takeScreenshot.asKnown().isPresent) 1 else 0) + - (if (targetPages.asKnown().isPresent) 1 else 0) + - (if (tier.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (useVendorMultimodalModel.asKnown().isPresent) 1 else 0) + - (if (userPrompt.asKnown().isPresent) 1 else 0) + - (if (vendorMultimodalApiKey.asKnown().isPresent) 1 else 0) + - (if (vendorMultimodalModelName.asKnown().isPresent) 1 else 0) + - (if (version.asKnown().isPresent) 1 else 0) + - (webhookConfigurations.asKnown().getOrNull()?.sumOf { - it.validity().toInt() - } ?: 0) + - (if (webhookUrl.asKnown().isPresent) 1 else 0) - - /** The custom metadata to attach to the documents. */ - class CustomMetadata - @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 - * [CustomMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [CustomMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(customMetadata: CustomMetadata) = apply { - additionalProperties = - customMetadata.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 [CustomMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): CustomMetadata = - CustomMetadata(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(): CustomMetadata = 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 CustomMetadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CustomMetadata{additionalProperties=$additionalProperties}" - } - - class ImagesToSave - @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 EMBEDDED = of("embedded") - - @JvmField val LAYOUT = of("layout") - - @JvmField val SCREENSHOT = of("screenshot") - - @JvmStatic fun of(value: String) = ImagesToSave(JsonField.of(value)) - } - - /** An enum containing [ImagesToSave]'s known values. */ - enum class Known { - EMBEDDED, - LAYOUT, - SCREENSHOT, - } - - /** - * An enum containing [ImagesToSave]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [ImagesToSave] 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 { - EMBEDDED, - LAYOUT, - SCREENSHOT, - /** - * An enum member indicating that [ImagesToSave] 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) { - EMBEDDED -> Value.EMBEDDED - LAYOUT -> Value.LAYOUT - SCREENSHOT -> Value.SCREENSHOT - 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) { - EMBEDDED -> Known.EMBEDDED - LAYOUT -> Known.LAYOUT - SCREENSHOT -> Known.SCREENSHOT - else -> - throw LlamaCloudInvalidDataException( - "Unknown ImagesToSave: $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(): ImagesToSave = 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 ImagesToSave && 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() - } - - /** The resource info about the file */ - class ResourceInfo - @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 - * [ResourceInfo]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [ResourceInfo]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(resourceInfo: ResourceInfo) = apply { - additionalProperties = - resourceInfo.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 [ResourceInfo]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): ResourceInfo = - ResourceInfo(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(): ResourceInfo = 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 ResourceInfo && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ResourceInfo{additionalProperties=$additionalProperties}" - } - - class Type - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data - * that doesn't match any known member, and you want to know that value. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val PARSE = of("parse") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - PARSE - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API - * may respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - PARSE, - /** - * An enum member indicating that [Type] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always - * known or if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - 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) { - PARSE -> Known.PARSE - else -> throw LlamaCloudInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily - * for debugging and generally doesn't throw. - * - * @throws 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(): Type = 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 Type && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Configuration for a single outbound webhook endpoint. */ - class WebhookConfiguration - @JsonCreator(mode = JsonCreator.Mode.DISABLED) - private constructor( - private val webhookEvents: JsonField>, - private val webhookHeaders: JsonField, - private val webhookOutputFormat: JsonField, - private val webhookSigningSecret: JsonField, - private val webhookUrl: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("webhook_events") - @ExcludeMissing - webhookEvents: JsonField> = JsonMissing.of(), - @JsonProperty("webhook_headers") - @ExcludeMissing - webhookHeaders: JsonField = JsonMissing.of(), - @JsonProperty("webhook_output_format") - @ExcludeMissing - webhookOutputFormat: JsonField = JsonMissing.of(), - @JsonProperty("webhook_signing_secret") - @ExcludeMissing - webhookSigningSecret: JsonField = JsonMissing.of(), - @JsonProperty("webhook_url") - @ExcludeMissing - webhookUrl: JsonField = JsonMissing.of(), - ) : this( - webhookEvents, - webhookHeaders, - webhookOutputFormat, - webhookSigningSecret, - webhookUrl, - mutableMapOf(), - ) - - /** - * Events to subscribe to (e.g. 'parse.success', 'extract.error'). If null, - * all events are delivered. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun webhookEvents(): Optional> = - webhookEvents.getOptional("webhook_events") - - /** - * Custom HTTP headers sent with each webhook request (e.g. auth tokens) - * - * @throws LlamaCloudInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun webhookHeaders(): Optional = - webhookHeaders.getOptional("webhook_headers") - - /** - * Response format sent to the webhook: 'string' (default) or 'json' - * - * @throws LlamaCloudInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun webhookOutputFormat(): Optional = - webhookOutputFormat.getOptional("webhook_output_format") - - /** - * Shared signing secret used to sign webhook deliveries. When set, each - * request includes an HMAC-SHA256 signature of the request body in the - * 'LC-Signature' header (value 'sha256='). Recompute the HMAC over the - * raw request body with this secret to verify the delivery is authentic. - * - * @throws LlamaCloudInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun webhookSigningSecret(): Optional = - webhookSigningSecret.getOptional("webhook_signing_secret") - - /** - * URL to receive webhook POST notifications - * - * @throws LlamaCloudInvalidDataException if the JSON field has an - * unexpected type (e.g. if the server responded with an unexpected - * value). - */ - fun webhookUrl(): Optional = webhookUrl.getOptional("webhook_url") - - /** - * Returns the raw JSON value of [webhookEvents]. - * - * Unlike [webhookEvents], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("webhook_events") - @ExcludeMissing - fun _webhookEvents(): JsonField> = webhookEvents - - /** - * Returns the raw JSON value of [webhookHeaders]. - * - * Unlike [webhookHeaders], this method doesn't throw if the JSON field has - * an unexpected type. - */ - @JsonProperty("webhook_headers") - @ExcludeMissing - fun _webhookHeaders(): JsonField = webhookHeaders - - /** - * Returns the raw JSON value of [webhookOutputFormat]. - * - * Unlike [webhookOutputFormat], this method doesn't throw if the JSON field - * has an unexpected type. - */ - @JsonProperty("webhook_output_format") - @ExcludeMissing - fun _webhookOutputFormat(): JsonField = webhookOutputFormat - - /** - * Returns the raw JSON value of [webhookSigningSecret]. - * - * Unlike [webhookSigningSecret], this method doesn't throw if the JSON - * field has an unexpected type. - */ - @JsonProperty("webhook_signing_secret") - @ExcludeMissing - fun _webhookSigningSecret(): JsonField = webhookSigningSecret - - /** - * Returns the raw JSON value of [webhookUrl]. - * - * Unlike [webhookUrl], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("webhook_url") - @ExcludeMissing - fun _webhookUrl(): JsonField = webhookUrl - - @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 - * [WebhookConfiguration]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [WebhookConfiguration]. */ - class Builder internal constructor() { - - private var webhookEvents: JsonField>? = null - private var webhookHeaders: JsonField = JsonMissing.of() - private var webhookOutputFormat: JsonField = JsonMissing.of() - private var webhookSigningSecret: JsonField = JsonMissing.of() - private var webhookUrl: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(webhookConfiguration: WebhookConfiguration) = apply { - webhookEvents = - webhookConfiguration.webhookEvents.map { it.toMutableList() } - webhookHeaders = webhookConfiguration.webhookHeaders - webhookOutputFormat = webhookConfiguration.webhookOutputFormat - webhookSigningSecret = webhookConfiguration.webhookSigningSecret - webhookUrl = webhookConfiguration.webhookUrl - additionalProperties = - webhookConfiguration.additionalProperties.toMutableMap() - } - - /** - * Events to subscribe to (e.g. 'parse.success', 'extract.error'). If - * null, all events are delivered. - */ - fun webhookEvents(webhookEvents: List?) = - webhookEvents(JsonField.ofNullable(webhookEvents)) - - /** - * Alias for calling [Builder.webhookEvents] with - * `webhookEvents.orElse(null)`. - */ - fun webhookEvents(webhookEvents: Optional>) = - webhookEvents(webhookEvents.getOrNull()) - - /** - * Sets [Builder.webhookEvents] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookEvents] with a well-typed - * `List` value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun webhookEvents(webhookEvents: JsonField>) = - apply { - this.webhookEvents = webhookEvents.map { it.toMutableList() } - } - - /** - * Adds a single [WebhookEvent] to [webhookEvents]. - * - * @throws IllegalStateException if the field was previously set to a - * non-list. - */ - fun addWebhookEvent(webhookEvent: WebhookEvent) = apply { - webhookEvents = - (webhookEvents ?: JsonField.of(mutableListOf())).also { - checkKnown("webhookEvents", it).add(webhookEvent) - } - } - - /** - * Custom HTTP headers sent with each webhook request (e.g. auth tokens) - */ - fun webhookHeaders(webhookHeaders: WebhookHeaders?) = - webhookHeaders(JsonField.ofNullable(webhookHeaders)) - - /** - * Alias for calling [Builder.webhookHeaders] with - * `webhookHeaders.orElse(null)`. - */ - fun webhookHeaders(webhookHeaders: Optional) = - webhookHeaders(webhookHeaders.getOrNull()) - - /** - * Sets [Builder.webhookHeaders] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookHeaders] with a well-typed - * [WebhookHeaders] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun webhookHeaders(webhookHeaders: JsonField) = apply { - this.webhookHeaders = webhookHeaders - } - - /** Response format sent to the webhook: 'string' (default) or 'json' */ - fun webhookOutputFormat(webhookOutputFormat: String?) = - webhookOutputFormat(JsonField.ofNullable(webhookOutputFormat)) - - /** - * Alias for calling [Builder.webhookOutputFormat] with - * `webhookOutputFormat.orElse(null)`. - */ - fun webhookOutputFormat(webhookOutputFormat: Optional) = - webhookOutputFormat(webhookOutputFormat.getOrNull()) - - /** - * Sets [Builder.webhookOutputFormat] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookOutputFormat] with a - * well-typed [String] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun webhookOutputFormat(webhookOutputFormat: JsonField) = - apply { - this.webhookOutputFormat = webhookOutputFormat - } - - /** - * Shared signing secret used to sign webhook deliveries. When set, each - * request includes an HMAC-SHA256 signature of the request body in the - * 'LC-Signature' header (value 'sha256='). Recompute the HMAC over - * the raw request body with this secret to verify the delivery is - * authentic. - */ - fun webhookSigningSecret(webhookSigningSecret: String?) = - webhookSigningSecret(JsonField.ofNullable(webhookSigningSecret)) - - /** - * Alias for calling [Builder.webhookSigningSecret] with - * `webhookSigningSecret.orElse(null)`. - */ - fun webhookSigningSecret(webhookSigningSecret: Optional) = - webhookSigningSecret(webhookSigningSecret.getOrNull()) - - /** - * Sets [Builder.webhookSigningSecret] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookSigningSecret] with a - * well-typed [String] value instead. This method is primarily for - * setting the field to an undocumented or not yet supported value. - */ - fun webhookSigningSecret(webhookSigningSecret: JsonField) = - apply { - this.webhookSigningSecret = webhookSigningSecret - } - - /** URL to receive webhook POST notifications */ - fun webhookUrl(webhookUrl: String?) = - webhookUrl(JsonField.ofNullable(webhookUrl)) - - /** - * Alias for calling [Builder.webhookUrl] with - * `webhookUrl.orElse(null)`. - */ - fun webhookUrl(webhookUrl: Optional) = - webhookUrl(webhookUrl.getOrNull()) - - /** - * Sets [Builder.webhookUrl] to an arbitrary JSON value. - * - * You should usually call [Builder.webhookUrl] with a well-typed - * [String] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun webhookUrl(webhookUrl: JsonField) = apply { - this.webhookUrl = webhookUrl - } - - 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 [WebhookConfiguration]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): WebhookConfiguration = - WebhookConfiguration( - (webhookEvents ?: JsonMissing.of()).map { it.toImmutable() }, - webhookHeaders, - webhookOutputFormat, - webhookSigningSecret, - webhookUrl, - 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(): WebhookConfiguration = apply { - if (validated) { - return@apply - } - - webhookEvents().ifPresent { it.forEach { it.validate() } } - webhookHeaders().ifPresent { it.validate() } - webhookOutputFormat() - webhookSigningSecret() - webhookUrl() - 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 = - (webhookEvents.asKnown().getOrNull()?.sumOf { it.validity().toInt() } - ?: 0) + - (webhookHeaders.asKnown().getOrNull()?.validity() ?: 0) + - (if (webhookOutputFormat.asKnown().isPresent) 1 else 0) + - (if (webhookSigningSecret.asKnown().isPresent) 1 else 0) + - (if (webhookUrl.asKnown().isPresent) 1 else 0) - - class WebhookEvent - @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 BATCH_CANCELLED = of("batch.cancelled") - - @JvmField val BATCH_ERROR = of("batch.error") - - @JvmField val BATCH_PENDING = of("batch.pending") - - @JvmField val BATCH_RUNNING = of("batch.running") - - @JvmField val BATCH_SUCCESS = of("batch.success") - - @JvmField val CLASSIFY_CANCELLED = of("classify.cancelled") - - @JvmField val CLASSIFY_ERROR = of("classify.error") - - @JvmField - val CLASSIFY_PARTIAL_SUCCESS = of("classify.partial_success") - - @JvmField val CLASSIFY_PENDING = of("classify.pending") - - @JvmField val CLASSIFY_RUNNING = of("classify.running") - - @JvmField val CLASSIFY_SUCCESS = of("classify.success") - - @JvmField val EXTRACT_CANCELLED = of("extract.cancelled") - - @JvmField val EXTRACT_ERROR = of("extract.error") - - @JvmField - val EXTRACT_PARTIAL_SUCCESS = of("extract.partial_success") - - @JvmField val EXTRACT_PENDING = of("extract.pending") - - @JvmField val EXTRACT_SUCCESS = of("extract.success") - - @JvmField val PARSE_CANCELLED = of("parse.cancelled") - - @JvmField val PARSE_ERROR = of("parse.error") - - @JvmField val PARSE_PARTIAL_SUCCESS = of("parse.partial_success") - - @JvmField val PARSE_PENDING = of("parse.pending") - - @JvmField val PARSE_RUNNING = of("parse.running") - - @JvmField val PARSE_SUCCESS = of("parse.success") - - @JvmField val SHEETS_CANCELLED = of("sheets.cancelled") - - @JvmField val SHEETS_ERROR = of("sheets.error") - - @JvmField val SHEETS_PARTIAL_SUCCESS = of("sheets.partial_success") - - @JvmField val SHEETS_PENDING = of("sheets.pending") - - @JvmField val SHEETS_SUCCESS = of("sheets.success") - - @JvmField val SPLIT_CANCELLED = of("split.cancelled") - - @JvmField val SPLIT_ERROR = of("split.error") - - @JvmField val SPLIT_PENDING = of("split.pending") - - @JvmField val SPLIT_PROCESSING = of("split.processing") - - @JvmField val SPLIT_SUCCESS = of("split.success") - - @JvmField val UNMAPPED_EVENT = of("unmapped_event") - - @JvmStatic fun of(value: String) = WebhookEvent(JsonField.of(value)) - } - - /** An enum containing [WebhookEvent]'s known values. */ - enum class Known { - BATCH_CANCELLED, - BATCH_ERROR, - BATCH_PENDING, - BATCH_RUNNING, - BATCH_SUCCESS, - CLASSIFY_CANCELLED, - CLASSIFY_ERROR, - CLASSIFY_PARTIAL_SUCCESS, - CLASSIFY_PENDING, - CLASSIFY_RUNNING, - CLASSIFY_SUCCESS, - EXTRACT_CANCELLED, - EXTRACT_ERROR, - EXTRACT_PARTIAL_SUCCESS, - EXTRACT_PENDING, - EXTRACT_SUCCESS, - PARSE_CANCELLED, - PARSE_ERROR, - PARSE_PARTIAL_SUCCESS, - PARSE_PENDING, - PARSE_RUNNING, - PARSE_SUCCESS, - SHEETS_CANCELLED, - SHEETS_ERROR, - SHEETS_PARTIAL_SUCCESS, - SHEETS_PENDING, - SHEETS_SUCCESS, - SPLIT_CANCELLED, - SPLIT_ERROR, - SPLIT_PENDING, - SPLIT_PROCESSING, - SPLIT_SUCCESS, - UNMAPPED_EVENT, - } - - /** - * An enum containing [WebhookEvent]'s known values, as well as an - * [_UNKNOWN] member. - * - * An instance of [WebhookEvent] 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 { - BATCH_CANCELLED, - BATCH_ERROR, - BATCH_PENDING, - BATCH_RUNNING, - BATCH_SUCCESS, - CLASSIFY_CANCELLED, - CLASSIFY_ERROR, - CLASSIFY_PARTIAL_SUCCESS, - CLASSIFY_PENDING, - CLASSIFY_RUNNING, - CLASSIFY_SUCCESS, - EXTRACT_CANCELLED, - EXTRACT_ERROR, - EXTRACT_PARTIAL_SUCCESS, - EXTRACT_PENDING, - EXTRACT_SUCCESS, - PARSE_CANCELLED, - PARSE_ERROR, - PARSE_PARTIAL_SUCCESS, - PARSE_PENDING, - PARSE_RUNNING, - PARSE_SUCCESS, - SHEETS_CANCELLED, - SHEETS_ERROR, - SHEETS_PARTIAL_SUCCESS, - SHEETS_PENDING, - SHEETS_SUCCESS, - SPLIT_CANCELLED, - SPLIT_ERROR, - SPLIT_PENDING, - SPLIT_PROCESSING, - SPLIT_SUCCESS, - UNMAPPED_EVENT, - /** - * An enum member indicating that [WebhookEvent] 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) { - BATCH_CANCELLED -> Value.BATCH_CANCELLED - BATCH_ERROR -> Value.BATCH_ERROR - BATCH_PENDING -> Value.BATCH_PENDING - BATCH_RUNNING -> Value.BATCH_RUNNING - BATCH_SUCCESS -> Value.BATCH_SUCCESS - CLASSIFY_CANCELLED -> Value.CLASSIFY_CANCELLED - CLASSIFY_ERROR -> Value.CLASSIFY_ERROR - CLASSIFY_PARTIAL_SUCCESS -> Value.CLASSIFY_PARTIAL_SUCCESS - CLASSIFY_PENDING -> Value.CLASSIFY_PENDING - CLASSIFY_RUNNING -> Value.CLASSIFY_RUNNING - CLASSIFY_SUCCESS -> Value.CLASSIFY_SUCCESS - EXTRACT_CANCELLED -> Value.EXTRACT_CANCELLED - EXTRACT_ERROR -> Value.EXTRACT_ERROR - EXTRACT_PARTIAL_SUCCESS -> Value.EXTRACT_PARTIAL_SUCCESS - EXTRACT_PENDING -> Value.EXTRACT_PENDING - EXTRACT_SUCCESS -> Value.EXTRACT_SUCCESS - PARSE_CANCELLED -> Value.PARSE_CANCELLED - PARSE_ERROR -> Value.PARSE_ERROR - PARSE_PARTIAL_SUCCESS -> Value.PARSE_PARTIAL_SUCCESS - PARSE_PENDING -> Value.PARSE_PENDING - PARSE_RUNNING -> Value.PARSE_RUNNING - PARSE_SUCCESS -> Value.PARSE_SUCCESS - SHEETS_CANCELLED -> Value.SHEETS_CANCELLED - SHEETS_ERROR -> Value.SHEETS_ERROR - SHEETS_PARTIAL_SUCCESS -> Value.SHEETS_PARTIAL_SUCCESS - SHEETS_PENDING -> Value.SHEETS_PENDING - SHEETS_SUCCESS -> Value.SHEETS_SUCCESS - SPLIT_CANCELLED -> Value.SPLIT_CANCELLED - SPLIT_ERROR -> Value.SPLIT_ERROR - SPLIT_PENDING -> Value.SPLIT_PENDING - SPLIT_PROCESSING -> Value.SPLIT_PROCESSING - SPLIT_SUCCESS -> Value.SPLIT_SUCCESS - UNMAPPED_EVENT -> Value.UNMAPPED_EVENT - 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) { - BATCH_CANCELLED -> Known.BATCH_CANCELLED - BATCH_ERROR -> Known.BATCH_ERROR - BATCH_PENDING -> Known.BATCH_PENDING - BATCH_RUNNING -> Known.BATCH_RUNNING - BATCH_SUCCESS -> Known.BATCH_SUCCESS - CLASSIFY_CANCELLED -> Known.CLASSIFY_CANCELLED - CLASSIFY_ERROR -> Known.CLASSIFY_ERROR - CLASSIFY_PARTIAL_SUCCESS -> Known.CLASSIFY_PARTIAL_SUCCESS - CLASSIFY_PENDING -> Known.CLASSIFY_PENDING - CLASSIFY_RUNNING -> Known.CLASSIFY_RUNNING - CLASSIFY_SUCCESS -> Known.CLASSIFY_SUCCESS - EXTRACT_CANCELLED -> Known.EXTRACT_CANCELLED - EXTRACT_ERROR -> Known.EXTRACT_ERROR - EXTRACT_PARTIAL_SUCCESS -> Known.EXTRACT_PARTIAL_SUCCESS - EXTRACT_PENDING -> Known.EXTRACT_PENDING - EXTRACT_SUCCESS -> Known.EXTRACT_SUCCESS - PARSE_CANCELLED -> Known.PARSE_CANCELLED - PARSE_ERROR -> Known.PARSE_ERROR - PARSE_PARTIAL_SUCCESS -> Known.PARSE_PARTIAL_SUCCESS - PARSE_PENDING -> Known.PARSE_PENDING - PARSE_RUNNING -> Known.PARSE_RUNNING - PARSE_SUCCESS -> Known.PARSE_SUCCESS - SHEETS_CANCELLED -> Known.SHEETS_CANCELLED - SHEETS_ERROR -> Known.SHEETS_ERROR - SHEETS_PARTIAL_SUCCESS -> Known.SHEETS_PARTIAL_SUCCESS - SHEETS_PENDING -> Known.SHEETS_PENDING - SHEETS_SUCCESS -> Known.SHEETS_SUCCESS - SPLIT_CANCELLED -> Known.SPLIT_CANCELLED - SPLIT_ERROR -> Known.SPLIT_ERROR - SPLIT_PENDING -> Known.SPLIT_PENDING - SPLIT_PROCESSING -> Known.SPLIT_PROCESSING - SPLIT_SUCCESS -> Known.SPLIT_SUCCESS - UNMAPPED_EVENT -> Known.UNMAPPED_EVENT - else -> - throw LlamaCloudInvalidDataException( - "Unknown WebhookEvent: $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(): WebhookEvent = 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 WebhookEvent && value == other.value - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - /** Custom HTTP headers sent with each webhook request (e.g. auth tokens) */ - class WebhookHeaders - @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 - * [WebhookHeaders]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [WebhookHeaders]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(webhookHeaders: WebhookHeaders) = apply { - additionalProperties = - webhookHeaders.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 [WebhookHeaders]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): WebhookHeaders = - WebhookHeaders(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(): WebhookHeaders = 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 WebhookHeaders && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "WebhookHeaders{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is WebhookConfiguration && - webhookEvents == other.webhookEvents && - webhookHeaders == other.webhookHeaders && - webhookOutputFormat == other.webhookOutputFormat && - webhookSigningSecret == other.webhookSigningSecret && - webhookUrl == other.webhookUrl && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - webhookEvents, - webhookHeaders, - webhookOutputFormat, - webhookSigningSecret, - webhookUrl, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "WebhookConfiguration{webhookEvents=$webhookEvents, webhookHeaders=$webhookHeaders, webhookOutputFormat=$webhookOutputFormat, webhookSigningSecret=$webhookSigningSecret, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is Parameters && - adaptiveLongTable == other.adaptiveLongTable && - aggressiveTableExtraction == other.aggressiveTableExtraction && - annotateLinks == other.annotateLinks && - annotateRevisions == other.annotateRevisions && - autoMode == other.autoMode && - autoModeConfigurationJson == other.autoModeConfigurationJson && - autoModeTriggerOnImageInPage == other.autoModeTriggerOnImageInPage && - autoModeTriggerOnRegexpInPage == other.autoModeTriggerOnRegexpInPage && - autoModeTriggerOnTableInPage == other.autoModeTriggerOnTableInPage && - autoModeTriggerOnTextInPage == other.autoModeTriggerOnTextInPage && - azureOpenAIApiVersion == other.azureOpenAIApiVersion && - azureOpenAIDeploymentName == other.azureOpenAIDeploymentName && - azureOpenAIEndpoint == other.azureOpenAIEndpoint && - azureOpenAIKey == other.azureOpenAIKey && - bboxBottom == other.bboxBottom && - bboxLeft == other.bboxLeft && - bboxRight == other.bboxRight && - bboxTop == other.bboxTop && - boundingBox == other.boundingBox && - compactMarkdownTable == other.compactMarkdownTable && - complementalFormattingInstruction == - other.complementalFormattingInstruction && - confidenceScoreEffort == other.confidenceScoreEffort && - contentGuidelineInstruction == other.contentGuidelineInstruction && - continuousMode == other.continuousMode && - customMetadata == other.customMetadata && - disableImageExtraction == other.disableImageExtraction && - disableOcr == other.disableOcr && - disableReconstruction == other.disableReconstruction && - doNotCache == other.doNotCache && - doNotUnrollColumns == other.doNotUnrollColumns && - enableCostOptimizer == other.enableCostOptimizer && - extractCharts == other.extractCharts && - extractLayout == other.extractLayout && - extractPrintedPageNumber == other.extractPrintedPageNumber && - fastMode == other.fastMode && - formattingInstruction == other.formattingInstruction && - gpt4oApiKey == other.gpt4oApiKey && - gpt4oMode == other.gpt4oMode && - guessXlsxSheetName == other.guessXlsxSheetName && - hideFooters == other.hideFooters && - hideHeaders == other.hideHeaders && - highResOcr == other.highResOcr && - htmlMakeAllElementsVisible == other.htmlMakeAllElementsVisible && - htmlRemoveFixedElements == other.htmlRemoveFixedElements && - htmlRemoveNavigationElements == other.htmlRemoveNavigationElements && - httpProxy == other.httpProxy && - ignoreDocumentElementsForLayoutDetection == - other.ignoreDocumentElementsForLayoutDetection && - imagesToSave == other.imagesToSave && - inlineImagesInMarkdown == other.inlineImagesInMarkdown && - inputS3Path == other.inputS3Path && - inputS3Region == other.inputS3Region && - inputUrl == other.inputUrl && - internalIsScreenshotJob == other.internalIsScreenshotJob && - invalidateCache == other.invalidateCache && - isFormattingInstruction == other.isFormattingInstruction && - jobTimeoutExtraTimePerPageInSeconds == - other.jobTimeoutExtraTimePerPageInSeconds && - jobTimeoutInSeconds == other.jobTimeoutInSeconds && - keepPageSeparatorWhenMergingTables == - other.keepPageSeparatorWhenMergingTables && - lang == other.lang && - languages == other.languages && - layoutAware == other.layoutAware && - lineLevelBoundingBox == other.lineLevelBoundingBox && - markdownTableMultilineHeaderSeparator == - other.markdownTableMultilineHeaderSeparator && - maxPages == other.maxPages && - maxPagesEnforced == other.maxPagesEnforced && - mergeTablesAcrossPagesInMarkdown == - other.mergeTablesAcrossPagesInMarkdown && - model == other.model && - outlinedTableExtraction == other.outlinedTableExtraction && - outputPdfOfDocument == other.outputPdfOfDocument && - outputS3PathPrefix == other.outputS3PathPrefix && - outputS3Region == other.outputS3Region && - outputTablesAsHtml == other.outputTablesAsHtml && - outputBucket == other.outputBucket && - pageErrorTolerance == other.pageErrorTolerance && - pageFooterPrefix == other.pageFooterPrefix && - pageFooterSuffix == other.pageFooterSuffix && - pageHeaderPrefix == other.pageHeaderPrefix && - pageHeaderSuffix == other.pageHeaderSuffix && - pagePrefix == other.pagePrefix && - pageSeparator == other.pageSeparator && - pageSuffix == other.pageSuffix && - parseMode == other.parseMode && - parsingInstruction == other.parsingInstruction && - pipelineId == other.pipelineId && - preciseBoundingBox == other.preciseBoundingBox && - premiumMode == other.premiumMode && - presentationOutOfBoundsContent == - other.presentationOutOfBoundsContent && - presentationSkipEmbeddedData == other.presentationSkipEmbeddedData && - preserveLayoutAlignmentAcrossPages == - other.preserveLayoutAlignmentAcrossPages && - preserveVerySmallText == other.preserveVerySmallText && - preset == other.preset && - priority == other.priority && - projectId == other.projectId && - removeHiddenText == other.removeHiddenText && - replaceFailedPageMode == other.replaceFailedPageMode && - replaceFailedPageWithErrorMessagePrefix == - other.replaceFailedPageWithErrorMessagePrefix && - replaceFailedPageWithErrorMessageSuffix == - other.replaceFailedPageWithErrorMessageSuffix && - resourceInfo == other.resourceInfo && - saveImages == other.saveImages && - skipDiagonalText == other.skipDiagonalText && - specializedChartParsingAgentic == - other.specializedChartParsingAgentic && - specializedChartParsingEfficient == - other.specializedChartParsingEfficient && - specializedChartParsingPlus == other.specializedChartParsingPlus && - specializedImageParsing == other.specializedImageParsing && - spreadsheetExtractSubTables == other.spreadsheetExtractSubTables && - spreadsheetForceFormulaComputation == - other.spreadsheetForceFormulaComputation && - spreadsheetIncludeHiddenSheets == - other.spreadsheetIncludeHiddenSheets && - strictModeBuggyFont == other.strictModeBuggyFont && - strictModeImageExtraction == other.strictModeImageExtraction && - strictModeImageOcr == other.strictModeImageOcr && - strictModeReconstruction == other.strictModeReconstruction && - structuredOutput == other.structuredOutput && - structuredOutputJsonSchema == other.structuredOutputJsonSchema && - structuredOutputJsonSchemaName == - other.structuredOutputJsonSchemaName && - systemPrompt == other.systemPrompt && - systemPromptAppend == other.systemPromptAppend && - takeScreenshot == other.takeScreenshot && - targetPages == other.targetPages && - tier == other.tier && - type == other.type && - useVendorMultimodalModel == other.useVendorMultimodalModel && - userPrompt == other.userPrompt && - vendorMultimodalApiKey == other.vendorMultimodalApiKey && - vendorMultimodalModelName == other.vendorMultimodalModelName && - version == other.version && - webhookConfigurations == other.webhookConfigurations && - webhookUrl == other.webhookUrl && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - adaptiveLongTable, - aggressiveTableExtraction, - annotateLinks, - annotateRevisions, - autoMode, - autoModeConfigurationJson, - autoModeTriggerOnImageInPage, - autoModeTriggerOnRegexpInPage, - autoModeTriggerOnTableInPage, - autoModeTriggerOnTextInPage, - azureOpenAIApiVersion, - azureOpenAIDeploymentName, - azureOpenAIEndpoint, - azureOpenAIKey, - bboxBottom, - bboxLeft, - bboxRight, - bboxTop, - boundingBox, - compactMarkdownTable, - complementalFormattingInstruction, - confidenceScoreEffort, - contentGuidelineInstruction, - continuousMode, - customMetadata, - disableImageExtraction, - disableOcr, - disableReconstruction, - doNotCache, - doNotUnrollColumns, - enableCostOptimizer, - extractCharts, - extractLayout, - extractPrintedPageNumber, - fastMode, - formattingInstruction, - gpt4oApiKey, - gpt4oMode, - guessXlsxSheetName, - hideFooters, - hideHeaders, - highResOcr, - htmlMakeAllElementsVisible, - htmlRemoveFixedElements, - htmlRemoveNavigationElements, - httpProxy, - ignoreDocumentElementsForLayoutDetection, - imagesToSave, - inlineImagesInMarkdown, - inputS3Path, - inputS3Region, - inputUrl, - internalIsScreenshotJob, - invalidateCache, - isFormattingInstruction, - jobTimeoutExtraTimePerPageInSeconds, - jobTimeoutInSeconds, - keepPageSeparatorWhenMergingTables, - lang, - languages, - layoutAware, - lineLevelBoundingBox, - markdownTableMultilineHeaderSeparator, - maxPages, - maxPagesEnforced, - mergeTablesAcrossPagesInMarkdown, - model, - outlinedTableExtraction, - outputPdfOfDocument, - outputS3PathPrefix, - outputS3Region, - outputTablesAsHtml, - outputBucket, - pageErrorTolerance, - pageFooterPrefix, - pageFooterSuffix, - pageHeaderPrefix, - pageHeaderSuffix, - pagePrefix, - pageSeparator, - pageSuffix, - parseMode, - parsingInstruction, - pipelineId, - preciseBoundingBox, - premiumMode, - presentationOutOfBoundsContent, - presentationSkipEmbeddedData, - preserveLayoutAlignmentAcrossPages, - preserveVerySmallText, - preset, - priority, - projectId, - removeHiddenText, - replaceFailedPageMode, - replaceFailedPageWithErrorMessagePrefix, - replaceFailedPageWithErrorMessageSuffix, - resourceInfo, - saveImages, - skipDiagonalText, - specializedChartParsingAgentic, - specializedChartParsingEfficient, - specializedChartParsingPlus, - specializedImageParsing, - spreadsheetExtractSubTables, - spreadsheetForceFormulaComputation, - spreadsheetIncludeHiddenSheets, - strictModeBuggyFont, - strictModeImageExtraction, - strictModeImageOcr, - strictModeReconstruction, - structuredOutput, - structuredOutputJsonSchema, - structuredOutputJsonSchemaName, - systemPrompt, - systemPromptAppend, - takeScreenshot, - targetPages, - tier, - type, - useVendorMultimodalModel, - userPrompt, - vendorMultimodalApiKey, - vendorMultimodalModelName, - version, - webhookConfigurations, - webhookUrl, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Parameters{adaptiveLongTable=$adaptiveLongTable, aggressiveTableExtraction=$aggressiveTableExtraction, annotateLinks=$annotateLinks, annotateRevisions=$annotateRevisions, autoMode=$autoMode, autoModeConfigurationJson=$autoModeConfigurationJson, autoModeTriggerOnImageInPage=$autoModeTriggerOnImageInPage, autoModeTriggerOnRegexpInPage=$autoModeTriggerOnRegexpInPage, autoModeTriggerOnTableInPage=$autoModeTriggerOnTableInPage, autoModeTriggerOnTextInPage=$autoModeTriggerOnTextInPage, azureOpenAIApiVersion=$azureOpenAIApiVersion, azureOpenAIDeploymentName=$azureOpenAIDeploymentName, azureOpenAIEndpoint=$azureOpenAIEndpoint, azureOpenAIKey=$azureOpenAIKey, bboxBottom=$bboxBottom, bboxLeft=$bboxLeft, bboxRight=$bboxRight, bboxTop=$bboxTop, boundingBox=$boundingBox, compactMarkdownTable=$compactMarkdownTable, complementalFormattingInstruction=$complementalFormattingInstruction, confidenceScoreEffort=$confidenceScoreEffort, contentGuidelineInstruction=$contentGuidelineInstruction, continuousMode=$continuousMode, customMetadata=$customMetadata, disableImageExtraction=$disableImageExtraction, disableOcr=$disableOcr, disableReconstruction=$disableReconstruction, doNotCache=$doNotCache, doNotUnrollColumns=$doNotUnrollColumns, enableCostOptimizer=$enableCostOptimizer, extractCharts=$extractCharts, extractLayout=$extractLayout, extractPrintedPageNumber=$extractPrintedPageNumber, fastMode=$fastMode, formattingInstruction=$formattingInstruction, gpt4oApiKey=$gpt4oApiKey, gpt4oMode=$gpt4oMode, guessXlsxSheetName=$guessXlsxSheetName, hideFooters=$hideFooters, hideHeaders=$hideHeaders, highResOcr=$highResOcr, htmlMakeAllElementsVisible=$htmlMakeAllElementsVisible, htmlRemoveFixedElements=$htmlRemoveFixedElements, htmlRemoveNavigationElements=$htmlRemoveNavigationElements, httpProxy=$httpProxy, ignoreDocumentElementsForLayoutDetection=$ignoreDocumentElementsForLayoutDetection, imagesToSave=$imagesToSave, inlineImagesInMarkdown=$inlineImagesInMarkdown, inputS3Path=$inputS3Path, inputS3Region=$inputS3Region, inputUrl=$inputUrl, internalIsScreenshotJob=$internalIsScreenshotJob, invalidateCache=$invalidateCache, isFormattingInstruction=$isFormattingInstruction, jobTimeoutExtraTimePerPageInSeconds=$jobTimeoutExtraTimePerPageInSeconds, jobTimeoutInSeconds=$jobTimeoutInSeconds, keepPageSeparatorWhenMergingTables=$keepPageSeparatorWhenMergingTables, lang=$lang, languages=$languages, layoutAware=$layoutAware, lineLevelBoundingBox=$lineLevelBoundingBox, markdownTableMultilineHeaderSeparator=$markdownTableMultilineHeaderSeparator, maxPages=$maxPages, maxPagesEnforced=$maxPagesEnforced, mergeTablesAcrossPagesInMarkdown=$mergeTablesAcrossPagesInMarkdown, model=$model, outlinedTableExtraction=$outlinedTableExtraction, outputPdfOfDocument=$outputPdfOfDocument, outputS3PathPrefix=$outputS3PathPrefix, outputS3Region=$outputS3Region, outputTablesAsHtml=$outputTablesAsHtml, outputBucket=$outputBucket, pageErrorTolerance=$pageErrorTolerance, pageFooterPrefix=$pageFooterPrefix, pageFooterSuffix=$pageFooterSuffix, pageHeaderPrefix=$pageHeaderPrefix, pageHeaderSuffix=$pageHeaderSuffix, pagePrefix=$pagePrefix, pageSeparator=$pageSeparator, pageSuffix=$pageSuffix, parseMode=$parseMode, parsingInstruction=$parsingInstruction, pipelineId=$pipelineId, preciseBoundingBox=$preciseBoundingBox, premiumMode=$premiumMode, presentationOutOfBoundsContent=$presentationOutOfBoundsContent, presentationSkipEmbeddedData=$presentationSkipEmbeddedData, preserveLayoutAlignmentAcrossPages=$preserveLayoutAlignmentAcrossPages, preserveVerySmallText=$preserveVerySmallText, preset=$preset, priority=$priority, projectId=$projectId, removeHiddenText=$removeHiddenText, replaceFailedPageMode=$replaceFailedPageMode, replaceFailedPageWithErrorMessagePrefix=$replaceFailedPageWithErrorMessagePrefix, replaceFailedPageWithErrorMessageSuffix=$replaceFailedPageWithErrorMessageSuffix, resourceInfo=$resourceInfo, saveImages=$saveImages, skipDiagonalText=$skipDiagonalText, specializedChartParsingAgentic=$specializedChartParsingAgentic, specializedChartParsingEfficient=$specializedChartParsingEfficient, specializedChartParsingPlus=$specializedChartParsingPlus, specializedImageParsing=$specializedImageParsing, spreadsheetExtractSubTables=$spreadsheetExtractSubTables, spreadsheetForceFormulaComputation=$spreadsheetForceFormulaComputation, spreadsheetIncludeHiddenSheets=$spreadsheetIncludeHiddenSheets, strictModeBuggyFont=$strictModeBuggyFont, strictModeImageExtraction=$strictModeImageExtraction, strictModeImageOcr=$strictModeImageOcr, strictModeReconstruction=$strictModeReconstruction, structuredOutput=$structuredOutput, structuredOutputJsonSchema=$structuredOutputJsonSchema, structuredOutputJsonSchemaName=$structuredOutputJsonSchemaName, systemPrompt=$systemPrompt, systemPromptAppend=$systemPromptAppend, takeScreenshot=$takeScreenshot, targetPages=$targetPages, tier=$tier, type=$type, useVendorMultimodalModel=$useVendorMultimodalModel, userPrompt=$userPrompt, vendorMultimodalApiKey=$vendorMultimodalApiKey, vendorMultimodalModelName=$vendorMultimodalModelName, version=$version, webhookConfigurations=$webhookConfigurations, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" - } - - /** - * The partitions for this execution. Used for determining where to save job output. - */ - class Partitions - @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 [Partitions]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Partitions]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(partitions: Partitions) = apply { - additionalProperties = partitions.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 [Partitions]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Partitions = Partitions(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(): Partitions = 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 Partitions && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Partitions{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is BatchParseJobRecordCreate && - correlationId == other.correlationId && - jobName == other.jobName && - parameters == other.parameters && - parentJobExecutionId == other.parentJobExecutionId && - partitions == other.partitions && - projectId == other.projectId && - sessionId == other.sessionId && - userId == other.userId && - webhookUrl == other.webhookUrl && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - correlationId, - jobName, - parameters, - parentJobExecutionId, - partitions, - projectId, - sessionId, - userId, - webhookUrl, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BatchParseJobRecordCreate{correlationId=$correlationId, jobName=$jobName, parameters=$parameters, parentJobExecutionId=$parentJobExecutionId, partitions=$partitions, projectId=$projectId, sessionId=$sessionId, userId=$userId, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" - } - } - - /** Type of processing performed */ - 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 ProcessingResult && - itemId == other.itemId && - jobConfig == other.jobConfig && - jobType == other.jobType && - outputS3Path == other.outputS3Path && - parametersHash == other.parametersHash && - processedAt == other.processedAt && - resultId == other.resultId && - outputMetadata == other.outputMetadata && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash( - itemId, - jobConfig, - jobType, - outputS3Path, - parametersHash, - processedAt, - resultId, - outputMetadata, - additionalProperties, - ) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "ProcessingResult{itemId=$itemId, jobConfig=$jobConfig, jobType=$jobType, outputS3Path=$outputS3Path, parametersHash=$parametersHash, processedAt=$processedAt, resultId=$resultId, outputMetadata=$outputMetadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is JobItemGetProcessingResultsResponse && - itemId == other.itemId && - itemName == other.itemName && - processingResults == other.processingResults && - additionalProperties == other.additionalProperties - } - - private val hashCode: Int by lazy { - Objects.hash(itemId, itemName, processingResults, additionalProperties) - } - - override fun hashCode(): Int = hashCode - - override fun toString() = - "JobItemGetProcessingResultsResponse{itemId=$itemId, itemName=$itemName, processingResults=$processingResults, additionalProperties=$additionalProperties}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListPage.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListPage.kt deleted file mode 100644 index c962623..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListPage.kt +++ /dev/null @@ -1,138 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch.jobitems - -import ai.llamaindex.llamacloud.core.AutoPager -import ai.llamaindex.llamacloud.core.Page -import ai.llamaindex.llamacloud.core.checkRequired -import ai.llamaindex.llamacloud.services.blocking.beta.batch.JobItemService -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrDefault -import kotlin.jvm.optionals.getOrNull - -/** @see JobItemService.list */ -class JobItemListPage -private constructor( - private val service: JobItemService, - private val params: JobItemListParams, - private val response: JobItemListPageResponse, -) : Page { - - /** - * Delegates to [JobItemListPageResponse], but gracefully handles missing data. - * - * @see JobItemListPageResponse.items - */ - override fun items(): List = - response._items().getOptional("items").getOrNull() ?: emptyList() - - /** - * Delegates to [JobItemListPageResponse], but gracefully handles missing data. - * - * @see JobItemListPageResponse.totalSize - */ - fun totalSize(): Optional = response._totalSize().getOptional("total_size") - - override fun hasNextPage(): Boolean { - if (items().isEmpty()) { - return false - } - - val offset = params.offset().getOrDefault(0) - val totalCount = totalSize().getOrNull() - return totalCount == null || offset + items().size < totalCount - } - - fun nextPageParams(): JobItemListParams { - val offset = params.offset().getOrDefault(0) - return params.toBuilder().offset(offset + items().size).build() - } - - override fun nextPage(): JobItemListPage = service.list(nextPageParams()) - - fun autoPager(): AutoPager = AutoPager.from(this) - - /** The parameters that were used to request this page. */ - fun params(): JobItemListParams = params - - /** The response that this page was parsed from. */ - fun response(): JobItemListPageResponse = response - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [JobItemListPage]. - * - * The following fields are required: - * ```java - * .service() - * .params() - * .response() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [JobItemListPage]. */ - class Builder internal constructor() { - - private var service: JobItemService? = null - private var params: JobItemListParams? = null - private var response: JobItemListPageResponse? = null - - @JvmSynthetic - internal fun from(jobItemListPage: JobItemListPage) = apply { - service = jobItemListPage.service - params = jobItemListPage.params - response = jobItemListPage.response - } - - fun service(service: JobItemService) = apply { this.service = service } - - /** The parameters that were used to request this page. */ - fun params(params: JobItemListParams) = apply { this.params = params } - - /** The response that this page was parsed from. */ - fun response(response: JobItemListPageResponse) = apply { this.response = response } - - /** - * Returns an immutable instance of [JobItemListPage]. - * - * 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(): JobItemListPage = - JobItemListPage( - checkRequired("service", service), - checkRequired("params", params), - checkRequired("response", response), - ) - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return other is JobItemListPage && - service == other.service && - params == other.params && - response == other.response - } - - override fun hashCode(): Int = Objects.hash(service, params, response) - - override fun toString() = - "JobItemListPage{service=$service, params=$params, response=$response}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListPageAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListPageAsync.kt deleted file mode 100644 index 49b7c5d..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListPageAsync.kt +++ /dev/null @@ -1,153 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch.jobitems - -import ai.llamaindex.llamacloud.core.AutoPagerAsync -import ai.llamaindex.llamacloud.core.PageAsync -import ai.llamaindex.llamacloud.core.checkRequired -import ai.llamaindex.llamacloud.services.async.beta.batch.JobItemServiceAsync -import java.util.Objects -import java.util.Optional -import java.util.concurrent.CompletableFuture -import java.util.concurrent.Executor -import kotlin.jvm.optionals.getOrDefault -import kotlin.jvm.optionals.getOrNull - -/** @see JobItemServiceAsync.list */ -class JobItemListPageAsync -private constructor( - private val service: JobItemServiceAsync, - private val streamHandlerExecutor: Executor, - private val params: JobItemListParams, - private val response: JobItemListPageResponse, -) : PageAsync { - - /** - * Delegates to [JobItemListPageResponse], but gracefully handles missing data. - * - * @see JobItemListPageResponse.items - */ - override fun items(): List = - response._items().getOptional("items").getOrNull() ?: emptyList() - - /** - * Delegates to [JobItemListPageResponse], but gracefully handles missing data. - * - * @see JobItemListPageResponse.totalSize - */ - fun totalSize(): Optional = response._totalSize().getOptional("total_size") - - override fun hasNextPage(): Boolean { - if (items().isEmpty()) { - return false - } - - val offset = params.offset().getOrDefault(0) - val totalCount = totalSize().getOrNull() - return totalCount == null || offset + items().size < totalCount - } - - fun nextPageParams(): JobItemListParams { - val offset = params.offset().getOrDefault(0) - return params.toBuilder().offset(offset + items().size).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(): JobItemListParams = params - - /** The response that this page was parsed from. */ - fun response(): JobItemListPageResponse = response - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [JobItemListPageAsync]. - * - * The following fields are required: - * ```java - * .service() - * .streamHandlerExecutor() - * .params() - * .response() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [JobItemListPageAsync]. */ - class Builder internal constructor() { - - private var service: JobItemServiceAsync? = null - private var streamHandlerExecutor: Executor? = null - private var params: JobItemListParams? = null - private var response: JobItemListPageResponse? = null - - @JvmSynthetic - internal fun from(jobItemListPageAsync: JobItemListPageAsync) = apply { - service = jobItemListPageAsync.service - streamHandlerExecutor = jobItemListPageAsync.streamHandlerExecutor - params = jobItemListPageAsync.params - response = jobItemListPageAsync.response - } - - fun service(service: JobItemServiceAsync) = apply { this.service = service } - - fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { - this.streamHandlerExecutor = streamHandlerExecutor - } - - /** The parameters that were used to request this page. */ - fun params(params: JobItemListParams) = apply { this.params = params } - - /** The response that this page was parsed from. */ - fun response(response: JobItemListPageResponse) = apply { this.response = response } - - /** - * Returns an immutable instance of [JobItemListPageAsync]. - * - * 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(): JobItemListPageAsync = - JobItemListPageAsync( - 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 JobItemListPageAsync && - 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() = - "JobItemListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListPageResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListPageResponse.kt deleted file mode 100644 index cc555d8..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListPageResponse.kt +++ /dev/null @@ -1,290 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch.jobitems - -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.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 response containing batch job item details. */ -class JobItemListPageResponse -@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()) - - /** - * List of item details - * - * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun items(): Optional> = items.getOptional("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 [JobItemListPageResponse]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [JobItemListPageResponse]. */ - 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(jobItemListPageResponse: JobItemListPageResponse) = apply { - items = jobItemListPageResponse.items.map { it.toMutableList() } - nextPageToken = jobItemListPageResponse.nextPageToken - totalSize = jobItemListPageResponse.totalSize - additionalProperties = jobItemListPageResponse.additionalProperties.toMutableMap() - } - - /** List of item details */ - 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 [JobItemListResponse] to [items]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addItem(item: JobItemListResponse) = 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 [JobItemListPageResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): JobItemListPageResponse = - JobItemListPageResponse( - (items ?: JsonMissing.of()).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(): JobItemListPageResponse = apply { - if (validated) { - return@apply - } - - items().ifPresent { it.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 JobItemListPageResponse && - 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() = - "JobItemListPageResponse{items=$items, nextPageToken=$nextPageToken, totalSize=$totalSize, additionalProperties=$additionalProperties}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListParams.kt deleted file mode 100644 index d0a84e1..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListParams.kt +++ /dev/null @@ -1,463 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch.jobitems - -import ai.llamaindex.llamacloud.core.Enum -import ai.llamaindex.llamacloud.core.JsonField -import ai.llamaindex.llamacloud.core.Params -import ai.llamaindex.llamacloud.core.http.Headers -import ai.llamaindex.llamacloud.core.http.QueryParams -import ai.llamaindex.llamacloud.errors.LlamaCloudInvalidDataException -import com.fasterxml.jackson.annotation.JsonCreator -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -/** - * List items in a batch job with optional status filtering. - * - * Useful for finding failed items, viewing completed items, or debugging processing issues. - */ -class JobItemListParams -private constructor( - private val jobId: String?, - private val limit: Long?, - private val offset: Long?, - private val organizationId: String?, - private val projectId: String?, - private val status: Status?, - private val additionalHeaders: Headers, - private val additionalQueryParams: QueryParams, -) : Params { - - fun jobId(): Optional = Optional.ofNullable(jobId) - - /** Maximum number of items to return */ - fun limit(): Optional = Optional.ofNullable(limit) - - /** Number of items to skip */ - fun offset(): Optional = Optional.ofNullable(offset) - - fun organizationId(): Optional = Optional.ofNullable(organizationId) - - fun projectId(): Optional = Optional.ofNullable(projectId) - - /** Filter items 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 { - - @JvmStatic fun none(): JobItemListParams = builder().build() - - /** Returns a mutable builder for constructing an instance of [JobItemListParams]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [JobItemListParams]. */ - class Builder internal constructor() { - - private var jobId: String? = null - private var limit: Long? = null - private var offset: Long? = null - private var organizationId: String? = null - private var projectId: String? = null - private var status: Status? = null - private var additionalHeaders: Headers.Builder = Headers.builder() - private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() - - @JvmSynthetic - internal fun from(jobItemListParams: JobItemListParams) = apply { - jobId = jobItemListParams.jobId - limit = jobItemListParams.limit - offset = jobItemListParams.offset - organizationId = jobItemListParams.organizationId - projectId = jobItemListParams.projectId - status = jobItemListParams.status - additionalHeaders = jobItemListParams.additionalHeaders.toBuilder() - additionalQueryParams = jobItemListParams.additionalQueryParams.toBuilder() - } - - fun jobId(jobId: String?) = apply { this.jobId = jobId } - - /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ - fun jobId(jobId: Optional) = jobId(jobId.getOrNull()) - - /** Maximum number of items to return */ - fun limit(limit: Long?) = apply { this.limit = limit } - - /** - * Alias for [Builder.limit]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun limit(limit: Long) = limit(limit as Long?) - - /** Alias for calling [Builder.limit] with `limit.orElse(null)`. */ - fun limit(limit: Optional) = limit(limit.getOrNull()) - - /** Number of items to skip */ - fun offset(offset: Long?) = apply { this.offset = offset } - - /** - * Alias for [Builder.offset]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun offset(offset: Long) = offset(offset as Long?) - - /** Alias for calling [Builder.offset] with `offset.orElse(null)`. */ - fun offset(offset: Optional) = offset(offset.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()) - - /** Filter items by status */ - fun status(status: Status?) = apply { this.status = status } - - /** Alias for calling [Builder.status] with `status.orElse(null)`. */ - fun status(status: Optional) = status(status.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 [JobItemListParams]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): JobItemListParams = - JobItemListParams( - jobId, - limit, - offset, - organizationId, - projectId, - status, - additionalHeaders.build(), - additionalQueryParams.build(), - ) - } - - fun _pathParam(index: Int): String = - when (index) { - 0 -> jobId ?: "" - else -> "" - } - - override fun _headers(): Headers = additionalHeaders - - override fun _queryParams(): QueryParams = - QueryParams.builder() - .apply { - limit?.let { put("limit", it.toString()) } - offset?.let { put("offset", it.toString()) } - organizationId?.let { put("organization_id", it) } - projectId?.let { put("project_id", it) } - status?.let { put("status", it.toString()) } - putAll(additionalQueryParams) - } - .build() - - /** Filter items by status */ - class Status @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CANCELLED = of("cancelled") - - @JvmField val COMPLETED = of("completed") - - @JvmField val FAILED = of("failed") - - @JvmField val PENDING = of("pending") - - @JvmField val PROCESSING = of("processing") - - @JvmField val SKIPPED = of("skipped") - - @JvmStatic fun of(value: String) = Status(JsonField.of(value)) - } - - /** An enum containing [Status]'s known values. */ - enum class Known { - CANCELLED, - COMPLETED, - FAILED, - PENDING, - PROCESSING, - SKIPPED, - } - - /** - * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Status] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CANCELLED, - COMPLETED, - FAILED, - PENDING, - PROCESSING, - SKIPPED, - /** An enum member indicating that [Status] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CANCELLED -> Value.CANCELLED - COMPLETED -> Value.COMPLETED - FAILED -> Value.FAILED - PENDING -> Value.PENDING - PROCESSING -> Value.PROCESSING - SKIPPED -> Value.SKIPPED - 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) { - CANCELLED -> Known.CANCELLED - COMPLETED -> Known.COMPLETED - FAILED -> Known.FAILED - PENDING -> Known.PENDING - PROCESSING -> Known.PROCESSING - SKIPPED -> Known.SKIPPED - else -> throw LlamaCloudInvalidDataException("Unknown Status: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws 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(): Status = 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 Status && 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 JobItemListParams && - jobId == other.jobId && - limit == other.limit && - offset == other.offset && - organizationId == other.organizationId && - projectId == other.projectId && - status == other.status && - additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams - } - - override fun hashCode(): Int = - Objects.hash( - jobId, - limit, - offset, - organizationId, - projectId, - status, - additionalHeaders, - additionalQueryParams, - ) - - override fun toString() = - "JobItemListParams{jobId=$jobId, limit=$limit, offset=$offset, organizationId=$organizationId, projectId=$projectId, status=$status, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchGetStatusParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCancelParams.kt similarity index 70% rename from llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchGetStatusParams.kt rename to llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCancelParams.kt index 3596cb1..faebf9d 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchGetStatusParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCancelParams.kt @@ -1,27 +1,30 @@ // File generated from our OpenAPI spec by Stainless. -package ai.llamaindex.llamacloud.models.beta.batch +package ai.llamaindex.llamacloud.models.parsing +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 /** - * Get detailed status of a batch processing job. + * Cancel a running parse job. * - * Returns current progress percentage, file counts (total, processed, failed, skipped), and - * timestamps. + * Stops processing and marks the job as CANCELLED. Returns the updated job. Jobs already in a + * terminal state (COMPLETED, FAILED, CANCELLED) cannot be cancelled. */ -class BatchGetStatusParams +class ParsingCancelParams 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) @@ -30,6 +33,9 @@ private constructor( 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 @@ -40,13 +46,13 @@ private constructor( companion object { - @JvmStatic fun none(): BatchGetStatusParams = builder().build() + @JvmStatic fun none(): ParsingCancelParams = builder().build() - /** Returns a mutable builder for constructing an instance of [BatchGetStatusParams]. */ + /** Returns a mutable builder for constructing an instance of [ParsingCancelParams]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [BatchGetStatusParams]. */ + /** A builder for [ParsingCancelParams]. */ class Builder internal constructor() { private var jobId: String? = null @@ -54,14 +60,16 @@ private constructor( 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(batchGetStatusParams: BatchGetStatusParams) = apply { - jobId = batchGetStatusParams.jobId - organizationId = batchGetStatusParams.organizationId - projectId = batchGetStatusParams.projectId - additionalHeaders = batchGetStatusParams.additionalHeaders.toBuilder() - additionalQueryParams = batchGetStatusParams.additionalQueryParams.toBuilder() + internal fun from(parsingCancelParams: ParsingCancelParams) = apply { + jobId = parsingCancelParams.jobId + organizationId = parsingCancelParams.organizationId + projectId = parsingCancelParams.projectId + additionalHeaders = parsingCancelParams.additionalHeaders.toBuilder() + additionalQueryParams = parsingCancelParams.additionalQueryParams.toBuilder() + additionalBodyProperties = parsingCancelParams.additionalBodyProperties.toMutableMap() } fun jobId(jobId: String?) = apply { this.jobId = jobId } @@ -178,21 +186,47 @@ private constructor( 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 [BatchGetStatusParams]. + * Returns an immutable instance of [ParsingCancelParams]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): BatchGetStatusParams = - BatchGetStatusParams( + fun build(): ParsingCancelParams = + ParsingCancelParams( 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 ?: "" @@ -215,17 +249,25 @@ private constructor( return true } - return other is BatchGetStatusParams && + return other is ParsingCancelParams && jobId == other.jobId && organizationId == other.organizationId && projectId == other.projectId && additionalHeaders == other.additionalHeaders && - additionalQueryParams == other.additionalQueryParams + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties } override fun hashCode(): Int = - Objects.hash(jobId, organizationId, projectId, additionalHeaders, additionalQueryParams) + Objects.hash( + jobId, + organizationId, + projectId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) override fun toString() = - "BatchGetStatusParams{jobId=$jobId, organizationId=$organizationId, projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "ParsingCancelParams{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/beta/batch/jobitems/JobItemListResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCancelResponse.kt similarity index 51% rename from llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListResponse.kt rename to llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCancelResponse.kt index 7038693..7237fff 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCancelResponse.kt @@ -1,6 +1,6 @@ // File generated from our OpenAPI spec by Stainless. -package ai.llamaindex.llamacloud.models.beta.batch.jobitems +package ai.llamaindex.llamacloud.models.parsing import ai.llamaindex.llamacloud.core.Enum import ai.llamaindex.llamacloud.core.ExcludeMissing @@ -8,6 +8,7 @@ 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 @@ -19,79 +20,72 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -/** Detailed information about an item in a batch job. */ -class JobItemListResponse +/** A parse job. */ +class ParsingCancelResponse @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( - private val itemId: JsonField, - private val itemName: JsonField, + private val id: JsonField, + private val projectId: JsonField, private val status: JsonField, - private val completedAt: JsonField, - private val effectiveAt: JsonField, + private val createdAt: JsonField, private val errorMessage: JsonField, - private val jobId: JsonField, - private val jobRecordId: JsonField, - private val skipReason: JsonField, - private val startedAt: JsonField, + private val name: JsonField, + private val tier: JsonField, + private val updatedAt: JsonField, + private val userMetadata: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("item_id") @ExcludeMissing itemId: JsonField = JsonMissing.of(), - @JsonProperty("item_name") @ExcludeMissing itemName: JsonField = JsonMissing.of(), + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), - @JsonProperty("completed_at") + @JsonProperty("created_at") @ExcludeMissing - completedAt: JsonField = JsonMissing.of(), - @JsonProperty("effective_at") - @ExcludeMissing - effectiveAt: JsonField = JsonMissing.of(), + createdAt: JsonField = JsonMissing.of(), @JsonProperty("error_message") @ExcludeMissing errorMessage: JsonField = JsonMissing.of(), - @JsonProperty("job_id") @ExcludeMissing jobId: JsonField = JsonMissing.of(), - @JsonProperty("job_record_id") - @ExcludeMissing - jobRecordId: JsonField = JsonMissing.of(), - @JsonProperty("skip_reason") + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("tier") @ExcludeMissing tier: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") @ExcludeMissing - skipReason: JsonField = JsonMissing.of(), - @JsonProperty("started_at") + updatedAt: JsonField = JsonMissing.of(), + @JsonProperty("user_metadata") @ExcludeMissing - startedAt: JsonField = JsonMissing.of(), + userMetadata: JsonField = JsonMissing.of(), ) : this( - itemId, - itemName, + id, + projectId, status, - completedAt, - effectiveAt, + createdAt, errorMessage, - jobId, - jobRecordId, - skipReason, - startedAt, + name, + tier, + updatedAt, + userMetadata, mutableMapOf(), ) /** - * ID of the item + * Unique parse job identifier * * @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 itemId(): String = itemId.getRequired("item_id") + fun id(): String = id.getRequired("id") /** - * Name of the item + * Project this job 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 itemName(): String = itemName.getRequired("item_name") + fun projectId(): String = projectId.getRequired("project_id") /** - * Processing status of this item + * Current job status: PENDING, RUNNING, COMPLETED, FAILED, or CANCELLED * * @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). @@ -99,21 +93,15 @@ private constructor( fun status(): Status = status.getRequired("status") /** - * When processing completed for this item + * Creation datetime * * @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 effectiveAt(): Optional = effectiveAt.getOptional("effective_at") + fun createdAt(): Optional = createdAt.getOptional("created_at") /** - * Error message for the latest job attempt, if any. + * Error details when status is FAILED * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -121,50 +109,50 @@ private constructor( fun errorMessage(): Optional = errorMessage.getOptional("error_message") /** - * Job ID for the underlying processing job (links to parse/extract job results) + * Optional display name for this parse job * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun jobId(): Optional = jobId.getOptional("job_id") + fun name(): Optional = name.getOptional("name") /** - * The job record ID associated with this status, if any. + * Parsing tier used for this job * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun jobRecordId(): Optional = jobRecordId.getOptional("job_record_id") + fun tier(): Optional = tier.getOptional("tier") /** - * Reason item was skipped (e.g., 'already_processed', 'size_limit_exceeded') + * Update datetime * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun skipReason(): Optional = skipReason.getOptional("skip_reason") + fun updatedAt(): Optional = updatedAt.getOptional("updated_at") /** - * When processing started for this item + * Key/value tags associated with this job. * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun startedAt(): Optional = startedAt.getOptional("started_at") + fun userMetadata(): Optional = userMetadata.getOptional("user_metadata") /** - * Returns the raw JSON value of [itemId]. + * Returns the raw JSON value of [id]. * - * Unlike [itemId], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** - * Returns the raw JSON value of [itemName]. + * Returns the raw JSON value of [projectId]. * - * Unlike [itemName], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [projectId], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("item_name") @ExcludeMissing fun _itemName(): JsonField = itemName + @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId /** * Returns the raw JSON value of [status]. @@ -174,22 +162,13 @@ private constructor( @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** - * Returns the raw JSON value of [completedAt]. + * Returns the raw JSON value of [createdAt]. * - * Unlike [completedAt], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [createdAt], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("completed_at") + @JsonProperty("created_at") @ExcludeMissing - fun _completedAt(): JsonField = completedAt - - /** - * Returns the raw JSON value of [effectiveAt]. - * - * Unlike [effectiveAt], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("effective_at") - @ExcludeMissing - fun _effectiveAt(): JsonField = effectiveAt + fun _createdAt(): JsonField = createdAt /** * Returns the raw JSON value of [errorMessage]. @@ -201,36 +180,36 @@ private constructor( fun _errorMessage(): JsonField = errorMessage /** - * Returns the raw JSON value of [jobId]. + * Returns the raw JSON value of [name]. * - * Unlike [jobId], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("job_id") @ExcludeMissing fun _jobId(): JsonField = jobId + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** - * Returns the raw JSON value of [jobRecordId]. + * Returns the raw JSON value of [tier]. * - * Unlike [jobRecordId], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [tier], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("job_record_id") - @ExcludeMissing - fun _jobRecordId(): JsonField = jobRecordId + @JsonProperty("tier") @ExcludeMissing fun _tier(): JsonField = tier /** - * Returns the raw JSON value of [skipReason]. + * Returns the raw JSON value of [updatedAt]. * - * Unlike [skipReason], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [updatedAt], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("skip_reason") @ExcludeMissing fun _skipReason(): JsonField = skipReason + @JsonProperty("updated_at") + @ExcludeMissing + fun _updatedAt(): JsonField = updatedAt /** - * Returns the raw JSON value of [startedAt]. + * Returns the raw JSON value of [userMetadata]. * - * Unlike [startedAt], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [userMetadata], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("started_at") + @JsonProperty("user_metadata") @ExcludeMissing - fun _startedAt(): JsonField = startedAt + fun _userMetadata(): JsonField = userMetadata @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -247,71 +226,70 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [JobItemListResponse]. + * Returns a mutable builder for constructing an instance of [ParsingCancelResponse]. * * The following fields are required: * ```java - * .itemId() - * .itemName() + * .id() + * .projectId() * .status() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [JobItemListResponse]. */ + /** A builder for [ParsingCancelResponse]. */ class Builder internal constructor() { - private var itemId: JsonField? = null - private var itemName: JsonField? = null + private var id: JsonField? = null + private var projectId: JsonField? = null private var status: JsonField? = null - private var completedAt: JsonField = JsonMissing.of() - private var effectiveAt: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() private var errorMessage: JsonField = JsonMissing.of() - private var jobId: JsonField = JsonMissing.of() - private var jobRecordId: JsonField = JsonMissing.of() - private var skipReason: JsonField = JsonMissing.of() - private var startedAt: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var tier: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var userMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(jobItemListResponse: JobItemListResponse) = apply { - itemId = jobItemListResponse.itemId - itemName = jobItemListResponse.itemName - status = jobItemListResponse.status - completedAt = jobItemListResponse.completedAt - effectiveAt = jobItemListResponse.effectiveAt - errorMessage = jobItemListResponse.errorMessage - jobId = jobItemListResponse.jobId - jobRecordId = jobItemListResponse.jobRecordId - skipReason = jobItemListResponse.skipReason - startedAt = jobItemListResponse.startedAt - additionalProperties = jobItemListResponse.additionalProperties.toMutableMap() + internal fun from(parsingCancelResponse: ParsingCancelResponse) = apply { + id = parsingCancelResponse.id + projectId = parsingCancelResponse.projectId + status = parsingCancelResponse.status + createdAt = parsingCancelResponse.createdAt + errorMessage = parsingCancelResponse.errorMessage + name = parsingCancelResponse.name + tier = parsingCancelResponse.tier + updatedAt = parsingCancelResponse.updatedAt + userMetadata = parsingCancelResponse.userMetadata + additionalProperties = parsingCancelResponse.additionalProperties.toMutableMap() } - /** ID of the item */ - fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + /** Unique parse job identifier */ + fun id(id: String) = id(JsonField.of(id)) /** - * Sets [Builder.itemId] to an arbitrary JSON value. + * Sets [Builder.id] to an arbitrary JSON value. * - * You should usually call [Builder.itemId] with a well-typed [String] value instead. This + * 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 itemId(itemId: JsonField) = apply { this.itemId = itemId } + fun id(id: JsonField) = apply { this.id = id } - /** Name of the item */ - fun itemName(itemName: String) = itemName(JsonField.of(itemName)) + /** Project this job belongs to */ + fun projectId(projectId: String) = projectId(JsonField.of(projectId)) /** - * Sets [Builder.itemName] to an arbitrary JSON value. + * Sets [Builder.projectId] to an arbitrary JSON value. * - * You should usually call [Builder.itemName] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported 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 itemName(itemName: JsonField) = apply { this.itemName = itemName } + fun projectId(projectId: JsonField) = apply { this.projectId = projectId } - /** Processing status of this item */ + /** Current job status: PENDING, RUNNING, COMPLETED, FAILED, or CANCELLED */ fun status(status: Status) = status(JsonField.of(status)) /** @@ -322,39 +300,22 @@ private constructor( */ fun status(status: JsonField) = apply { this.status = status } - /** When processing completed for this item */ - fun completedAt(completedAt: OffsetDateTime?) = - completedAt(JsonField.ofNullable(completedAt)) + /** Creation datetime */ + fun createdAt(createdAt: OffsetDateTime?) = createdAt(JsonField.ofNullable(createdAt)) - /** Alias for calling [Builder.completedAt] with `completedAt.orElse(null)`. */ - fun completedAt(completedAt: Optional) = - completedAt(completedAt.getOrNull()) + /** Alias for calling [Builder.createdAt] with `createdAt.orElse(null)`. */ + fun createdAt(createdAt: Optional) = createdAt(createdAt.getOrNull()) /** - * Sets [Builder.completedAt] to an arbitrary JSON value. + * Sets [Builder.createdAt] to an arbitrary JSON value. * - * You should usually call [Builder.completedAt] with a well-typed [OffsetDateTime] 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 completedAt(completedAt: JsonField) = apply { - this.completedAt = completedAt - } + fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - fun effectiveAt(effectiveAt: OffsetDateTime) = effectiveAt(JsonField.of(effectiveAt)) - - /** - * Sets [Builder.effectiveAt] to an arbitrary JSON value. - * - * You should usually call [Builder.effectiveAt] with a well-typed [OffsetDateTime] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun effectiveAt(effectiveAt: JsonField) = apply { - this.effectiveAt = effectiveAt - } - - /** Error message for the latest job attempt, if any. */ + /** Error details when status is FAILED */ fun errorMessage(errorMessage: String?) = errorMessage(JsonField.ofNullable(errorMessage)) /** Alias for calling [Builder.errorMessage] with `errorMessage.orElse(null)`. */ @@ -371,64 +332,67 @@ private constructor( this.errorMessage = errorMessage } - /** Job ID for the underlying processing job (links to parse/extract job results) */ - fun jobId(jobId: String?) = jobId(JsonField.ofNullable(jobId)) + /** Optional display name for this parse job */ + fun name(name: String?) = name(JsonField.ofNullable(name)) - /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ - fun jobId(jobId: Optional) = jobId(jobId.getOrNull()) + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) /** - * Sets [Builder.jobId] to an arbitrary JSON value. + * Sets [Builder.name] to an arbitrary JSON value. * - * You should usually call [Builder.jobId] with a well-typed [String] value instead. This + * 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 jobId(jobId: JsonField) = apply { this.jobId = jobId } + fun name(name: JsonField) = apply { this.name = name } - /** The job record ID associated with this status, if any. */ - fun jobRecordId(jobRecordId: String?) = jobRecordId(JsonField.ofNullable(jobRecordId)) + /** Parsing tier used for this job */ + fun tier(tier: String?) = tier(JsonField.ofNullable(tier)) - /** Alias for calling [Builder.jobRecordId] with `jobRecordId.orElse(null)`. */ - fun jobRecordId(jobRecordId: Optional) = jobRecordId(jobRecordId.getOrNull()) + /** Alias for calling [Builder.tier] with `tier.orElse(null)`. */ + fun tier(tier: Optional) = tier(tier.getOrNull()) /** - * Sets [Builder.jobRecordId] to an arbitrary JSON value. + * Sets [Builder.tier] to an arbitrary JSON value. * - * You should usually call [Builder.jobRecordId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.tier] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ - fun jobRecordId(jobRecordId: JsonField) = apply { this.jobRecordId = jobRecordId } + fun tier(tier: JsonField) = apply { this.tier = tier } - /** Reason item was skipped (e.g., 'already_processed', 'size_limit_exceeded') */ - fun skipReason(skipReason: String?) = skipReason(JsonField.ofNullable(skipReason)) + /** Update datetime */ + fun updatedAt(updatedAt: OffsetDateTime?) = updatedAt(JsonField.ofNullable(updatedAt)) - /** Alias for calling [Builder.skipReason] with `skipReason.orElse(null)`. */ - fun skipReason(skipReason: Optional) = skipReason(skipReason.getOrNull()) + /** Alias for calling [Builder.updatedAt] with `updatedAt.orElse(null)`. */ + fun updatedAt(updatedAt: Optional) = updatedAt(updatedAt.getOrNull()) /** - * Sets [Builder.skipReason] to an arbitrary JSON value. + * Sets [Builder.updatedAt] to an arbitrary JSON value. * - * You should usually call [Builder.skipReason] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * 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 skipReason(skipReason: JsonField) = apply { this.skipReason = skipReason } + fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } - /** When processing started for this item */ - fun startedAt(startedAt: OffsetDateTime?) = startedAt(JsonField.ofNullable(startedAt)) + /** Key/value tags associated with this job. */ + fun userMetadata(userMetadata: UserMetadata?) = + userMetadata(JsonField.ofNullable(userMetadata)) - /** Alias for calling [Builder.startedAt] with `startedAt.orElse(null)`. */ - fun startedAt(startedAt: Optional) = startedAt(startedAt.getOrNull()) + /** Alias for calling [Builder.userMetadata] with `userMetadata.orElse(null)`. */ + fun userMetadata(userMetadata: Optional) = + userMetadata(userMetadata.getOrNull()) /** - * Sets [Builder.startedAt] to an arbitrary JSON value. + * Sets [Builder.userMetadata] to an arbitrary JSON value. * - * You should usually call [Builder.startedAt] with a well-typed [OffsetDateTime] value + * You should usually call [Builder.userMetadata] with a well-typed [UserMetadata] value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun startedAt(startedAt: JsonField) = apply { this.startedAt = startedAt } + fun userMetadata(userMetadata: JsonField) = apply { + this.userMetadata = userMetadata + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -450,31 +414,30 @@ private constructor( } /** - * Returns an immutable instance of [JobItemListResponse]. + * Returns an immutable instance of [ParsingCancelResponse]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .itemId() - * .itemName() + * .id() + * .projectId() * .status() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): JobItemListResponse = - JobItemListResponse( - checkRequired("itemId", itemId), - checkRequired("itemName", itemName), + fun build(): ParsingCancelResponse = + ParsingCancelResponse( + checkRequired("id", id), + checkRequired("projectId", projectId), checkRequired("status", status), - completedAt, - effectiveAt, + createdAt, errorMessage, - jobId, - jobRecordId, - skipReason, - startedAt, + name, + tier, + updatedAt, + userMetadata, additionalProperties.toMutableMap(), ) } @@ -489,21 +452,20 @@ private constructor( * @throws LlamaCloudInvalidDataException if any value type in this object doesn't match its * expected type. */ - fun validate(): JobItemListResponse = apply { + fun validate(): ParsingCancelResponse = apply { if (validated) { return@apply } - itemId() - itemName() + id() + projectId() status().validate() - completedAt() - effectiveAt() + createdAt() errorMessage() - jobId() - jobRecordId() - skipReason() - startedAt() + name() + tier() + updatedAt() + userMetadata().ifPresent { it.validate() } validated = true } @@ -522,18 +484,17 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (itemId.asKnown().isPresent) 1 else 0) + - (if (itemName.asKnown().isPresent) 1 else 0) + + (if (id.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + (status.asKnown().getOrNull()?.validity() ?: 0) + - (if (completedAt.asKnown().isPresent) 1 else 0) + - (if (effectiveAt.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + (if (errorMessage.asKnown().isPresent) 1 else 0) + - (if (jobId.asKnown().isPresent) 1 else 0) + - (if (jobRecordId.asKnown().isPresent) 1 else 0) + - (if (skipReason.asKnown().isPresent) 1 else 0) + - (if (startedAt.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + + (if (tier.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (userMetadata.asKnown().getOrNull()?.validity() ?: 0) - /** Processing status of this item */ + /** Current job status: PENDING, RUNNING, COMPLETED, FAILED, or CANCELLED */ class Status @JsonCreator private constructor(private val value: JsonField) : Enum { /** @@ -548,17 +509,15 @@ private constructor( companion object { - @JvmField val CANCELLED = of("cancelled") + @JvmField val CANCELLED = of("CANCELLED") - @JvmField val COMPLETED = of("completed") + @JvmField val COMPLETED = of("COMPLETED") - @JvmField val FAILED = of("failed") + @JvmField val FAILED = of("FAILED") - @JvmField val PENDING = of("pending") + @JvmField val PENDING = of("PENDING") - @JvmField val PROCESSING = of("processing") - - @JvmField val SKIPPED = of("skipped") + @JvmField val RUNNING = of("RUNNING") @JvmStatic fun of(value: String) = Status(JsonField.of(value)) } @@ -569,8 +528,7 @@ private constructor( COMPLETED, FAILED, PENDING, - PROCESSING, - SKIPPED, + RUNNING, } /** @@ -587,8 +545,7 @@ private constructor( COMPLETED, FAILED, PENDING, - PROCESSING, - SKIPPED, + RUNNING, /** An enum member indicating that [Status] was instantiated with an unknown value. */ _UNKNOWN, } @@ -606,8 +563,7 @@ private constructor( COMPLETED -> Value.COMPLETED FAILED -> Value.FAILED PENDING -> Value.PENDING - PROCESSING -> Value.PROCESSING - SKIPPED -> Value.SKIPPED + RUNNING -> Value.RUNNING else -> Value._UNKNOWN } @@ -626,8 +582,7 @@ private constructor( COMPLETED -> Known.COMPLETED FAILED -> Known.FAILED PENDING -> Known.PENDING - PROCESSING -> Known.PROCESSING - SKIPPED -> Known.SKIPPED + RUNNING -> Known.RUNNING else -> throw LlamaCloudInvalidDataException("Unknown Status: $value") } @@ -694,37 +649,144 @@ private constructor( override fun toString() = value.toString() } + /** Key/value tags associated with this job. */ + class UserMetadata + @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 [UserMetadata]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UserMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(userMetadata: UserMetadata) = apply { + additionalProperties = userMetadata.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 [UserMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): UserMetadata = UserMetadata(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(): UserMetadata = 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 UserMetadata && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "UserMetadata{additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return other is JobItemListResponse && - itemId == other.itemId && - itemName == other.itemName && + return other is ParsingCancelResponse && + id == other.id && + projectId == other.projectId && status == other.status && - completedAt == other.completedAt && - effectiveAt == other.effectiveAt && + createdAt == other.createdAt && errorMessage == other.errorMessage && - jobId == other.jobId && - jobRecordId == other.jobRecordId && - skipReason == other.skipReason && - startedAt == other.startedAt && + name == other.name && + tier == other.tier && + updatedAt == other.updatedAt && + userMetadata == other.userMetadata && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { Objects.hash( - itemId, - itemName, + id, + projectId, status, - completedAt, - effectiveAt, + createdAt, errorMessage, - jobId, - jobRecordId, - skipReason, - startedAt, + name, + tier, + updatedAt, + userMetadata, additionalProperties, ) } @@ -732,5 +794,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "JobItemListResponse{itemId=$itemId, itemName=$itemName, status=$status, completedAt=$completedAt, effectiveAt=$effectiveAt, errorMessage=$errorMessage, jobId=$jobId, jobRecordId=$jobRecordId, skipReason=$skipReason, startedAt=$startedAt, additionalProperties=$additionalProperties}" + "ParsingCancelResponse{id=$id, projectId=$projectId, status=$status, createdAt=$createdAt, errorMessage=$errorMessage, name=$name, tier=$tier, updatedAt=$updatedAt, userMetadata=$userMetadata, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsync.kt deleted file mode 100644 index d26f2fe..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsync.kt +++ /dev/null @@ -1,195 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.services.async - -import ai.llamaindex.llamacloud.core.ClientOptions -import ai.llamaindex.llamacloud.core.RequestOptions -import ai.llamaindex.llamacloud.core.http.HttpResponseFor -import ai.llamaindex.llamacloud.models.batches.BatchCreateParams -import ai.llamaindex.llamacloud.models.batches.BatchCreateResponse -import ai.llamaindex.llamacloud.models.batches.BatchGetParams -import ai.llamaindex.llamacloud.models.batches.BatchGetResponse -import ai.llamaindex.llamacloud.models.batches.BatchListPageAsync -import ai.llamaindex.llamacloud.models.batches.BatchListParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface BatchServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): BatchServiceAsync - - /** - * Create a batch over a source directory and start processing asynchronously. - * - * To be notified as the batch progresses, pass `webhook_configurations` with inline endpoints - * and/or `webhook_configuration_ids` referencing saved configurations. Batches emit - * `batch.pending` on create, `batch.running` once processing starts, and a terminal - * `batch.success` or `batch.error`. - * - * `batch.success` means the batch finished mapping every source file to a job — individual - * files may still have failed, so read `results` (with `expand=results`) for per-file outcomes. - * - * Delivery order across events is not guaranteed; key on the `status` field in the payload - * rather than arrival order. - */ - fun create(params: BatchCreateParams): CompletableFuture = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - params: BatchCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** List batches for the current project. */ - fun list(): CompletableFuture = list(BatchListParams.none()) - - /** @see list */ - fun list( - params: BatchListParams = BatchListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see list */ - fun list( - params: BatchListParams = BatchListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) - - /** @see list */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(BatchListParams.none(), requestOptions) - - /** Get a batch by ID. */ - fun get(batchId: String): CompletableFuture = - get(batchId, BatchGetParams.none()) - - /** @see get */ - fun get( - batchId: String, - params: BatchGetParams = BatchGetParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - get(params.toBuilder().batchId(batchId).build(), requestOptions) - - /** @see get */ - fun get( - batchId: String, - params: BatchGetParams = BatchGetParams.none(), - ): CompletableFuture = get(batchId, params, RequestOptions.none()) - - /** @see get */ - fun get( - params: BatchGetParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see get */ - fun get(params: BatchGetParams): CompletableFuture = - get(params, RequestOptions.none()) - - /** @see get */ - fun get(batchId: String, requestOptions: RequestOptions): CompletableFuture = - get(batchId, BatchGetParams.none(), requestOptions) - - /** A view of [BatchServiceAsync] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): BatchServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /api/v2/batches`, but is otherwise the same as - * [BatchServiceAsync.create]. - */ - fun create( - params: BatchCreateParams - ): CompletableFuture> = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - params: BatchCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `get /api/v2/batches`, but is otherwise the same as - * [BatchServiceAsync.list]. - */ - fun list(): CompletableFuture> = - list(BatchListParams.none()) - - /** @see list */ - fun list( - params: BatchListParams = BatchListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see list */ - fun list( - params: BatchListParams = BatchListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(BatchListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /api/v2/batches/{batch_id}`, but is otherwise the - * same as [BatchServiceAsync.get]. - */ - fun get(batchId: String): CompletableFuture> = - get(batchId, BatchGetParams.none()) - - /** @see get */ - fun get( - batchId: String, - params: BatchGetParams = BatchGetParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - get(params.toBuilder().batchId(batchId).build(), requestOptions) - - /** @see get */ - fun get( - batchId: String, - params: BatchGetParams = BatchGetParams.none(), - ): CompletableFuture> = - get(batchId, params, RequestOptions.none()) - - /** @see get */ - fun get( - params: BatchGetParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see get */ - fun get(params: BatchGetParams): CompletableFuture> = - get(params, RequestOptions.none()) - - /** @see get */ - fun get( - batchId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - get(batchId, BatchGetParams.none(), requestOptions) - } -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncImpl.kt deleted file mode 100644 index 6eace8b..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncImpl.kt +++ /dev/null @@ -1,178 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.services.async - -import ai.llamaindex.llamacloud.core.ClientOptions -import ai.llamaindex.llamacloud.core.RequestOptions -import ai.llamaindex.llamacloud.core.checkRequired -import ai.llamaindex.llamacloud.core.handlers.errorBodyHandler -import ai.llamaindex.llamacloud.core.handlers.errorHandler -import ai.llamaindex.llamacloud.core.handlers.jsonHandler -import ai.llamaindex.llamacloud.core.http.HttpMethod -import ai.llamaindex.llamacloud.core.http.HttpRequest -import ai.llamaindex.llamacloud.core.http.HttpResponse -import ai.llamaindex.llamacloud.core.http.HttpResponse.Handler -import ai.llamaindex.llamacloud.core.http.HttpResponseFor -import ai.llamaindex.llamacloud.core.http.json -import ai.llamaindex.llamacloud.core.http.parseable -import ai.llamaindex.llamacloud.core.prepareAsync -import ai.llamaindex.llamacloud.models.batches.BatchCreateParams -import ai.llamaindex.llamacloud.models.batches.BatchCreateResponse -import ai.llamaindex.llamacloud.models.batches.BatchGetParams -import ai.llamaindex.llamacloud.models.batches.BatchGetResponse -import ai.llamaindex.llamacloud.models.batches.BatchListPageAsync -import ai.llamaindex.llamacloud.models.batches.BatchListPageResponse -import ai.llamaindex.llamacloud.models.batches.BatchListParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class BatchServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - BatchServiceAsync { - - private val withRawResponse: BatchServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): BatchServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): BatchServiceAsync = - BatchServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun create( - params: BatchCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /api/v2/batches - withRawResponse().create(params, requestOptions).thenApply { it.parse() } - - override fun list( - params: BatchListParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /api/v2/batches - withRawResponse().list(params, requestOptions).thenApply { it.parse() } - - override fun get( - params: BatchGetParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /api/v2/batches/{batch_id} - withRawResponse().get(params, requestOptions).thenApply { it.parse() } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - BatchServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): BatchServiceAsync.WithRawResponse = - BatchServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun create( - params: BatchCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("api", "v2", "batches") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: BatchListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("api", "v2", "batches") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - BatchListPageAsync.builder() - .service(BatchServiceAsyncImpl(clientOptions)) - .streamHandlerExecutor(clientOptions.streamHandlerExecutor) - .params(params) - .response(it) - .build() - } - } - } - } - - private val getHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun get( - params: BatchGetParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("batchId", params.batchId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("api", "v2", "batches", params._pathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { getHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - } -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BetaServiceAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BetaServiceAsync.kt index b7c2e6e..cfa3966 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BetaServiceAsync.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BetaServiceAsync.kt @@ -4,7 +4,6 @@ package ai.llamaindex.llamacloud.services.async import ai.llamaindex.llamacloud.core.ClientOptions import ai.llamaindex.llamacloud.services.async.beta.AgentDataServiceAsync -import ai.llamaindex.llamacloud.services.async.beta.BatchServiceAsync import ai.llamaindex.llamacloud.services.async.beta.ChatServiceAsync import ai.llamaindex.llamacloud.services.async.beta.DirectoryServiceAsync import ai.llamaindex.llamacloud.services.async.beta.IndexServiceAsync @@ -39,8 +38,6 @@ interface BetaServiceAsync { fun directories(): DirectoryServiceAsync - fun batch(): BatchServiceAsync - fun split(): SplitServiceAsync /** A view of [BetaServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -65,8 +62,6 @@ interface BetaServiceAsync { fun directories(): DirectoryServiceAsync.WithRawResponse - fun batch(): BatchServiceAsync.WithRawResponse - fun split(): SplitServiceAsync.WithRawResponse } } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BetaServiceAsyncImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BetaServiceAsyncImpl.kt index 53d5c3d..f42b009 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BetaServiceAsyncImpl.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BetaServiceAsyncImpl.kt @@ -5,8 +5,6 @@ package ai.llamaindex.llamacloud.services.async import ai.llamaindex.llamacloud.core.ClientOptions import ai.llamaindex.llamacloud.services.async.beta.AgentDataServiceAsync import ai.llamaindex.llamacloud.services.async.beta.AgentDataServiceAsyncImpl -import ai.llamaindex.llamacloud.services.async.beta.BatchServiceAsync -import ai.llamaindex.llamacloud.services.async.beta.BatchServiceAsyncImpl import ai.llamaindex.llamacloud.services.async.beta.ChatServiceAsync import ai.llamaindex.llamacloud.services.async.beta.ChatServiceAsyncImpl import ai.llamaindex.llamacloud.services.async.beta.DirectoryServiceAsync @@ -46,8 +44,6 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien DirectoryServiceAsyncImpl(clientOptions) } - private val batch: BatchServiceAsync by lazy { BatchServiceAsyncImpl(clientOptions) } - private val split: SplitServiceAsync by lazy { SplitServiceAsyncImpl(clientOptions) } override fun withRawResponse(): BetaServiceAsync.WithRawResponse = withRawResponse @@ -67,8 +63,6 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun directories(): DirectoryServiceAsync = directories - override fun batch(): BatchServiceAsync = batch - override fun split(): SplitServiceAsync = split class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -98,10 +92,6 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien DirectoryServiceAsyncImpl.WithRawResponseImpl(clientOptions) } - private val batch: BatchServiceAsync.WithRawResponse by lazy { - BatchServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - private val split: SplitServiceAsync.WithRawResponse by lazy { SplitServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -125,8 +115,6 @@ class BetaServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun directories(): DirectoryServiceAsync.WithRawResponse = directories - override fun batch(): BatchServiceAsync.WithRawResponse = batch - override fun split(): SplitServiceAsync.WithRawResponse = split } } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsync.kt index 8265a68..8c9439a 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsync.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsync.kt @@ -5,6 +5,8 @@ package ai.llamaindex.llamacloud.services.async import ai.llamaindex.llamacloud.core.ClientOptions import ai.llamaindex.llamacloud.core.RequestOptions import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.models.parsing.ParsingCancelParams +import ai.llamaindex.llamacloud.models.parsing.ParsingCancelResponse import ai.llamaindex.llamacloud.models.parsing.ParsingCreateParams import ai.llamaindex.llamacloud.models.parsing.ParsingCreateResponse import ai.llamaindex.llamacloud.models.parsing.ParsingGetParams @@ -75,6 +77,46 @@ interface ParsingServiceAsync { fun list(requestOptions: RequestOptions): CompletableFuture = list(ParsingListParams.none(), requestOptions) + /** + * Cancel a running parse job. + * + * Stops processing and marks the job as CANCELLED. Returns the updated job. Jobs already in a + * terminal state (COMPLETED, FAILED, CANCELLED) cannot be cancelled. + */ + fun cancel(jobId: String): CompletableFuture = + cancel(jobId, ParsingCancelParams.none()) + + /** @see cancel */ + fun cancel( + jobId: String, + params: ParsingCancelParams = ParsingCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + cancel(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + jobId: String, + params: ParsingCancelParams = ParsingCancelParams.none(), + ): CompletableFuture = cancel(jobId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: ParsingCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see cancel */ + fun cancel(params: ParsingCancelParams): CompletableFuture = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + jobId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + cancel(jobId, ParsingCancelParams.none(), requestOptions) + /** * Retrieve a parse job with optional expanded content. * @@ -172,6 +214,47 @@ interface ParsingServiceAsync { ): CompletableFuture> = list(ParsingListParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /api/v2/parse/{job_id}/cancel`, but is otherwise + * the same as [ParsingServiceAsync.cancel]. + */ + fun cancel(jobId: String): CompletableFuture> = + cancel(jobId, ParsingCancelParams.none()) + + /** @see cancel */ + fun cancel( + jobId: String, + params: ParsingCancelParams = ParsingCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + cancel(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + jobId: String, + params: ParsingCancelParams = ParsingCancelParams.none(), + ): CompletableFuture> = + cancel(jobId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: ParsingCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see cancel */ + fun cancel( + params: ParsingCancelParams + ): CompletableFuture> = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + jobId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + cancel(jobId, ParsingCancelParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /api/v2/parse/{job_id}`, but is otherwise the same * as [ParsingServiceAsync.get]. diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncImpl.kt index 21fd4e9..61986d374 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncImpl.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncImpl.kt @@ -16,6 +16,8 @@ import ai.llamaindex.llamacloud.core.http.HttpResponseFor import ai.llamaindex.llamacloud.core.http.json import ai.llamaindex.llamacloud.core.http.parseable import ai.llamaindex.llamacloud.core.prepareAsync +import ai.llamaindex.llamacloud.models.parsing.ParsingCancelParams +import ai.llamaindex.llamacloud.models.parsing.ParsingCancelResponse import ai.llamaindex.llamacloud.models.parsing.ParsingCreateParams import ai.llamaindex.llamacloud.models.parsing.ParsingCreateResponse import ai.llamaindex.llamacloud.models.parsing.ParsingGetParams @@ -53,6 +55,13 @@ class ParsingServiceAsyncImpl internal constructor(private val clientOptions: Cl // get /api/v2/parse withRawResponse().list(params, requestOptions).thenApply { it.parse() } + override fun cancel( + params: ParsingCancelParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /api/v2/parse/{job_id}/cancel + withRawResponse().cancel(params, requestOptions).thenApply { it.parse() } + override fun get( params: ParsingGetParams, requestOptions: RequestOptions, @@ -142,6 +151,40 @@ class ParsingServiceAsyncImpl internal constructor(private val clientOptions: Cl } } + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun cancel( + params: ParsingCancelParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v2", "parse", params._pathParam(0), "cancel") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { cancelHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/beta/BatchServiceAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/beta/BatchServiceAsync.kt deleted file mode 100644 index bb36259..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/beta/BatchServiceAsync.kt +++ /dev/null @@ -1,293 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.services.async.beta - -import ai.llamaindex.llamacloud.core.ClientOptions -import ai.llamaindex.llamacloud.core.RequestOptions -import ai.llamaindex.llamacloud.core.http.HttpResponseFor -import ai.llamaindex.llamacloud.models.beta.batch.BatchCancelParams -import ai.llamaindex.llamacloud.models.beta.batch.BatchCancelResponse -import ai.llamaindex.llamacloud.models.beta.batch.BatchCreateParams -import ai.llamaindex.llamacloud.models.beta.batch.BatchCreateResponse -import ai.llamaindex.llamacloud.models.beta.batch.BatchGetStatusParams -import ai.llamaindex.llamacloud.models.beta.batch.BatchGetStatusResponse -import ai.llamaindex.llamacloud.models.beta.batch.BatchListPageAsync -import ai.llamaindex.llamacloud.models.beta.batch.BatchListParams -import ai.llamaindex.llamacloud.services.async.beta.batch.JobItemServiceAsync -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface BatchServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): BatchServiceAsync - - fun jobItems(): JobItemServiceAsync - - /** - * Create a batch processing job. - * - * Processes files from a directory or a specific list of item IDs. Supports batch parsing and - * classification operations. - * - * Provide either `directory_id` to process all files in a directory, or `item_ids` for specific - * items. The job runs asynchronously — poll `GET /batch/{job_id}` for progress. - */ - fun create(params: BatchCreateParams): CompletableFuture = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - params: BatchCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** - * List batch processing jobs with optional filtering. - * - * Filter by `directory_id`, `job_type`, or `status`. Results are paginated with configurable - * `limit` and `offset`. - */ - fun list(): CompletableFuture = list(BatchListParams.none()) - - /** @see list */ - fun list( - params: BatchListParams = BatchListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see list */ - fun list( - params: BatchListParams = BatchListParams.none() - ): CompletableFuture = list(params, RequestOptions.none()) - - /** @see list */ - fun list(requestOptions: RequestOptions): CompletableFuture = - list(BatchListParams.none(), requestOptions) - - /** - * Cancel a running batch processing job. - * - * Stops processing and marks pending items as cancelled. Items currently being processed may - * still complete. - */ - fun cancel(jobId: String): CompletableFuture = - cancel(jobId, BatchCancelParams.none()) - - /** @see cancel */ - fun cancel( - jobId: String, - params: BatchCancelParams = BatchCancelParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - cancel(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see cancel */ - fun cancel( - jobId: String, - params: BatchCancelParams = BatchCancelParams.none(), - ): CompletableFuture = cancel(jobId, params, RequestOptions.none()) - - /** @see cancel */ - fun cancel( - params: BatchCancelParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see cancel */ - fun cancel(params: BatchCancelParams): CompletableFuture = - cancel(params, RequestOptions.none()) - - /** @see cancel */ - fun cancel( - jobId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - cancel(jobId, BatchCancelParams.none(), requestOptions) - - /** - * Get detailed status of a batch processing job. - * - * Returns current progress percentage, file counts (total, processed, failed, skipped), and - * timestamps. - */ - fun getStatus(jobId: String): CompletableFuture = - getStatus(jobId, BatchGetStatusParams.none()) - - /** @see getStatus */ - fun getStatus( - jobId: String, - params: BatchGetStatusParams = BatchGetStatusParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - getStatus(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see getStatus */ - fun getStatus( - jobId: String, - params: BatchGetStatusParams = BatchGetStatusParams.none(), - ): CompletableFuture = getStatus(jobId, params, RequestOptions.none()) - - /** @see getStatus */ - fun getStatus( - params: BatchGetStatusParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see getStatus */ - fun getStatus(params: BatchGetStatusParams): CompletableFuture = - getStatus(params, RequestOptions.none()) - - /** @see getStatus */ - fun getStatus( - jobId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - getStatus(jobId, BatchGetStatusParams.none(), requestOptions) - - /** A view of [BatchServiceAsync] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): BatchServiceAsync.WithRawResponse - - fun jobItems(): JobItemServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `post /api/v1/beta/batch-processing`, but is otherwise - * the same as [BatchServiceAsync.create]. - */ - fun create( - params: BatchCreateParams - ): CompletableFuture> = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - params: BatchCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** - * Returns a raw HTTP response for `get /api/v1/beta/batch-processing`, but is otherwise the - * same as [BatchServiceAsync.list]. - */ - fun list(): CompletableFuture> = - list(BatchListParams.none()) - - /** @see list */ - fun list( - params: BatchListParams = BatchListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see list */ - fun list( - params: BatchListParams = BatchListParams.none() - ): CompletableFuture> = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - requestOptions: RequestOptions - ): CompletableFuture> = - list(BatchListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /api/v1/beta/batch-processing/{job_id}/cancel`, but - * is otherwise the same as [BatchServiceAsync.cancel]. - */ - fun cancel(jobId: String): CompletableFuture> = - cancel(jobId, BatchCancelParams.none()) - - /** @see cancel */ - fun cancel( - jobId: String, - params: BatchCancelParams = BatchCancelParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - cancel(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see cancel */ - fun cancel( - jobId: String, - params: BatchCancelParams = BatchCancelParams.none(), - ): CompletableFuture> = - cancel(jobId, params, RequestOptions.none()) - - /** @see cancel */ - fun cancel( - params: BatchCancelParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see cancel */ - fun cancel( - params: BatchCancelParams - ): CompletableFuture> = - cancel(params, RequestOptions.none()) - - /** @see cancel */ - fun cancel( - jobId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - cancel(jobId, BatchCancelParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /api/v1/beta/batch-processing/{job_id}`, but is - * otherwise the same as [BatchServiceAsync.getStatus]. - */ - fun getStatus(jobId: String): CompletableFuture> = - getStatus(jobId, BatchGetStatusParams.none()) - - /** @see getStatus */ - fun getStatus( - jobId: String, - params: BatchGetStatusParams = BatchGetStatusParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - getStatus(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see getStatus */ - fun getStatus( - jobId: String, - params: BatchGetStatusParams = BatchGetStatusParams.none(), - ): CompletableFuture> = - getStatus(jobId, params, RequestOptions.none()) - - /** @see getStatus */ - fun getStatus( - params: BatchGetStatusParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see getStatus */ - fun getStatus( - params: BatchGetStatusParams - ): CompletableFuture> = - getStatus(params, RequestOptions.none()) - - /** @see getStatus */ - fun getStatus( - jobId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - getStatus(jobId, BatchGetStatusParams.none(), requestOptions) - } -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/beta/BatchServiceAsyncImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/beta/BatchServiceAsyncImpl.kt deleted file mode 100644 index 79ff7e1..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/beta/BatchServiceAsyncImpl.kt +++ /dev/null @@ -1,240 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.services.async.beta - -import ai.llamaindex.llamacloud.core.ClientOptions -import ai.llamaindex.llamacloud.core.RequestOptions -import ai.llamaindex.llamacloud.core.checkRequired -import ai.llamaindex.llamacloud.core.handlers.errorBodyHandler -import ai.llamaindex.llamacloud.core.handlers.errorHandler -import ai.llamaindex.llamacloud.core.handlers.jsonHandler -import ai.llamaindex.llamacloud.core.http.HttpMethod -import ai.llamaindex.llamacloud.core.http.HttpRequest -import ai.llamaindex.llamacloud.core.http.HttpResponse -import ai.llamaindex.llamacloud.core.http.HttpResponse.Handler -import ai.llamaindex.llamacloud.core.http.HttpResponseFor -import ai.llamaindex.llamacloud.core.http.json -import ai.llamaindex.llamacloud.core.http.parseable -import ai.llamaindex.llamacloud.core.prepareAsync -import ai.llamaindex.llamacloud.models.beta.batch.BatchCancelParams -import ai.llamaindex.llamacloud.models.beta.batch.BatchCancelResponse -import ai.llamaindex.llamacloud.models.beta.batch.BatchCreateParams -import ai.llamaindex.llamacloud.models.beta.batch.BatchCreateResponse -import ai.llamaindex.llamacloud.models.beta.batch.BatchGetStatusParams -import ai.llamaindex.llamacloud.models.beta.batch.BatchGetStatusResponse -import ai.llamaindex.llamacloud.models.beta.batch.BatchListPageAsync -import ai.llamaindex.llamacloud.models.beta.batch.BatchListPageResponse -import ai.llamaindex.llamacloud.models.beta.batch.BatchListParams -import ai.llamaindex.llamacloud.services.async.beta.batch.JobItemServiceAsync -import ai.llamaindex.llamacloud.services.async.beta.batch.JobItemServiceAsyncImpl -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class BatchServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - BatchServiceAsync { - - private val withRawResponse: BatchServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - private val jobItems: JobItemServiceAsync by lazy { JobItemServiceAsyncImpl(clientOptions) } - - override fun withRawResponse(): BatchServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): BatchServiceAsync = - BatchServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun jobItems(): JobItemServiceAsync = jobItems - - override fun create( - params: BatchCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /api/v1/beta/batch-processing - withRawResponse().create(params, requestOptions).thenApply { it.parse() } - - override fun list( - params: BatchListParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /api/v1/beta/batch-processing - withRawResponse().list(params, requestOptions).thenApply { it.parse() } - - override fun cancel( - params: BatchCancelParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // post /api/v1/beta/batch-processing/{job_id}/cancel - withRawResponse().cancel(params, requestOptions).thenApply { it.parse() } - - override fun getStatus( - params: BatchGetStatusParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /api/v1/beta/batch-processing/{job_id} - withRawResponse().getStatus(params, requestOptions).thenApply { it.parse() } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - BatchServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - private val jobItems: JobItemServiceAsync.WithRawResponse by lazy { - JobItemServiceAsyncImpl.WithRawResponseImpl(clientOptions) - } - - override fun withOptions( - modifier: Consumer - ): BatchServiceAsync.WithRawResponse = - BatchServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - override fun jobItems(): JobItemServiceAsync.WithRawResponse = jobItems - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun create( - params: BatchCreateParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("api", "v1", "beta", "batch-processing") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: BatchListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("api", "v1", "beta", "batch-processing") - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - BatchListPageAsync.builder() - .service(BatchServiceAsyncImpl(clientOptions)) - .streamHandlerExecutor(clientOptions.streamHandlerExecutor) - .params(params) - .response(it) - .build() - } - } - } - } - - private val cancelHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun cancel( - params: BatchCancelParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "api", - "v1", - "beta", - "batch-processing", - params._pathParam(0), - "cancel", - ) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { cancelHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - - private val getStatusHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun getStatus( - params: BatchGetStatusParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("api", "v1", "beta", "batch-processing", params._pathParam(0)) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { getStatusHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - } -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/beta/batch/JobItemServiceAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/beta/batch/JobItemServiceAsync.kt deleted file mode 100644 index 86c5f63..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/beta/batch/JobItemServiceAsync.kt +++ /dev/null @@ -1,212 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.services.async.beta.batch - -import ai.llamaindex.llamacloud.core.ClientOptions -import ai.llamaindex.llamacloud.core.RequestOptions -import ai.llamaindex.llamacloud.core.http.HttpResponseFor -import ai.llamaindex.llamacloud.models.beta.batch.jobitems.JobItemGetProcessingResultsParams -import ai.llamaindex.llamacloud.models.beta.batch.jobitems.JobItemGetProcessingResultsResponse -import ai.llamaindex.llamacloud.models.beta.batch.jobitems.JobItemListPageAsync -import ai.llamaindex.llamacloud.models.beta.batch.jobitems.JobItemListParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer - -interface JobItemServiceAsync { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): JobItemServiceAsync - - /** - * List items in a batch job with optional status filtering. - * - * Useful for finding failed items, viewing completed items, or debugging processing issues. - */ - fun list(jobId: String): CompletableFuture = - list(jobId, JobItemListParams.none()) - - /** @see list */ - fun list( - jobId: String, - params: JobItemListParams = JobItemListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - list(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see list */ - fun list( - jobId: String, - params: JobItemListParams = JobItemListParams.none(), - ): CompletableFuture = list(jobId, params, RequestOptions.none()) - - /** @see list */ - fun list( - params: JobItemListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see list */ - fun list(params: JobItemListParams): CompletableFuture = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - jobId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - list(jobId, JobItemListParams.none(), requestOptions) - - /** - * Get all processing results for a specific item. - * - * Returns the complete processing history for an item including what operations were performed, - * parameters used, and where outputs are stored. Optionally filter by `job_type`. - */ - fun getProcessingResults( - itemId: String - ): CompletableFuture = - getProcessingResults(itemId, JobItemGetProcessingResultsParams.none()) - - /** @see getProcessingResults */ - fun getProcessingResults( - itemId: String, - params: JobItemGetProcessingResultsParams = JobItemGetProcessingResultsParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture = - getProcessingResults(params.toBuilder().itemId(itemId).build(), requestOptions) - - /** @see getProcessingResults */ - fun getProcessingResults( - itemId: String, - params: JobItemGetProcessingResultsParams = JobItemGetProcessingResultsParams.none(), - ): CompletableFuture = - getProcessingResults(itemId, params, RequestOptions.none()) - - /** @see getProcessingResults */ - fun getProcessingResults( - params: JobItemGetProcessingResultsParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture - - /** @see getProcessingResults */ - fun getProcessingResults( - params: JobItemGetProcessingResultsParams - ): CompletableFuture = - getProcessingResults(params, RequestOptions.none()) - - /** @see getProcessingResults */ - fun getProcessingResults( - itemId: String, - requestOptions: RequestOptions, - ): CompletableFuture = - getProcessingResults(itemId, JobItemGetProcessingResultsParams.none(), requestOptions) - - /** - * A view of [JobItemServiceAsync] that provides access to raw HTTP responses for each method. - */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions( - modifier: Consumer - ): JobItemServiceAsync.WithRawResponse - - /** - * Returns a raw HTTP response for `get /api/v1/beta/batch-processing/{job_id}/items`, but - * is otherwise the same as [JobItemServiceAsync.list]. - */ - fun list(jobId: String): CompletableFuture> = - list(jobId, JobItemListParams.none()) - - /** @see list */ - fun list( - jobId: String, - params: JobItemListParams = JobItemListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - list(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see list */ - fun list( - jobId: String, - params: JobItemListParams = JobItemListParams.none(), - ): CompletableFuture> = - list(jobId, params, RequestOptions.none()) - - /** @see list */ - fun list( - params: JobItemListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see list */ - fun list( - params: JobItemListParams - ): CompletableFuture> = - list(params, RequestOptions.none()) - - /** @see list */ - fun list( - jobId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - list(jobId, JobItemListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get - * /api/v1/beta/batch-processing/items/{item_id}/processing-results`, but is otherwise the - * same as [JobItemServiceAsync.getProcessingResults]. - */ - fun getProcessingResults( - itemId: String - ): CompletableFuture> = - getProcessingResults(itemId, JobItemGetProcessingResultsParams.none()) - - /** @see getProcessingResults */ - fun getProcessingResults( - itemId: String, - params: JobItemGetProcessingResultsParams = JobItemGetProcessingResultsParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> = - getProcessingResults(params.toBuilder().itemId(itemId).build(), requestOptions) - - /** @see getProcessingResults */ - fun getProcessingResults( - itemId: String, - params: JobItemGetProcessingResultsParams = JobItemGetProcessingResultsParams.none(), - ): CompletableFuture> = - getProcessingResults(itemId, params, RequestOptions.none()) - - /** @see getProcessingResults */ - fun getProcessingResults( - params: JobItemGetProcessingResultsParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> - - /** @see getProcessingResults */ - fun getProcessingResults( - params: JobItemGetProcessingResultsParams - ): CompletableFuture> = - getProcessingResults(params, RequestOptions.none()) - - /** @see getProcessingResults */ - fun getProcessingResults( - itemId: String, - requestOptions: RequestOptions, - ): CompletableFuture> = - getProcessingResults(itemId, JobItemGetProcessingResultsParams.none(), requestOptions) - } -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/beta/batch/JobItemServiceAsyncImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/beta/batch/JobItemServiceAsyncImpl.kt deleted file mode 100644 index 7742150..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/beta/batch/JobItemServiceAsyncImpl.kt +++ /dev/null @@ -1,155 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.services.async.beta.batch - -import ai.llamaindex.llamacloud.core.ClientOptions -import ai.llamaindex.llamacloud.core.RequestOptions -import ai.llamaindex.llamacloud.core.checkRequired -import ai.llamaindex.llamacloud.core.handlers.errorBodyHandler -import ai.llamaindex.llamacloud.core.handlers.errorHandler -import ai.llamaindex.llamacloud.core.handlers.jsonHandler -import ai.llamaindex.llamacloud.core.http.HttpMethod -import ai.llamaindex.llamacloud.core.http.HttpRequest -import ai.llamaindex.llamacloud.core.http.HttpResponse -import ai.llamaindex.llamacloud.core.http.HttpResponse.Handler -import ai.llamaindex.llamacloud.core.http.HttpResponseFor -import ai.llamaindex.llamacloud.core.http.parseable -import ai.llamaindex.llamacloud.core.prepareAsync -import ai.llamaindex.llamacloud.models.beta.batch.jobitems.JobItemGetProcessingResultsParams -import ai.llamaindex.llamacloud.models.beta.batch.jobitems.JobItemGetProcessingResultsResponse -import ai.llamaindex.llamacloud.models.beta.batch.jobitems.JobItemListPageAsync -import ai.llamaindex.llamacloud.models.beta.batch.jobitems.JobItemListPageResponse -import ai.llamaindex.llamacloud.models.beta.batch.jobitems.JobItemListParams -import java.util.concurrent.CompletableFuture -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class JobItemServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : - JobItemServiceAsync { - - private val withRawResponse: JobItemServiceAsync.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): JobItemServiceAsync.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): JobItemServiceAsync = - JobItemServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun list( - params: JobItemListParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /api/v1/beta/batch-processing/{job_id}/items - withRawResponse().list(params, requestOptions).thenApply { it.parse() } - - override fun getProcessingResults( - params: JobItemGetProcessingResultsParams, - requestOptions: RequestOptions, - ): CompletableFuture = - // get /api/v1/beta/batch-processing/items/{item_id}/processing-results - withRawResponse().getProcessingResults(params, requestOptions).thenApply { it.parse() } - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - JobItemServiceAsync.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): JobItemServiceAsync.WithRawResponse = - JobItemServiceAsyncImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: JobItemListParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "api", - "v1", - "beta", - "batch-processing", - params._pathParam(0), - "items", - ) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - JobItemListPageAsync.builder() - .service(JobItemServiceAsyncImpl(clientOptions)) - .streamHandlerExecutor(clientOptions.streamHandlerExecutor) - .params(params) - .response(it) - .build() - } - } - } - } - - private val getProcessingResultsHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun getProcessingResults( - params: JobItemGetProcessingResultsParams, - requestOptions: RequestOptions, - ): CompletableFuture> { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("itemId", params.itemId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "api", - "v1", - "beta", - "batch-processing", - "items", - params._pathParam(0), - "processing-results", - ) - .build() - .prepareAsync(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - return request - .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } - .thenApply { response -> - errorHandler.handle(response).parseable { - response - .use { getProcessingResultsHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } - } -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchService.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchService.kt deleted file mode 100644 index 24634ab..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchService.kt +++ /dev/null @@ -1,189 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.services.blocking - -import ai.llamaindex.llamacloud.core.ClientOptions -import ai.llamaindex.llamacloud.core.RequestOptions -import ai.llamaindex.llamacloud.core.http.HttpResponseFor -import ai.llamaindex.llamacloud.models.batches.BatchCreateParams -import ai.llamaindex.llamacloud.models.batches.BatchCreateResponse -import ai.llamaindex.llamacloud.models.batches.BatchGetParams -import ai.llamaindex.llamacloud.models.batches.BatchGetResponse -import ai.llamaindex.llamacloud.models.batches.BatchListPage -import ai.llamaindex.llamacloud.models.batches.BatchListParams -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface BatchService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): BatchService - - /** - * Create a batch over a source directory and start processing asynchronously. - * - * To be notified as the batch progresses, pass `webhook_configurations` with inline endpoints - * and/or `webhook_configuration_ids` referencing saved configurations. Batches emit - * `batch.pending` on create, `batch.running` once processing starts, and a terminal - * `batch.success` or `batch.error`. - * - * `batch.success` means the batch finished mapping every source file to a job — individual - * files may still have failed, so read `results` (with `expand=results`) for per-file outcomes. - * - * Delivery order across events is not guaranteed; key on the `status` field in the payload - * rather than arrival order. - */ - fun create(params: BatchCreateParams): BatchCreateResponse = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - params: BatchCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): BatchCreateResponse - - /** List batches for the current project. */ - fun list(): BatchListPage = list(BatchListParams.none()) - - /** @see list */ - fun list( - params: BatchListParams = BatchListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): BatchListPage - - /** @see list */ - fun list(params: BatchListParams = BatchListParams.none()): BatchListPage = - list(params, RequestOptions.none()) - - /** @see list */ - fun list(requestOptions: RequestOptions): BatchListPage = - list(BatchListParams.none(), requestOptions) - - /** Get a batch by ID. */ - fun get(batchId: String): BatchGetResponse = get(batchId, BatchGetParams.none()) - - /** @see get */ - fun get( - batchId: String, - params: BatchGetParams = BatchGetParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): BatchGetResponse = get(params.toBuilder().batchId(batchId).build(), requestOptions) - - /** @see get */ - fun get(batchId: String, params: BatchGetParams = BatchGetParams.none()): BatchGetResponse = - get(batchId, params, RequestOptions.none()) - - /** @see get */ - fun get( - params: BatchGetParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): BatchGetResponse - - /** @see get */ - fun get(params: BatchGetParams): BatchGetResponse = get(params, RequestOptions.none()) - - /** @see get */ - fun get(batchId: String, requestOptions: RequestOptions): BatchGetResponse = - get(batchId, BatchGetParams.none(), requestOptions) - - /** A view of [BatchService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): BatchService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /api/v2/batches`, but is otherwise the same as - * [BatchService.create]. - */ - @MustBeClosed - fun create(params: BatchCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) - - /** @see create */ - @MustBeClosed - fun create( - params: BatchCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `get /api/v2/batches`, but is otherwise the same as - * [BatchService.list]. - */ - @MustBeClosed fun list(): HttpResponseFor = list(BatchListParams.none()) - - /** @see list */ - @MustBeClosed - fun list( - params: BatchListParams = BatchListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see list */ - @MustBeClosed - fun list(params: BatchListParams = BatchListParams.none()): HttpResponseFor = - list(params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(BatchListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /api/v2/batches/{batch_id}`, but is otherwise the - * same as [BatchService.get]. - */ - @MustBeClosed - fun get(batchId: String): HttpResponseFor = - get(batchId, BatchGetParams.none()) - - /** @see get */ - @MustBeClosed - fun get( - batchId: String, - params: BatchGetParams = BatchGetParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - get(params.toBuilder().batchId(batchId).build(), requestOptions) - - /** @see get */ - @MustBeClosed - fun get( - batchId: String, - params: BatchGetParams = BatchGetParams.none(), - ): HttpResponseFor = get(batchId, params, RequestOptions.none()) - - /** @see get */ - @MustBeClosed - fun get( - params: BatchGetParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see get */ - @MustBeClosed - fun get(params: BatchGetParams): HttpResponseFor = - get(params, RequestOptions.none()) - - /** @see get */ - @MustBeClosed - fun get( - batchId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = get(batchId, BatchGetParams.none(), requestOptions) - } -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceImpl.kt deleted file mode 100644 index 4329ec4..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceImpl.kt +++ /dev/null @@ -1,161 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.services.blocking - -import ai.llamaindex.llamacloud.core.ClientOptions -import ai.llamaindex.llamacloud.core.RequestOptions -import ai.llamaindex.llamacloud.core.checkRequired -import ai.llamaindex.llamacloud.core.handlers.errorBodyHandler -import ai.llamaindex.llamacloud.core.handlers.errorHandler -import ai.llamaindex.llamacloud.core.handlers.jsonHandler -import ai.llamaindex.llamacloud.core.http.HttpMethod -import ai.llamaindex.llamacloud.core.http.HttpRequest -import ai.llamaindex.llamacloud.core.http.HttpResponse -import ai.llamaindex.llamacloud.core.http.HttpResponse.Handler -import ai.llamaindex.llamacloud.core.http.HttpResponseFor -import ai.llamaindex.llamacloud.core.http.json -import ai.llamaindex.llamacloud.core.http.parseable -import ai.llamaindex.llamacloud.core.prepare -import ai.llamaindex.llamacloud.models.batches.BatchCreateParams -import ai.llamaindex.llamacloud.models.batches.BatchCreateResponse -import ai.llamaindex.llamacloud.models.batches.BatchGetParams -import ai.llamaindex.llamacloud.models.batches.BatchGetResponse -import ai.llamaindex.llamacloud.models.batches.BatchListPage -import ai.llamaindex.llamacloud.models.batches.BatchListPageResponse -import ai.llamaindex.llamacloud.models.batches.BatchListParams -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class BatchServiceImpl internal constructor(private val clientOptions: ClientOptions) : - BatchService { - - private val withRawResponse: BatchService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): BatchService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): BatchService = - BatchServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun create( - params: BatchCreateParams, - requestOptions: RequestOptions, - ): BatchCreateResponse = - // post /api/v2/batches - withRawResponse().create(params, requestOptions).parse() - - override fun list(params: BatchListParams, requestOptions: RequestOptions): BatchListPage = - // get /api/v2/batches - withRawResponse().list(params, requestOptions).parse() - - override fun get(params: BatchGetParams, requestOptions: RequestOptions): BatchGetResponse = - // get /api/v2/batches/{batch_id} - withRawResponse().get(params, requestOptions).parse() - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - BatchService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): BatchService.WithRawResponse = - BatchServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun create( - params: BatchCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("api", "v2", "batches") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: BatchListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("api", "v2", "batches") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - BatchListPage.builder() - .service(BatchServiceImpl(clientOptions)) - .params(params) - .response(it) - .build() - } - } - } - - private val getHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun get( - params: BatchGetParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("batchId", params.batchId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("api", "v2", "batches", params._pathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { getHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BetaService.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BetaService.kt index 18546a0..64b26b5 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BetaService.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BetaService.kt @@ -4,7 +4,6 @@ package ai.llamaindex.llamacloud.services.blocking import ai.llamaindex.llamacloud.core.ClientOptions import ai.llamaindex.llamacloud.services.blocking.beta.AgentDataService -import ai.llamaindex.llamacloud.services.blocking.beta.BatchService import ai.llamaindex.llamacloud.services.blocking.beta.ChatService import ai.llamaindex.llamacloud.services.blocking.beta.DirectoryService import ai.llamaindex.llamacloud.services.blocking.beta.IndexService @@ -39,8 +38,6 @@ interface BetaService { fun directories(): DirectoryService - fun batch(): BatchService - fun split(): SplitService /** A view of [BetaService] that provides access to raw HTTP responses for each method. */ @@ -65,8 +62,6 @@ interface BetaService { fun directories(): DirectoryService.WithRawResponse - fun batch(): BatchService.WithRawResponse - fun split(): SplitService.WithRawResponse } } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BetaServiceImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BetaServiceImpl.kt index 94d0bb3..8a720ef 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BetaServiceImpl.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BetaServiceImpl.kt @@ -5,8 +5,6 @@ package ai.llamaindex.llamacloud.services.blocking import ai.llamaindex.llamacloud.core.ClientOptions import ai.llamaindex.llamacloud.services.blocking.beta.AgentDataService import ai.llamaindex.llamacloud.services.blocking.beta.AgentDataServiceImpl -import ai.llamaindex.llamacloud.services.blocking.beta.BatchService -import ai.llamaindex.llamacloud.services.blocking.beta.BatchServiceImpl import ai.llamaindex.llamacloud.services.blocking.beta.ChatService import ai.llamaindex.llamacloud.services.blocking.beta.ChatServiceImpl import ai.llamaindex.llamacloud.services.blocking.beta.DirectoryService @@ -39,8 +37,6 @@ class BetaServiceImpl internal constructor(private val clientOptions: ClientOpti private val directories: DirectoryService by lazy { DirectoryServiceImpl(clientOptions) } - private val batch: BatchService by lazy { BatchServiceImpl(clientOptions) } - private val split: SplitService by lazy { SplitServiceImpl(clientOptions) } override fun withRawResponse(): BetaService.WithRawResponse = withRawResponse @@ -60,8 +56,6 @@ class BetaServiceImpl internal constructor(private val clientOptions: ClientOpti override fun directories(): DirectoryService = directories - override fun batch(): BatchService = batch - override fun split(): SplitService = split class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -91,10 +85,6 @@ class BetaServiceImpl internal constructor(private val clientOptions: ClientOpti DirectoryServiceImpl.WithRawResponseImpl(clientOptions) } - private val batch: BatchService.WithRawResponse by lazy { - BatchServiceImpl.WithRawResponseImpl(clientOptions) - } - private val split: SplitService.WithRawResponse by lazy { SplitServiceImpl.WithRawResponseImpl(clientOptions) } @@ -118,8 +108,6 @@ class BetaServiceImpl internal constructor(private val clientOptions: ClientOpti override fun directories(): DirectoryService.WithRawResponse = directories - override fun batch(): BatchService.WithRawResponse = batch - override fun split(): SplitService.WithRawResponse = split } } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingService.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingService.kt index 576f883..330d76b 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingService.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingService.kt @@ -5,6 +5,8 @@ package ai.llamaindex.llamacloud.services.blocking import ai.llamaindex.llamacloud.core.ClientOptions import ai.llamaindex.llamacloud.core.RequestOptions import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.models.parsing.ParsingCancelParams +import ai.llamaindex.llamacloud.models.parsing.ParsingCancelResponse import ai.llamaindex.llamacloud.models.parsing.ParsingCreateParams import ai.llamaindex.llamacloud.models.parsing.ParsingCreateResponse import ai.llamaindex.llamacloud.models.parsing.ParsingGetParams @@ -74,6 +76,41 @@ interface ParsingService { fun list(requestOptions: RequestOptions): ParsingListPage = list(ParsingListParams.none(), requestOptions) + /** + * Cancel a running parse job. + * + * Stops processing and marks the job as CANCELLED. Returns the updated job. Jobs already in a + * terminal state (COMPLETED, FAILED, CANCELLED) cannot be cancelled. + */ + fun cancel(jobId: String): ParsingCancelResponse = cancel(jobId, ParsingCancelParams.none()) + + /** @see cancel */ + fun cancel( + jobId: String, + params: ParsingCancelParams = ParsingCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ParsingCancelResponse = cancel(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + jobId: String, + params: ParsingCancelParams = ParsingCancelParams.none(), + ): ParsingCancelResponse = cancel(jobId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: ParsingCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ParsingCancelResponse + + /** @see cancel */ + fun cancel(params: ParsingCancelParams): ParsingCancelResponse = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel(jobId: String, requestOptions: RequestOptions): ParsingCancelResponse = + cancel(jobId, ParsingCancelParams.none(), requestOptions) + /** * Retrieve a parse job with optional expanded content. * @@ -161,6 +198,50 @@ interface ParsingService { fun list(requestOptions: RequestOptions): HttpResponseFor = list(ParsingListParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /api/v2/parse/{job_id}/cancel`, but is otherwise + * the same as [ParsingService.cancel]. + */ + @MustBeClosed + fun cancel(jobId: String): HttpResponseFor = + cancel(jobId, ParsingCancelParams.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + jobId: String, + params: ParsingCancelParams = ParsingCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + cancel(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see cancel */ + @MustBeClosed + fun cancel( + jobId: String, + params: ParsingCancelParams = ParsingCancelParams.none(), + ): HttpResponseFor = cancel(jobId, params, RequestOptions.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + params: ParsingCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see cancel */ + @MustBeClosed + fun cancel(params: ParsingCancelParams): HttpResponseFor = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + jobId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + cancel(jobId, ParsingCancelParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /api/v2/parse/{job_id}`, but is otherwise the same * as [ParsingService.get]. diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceImpl.kt index 0181ba4..9ca75ac 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceImpl.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceImpl.kt @@ -16,6 +16,8 @@ import ai.llamaindex.llamacloud.core.http.HttpResponseFor import ai.llamaindex.llamacloud.core.http.json import ai.llamaindex.llamacloud.core.http.parseable import ai.llamaindex.llamacloud.core.prepare +import ai.llamaindex.llamacloud.models.parsing.ParsingCancelParams +import ai.llamaindex.llamacloud.models.parsing.ParsingCancelResponse import ai.llamaindex.llamacloud.models.parsing.ParsingCreateParams import ai.llamaindex.llamacloud.models.parsing.ParsingCreateResponse import ai.llamaindex.llamacloud.models.parsing.ParsingGetParams @@ -49,6 +51,13 @@ class ParsingServiceImpl internal constructor(private val clientOptions: ClientO // get /api/v2/parse withRawResponse().list(params, requestOptions).parse() + override fun cancel( + params: ParsingCancelParams, + requestOptions: RequestOptions, + ): ParsingCancelResponse = + // post /api/v2/parse/{job_id}/cancel + withRawResponse().cancel(params, requestOptions).parse() + override fun get(params: ParsingGetParams, requestOptions: RequestOptions): ParsingGetResponse = // get /api/v2/parse/{job_id} withRawResponse().get(params, requestOptions).parse() @@ -128,6 +137,37 @@ class ParsingServiceImpl internal constructor(private val clientOptions: ClientO } } + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun cancel( + params: ParsingCancelParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v2", "parse", params._pathParam(0), "cancel") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { cancelHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/BatchService.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/BatchService.kt deleted file mode 100644 index a60e051..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/BatchService.kt +++ /dev/null @@ -1,285 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.services.blocking.beta - -import ai.llamaindex.llamacloud.core.ClientOptions -import ai.llamaindex.llamacloud.core.RequestOptions -import ai.llamaindex.llamacloud.core.http.HttpResponseFor -import ai.llamaindex.llamacloud.models.beta.batch.BatchCancelParams -import ai.llamaindex.llamacloud.models.beta.batch.BatchCancelResponse -import ai.llamaindex.llamacloud.models.beta.batch.BatchCreateParams -import ai.llamaindex.llamacloud.models.beta.batch.BatchCreateResponse -import ai.llamaindex.llamacloud.models.beta.batch.BatchGetStatusParams -import ai.llamaindex.llamacloud.models.beta.batch.BatchGetStatusResponse -import ai.llamaindex.llamacloud.models.beta.batch.BatchListPage -import ai.llamaindex.llamacloud.models.beta.batch.BatchListParams -import ai.llamaindex.llamacloud.services.blocking.beta.batch.JobItemService -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface BatchService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): BatchService - - fun jobItems(): JobItemService - - /** - * Create a batch processing job. - * - * Processes files from a directory or a specific list of item IDs. Supports batch parsing and - * classification operations. - * - * Provide either `directory_id` to process all files in a directory, or `item_ids` for specific - * items. The job runs asynchronously — poll `GET /batch/{job_id}` for progress. - */ - fun create(params: BatchCreateParams): BatchCreateResponse = - create(params, RequestOptions.none()) - - /** @see create */ - fun create( - params: BatchCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): BatchCreateResponse - - /** - * List batch processing jobs with optional filtering. - * - * Filter by `directory_id`, `job_type`, or `status`. Results are paginated with configurable - * `limit` and `offset`. - */ - fun list(): BatchListPage = list(BatchListParams.none()) - - /** @see list */ - fun list( - params: BatchListParams = BatchListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): BatchListPage - - /** @see list */ - fun list(params: BatchListParams = BatchListParams.none()): BatchListPage = - list(params, RequestOptions.none()) - - /** @see list */ - fun list(requestOptions: RequestOptions): BatchListPage = - list(BatchListParams.none(), requestOptions) - - /** - * Cancel a running batch processing job. - * - * Stops processing and marks pending items as cancelled. Items currently being processed may - * still complete. - */ - fun cancel(jobId: String): BatchCancelResponse = cancel(jobId, BatchCancelParams.none()) - - /** @see cancel */ - fun cancel( - jobId: String, - params: BatchCancelParams = BatchCancelParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): BatchCancelResponse = cancel(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see cancel */ - fun cancel( - jobId: String, - params: BatchCancelParams = BatchCancelParams.none(), - ): BatchCancelResponse = cancel(jobId, params, RequestOptions.none()) - - /** @see cancel */ - fun cancel( - params: BatchCancelParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): BatchCancelResponse - - /** @see cancel */ - fun cancel(params: BatchCancelParams): BatchCancelResponse = - cancel(params, RequestOptions.none()) - - /** @see cancel */ - fun cancel(jobId: String, requestOptions: RequestOptions): BatchCancelResponse = - cancel(jobId, BatchCancelParams.none(), requestOptions) - - /** - * Get detailed status of a batch processing job. - * - * Returns current progress percentage, file counts (total, processed, failed, skipped), and - * timestamps. - */ - fun getStatus(jobId: String): BatchGetStatusResponse = - getStatus(jobId, BatchGetStatusParams.none()) - - /** @see getStatus */ - fun getStatus( - jobId: String, - params: BatchGetStatusParams = BatchGetStatusParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): BatchGetStatusResponse = getStatus(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see getStatus */ - fun getStatus( - jobId: String, - params: BatchGetStatusParams = BatchGetStatusParams.none(), - ): BatchGetStatusResponse = getStatus(jobId, params, RequestOptions.none()) - - /** @see getStatus */ - fun getStatus( - params: BatchGetStatusParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): BatchGetStatusResponse - - /** @see getStatus */ - fun getStatus(params: BatchGetStatusParams): BatchGetStatusResponse = - getStatus(params, RequestOptions.none()) - - /** @see getStatus */ - fun getStatus(jobId: String, requestOptions: RequestOptions): BatchGetStatusResponse = - getStatus(jobId, BatchGetStatusParams.none(), requestOptions) - - /** A view of [BatchService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): BatchService.WithRawResponse - - fun jobItems(): JobItemService.WithRawResponse - - /** - * Returns a raw HTTP response for `post /api/v1/beta/batch-processing`, but is otherwise - * the same as [BatchService.create]. - */ - @MustBeClosed - fun create(params: BatchCreateParams): HttpResponseFor = - create(params, RequestOptions.none()) - - /** @see create */ - @MustBeClosed - fun create( - params: BatchCreateParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** - * Returns a raw HTTP response for `get /api/v1/beta/batch-processing`, but is otherwise the - * same as [BatchService.list]. - */ - @MustBeClosed fun list(): HttpResponseFor = list(BatchListParams.none()) - - /** @see list */ - @MustBeClosed - fun list( - params: BatchListParams = BatchListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see list */ - @MustBeClosed - fun list(params: BatchListParams = BatchListParams.none()): HttpResponseFor = - list(params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list(requestOptions: RequestOptions): HttpResponseFor = - list(BatchListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `post /api/v1/beta/batch-processing/{job_id}/cancel`, but - * is otherwise the same as [BatchService.cancel]. - */ - @MustBeClosed - fun cancel(jobId: String): HttpResponseFor = - cancel(jobId, BatchCancelParams.none()) - - /** @see cancel */ - @MustBeClosed - fun cancel( - jobId: String, - params: BatchCancelParams = BatchCancelParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - cancel(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see cancel */ - @MustBeClosed - fun cancel( - jobId: String, - params: BatchCancelParams = BatchCancelParams.none(), - ): HttpResponseFor = cancel(jobId, params, RequestOptions.none()) - - /** @see cancel */ - @MustBeClosed - fun cancel( - params: BatchCancelParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see cancel */ - @MustBeClosed - fun cancel(params: BatchCancelParams): HttpResponseFor = - cancel(params, RequestOptions.none()) - - /** @see cancel */ - @MustBeClosed - fun cancel( - jobId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - cancel(jobId, BatchCancelParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get /api/v1/beta/batch-processing/{job_id}`, but is - * otherwise the same as [BatchService.getStatus]. - */ - @MustBeClosed - fun getStatus(jobId: String): HttpResponseFor = - getStatus(jobId, BatchGetStatusParams.none()) - - /** @see getStatus */ - @MustBeClosed - fun getStatus( - jobId: String, - params: BatchGetStatusParams = BatchGetStatusParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - getStatus(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see getStatus */ - @MustBeClosed - fun getStatus( - jobId: String, - params: BatchGetStatusParams = BatchGetStatusParams.none(), - ): HttpResponseFor = getStatus(jobId, params, RequestOptions.none()) - - /** @see getStatus */ - @MustBeClosed - fun getStatus( - params: BatchGetStatusParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see getStatus */ - @MustBeClosed - fun getStatus(params: BatchGetStatusParams): HttpResponseFor = - getStatus(params, RequestOptions.none()) - - /** @see getStatus */ - @MustBeClosed - fun getStatus( - jobId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - getStatus(jobId, BatchGetStatusParams.none(), requestOptions) - } -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/BatchServiceImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/BatchServiceImpl.kt deleted file mode 100644 index 2deef58..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/BatchServiceImpl.kt +++ /dev/null @@ -1,223 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.services.blocking.beta - -import ai.llamaindex.llamacloud.core.ClientOptions -import ai.llamaindex.llamacloud.core.RequestOptions -import ai.llamaindex.llamacloud.core.checkRequired -import ai.llamaindex.llamacloud.core.handlers.errorBodyHandler -import ai.llamaindex.llamacloud.core.handlers.errorHandler -import ai.llamaindex.llamacloud.core.handlers.jsonHandler -import ai.llamaindex.llamacloud.core.http.HttpMethod -import ai.llamaindex.llamacloud.core.http.HttpRequest -import ai.llamaindex.llamacloud.core.http.HttpResponse -import ai.llamaindex.llamacloud.core.http.HttpResponse.Handler -import ai.llamaindex.llamacloud.core.http.HttpResponseFor -import ai.llamaindex.llamacloud.core.http.json -import ai.llamaindex.llamacloud.core.http.parseable -import ai.llamaindex.llamacloud.core.prepare -import ai.llamaindex.llamacloud.models.beta.batch.BatchCancelParams -import ai.llamaindex.llamacloud.models.beta.batch.BatchCancelResponse -import ai.llamaindex.llamacloud.models.beta.batch.BatchCreateParams -import ai.llamaindex.llamacloud.models.beta.batch.BatchCreateResponse -import ai.llamaindex.llamacloud.models.beta.batch.BatchGetStatusParams -import ai.llamaindex.llamacloud.models.beta.batch.BatchGetStatusResponse -import ai.llamaindex.llamacloud.models.beta.batch.BatchListPage -import ai.llamaindex.llamacloud.models.beta.batch.BatchListPageResponse -import ai.llamaindex.llamacloud.models.beta.batch.BatchListParams -import ai.llamaindex.llamacloud.services.blocking.beta.batch.JobItemService -import ai.llamaindex.llamacloud.services.blocking.beta.batch.JobItemServiceImpl -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class BatchServiceImpl internal constructor(private val clientOptions: ClientOptions) : - BatchService { - - private val withRawResponse: BatchService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - private val jobItems: JobItemService by lazy { JobItemServiceImpl(clientOptions) } - - override fun withRawResponse(): BatchService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): BatchService = - BatchServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun jobItems(): JobItemService = jobItems - - override fun create( - params: BatchCreateParams, - requestOptions: RequestOptions, - ): BatchCreateResponse = - // post /api/v1/beta/batch-processing - withRawResponse().create(params, requestOptions).parse() - - override fun list(params: BatchListParams, requestOptions: RequestOptions): BatchListPage = - // get /api/v1/beta/batch-processing - withRawResponse().list(params, requestOptions).parse() - - override fun cancel( - params: BatchCancelParams, - requestOptions: RequestOptions, - ): BatchCancelResponse = - // post /api/v1/beta/batch-processing/{job_id}/cancel - withRawResponse().cancel(params, requestOptions).parse() - - override fun getStatus( - params: BatchGetStatusParams, - requestOptions: RequestOptions, - ): BatchGetStatusResponse = - // get /api/v1/beta/batch-processing/{job_id} - withRawResponse().getStatus(params, requestOptions).parse() - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - BatchService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - private val jobItems: JobItemService.WithRawResponse by lazy { - JobItemServiceImpl.WithRawResponseImpl(clientOptions) - } - - override fun withOptions( - modifier: Consumer - ): BatchService.WithRawResponse = - BatchServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - override fun jobItems(): JobItemService.WithRawResponse = jobItems - - private val createHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun create( - params: BatchCreateParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("api", "v1", "beta", "batch-processing") - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { createHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: BatchListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("api", "v1", "beta", "batch-processing") - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - BatchListPage.builder() - .service(BatchServiceImpl(clientOptions)) - .params(params) - .response(it) - .build() - } - } - } - - private val cancelHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun cancel( - params: BatchCancelParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.POST) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "api", - "v1", - "beta", - "batch-processing", - params._pathParam(0), - "cancel", - ) - .body(json(clientOptions.jsonMapper, params._body())) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { cancelHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - - private val getStatusHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun getStatus( - params: BatchGetStatusParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments("api", "v1", "beta", "batch-processing", params._pathParam(0)) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { getStatusHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/batch/JobItemService.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/batch/JobItemService.kt deleted file mode 100644 index f39c5ee..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/batch/JobItemService.kt +++ /dev/null @@ -1,203 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.services.blocking.beta.batch - -import ai.llamaindex.llamacloud.core.ClientOptions -import ai.llamaindex.llamacloud.core.RequestOptions -import ai.llamaindex.llamacloud.core.http.HttpResponseFor -import ai.llamaindex.llamacloud.models.beta.batch.jobitems.JobItemGetProcessingResultsParams -import ai.llamaindex.llamacloud.models.beta.batch.jobitems.JobItemGetProcessingResultsResponse -import ai.llamaindex.llamacloud.models.beta.batch.jobitems.JobItemListPage -import ai.llamaindex.llamacloud.models.beta.batch.jobitems.JobItemListParams -import com.google.errorprone.annotations.MustBeClosed -import java.util.function.Consumer - -interface JobItemService { - - /** - * Returns a view of this service that provides access to raw HTTP responses for each method. - */ - fun withRawResponse(): WithRawResponse - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): JobItemService - - /** - * List items in a batch job with optional status filtering. - * - * Useful for finding failed items, viewing completed items, or debugging processing issues. - */ - fun list(jobId: String): JobItemListPage = list(jobId, JobItemListParams.none()) - - /** @see list */ - fun list( - jobId: String, - params: JobItemListParams = JobItemListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): JobItemListPage = list(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see list */ - fun list(jobId: String, params: JobItemListParams = JobItemListParams.none()): JobItemListPage = - list(jobId, params, RequestOptions.none()) - - /** @see list */ - fun list( - params: JobItemListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): JobItemListPage - - /** @see list */ - fun list(params: JobItemListParams): JobItemListPage = list(params, RequestOptions.none()) - - /** @see list */ - fun list(jobId: String, requestOptions: RequestOptions): JobItemListPage = - list(jobId, JobItemListParams.none(), requestOptions) - - /** - * Get all processing results for a specific item. - * - * Returns the complete processing history for an item including what operations were performed, - * parameters used, and where outputs are stored. Optionally filter by `job_type`. - */ - fun getProcessingResults(itemId: String): JobItemGetProcessingResultsResponse = - getProcessingResults(itemId, JobItemGetProcessingResultsParams.none()) - - /** @see getProcessingResults */ - fun getProcessingResults( - itemId: String, - params: JobItemGetProcessingResultsParams = JobItemGetProcessingResultsParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): JobItemGetProcessingResultsResponse = - getProcessingResults(params.toBuilder().itemId(itemId).build(), requestOptions) - - /** @see getProcessingResults */ - fun getProcessingResults( - itemId: String, - params: JobItemGetProcessingResultsParams = JobItemGetProcessingResultsParams.none(), - ): JobItemGetProcessingResultsResponse = - getProcessingResults(itemId, params, RequestOptions.none()) - - /** @see getProcessingResults */ - fun getProcessingResults( - params: JobItemGetProcessingResultsParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): JobItemGetProcessingResultsResponse - - /** @see getProcessingResults */ - fun getProcessingResults( - params: JobItemGetProcessingResultsParams - ): JobItemGetProcessingResultsResponse = getProcessingResults(params, RequestOptions.none()) - - /** @see getProcessingResults */ - fun getProcessingResults( - itemId: String, - requestOptions: RequestOptions, - ): JobItemGetProcessingResultsResponse = - getProcessingResults(itemId, JobItemGetProcessingResultsParams.none(), requestOptions) - - /** A view of [JobItemService] that provides access to raw HTTP responses for each method. */ - interface WithRawResponse { - - /** - * Returns a view of this service with the given option modifications applied. - * - * The original service is not modified. - */ - fun withOptions(modifier: Consumer): JobItemService.WithRawResponse - - /** - * Returns a raw HTTP response for `get /api/v1/beta/batch-processing/{job_id}/items`, but - * is otherwise the same as [JobItemService.list]. - */ - @MustBeClosed - fun list(jobId: String): HttpResponseFor = - list(jobId, JobItemListParams.none()) - - /** @see list */ - @MustBeClosed - fun list( - jobId: String, - params: JobItemListParams = JobItemListParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - list(params.toBuilder().jobId(jobId).build(), requestOptions) - - /** @see list */ - @MustBeClosed - fun list( - jobId: String, - params: JobItemListParams = JobItemListParams.none(), - ): HttpResponseFor = list(jobId, params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list( - params: JobItemListParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see list */ - @MustBeClosed - fun list(params: JobItemListParams): HttpResponseFor = - list(params, RequestOptions.none()) - - /** @see list */ - @MustBeClosed - fun list(jobId: String, requestOptions: RequestOptions): HttpResponseFor = - list(jobId, JobItemListParams.none(), requestOptions) - - /** - * Returns a raw HTTP response for `get - * /api/v1/beta/batch-processing/items/{item_id}/processing-results`, but is otherwise the - * same as [JobItemService.getProcessingResults]. - */ - @MustBeClosed - fun getProcessingResults( - itemId: String - ): HttpResponseFor = - getProcessingResults(itemId, JobItemGetProcessingResultsParams.none()) - - /** @see getProcessingResults */ - @MustBeClosed - fun getProcessingResults( - itemId: String, - params: JobItemGetProcessingResultsParams = JobItemGetProcessingResultsParams.none(), - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor = - getProcessingResults(params.toBuilder().itemId(itemId).build(), requestOptions) - - /** @see getProcessingResults */ - @MustBeClosed - fun getProcessingResults( - itemId: String, - params: JobItemGetProcessingResultsParams = JobItemGetProcessingResultsParams.none(), - ): HttpResponseFor = - getProcessingResults(itemId, params, RequestOptions.none()) - - /** @see getProcessingResults */ - @MustBeClosed - fun getProcessingResults( - params: JobItemGetProcessingResultsParams, - requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor - - /** @see getProcessingResults */ - @MustBeClosed - fun getProcessingResults( - params: JobItemGetProcessingResultsParams - ): HttpResponseFor = - getProcessingResults(params, RequestOptions.none()) - - /** @see getProcessingResults */ - @MustBeClosed - fun getProcessingResults( - itemId: String, - requestOptions: RequestOptions, - ): HttpResponseFor = - getProcessingResults(itemId, JobItemGetProcessingResultsParams.none(), requestOptions) - } -} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/batch/JobItemServiceImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/batch/JobItemServiceImpl.kt deleted file mode 100644 index 4251655..0000000 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/batch/JobItemServiceImpl.kt +++ /dev/null @@ -1,144 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.services.blocking.beta.batch - -import ai.llamaindex.llamacloud.core.ClientOptions -import ai.llamaindex.llamacloud.core.RequestOptions -import ai.llamaindex.llamacloud.core.checkRequired -import ai.llamaindex.llamacloud.core.handlers.errorBodyHandler -import ai.llamaindex.llamacloud.core.handlers.errorHandler -import ai.llamaindex.llamacloud.core.handlers.jsonHandler -import ai.llamaindex.llamacloud.core.http.HttpMethod -import ai.llamaindex.llamacloud.core.http.HttpRequest -import ai.llamaindex.llamacloud.core.http.HttpResponse -import ai.llamaindex.llamacloud.core.http.HttpResponse.Handler -import ai.llamaindex.llamacloud.core.http.HttpResponseFor -import ai.llamaindex.llamacloud.core.http.parseable -import ai.llamaindex.llamacloud.core.prepare -import ai.llamaindex.llamacloud.models.beta.batch.jobitems.JobItemGetProcessingResultsParams -import ai.llamaindex.llamacloud.models.beta.batch.jobitems.JobItemGetProcessingResultsResponse -import ai.llamaindex.llamacloud.models.beta.batch.jobitems.JobItemListPage -import ai.llamaindex.llamacloud.models.beta.batch.jobitems.JobItemListPageResponse -import ai.llamaindex.llamacloud.models.beta.batch.jobitems.JobItemListParams -import java.util.function.Consumer -import kotlin.jvm.optionals.getOrNull - -class JobItemServiceImpl internal constructor(private val clientOptions: ClientOptions) : - JobItemService { - - private val withRawResponse: JobItemService.WithRawResponse by lazy { - WithRawResponseImpl(clientOptions) - } - - override fun withRawResponse(): JobItemService.WithRawResponse = withRawResponse - - override fun withOptions(modifier: Consumer): JobItemService = - JobItemServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) - - override fun list(params: JobItemListParams, requestOptions: RequestOptions): JobItemListPage = - // get /api/v1/beta/batch-processing/{job_id}/items - withRawResponse().list(params, requestOptions).parse() - - override fun getProcessingResults( - params: JobItemGetProcessingResultsParams, - requestOptions: RequestOptions, - ): JobItemGetProcessingResultsResponse = - // get /api/v1/beta/batch-processing/items/{item_id}/processing-results - withRawResponse().getProcessingResults(params, requestOptions).parse() - - class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : - JobItemService.WithRawResponse { - - private val errorHandler: Handler = - errorHandler(errorBodyHandler(clientOptions.jsonMapper)) - - override fun withOptions( - modifier: Consumer - ): JobItemService.WithRawResponse = - JobItemServiceImpl.WithRawResponseImpl( - clientOptions.toBuilder().apply(modifier::accept).build() - ) - - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun list( - params: JobItemListParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("jobId", params.jobId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "api", - "v1", - "beta", - "batch-processing", - params._pathParam(0), - "items", - ) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { listHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - .let { - JobItemListPage.builder() - .service(JobItemServiceImpl(clientOptions)) - .params(params) - .response(it) - .build() - } - } - } - - private val getProcessingResultsHandler: Handler = - jsonHandler(clientOptions.jsonMapper) - - override fun getProcessingResults( - params: JobItemGetProcessingResultsParams, - requestOptions: RequestOptions, - ): HttpResponseFor { - // We check here instead of in the params builder because this can be specified - // positionally or in the params class. - checkRequired("itemId", params.itemId().getOrNull()) - val request = - HttpRequest.builder() - .method(HttpMethod.GET) - .baseUrl(clientOptions.baseUrl()) - .addPathSegments( - "api", - "v1", - "beta", - "batch-processing", - "items", - params._pathParam(0), - "processing-results", - ) - .build() - .prepare(clientOptions, params) - val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) - val response = clientOptions.httpClient.execute(request, requestOptions) - return errorHandler.handle(response).parseable { - response - .use { getProcessingResultsHandler.handle(it) } - .also { - if (requestOptions.responseValidation!!) { - it.validate() - } - } - } - } - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParamsTest.kt deleted file mode 100644 index 56f4860..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParamsTest.kt +++ /dev/null @@ -1,237 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.batches - -import ai.llamaindex.llamacloud.core.JsonValue -import ai.llamaindex.llamacloud.core.http.QueryParams -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BatchCreateParamsTest { - - @Test - fun create() { - BatchCreateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config( - BatchCreateParams.Config.builder() - .job( - BatchCreateParams.Config.Job.builder() - .configurationId("cfg-PARSE_AGENTIC") - .type(BatchCreateParams.Config.Job.Type.PARSE_V2) - .build() - ) - .build() - ) - .sourceDirectoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .addWebhookConfigurationId("whc-...") - .addWebhookConfigurationId("whc-...") - .addWebhookConfiguration( - BatchCreateParams.WebhookConfiguration.builder() - .addWebhookEvent( - BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS - ) - .addWebhookEvent( - BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR - ) - .webhookHeaders( - BatchCreateParams.WebhookConfiguration.WebhookHeaders.builder() - .putAdditionalProperty("Authorization", JsonValue.from("Bearer sk-...")) - .build() - ) - .webhookOutputFormat("json") - .webhookSigningSecret("whsec_...") - .webhookUrl("https://example.com/webhooks/llamacloud") - .build() - ) - .build() - } - - @Test - fun queryParams() { - val params = - BatchCreateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config( - BatchCreateParams.Config.builder() - .job( - BatchCreateParams.Config.Job.builder() - .configurationId("cfg-PARSE_AGENTIC") - .type(BatchCreateParams.Config.Job.Type.PARSE_V2) - .build() - ) - .build() - ) - .sourceDirectoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .addWebhookConfigurationId("whc-...") - .addWebhookConfigurationId("whc-...") - .addWebhookConfiguration( - BatchCreateParams.WebhookConfiguration.builder() - .addWebhookEvent( - BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS - ) - .addWebhookEvent( - BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR - ) - .webhookHeaders( - BatchCreateParams.WebhookConfiguration.WebhookHeaders.builder() - .putAdditionalProperty( - "Authorization", - JsonValue.from("Bearer sk-..."), - ) - .build() - ) - .webhookOutputFormat("json") - .webhookSigningSecret("whsec_...") - .webhookUrl("https://example.com/webhooks/llamacloud") - .build() - ) - .build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo( - QueryParams.builder() - .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = - BatchCreateParams.builder() - .config( - BatchCreateParams.Config.builder() - .job( - BatchCreateParams.Config.Job.builder() - .configurationId("cfg-PARSE_AGENTIC") - .type(BatchCreateParams.Config.Job.Type.PARSE_V2) - .build() - ) - .build() - ) - .sourceDirectoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } - - @Test - fun body() { - val params = - BatchCreateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config( - BatchCreateParams.Config.builder() - .job( - BatchCreateParams.Config.Job.builder() - .configurationId("cfg-PARSE_AGENTIC") - .type(BatchCreateParams.Config.Job.Type.PARSE_V2) - .build() - ) - .build() - ) - .sourceDirectoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .addWebhookConfigurationId("whc-...") - .addWebhookConfigurationId("whc-...") - .addWebhookConfiguration( - BatchCreateParams.WebhookConfiguration.builder() - .addWebhookEvent( - BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS - ) - .addWebhookEvent( - BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR - ) - .webhookHeaders( - BatchCreateParams.WebhookConfiguration.WebhookHeaders.builder() - .putAdditionalProperty( - "Authorization", - JsonValue.from("Bearer sk-..."), - ) - .build() - ) - .webhookOutputFormat("json") - .webhookSigningSecret("whsec_...") - .webhookUrl("https://example.com/webhooks/llamacloud") - .build() - ) - .build() - - val body = params._body() - - assertThat(body.config()) - .isEqualTo( - BatchCreateParams.Config.builder() - .job( - BatchCreateParams.Config.Job.builder() - .configurationId("cfg-PARSE_AGENTIC") - .type(BatchCreateParams.Config.Job.Type.PARSE_V2) - .build() - ) - .build() - ) - assertThat(body.sourceDirectoryId()).isEqualTo("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - assertThat(body.webhookConfigurationIds().getOrNull()).containsExactly("whc-...", "whc-...") - assertThat(body.webhookConfigurations().getOrNull()) - .containsExactly( - BatchCreateParams.WebhookConfiguration.builder() - .addWebhookEvent( - BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS - ) - .addWebhookEvent( - BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR - ) - .webhookHeaders( - BatchCreateParams.WebhookConfiguration.WebhookHeaders.builder() - .putAdditionalProperty("Authorization", JsonValue.from("Bearer sk-...")) - .build() - ) - .webhookOutputFormat("json") - .webhookSigningSecret("whsec_...") - .webhookUrl("https://example.com/webhooks/llamacloud") - .build() - ) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - BatchCreateParams.builder() - .config( - BatchCreateParams.Config.builder() - .job( - BatchCreateParams.Config.Job.builder() - .configurationId("cfg-PARSE_AGENTIC") - .type(BatchCreateParams.Config.Job.Type.PARSE_V2) - .build() - ) - .build() - ) - .sourceDirectoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .build() - - val body = params._body() - - assertThat(body.config()) - .isEqualTo( - BatchCreateParams.Config.builder() - .job( - BatchCreateParams.Config.Job.builder() - .configurationId("cfg-PARSE_AGENTIC") - .type(BatchCreateParams.Config.Job.Type.PARSE_V2) - .build() - ) - .build() - ) - assertThat(body.sourceDirectoryId()).isEqualTo("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateResponseTest.kt deleted file mode 100644 index 9ce81cb..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateResponseTest.kt +++ /dev/null @@ -1,125 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.batches - -import ai.llamaindex.llamacloud.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.OffsetDateTime -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BatchCreateResponseTest { - - @Test - fun create() { - val batchCreateResponse = - BatchCreateResponse.builder() - .id("id") - .config( - BatchCreateResponse.Config.builder() - .job( - BatchCreateResponse.Config.Job.builder() - .configurationId("cfg-PARSE_AGENTIC") - .type(BatchCreateResponse.Config.Job.Type.PARSE_V2) - .build() - ) - .build() - ) - .projectId("project_id") - .sourceDirectoryId("source_directory_id") - .status(BatchCreateResponse.Status.CANCELLED) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addResult( - BatchCreateResponse.Result.builder() - .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .errorMessage("error_message") - .jobReference( - BatchCreateResponse.Result.JobReference.builder() - .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .type(BatchCreateResponse.Result.JobReference.Type.PARSE_V2) - .build() - ) - .build() - ) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - - assertThat(batchCreateResponse.id()).isEqualTo("id") - assertThat(batchCreateResponse.config()) - .isEqualTo( - BatchCreateResponse.Config.builder() - .job( - BatchCreateResponse.Config.Job.builder() - .configurationId("cfg-PARSE_AGENTIC") - .type(BatchCreateResponse.Config.Job.Type.PARSE_V2) - .build() - ) - .build() - ) - assertThat(batchCreateResponse.projectId()).isEqualTo("project_id") - assertThat(batchCreateResponse.sourceDirectoryId()).isEqualTo("source_directory_id") - assertThat(batchCreateResponse.status()).isEqualTo(BatchCreateResponse.Status.CANCELLED) - assertThat(batchCreateResponse.createdAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(batchCreateResponse.results().getOrNull()) - .containsExactly( - BatchCreateResponse.Result.builder() - .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .errorMessage("error_message") - .jobReference( - BatchCreateResponse.Result.JobReference.builder() - .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .type(BatchCreateResponse.Result.JobReference.Type.PARSE_V2) - .build() - ) - .build() - ) - assertThat(batchCreateResponse.updatedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val batchCreateResponse = - BatchCreateResponse.builder() - .id("id") - .config( - BatchCreateResponse.Config.builder() - .job( - BatchCreateResponse.Config.Job.builder() - .configurationId("cfg-PARSE_AGENTIC") - .type(BatchCreateResponse.Config.Job.Type.PARSE_V2) - .build() - ) - .build() - ) - .projectId("project_id") - .sourceDirectoryId("source_directory_id") - .status(BatchCreateResponse.Status.CANCELLED) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addResult( - BatchCreateResponse.Result.builder() - .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .errorMessage("error_message") - .jobReference( - BatchCreateResponse.Result.JobReference.builder() - .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .type(BatchCreateResponse.Result.JobReference.Type.PARSE_V2) - .build() - ) - .build() - ) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - - val roundtrippedBatchCreateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(batchCreateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBatchCreateResponse).isEqualTo(batchCreateResponse) - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetParamsTest.kt deleted file mode 100644 index 4537206..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetParamsTest.kt +++ /dev/null @@ -1,63 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.batches - -import ai.llamaindex.llamacloud.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BatchGetParamsTest { - - @Test - fun create() { - BatchGetParams.builder() - .batchId("batch_id") - .addExpand("string") - .addExpand("string") - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - } - - @Test - fun pathParams() { - val params = BatchGetParams.builder().batchId("batch_id").build() - - assertThat(params._pathParam(0)).isEqualTo("batch_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun queryParams() { - val params = - BatchGetParams.builder() - .batchId("batch_id") - .addExpand("string") - .addExpand("string") - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo( - QueryParams.builder() - .put("expand", "string") - .put("expand", "string") - .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = BatchGetParams.builder().batchId("batch_id").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetResponseTest.kt deleted file mode 100644 index 1ad07cf..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetResponseTest.kt +++ /dev/null @@ -1,125 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.batches - -import ai.llamaindex.llamacloud.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.OffsetDateTime -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BatchGetResponseTest { - - @Test - fun create() { - val batchGetResponse = - BatchGetResponse.builder() - .id("id") - .config( - BatchGetResponse.Config.builder() - .job( - BatchGetResponse.Config.Job.builder() - .configurationId("cfg-PARSE_AGENTIC") - .type(BatchGetResponse.Config.Job.Type.PARSE_V2) - .build() - ) - .build() - ) - .projectId("project_id") - .sourceDirectoryId("source_directory_id") - .status(BatchGetResponse.Status.CANCELLED) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addResult( - BatchGetResponse.Result.builder() - .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .errorMessage("error_message") - .jobReference( - BatchGetResponse.Result.JobReference.builder() - .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .type(BatchGetResponse.Result.JobReference.Type.PARSE_V2) - .build() - ) - .build() - ) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - - assertThat(batchGetResponse.id()).isEqualTo("id") - assertThat(batchGetResponse.config()) - .isEqualTo( - BatchGetResponse.Config.builder() - .job( - BatchGetResponse.Config.Job.builder() - .configurationId("cfg-PARSE_AGENTIC") - .type(BatchGetResponse.Config.Job.Type.PARSE_V2) - .build() - ) - .build() - ) - assertThat(batchGetResponse.projectId()).isEqualTo("project_id") - assertThat(batchGetResponse.sourceDirectoryId()).isEqualTo("source_directory_id") - assertThat(batchGetResponse.status()).isEqualTo(BatchGetResponse.Status.CANCELLED) - assertThat(batchGetResponse.createdAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(batchGetResponse.results().getOrNull()) - .containsExactly( - BatchGetResponse.Result.builder() - .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .errorMessage("error_message") - .jobReference( - BatchGetResponse.Result.JobReference.builder() - .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .type(BatchGetResponse.Result.JobReference.Type.PARSE_V2) - .build() - ) - .build() - ) - assertThat(batchGetResponse.updatedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val batchGetResponse = - BatchGetResponse.builder() - .id("id") - .config( - BatchGetResponse.Config.builder() - .job( - BatchGetResponse.Config.Job.builder() - .configurationId("cfg-PARSE_AGENTIC") - .type(BatchGetResponse.Config.Job.Type.PARSE_V2) - .build() - ) - .build() - ) - .projectId("project_id") - .sourceDirectoryId("source_directory_id") - .status(BatchGetResponse.Status.CANCELLED) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addResult( - BatchGetResponse.Result.builder() - .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .errorMessage("error_message") - .jobReference( - BatchGetResponse.Result.JobReference.builder() - .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .type(BatchGetResponse.Result.JobReference.Type.PARSE_V2) - .build() - ) - .build() - ) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - - val roundtrippedBatchGetResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(batchGetResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBatchGetResponse).isEqualTo(batchGetResponse) - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageResponseTest.kt deleted file mode 100644 index 15a9057..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageResponseTest.kt +++ /dev/null @@ -1,139 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.batches - -import ai.llamaindex.llamacloud.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BatchListPageResponseTest { - - @Test - fun create() { - val batchListPageResponse = - BatchListPageResponse.builder() - .addItem( - BatchListResponse.builder() - .id("id") - .config( - BatchListResponse.Config.builder() - .job( - BatchListResponse.Config.Job.builder() - .configurationId("cfg-PARSE_AGENTIC") - .type(BatchListResponse.Config.Job.Type.PARSE_V2) - .build() - ) - .build() - ) - .projectId("project_id") - .sourceDirectoryId("source_directory_id") - .status(BatchListResponse.Status.CANCELLED) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addResult( - BatchListResponse.Result.builder() - .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .errorMessage("error_message") - .jobReference( - BatchListResponse.Result.JobReference.builder() - .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .type(BatchListResponse.Result.JobReference.Type.PARSE_V2) - .build() - ) - .build() - ) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .nextPageToken("next_page_token") - .totalSize(0L) - .build() - - assertThat(batchListPageResponse.items()) - .containsExactly( - BatchListResponse.builder() - .id("id") - .config( - BatchListResponse.Config.builder() - .job( - BatchListResponse.Config.Job.builder() - .configurationId("cfg-PARSE_AGENTIC") - .type(BatchListResponse.Config.Job.Type.PARSE_V2) - .build() - ) - .build() - ) - .projectId("project_id") - .sourceDirectoryId("source_directory_id") - .status(BatchListResponse.Status.CANCELLED) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addResult( - BatchListResponse.Result.builder() - .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .errorMessage("error_message") - .jobReference( - BatchListResponse.Result.JobReference.builder() - .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .type(BatchListResponse.Result.JobReference.Type.PARSE_V2) - .build() - ) - .build() - ) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(batchListPageResponse.nextPageToken()).contains("next_page_token") - assertThat(batchListPageResponse.totalSize()).contains(0L) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val batchListPageResponse = - BatchListPageResponse.builder() - .addItem( - BatchListResponse.builder() - .id("id") - .config( - BatchListResponse.Config.builder() - .job( - BatchListResponse.Config.Job.builder() - .configurationId("cfg-PARSE_AGENTIC") - .type(BatchListResponse.Config.Job.Type.PARSE_V2) - .build() - ) - .build() - ) - .projectId("project_id") - .sourceDirectoryId("source_directory_id") - .status(BatchListResponse.Status.CANCELLED) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addResult( - BatchListResponse.Result.builder() - .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .errorMessage("error_message") - .jobReference( - BatchListResponse.Result.JobReference.builder() - .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .type(BatchListResponse.Result.JobReference.Type.PARSE_V2) - .build() - ) - .build() - ) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .nextPageToken("next_page_token") - .totalSize(0L) - .build() - - val roundtrippedBatchListPageResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(batchListPageResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBatchListPageResponse).isEqualTo(batchListPageResponse) - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListParamsTest.kt deleted file mode 100644 index b1423cd..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListParamsTest.kt +++ /dev/null @@ -1,65 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.batches - -import ai.llamaindex.llamacloud.core.http.QueryParams -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BatchListParamsTest { - - @Test - fun create() { - BatchListParams.builder() - .createdAtOnOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdAtOnOrBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .pageSize(0L) - .pageToken("page_token") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sourceDirectoryId("source_directory_id") - .status(BatchListParams.Status.CANCELLED) - .build() - } - - @Test - fun queryParams() { - val params = - BatchListParams.builder() - .createdAtOnOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdAtOnOrBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .pageSize(0L) - .pageToken("page_token") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sourceDirectoryId("source_directory_id") - .status(BatchListParams.Status.CANCELLED) - .build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo( - QueryParams.builder() - .put("created_at_on_or_after", "2019-12-27T18:11:19.117Z") - .put("created_at_on_or_before", "2019-12-27T18:11:19.117Z") - .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .put("page_size", "0") - .put("page_token", "page_token") - .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .put("source_directory_id", "source_directory_id") - .put("status", "CANCELLED") - .build() - ) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = BatchListParams.builder().build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListResponseTest.kt deleted file mode 100644 index 27167b9..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListResponseTest.kt +++ /dev/null @@ -1,125 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.batches - -import ai.llamaindex.llamacloud.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.OffsetDateTime -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BatchListResponseTest { - - @Test - fun create() { - val batchListResponse = - BatchListResponse.builder() - .id("id") - .config( - BatchListResponse.Config.builder() - .job( - BatchListResponse.Config.Job.builder() - .configurationId("cfg-PARSE_AGENTIC") - .type(BatchListResponse.Config.Job.Type.PARSE_V2) - .build() - ) - .build() - ) - .projectId("project_id") - .sourceDirectoryId("source_directory_id") - .status(BatchListResponse.Status.CANCELLED) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addResult( - BatchListResponse.Result.builder() - .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .errorMessage("error_message") - .jobReference( - BatchListResponse.Result.JobReference.builder() - .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .type(BatchListResponse.Result.JobReference.Type.PARSE_V2) - .build() - ) - .build() - ) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - - assertThat(batchListResponse.id()).isEqualTo("id") - assertThat(batchListResponse.config()) - .isEqualTo( - BatchListResponse.Config.builder() - .job( - BatchListResponse.Config.Job.builder() - .configurationId("cfg-PARSE_AGENTIC") - .type(BatchListResponse.Config.Job.Type.PARSE_V2) - .build() - ) - .build() - ) - assertThat(batchListResponse.projectId()).isEqualTo("project_id") - assertThat(batchListResponse.sourceDirectoryId()).isEqualTo("source_directory_id") - assertThat(batchListResponse.status()).isEqualTo(BatchListResponse.Status.CANCELLED) - assertThat(batchListResponse.createdAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(batchListResponse.results().getOrNull()) - .containsExactly( - BatchListResponse.Result.builder() - .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .errorMessage("error_message") - .jobReference( - BatchListResponse.Result.JobReference.builder() - .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .type(BatchListResponse.Result.JobReference.Type.PARSE_V2) - .build() - ) - .build() - ) - assertThat(batchListResponse.updatedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val batchListResponse = - BatchListResponse.builder() - .id("id") - .config( - BatchListResponse.Config.builder() - .job( - BatchListResponse.Config.Job.builder() - .configurationId("cfg-PARSE_AGENTIC") - .type(BatchListResponse.Config.Job.Type.PARSE_V2) - .build() - ) - .build() - ) - .projectId("project_id") - .sourceDirectoryId("source_directory_id") - .status(BatchListResponse.Status.CANCELLED) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .addResult( - BatchListResponse.Result.builder() - .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .errorMessage("error_message") - .jobReference( - BatchListResponse.Result.JobReference.builder() - .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .type(BatchListResponse.Result.JobReference.Type.PARSE_V2) - .build() - ) - .build() - ) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - - val roundtrippedBatchListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(batchListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBatchListResponse).isEqualTo(batchListResponse) - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCancelParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCancelParamsTest.kt deleted file mode 100644 index 8178b03..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCancelParamsTest.kt +++ /dev/null @@ -1,111 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch - -import ai.llamaindex.llamacloud.core.http.Headers -import ai.llamaindex.llamacloud.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BatchCancelParamsTest { - - @Test - fun create() { - BatchCancelParams.builder() - .jobId("job_id") - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .temporalNamespace("temporal-namespace") - .reason("reason") - .build() - } - - @Test - fun pathParams() { - val params = BatchCancelParams.builder().jobId("job_id").build() - - assertThat(params._pathParam(0)).isEqualTo("job_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun headers() { - val params = - BatchCancelParams.builder() - .jobId("job_id") - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .temporalNamespace("temporal-namespace") - .reason("reason") - .build() - - val headers = params._headers() - - assertThat(headers) - .isEqualTo(Headers.builder().put("temporal-namespace", "temporal-namespace").build()) - } - - @Test - fun headersWithoutOptionalFields() { - val params = BatchCancelParams.builder().jobId("job_id").build() - - val headers = params._headers() - - assertThat(headers).isEqualTo(Headers.builder().build()) - } - - @Test - fun queryParams() { - val params = - BatchCancelParams.builder() - .jobId("job_id") - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .temporalNamespace("temporal-namespace") - .reason("reason") - .build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo( - QueryParams.builder() - .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = BatchCancelParams.builder().jobId("job_id").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } - - @Test - fun body() { - val params = - BatchCancelParams.builder() - .jobId("job_id") - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .temporalNamespace("temporal-namespace") - .reason("reason") - .build() - - val body = params._body() - - assertThat(body.reason()).contains("reason") - } - - @Test - fun bodyWithoutOptionalFields() { - val params = BatchCancelParams.builder().jobId("job_id").build() - - val body = params._body() - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCancelResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCancelResponseTest.kt deleted file mode 100644 index 8875622..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCancelResponseTest.kt +++ /dev/null @@ -1,47 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch - -import ai.llamaindex.llamacloud.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BatchCancelResponseTest { - - @Test - fun create() { - val batchCancelResponse = - BatchCancelResponse.builder() - .jobId("job_id") - .message("message") - .processedItems(0L) - .status(BatchCancelResponse.Status.CANCELLED) - .build() - - assertThat(batchCancelResponse.jobId()).isEqualTo("job_id") - assertThat(batchCancelResponse.message()).isEqualTo("message") - assertThat(batchCancelResponse.processedItems()).isEqualTo(0L) - assertThat(batchCancelResponse.status()).isEqualTo(BatchCancelResponse.Status.CANCELLED) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val batchCancelResponse = - BatchCancelResponse.builder() - .jobId("job_id") - .message("message") - .processedItems(0L) - .status(BatchCancelResponse.Status.CANCELLED) - .build() - - val roundtrippedBatchCancelResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(batchCancelResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBatchCancelResponse).isEqualTo(batchCancelResponse) - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateParamsTest.kt deleted file mode 100644 index 2b3cdd5..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateParamsTest.kt +++ /dev/null @@ -1,1264 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch - -import ai.llamaindex.llamacloud.core.JsonValue -import ai.llamaindex.llamacloud.core.http.Headers -import ai.llamaindex.llamacloud.core.http.QueryParams -import ai.llamaindex.llamacloud.models.parsing.FailPageMode -import ai.llamaindex.llamacloud.models.parsing.ParsingLanguages -import ai.llamaindex.llamacloud.models.parsing.ParsingMode -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BatchCreateParamsTest { - - @Test - fun create() { - BatchCreateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .temporalNamespace("temporal-namespace") - .jobConfig( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.builder() - .correlationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .jobName( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.JobName - .PARSE_RAW_FILE_JOB - ) - .parameters( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters.builder() - .adaptiveLongTable(true) - .aggressiveTableExtraction(true) - .annotateLinks(true) - .annotateRevisions(true) - .autoMode(true) - .autoModeConfigurationJson("auto_mode_configuration_json") - .autoModeTriggerOnImageInPage(true) - .autoModeTriggerOnRegexpInPage("auto_mode_trigger_on_regexp_in_page") - .autoModeTriggerOnTableInPage(true) - .autoModeTriggerOnTextInPage("auto_mode_trigger_on_text_in_page") - .azureOpenAIApiVersion("azure_openai_api_version") - .azureOpenAIDeploymentName("azure_openai_deployment_name") - .azureOpenAIEndpoint("azure_openai_endpoint") - .azureOpenAIKey("azure_openai_key") - .bboxBottom(0.0) - .bboxLeft(0.0) - .bboxRight(0.0) - .bboxTop(0.0) - .boundingBox("bounding_box") - .compactMarkdownTable(true) - .complementalFormattingInstruction( - "complemental_formatting_instruction" - ) - .confidenceScoreEffort("confidence_score_effort") - .contentGuidelineInstruction("content_guideline_instruction") - .continuousMode(true) - .customMetadata( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .CustomMetadata - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .disableImageExtraction(true) - .disableOcr(true) - .disableReconstruction(true) - .doNotCache(true) - .doNotUnrollColumns(true) - .enableCostOptimizer(true) - .extractCharts(true) - .extractLayout(true) - .extractPrintedPageNumber(true) - .fastMode(true) - .formattingInstruction("formatting_instruction") - .gpt4oApiKey("gpt4o_api_key") - .gpt4oMode(true) - .guessXlsxSheetName(true) - .hideFooters(true) - .hideHeaders(true) - .highResOcr(true) - .htmlMakeAllElementsVisible(true) - .htmlRemoveFixedElements(true) - .htmlRemoveNavigationElements(true) - .httpProxy("http_proxy") - .ignoreDocumentElementsForLayoutDetection(true) - .addImagesToSave( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .ImagesToSave - .EMBEDDED - ) - .inlineImagesInMarkdown(true) - .inputS3Path("input_s3_path") - .inputS3Region("input_s3_region") - .inputUrl("input_url") - .internalIsScreenshotJob(true) - .invalidateCache(true) - .isFormattingInstruction(true) - .jobTimeoutExtraTimePerPageInSeconds(0.0) - .jobTimeoutInSeconds(0.0) - .keepPageSeparatorWhenMergingTables(true) - .lang("lang") - .addLanguage(ParsingLanguages.ABQ) - .layoutAware(true) - .lineLevelBoundingBox(true) - .markdownTableMultilineHeaderSeparator( - "markdown_table_multiline_header_separator" - ) - .maxPages(0L) - .maxPagesEnforced(0L) - .mergeTablesAcrossPagesInMarkdown(true) - .model("model") - .outlinedTableExtraction(true) - .outputPdfOfDocument(true) - .outputS3PathPrefix("output_s3_path_prefix") - .outputS3Region("output_s3_region") - .outputTablesAsHtml(true) - .outputBucket("outputBucket") - .pageErrorTolerance(0.0) - .pageFooterPrefix("page_footer_prefix") - .pageFooterSuffix("page_footer_suffix") - .pageHeaderPrefix("page_header_prefix") - .pageHeaderSuffix("page_header_suffix") - .pagePrefix("page_prefix") - .pageSeparator("page_separator") - .pageSuffix("page_suffix") - .parseMode(ParsingMode.PARSE_DOCUMENT_WITH_AGENT) - .parsingInstruction("parsing_instruction") - .pipelineId("pipeline_id") - .preciseBoundingBox(true) - .premiumMode(true) - .presentationOutOfBoundsContent(true) - .presentationSkipEmbeddedData(true) - .preserveLayoutAlignmentAcrossPages(true) - .preserveVerySmallText(true) - .preset("preset") - .priority( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .Priority - .CRITICAL - ) - .projectId("project_id") - .removeHiddenText(true) - .replaceFailedPageMode(FailPageMode.BLANK_PAGE) - .replaceFailedPageWithErrorMessagePrefix( - "replace_failed_page_with_error_message_prefix" - ) - .replaceFailedPageWithErrorMessageSuffix( - "replace_failed_page_with_error_message_suffix" - ) - .resourceInfo( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .ResourceInfo - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .saveImages(true) - .skipDiagonalText(true) - .specializedChartParsingAgentic(true) - .specializedChartParsingEfficient(true) - .specializedChartParsingPlus(true) - .specializedImageParsing(true) - .spreadsheetExtractSubTables(true) - .spreadsheetForceFormulaComputation(true) - .spreadsheetIncludeHiddenSheets(true) - .strictModeBuggyFont(true) - .strictModeImageExtraction(true) - .strictModeImageOcr(true) - .strictModeReconstruction(true) - .structuredOutput(true) - .structuredOutputJsonSchema("structured_output_json_schema") - .structuredOutputJsonSchemaName("structured_output_json_schema_name") - .systemPrompt("system_prompt") - .systemPromptAppend("system_prompt_append") - .takeScreenshot(true) - .targetPages("target_pages") - .tier("tier") - .type( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .Type - .PARSE - ) - .useVendorMultimodalModel(true) - .userPrompt("user_prompt") - .vendorMultimodalApiKey("vendor_multimodal_api_key") - .vendorMultimodalModelName("vendor_multimodal_model_name") - .version("version") - .addWebhookConfiguration( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .WebhookConfiguration - .builder() - .addWebhookEvent( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookEvent - .PARSE_SUCCESS - ) - .addWebhookEvent( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookEvent - .PARSE_ERROR - ) - .webhookHeaders( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookHeaders - .builder() - .putAdditionalProperty( - "Authorization", - JsonValue.from("Bearer sk-..."), - ) - .build() - ) - .webhookOutputFormat("json") - .webhookSigningSecret("whsec_...") - .webhookUrl("https://example.com/webhooks/llamacloud") - .build() - ) - .webhookUrl("webhook_url") - .build() - ) - .parentJobExecutionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .partitions( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Partitions.builder() - .putAdditionalProperty( - "foo", - JsonValue.from("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), - ) - .build() - ) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("user_id") - .webhookUrl("webhook_url") - .build() - ) - .continueAsNewThreshold(0L) - .directoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .addItemId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .addItemId("dfl-11111111-2222-3333-4444-555555555555") - .pageSize(1L) - .build() - } - - @Test - fun headers() { - val params = - BatchCreateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .temporalNamespace("temporal-namespace") - .jobConfig( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.builder() - .correlationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .jobName( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.JobName - .PARSE_RAW_FILE_JOB - ) - .parameters( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .builder() - .adaptiveLongTable(true) - .aggressiveTableExtraction(true) - .annotateLinks(true) - .annotateRevisions(true) - .autoMode(true) - .autoModeConfigurationJson("auto_mode_configuration_json") - .autoModeTriggerOnImageInPage(true) - .autoModeTriggerOnRegexpInPage( - "auto_mode_trigger_on_regexp_in_page" - ) - .autoModeTriggerOnTableInPage(true) - .autoModeTriggerOnTextInPage("auto_mode_trigger_on_text_in_page") - .azureOpenAIApiVersion("azure_openai_api_version") - .azureOpenAIDeploymentName("azure_openai_deployment_name") - .azureOpenAIEndpoint("azure_openai_endpoint") - .azureOpenAIKey("azure_openai_key") - .bboxBottom(0.0) - .bboxLeft(0.0) - .bboxRight(0.0) - .bboxTop(0.0) - .boundingBox("bounding_box") - .compactMarkdownTable(true) - .complementalFormattingInstruction( - "complemental_formatting_instruction" - ) - .confidenceScoreEffort("confidence_score_effort") - .contentGuidelineInstruction("content_guideline_instruction") - .continuousMode(true) - .customMetadata( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .CustomMetadata - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .disableImageExtraction(true) - .disableOcr(true) - .disableReconstruction(true) - .doNotCache(true) - .doNotUnrollColumns(true) - .enableCostOptimizer(true) - .extractCharts(true) - .extractLayout(true) - .extractPrintedPageNumber(true) - .fastMode(true) - .formattingInstruction("formatting_instruction") - .gpt4oApiKey("gpt4o_api_key") - .gpt4oMode(true) - .guessXlsxSheetName(true) - .hideFooters(true) - .hideHeaders(true) - .highResOcr(true) - .htmlMakeAllElementsVisible(true) - .htmlRemoveFixedElements(true) - .htmlRemoveNavigationElements(true) - .httpProxy("http_proxy") - .ignoreDocumentElementsForLayoutDetection(true) - .addImagesToSave( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .ImagesToSave - .EMBEDDED - ) - .inlineImagesInMarkdown(true) - .inputS3Path("input_s3_path") - .inputS3Region("input_s3_region") - .inputUrl("input_url") - .internalIsScreenshotJob(true) - .invalidateCache(true) - .isFormattingInstruction(true) - .jobTimeoutExtraTimePerPageInSeconds(0.0) - .jobTimeoutInSeconds(0.0) - .keepPageSeparatorWhenMergingTables(true) - .lang("lang") - .addLanguage(ParsingLanguages.ABQ) - .layoutAware(true) - .lineLevelBoundingBox(true) - .markdownTableMultilineHeaderSeparator( - "markdown_table_multiline_header_separator" - ) - .maxPages(0L) - .maxPagesEnforced(0L) - .mergeTablesAcrossPagesInMarkdown(true) - .model("model") - .outlinedTableExtraction(true) - .outputPdfOfDocument(true) - .outputS3PathPrefix("output_s3_path_prefix") - .outputS3Region("output_s3_region") - .outputTablesAsHtml(true) - .outputBucket("outputBucket") - .pageErrorTolerance(0.0) - .pageFooterPrefix("page_footer_prefix") - .pageFooterSuffix("page_footer_suffix") - .pageHeaderPrefix("page_header_prefix") - .pageHeaderSuffix("page_header_suffix") - .pagePrefix("page_prefix") - .pageSeparator("page_separator") - .pageSuffix("page_suffix") - .parseMode(ParsingMode.PARSE_DOCUMENT_WITH_AGENT) - .parsingInstruction("parsing_instruction") - .pipelineId("pipeline_id") - .preciseBoundingBox(true) - .premiumMode(true) - .presentationOutOfBoundsContent(true) - .presentationSkipEmbeddedData(true) - .preserveLayoutAlignmentAcrossPages(true) - .preserveVerySmallText(true) - .preset("preset") - .priority( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .Priority - .CRITICAL - ) - .projectId("project_id") - .removeHiddenText(true) - .replaceFailedPageMode(FailPageMode.BLANK_PAGE) - .replaceFailedPageWithErrorMessagePrefix( - "replace_failed_page_with_error_message_prefix" - ) - .replaceFailedPageWithErrorMessageSuffix( - "replace_failed_page_with_error_message_suffix" - ) - .resourceInfo( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .ResourceInfo - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .saveImages(true) - .skipDiagonalText(true) - .specializedChartParsingAgentic(true) - .specializedChartParsingEfficient(true) - .specializedChartParsingPlus(true) - .specializedImageParsing(true) - .spreadsheetExtractSubTables(true) - .spreadsheetForceFormulaComputation(true) - .spreadsheetIncludeHiddenSheets(true) - .strictModeBuggyFont(true) - .strictModeImageExtraction(true) - .strictModeImageOcr(true) - .strictModeReconstruction(true) - .structuredOutput(true) - .structuredOutputJsonSchema("structured_output_json_schema") - .structuredOutputJsonSchemaName( - "structured_output_json_schema_name" - ) - .systemPrompt("system_prompt") - .systemPromptAppend("system_prompt_append") - .takeScreenshot(true) - .targetPages("target_pages") - .tier("tier") - .type( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .Type - .PARSE - ) - .useVendorMultimodalModel(true) - .userPrompt("user_prompt") - .vendorMultimodalApiKey("vendor_multimodal_api_key") - .vendorMultimodalModelName("vendor_multimodal_model_name") - .version("version") - .addWebhookConfiguration( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .WebhookConfiguration - .builder() - .addWebhookEvent( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookEvent - .PARSE_SUCCESS - ) - .addWebhookEvent( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookEvent - .PARSE_ERROR - ) - .webhookHeaders( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookHeaders - .builder() - .putAdditionalProperty( - "Authorization", - JsonValue.from("Bearer sk-..."), - ) - .build() - ) - .webhookOutputFormat("json") - .webhookSigningSecret("whsec_...") - .webhookUrl("https://example.com/webhooks/llamacloud") - .build() - ) - .webhookUrl("webhook_url") - .build() - ) - .parentJobExecutionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .partitions( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Partitions - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), - ) - .build() - ) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("user_id") - .webhookUrl("webhook_url") - .build() - ) - .continueAsNewThreshold(0L) - .directoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .addItemId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .addItemId("dfl-11111111-2222-3333-4444-555555555555") - .pageSize(1L) - .build() - - val headers = params._headers() - - assertThat(headers) - .isEqualTo(Headers.builder().put("temporal-namespace", "temporal-namespace").build()) - } - - @Test - fun headersWithoutOptionalFields() { - val params = - BatchCreateParams.builder() - .jobConfig(BatchCreateParams.JobConfig.BatchParseJobRecordCreate.builder().build()) - .build() - - val headers = params._headers() - - assertThat(headers).isEqualTo(Headers.builder().build()) - } - - @Test - fun queryParams() { - val params = - BatchCreateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .temporalNamespace("temporal-namespace") - .jobConfig( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.builder() - .correlationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .jobName( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.JobName - .PARSE_RAW_FILE_JOB - ) - .parameters( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .builder() - .adaptiveLongTable(true) - .aggressiveTableExtraction(true) - .annotateLinks(true) - .annotateRevisions(true) - .autoMode(true) - .autoModeConfigurationJson("auto_mode_configuration_json") - .autoModeTriggerOnImageInPage(true) - .autoModeTriggerOnRegexpInPage( - "auto_mode_trigger_on_regexp_in_page" - ) - .autoModeTriggerOnTableInPage(true) - .autoModeTriggerOnTextInPage("auto_mode_trigger_on_text_in_page") - .azureOpenAIApiVersion("azure_openai_api_version") - .azureOpenAIDeploymentName("azure_openai_deployment_name") - .azureOpenAIEndpoint("azure_openai_endpoint") - .azureOpenAIKey("azure_openai_key") - .bboxBottom(0.0) - .bboxLeft(0.0) - .bboxRight(0.0) - .bboxTop(0.0) - .boundingBox("bounding_box") - .compactMarkdownTable(true) - .complementalFormattingInstruction( - "complemental_formatting_instruction" - ) - .confidenceScoreEffort("confidence_score_effort") - .contentGuidelineInstruction("content_guideline_instruction") - .continuousMode(true) - .customMetadata( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .CustomMetadata - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .disableImageExtraction(true) - .disableOcr(true) - .disableReconstruction(true) - .doNotCache(true) - .doNotUnrollColumns(true) - .enableCostOptimizer(true) - .extractCharts(true) - .extractLayout(true) - .extractPrintedPageNumber(true) - .fastMode(true) - .formattingInstruction("formatting_instruction") - .gpt4oApiKey("gpt4o_api_key") - .gpt4oMode(true) - .guessXlsxSheetName(true) - .hideFooters(true) - .hideHeaders(true) - .highResOcr(true) - .htmlMakeAllElementsVisible(true) - .htmlRemoveFixedElements(true) - .htmlRemoveNavigationElements(true) - .httpProxy("http_proxy") - .ignoreDocumentElementsForLayoutDetection(true) - .addImagesToSave( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .ImagesToSave - .EMBEDDED - ) - .inlineImagesInMarkdown(true) - .inputS3Path("input_s3_path") - .inputS3Region("input_s3_region") - .inputUrl("input_url") - .internalIsScreenshotJob(true) - .invalidateCache(true) - .isFormattingInstruction(true) - .jobTimeoutExtraTimePerPageInSeconds(0.0) - .jobTimeoutInSeconds(0.0) - .keepPageSeparatorWhenMergingTables(true) - .lang("lang") - .addLanguage(ParsingLanguages.ABQ) - .layoutAware(true) - .lineLevelBoundingBox(true) - .markdownTableMultilineHeaderSeparator( - "markdown_table_multiline_header_separator" - ) - .maxPages(0L) - .maxPagesEnforced(0L) - .mergeTablesAcrossPagesInMarkdown(true) - .model("model") - .outlinedTableExtraction(true) - .outputPdfOfDocument(true) - .outputS3PathPrefix("output_s3_path_prefix") - .outputS3Region("output_s3_region") - .outputTablesAsHtml(true) - .outputBucket("outputBucket") - .pageErrorTolerance(0.0) - .pageFooterPrefix("page_footer_prefix") - .pageFooterSuffix("page_footer_suffix") - .pageHeaderPrefix("page_header_prefix") - .pageHeaderSuffix("page_header_suffix") - .pagePrefix("page_prefix") - .pageSeparator("page_separator") - .pageSuffix("page_suffix") - .parseMode(ParsingMode.PARSE_DOCUMENT_WITH_AGENT) - .parsingInstruction("parsing_instruction") - .pipelineId("pipeline_id") - .preciseBoundingBox(true) - .premiumMode(true) - .presentationOutOfBoundsContent(true) - .presentationSkipEmbeddedData(true) - .preserveLayoutAlignmentAcrossPages(true) - .preserveVerySmallText(true) - .preset("preset") - .priority( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .Priority - .CRITICAL - ) - .projectId("project_id") - .removeHiddenText(true) - .replaceFailedPageMode(FailPageMode.BLANK_PAGE) - .replaceFailedPageWithErrorMessagePrefix( - "replace_failed_page_with_error_message_prefix" - ) - .replaceFailedPageWithErrorMessageSuffix( - "replace_failed_page_with_error_message_suffix" - ) - .resourceInfo( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .ResourceInfo - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .saveImages(true) - .skipDiagonalText(true) - .specializedChartParsingAgentic(true) - .specializedChartParsingEfficient(true) - .specializedChartParsingPlus(true) - .specializedImageParsing(true) - .spreadsheetExtractSubTables(true) - .spreadsheetForceFormulaComputation(true) - .spreadsheetIncludeHiddenSheets(true) - .strictModeBuggyFont(true) - .strictModeImageExtraction(true) - .strictModeImageOcr(true) - .strictModeReconstruction(true) - .structuredOutput(true) - .structuredOutputJsonSchema("structured_output_json_schema") - .structuredOutputJsonSchemaName( - "structured_output_json_schema_name" - ) - .systemPrompt("system_prompt") - .systemPromptAppend("system_prompt_append") - .takeScreenshot(true) - .targetPages("target_pages") - .tier("tier") - .type( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .Type - .PARSE - ) - .useVendorMultimodalModel(true) - .userPrompt("user_prompt") - .vendorMultimodalApiKey("vendor_multimodal_api_key") - .vendorMultimodalModelName("vendor_multimodal_model_name") - .version("version") - .addWebhookConfiguration( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .WebhookConfiguration - .builder() - .addWebhookEvent( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookEvent - .PARSE_SUCCESS - ) - .addWebhookEvent( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookEvent - .PARSE_ERROR - ) - .webhookHeaders( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookHeaders - .builder() - .putAdditionalProperty( - "Authorization", - JsonValue.from("Bearer sk-..."), - ) - .build() - ) - .webhookOutputFormat("json") - .webhookSigningSecret("whsec_...") - .webhookUrl("https://example.com/webhooks/llamacloud") - .build() - ) - .webhookUrl("webhook_url") - .build() - ) - .parentJobExecutionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .partitions( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Partitions - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), - ) - .build() - ) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("user_id") - .webhookUrl("webhook_url") - .build() - ) - .continueAsNewThreshold(0L) - .directoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .addItemId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .addItemId("dfl-11111111-2222-3333-4444-555555555555") - .pageSize(1L) - .build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo( - QueryParams.builder() - .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = - BatchCreateParams.builder() - .jobConfig(BatchCreateParams.JobConfig.BatchParseJobRecordCreate.builder().build()) - .build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } - - @Test - fun body() { - val params = - BatchCreateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .temporalNamespace("temporal-namespace") - .jobConfig( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.builder() - .correlationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .jobName( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.JobName - .PARSE_RAW_FILE_JOB - ) - .parameters( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .builder() - .adaptiveLongTable(true) - .aggressiveTableExtraction(true) - .annotateLinks(true) - .annotateRevisions(true) - .autoMode(true) - .autoModeConfigurationJson("auto_mode_configuration_json") - .autoModeTriggerOnImageInPage(true) - .autoModeTriggerOnRegexpInPage( - "auto_mode_trigger_on_regexp_in_page" - ) - .autoModeTriggerOnTableInPage(true) - .autoModeTriggerOnTextInPage("auto_mode_trigger_on_text_in_page") - .azureOpenAIApiVersion("azure_openai_api_version") - .azureOpenAIDeploymentName("azure_openai_deployment_name") - .azureOpenAIEndpoint("azure_openai_endpoint") - .azureOpenAIKey("azure_openai_key") - .bboxBottom(0.0) - .bboxLeft(0.0) - .bboxRight(0.0) - .bboxTop(0.0) - .boundingBox("bounding_box") - .compactMarkdownTable(true) - .complementalFormattingInstruction( - "complemental_formatting_instruction" - ) - .confidenceScoreEffort("confidence_score_effort") - .contentGuidelineInstruction("content_guideline_instruction") - .continuousMode(true) - .customMetadata( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .CustomMetadata - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .disableImageExtraction(true) - .disableOcr(true) - .disableReconstruction(true) - .doNotCache(true) - .doNotUnrollColumns(true) - .enableCostOptimizer(true) - .extractCharts(true) - .extractLayout(true) - .extractPrintedPageNumber(true) - .fastMode(true) - .formattingInstruction("formatting_instruction") - .gpt4oApiKey("gpt4o_api_key") - .gpt4oMode(true) - .guessXlsxSheetName(true) - .hideFooters(true) - .hideHeaders(true) - .highResOcr(true) - .htmlMakeAllElementsVisible(true) - .htmlRemoveFixedElements(true) - .htmlRemoveNavigationElements(true) - .httpProxy("http_proxy") - .ignoreDocumentElementsForLayoutDetection(true) - .addImagesToSave( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .ImagesToSave - .EMBEDDED - ) - .inlineImagesInMarkdown(true) - .inputS3Path("input_s3_path") - .inputS3Region("input_s3_region") - .inputUrl("input_url") - .internalIsScreenshotJob(true) - .invalidateCache(true) - .isFormattingInstruction(true) - .jobTimeoutExtraTimePerPageInSeconds(0.0) - .jobTimeoutInSeconds(0.0) - .keepPageSeparatorWhenMergingTables(true) - .lang("lang") - .addLanguage(ParsingLanguages.ABQ) - .layoutAware(true) - .lineLevelBoundingBox(true) - .markdownTableMultilineHeaderSeparator( - "markdown_table_multiline_header_separator" - ) - .maxPages(0L) - .maxPagesEnforced(0L) - .mergeTablesAcrossPagesInMarkdown(true) - .model("model") - .outlinedTableExtraction(true) - .outputPdfOfDocument(true) - .outputS3PathPrefix("output_s3_path_prefix") - .outputS3Region("output_s3_region") - .outputTablesAsHtml(true) - .outputBucket("outputBucket") - .pageErrorTolerance(0.0) - .pageFooterPrefix("page_footer_prefix") - .pageFooterSuffix("page_footer_suffix") - .pageHeaderPrefix("page_header_prefix") - .pageHeaderSuffix("page_header_suffix") - .pagePrefix("page_prefix") - .pageSeparator("page_separator") - .pageSuffix("page_suffix") - .parseMode(ParsingMode.PARSE_DOCUMENT_WITH_AGENT) - .parsingInstruction("parsing_instruction") - .pipelineId("pipeline_id") - .preciseBoundingBox(true) - .premiumMode(true) - .presentationOutOfBoundsContent(true) - .presentationSkipEmbeddedData(true) - .preserveLayoutAlignmentAcrossPages(true) - .preserveVerySmallText(true) - .preset("preset") - .priority( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .Priority - .CRITICAL - ) - .projectId("project_id") - .removeHiddenText(true) - .replaceFailedPageMode(FailPageMode.BLANK_PAGE) - .replaceFailedPageWithErrorMessagePrefix( - "replace_failed_page_with_error_message_prefix" - ) - .replaceFailedPageWithErrorMessageSuffix( - "replace_failed_page_with_error_message_suffix" - ) - .resourceInfo( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .ResourceInfo - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .saveImages(true) - .skipDiagonalText(true) - .specializedChartParsingAgentic(true) - .specializedChartParsingEfficient(true) - .specializedChartParsingPlus(true) - .specializedImageParsing(true) - .spreadsheetExtractSubTables(true) - .spreadsheetForceFormulaComputation(true) - .spreadsheetIncludeHiddenSheets(true) - .strictModeBuggyFont(true) - .strictModeImageExtraction(true) - .strictModeImageOcr(true) - .strictModeReconstruction(true) - .structuredOutput(true) - .structuredOutputJsonSchema("structured_output_json_schema") - .structuredOutputJsonSchemaName( - "structured_output_json_schema_name" - ) - .systemPrompt("system_prompt") - .systemPromptAppend("system_prompt_append") - .takeScreenshot(true) - .targetPages("target_pages") - .tier("tier") - .type( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .Type - .PARSE - ) - .useVendorMultimodalModel(true) - .userPrompt("user_prompt") - .vendorMultimodalApiKey("vendor_multimodal_api_key") - .vendorMultimodalModelName("vendor_multimodal_model_name") - .version("version") - .addWebhookConfiguration( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .WebhookConfiguration - .builder() - .addWebhookEvent( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookEvent - .PARSE_SUCCESS - ) - .addWebhookEvent( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookEvent - .PARSE_ERROR - ) - .webhookHeaders( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookHeaders - .builder() - .putAdditionalProperty( - "Authorization", - JsonValue.from("Bearer sk-..."), - ) - .build() - ) - .webhookOutputFormat("json") - .webhookSigningSecret("whsec_...") - .webhookUrl("https://example.com/webhooks/llamacloud") - .build() - ) - .webhookUrl("webhook_url") - .build() - ) - .parentJobExecutionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .partitions( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Partitions - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), - ) - .build() - ) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("user_id") - .webhookUrl("webhook_url") - .build() - ) - .continueAsNewThreshold(0L) - .directoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .addItemId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .addItemId("dfl-11111111-2222-3333-4444-555555555555") - .pageSize(1L) - .build() - - val body = params._body() - - assertThat(body.jobConfig()) - .isEqualTo( - BatchCreateParams.JobConfig.ofBatchParseJobRecordCreate( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.builder() - .correlationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .jobName( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.JobName - .PARSE_RAW_FILE_JOB - ) - .parameters( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .builder() - .adaptiveLongTable(true) - .aggressiveTableExtraction(true) - .annotateLinks(true) - .annotateRevisions(true) - .autoMode(true) - .autoModeConfigurationJson("auto_mode_configuration_json") - .autoModeTriggerOnImageInPage(true) - .autoModeTriggerOnRegexpInPage( - "auto_mode_trigger_on_regexp_in_page" - ) - .autoModeTriggerOnTableInPage(true) - .autoModeTriggerOnTextInPage("auto_mode_trigger_on_text_in_page") - .azureOpenAIApiVersion("azure_openai_api_version") - .azureOpenAIDeploymentName("azure_openai_deployment_name") - .azureOpenAIEndpoint("azure_openai_endpoint") - .azureOpenAIKey("azure_openai_key") - .bboxBottom(0.0) - .bboxLeft(0.0) - .bboxRight(0.0) - .bboxTop(0.0) - .boundingBox("bounding_box") - .compactMarkdownTable(true) - .complementalFormattingInstruction( - "complemental_formatting_instruction" - ) - .confidenceScoreEffort("confidence_score_effort") - .contentGuidelineInstruction("content_guideline_instruction") - .continuousMode(true) - .customMetadata( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .CustomMetadata - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .disableImageExtraction(true) - .disableOcr(true) - .disableReconstruction(true) - .doNotCache(true) - .doNotUnrollColumns(true) - .enableCostOptimizer(true) - .extractCharts(true) - .extractLayout(true) - .extractPrintedPageNumber(true) - .fastMode(true) - .formattingInstruction("formatting_instruction") - .gpt4oApiKey("gpt4o_api_key") - .gpt4oMode(true) - .guessXlsxSheetName(true) - .hideFooters(true) - .hideHeaders(true) - .highResOcr(true) - .htmlMakeAllElementsVisible(true) - .htmlRemoveFixedElements(true) - .htmlRemoveNavigationElements(true) - .httpProxy("http_proxy") - .ignoreDocumentElementsForLayoutDetection(true) - .addImagesToSave( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .ImagesToSave - .EMBEDDED - ) - .inlineImagesInMarkdown(true) - .inputS3Path("input_s3_path") - .inputS3Region("input_s3_region") - .inputUrl("input_url") - .internalIsScreenshotJob(true) - .invalidateCache(true) - .isFormattingInstruction(true) - .jobTimeoutExtraTimePerPageInSeconds(0.0) - .jobTimeoutInSeconds(0.0) - .keepPageSeparatorWhenMergingTables(true) - .lang("lang") - .addLanguage(ParsingLanguages.ABQ) - .layoutAware(true) - .lineLevelBoundingBox(true) - .markdownTableMultilineHeaderSeparator( - "markdown_table_multiline_header_separator" - ) - .maxPages(0L) - .maxPagesEnforced(0L) - .mergeTablesAcrossPagesInMarkdown(true) - .model("model") - .outlinedTableExtraction(true) - .outputPdfOfDocument(true) - .outputS3PathPrefix("output_s3_path_prefix") - .outputS3Region("output_s3_region") - .outputTablesAsHtml(true) - .outputBucket("outputBucket") - .pageErrorTolerance(0.0) - .pageFooterPrefix("page_footer_prefix") - .pageFooterSuffix("page_footer_suffix") - .pageHeaderPrefix("page_header_prefix") - .pageHeaderSuffix("page_header_suffix") - .pagePrefix("page_prefix") - .pageSeparator("page_separator") - .pageSuffix("page_suffix") - .parseMode(ParsingMode.PARSE_DOCUMENT_WITH_AGENT) - .parsingInstruction("parsing_instruction") - .pipelineId("pipeline_id") - .preciseBoundingBox(true) - .premiumMode(true) - .presentationOutOfBoundsContent(true) - .presentationSkipEmbeddedData(true) - .preserveLayoutAlignmentAcrossPages(true) - .preserveVerySmallText(true) - .preset("preset") - .priority( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .Priority - .CRITICAL - ) - .projectId("project_id") - .removeHiddenText(true) - .replaceFailedPageMode(FailPageMode.BLANK_PAGE) - .replaceFailedPageWithErrorMessagePrefix( - "replace_failed_page_with_error_message_prefix" - ) - .replaceFailedPageWithErrorMessageSuffix( - "replace_failed_page_with_error_message_suffix" - ) - .resourceInfo( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .ResourceInfo - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .saveImages(true) - .skipDiagonalText(true) - .specializedChartParsingAgentic(true) - .specializedChartParsingEfficient(true) - .specializedChartParsingPlus(true) - .specializedImageParsing(true) - .spreadsheetExtractSubTables(true) - .spreadsheetForceFormulaComputation(true) - .spreadsheetIncludeHiddenSheets(true) - .strictModeBuggyFont(true) - .strictModeImageExtraction(true) - .strictModeImageOcr(true) - .strictModeReconstruction(true) - .structuredOutput(true) - .structuredOutputJsonSchema("structured_output_json_schema") - .structuredOutputJsonSchemaName( - "structured_output_json_schema_name" - ) - .systemPrompt("system_prompt") - .systemPromptAppend("system_prompt_append") - .takeScreenshot(true) - .targetPages("target_pages") - .tier("tier") - .type( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .Type - .PARSE - ) - .useVendorMultimodalModel(true) - .userPrompt("user_prompt") - .vendorMultimodalApiKey("vendor_multimodal_api_key") - .vendorMultimodalModelName("vendor_multimodal_model_name") - .version("version") - .addWebhookConfiguration( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .WebhookConfiguration - .builder() - .addWebhookEvent( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookEvent - .PARSE_SUCCESS - ) - .addWebhookEvent( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookEvent - .PARSE_ERROR - ) - .webhookHeaders( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookHeaders - .builder() - .putAdditionalProperty( - "Authorization", - JsonValue.from("Bearer sk-..."), - ) - .build() - ) - .webhookOutputFormat("json") - .webhookSigningSecret("whsec_...") - .webhookUrl("https://example.com/webhooks/llamacloud") - .build() - ) - .webhookUrl("webhook_url") - .build() - ) - .parentJobExecutionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .partitions( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Partitions - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), - ) - .build() - ) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("user_id") - .webhookUrl("webhook_url") - .build() - ) - ) - assertThat(body.continueAsNewThreshold()).contains(0L) - assertThat(body.directoryId()).contains("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - assertThat(body.itemIds().getOrNull()) - .containsExactly( - "dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", - "dfl-11111111-2222-3333-4444-555555555555", - ) - assertThat(body.pageSize()).contains(1L) - } - - @Test - fun bodyWithoutOptionalFields() { - val params = - BatchCreateParams.builder() - .jobConfig(BatchCreateParams.JobConfig.BatchParseJobRecordCreate.builder().build()) - .build() - - val body = params._body() - - assertThat(body.jobConfig()) - .isEqualTo( - BatchCreateParams.JobConfig.ofBatchParseJobRecordCreate( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.builder().build() - ) - ) - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateResponseTest.kt deleted file mode 100644 index 0605ea3..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchCreateResponseTest.kt +++ /dev/null @@ -1,94 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch - -import ai.llamaindex.llamacloud.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BatchCreateResponseTest { - - @Test - fun create() { - val batchCreateResponse = - BatchCreateResponse.builder() - .id("bjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .jobType(BatchCreateResponse.JobType.CLASSIFY) - .projectId("proj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .status(BatchCreateResponse.Status.CANCELLED) - .totalItems(0L) - .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .directoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .effectiveAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .errorMessage("error_message") - .failedItems(0L) - .jobRecordId("job_record_id") - .processedItems(0L) - .skippedItems(0L) - .startedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .workflowId("workflow_id") - .build() - - assertThat(batchCreateResponse.id()).isEqualTo("bjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - assertThat(batchCreateResponse.jobType()).isEqualTo(BatchCreateResponse.JobType.CLASSIFY) - assertThat(batchCreateResponse.projectId()) - .isEqualTo("proj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - assertThat(batchCreateResponse.status()).isEqualTo(BatchCreateResponse.Status.CANCELLED) - assertThat(batchCreateResponse.totalItems()).isEqualTo(0L) - assertThat(batchCreateResponse.completedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(batchCreateResponse.createdAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(batchCreateResponse.directoryId()) - .contains("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - assertThat(batchCreateResponse.effectiveAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(batchCreateResponse.errorMessage()).contains("error_message") - assertThat(batchCreateResponse.failedItems()).contains(0L) - assertThat(batchCreateResponse.jobRecordId()).contains("job_record_id") - assertThat(batchCreateResponse.processedItems()).contains(0L) - assertThat(batchCreateResponse.skippedItems()).contains(0L) - assertThat(batchCreateResponse.startedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(batchCreateResponse.updatedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(batchCreateResponse.workflowId()).contains("workflow_id") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val batchCreateResponse = - BatchCreateResponse.builder() - .id("bjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .jobType(BatchCreateResponse.JobType.CLASSIFY) - .projectId("proj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .status(BatchCreateResponse.Status.CANCELLED) - .totalItems(0L) - .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .directoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .effectiveAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .errorMessage("error_message") - .failedItems(0L) - .jobRecordId("job_record_id") - .processedItems(0L) - .skippedItems(0L) - .startedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .workflowId("workflow_id") - .build() - - val roundtrippedBatchCreateResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(batchCreateResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBatchCreateResponse).isEqualTo(batchCreateResponse) - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchGetStatusResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchGetStatusResponseTest.kt deleted file mode 100644 index 4109bd5..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchGetStatusResponseTest.kt +++ /dev/null @@ -1,103 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch - -import ai.llamaindex.llamacloud.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BatchGetStatusResponseTest { - - @Test - fun create() { - val batchGetStatusResponse = - BatchGetStatusResponse.builder() - .job( - BatchGetStatusResponse.Job.builder() - .id("bjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .jobType(BatchGetStatusResponse.Job.JobType.CLASSIFY) - .projectId("proj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .status(BatchGetStatusResponse.Job.Status.CANCELLED) - .totalItems(0L) - .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .directoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .effectiveAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .errorMessage("error_message") - .failedItems(0L) - .jobRecordId("job_record_id") - .processedItems(0L) - .skippedItems(0L) - .startedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .workflowId("workflow_id") - .build() - ) - .progressPercentage(0.0) - .build() - - assertThat(batchGetStatusResponse.job()) - .isEqualTo( - BatchGetStatusResponse.Job.builder() - .id("bjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .jobType(BatchGetStatusResponse.Job.JobType.CLASSIFY) - .projectId("proj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .status(BatchGetStatusResponse.Job.Status.CANCELLED) - .totalItems(0L) - .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .directoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .effectiveAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .errorMessage("error_message") - .failedItems(0L) - .jobRecordId("job_record_id") - .processedItems(0L) - .skippedItems(0L) - .startedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .workflowId("workflow_id") - .build() - ) - assertThat(batchGetStatusResponse.progressPercentage()).isEqualTo(0.0) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val batchGetStatusResponse = - BatchGetStatusResponse.builder() - .job( - BatchGetStatusResponse.Job.builder() - .id("bjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .jobType(BatchGetStatusResponse.Job.JobType.CLASSIFY) - .projectId("proj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .status(BatchGetStatusResponse.Job.Status.CANCELLED) - .totalItems(0L) - .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .directoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .effectiveAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .errorMessage("error_message") - .failedItems(0L) - .jobRecordId("job_record_id") - .processedItems(0L) - .skippedItems(0L) - .startedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .workflowId("workflow_id") - .build() - ) - .progressPercentage(0.0) - .build() - - val roundtrippedBatchGetStatusResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(batchGetStatusResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBatchGetStatusResponse).isEqualTo(batchGetStatusResponse) - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListPageResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListPageResponseTest.kt deleted file mode 100644 index 693189d..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListPageResponseTest.kt +++ /dev/null @@ -1,106 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch - -import ai.llamaindex.llamacloud.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BatchListPageResponseTest { - - @Test - fun create() { - val batchListPageResponse = - BatchListPageResponse.builder() - .addItem( - BatchListResponse.builder() - .id("bjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .jobType(BatchListResponse.JobType.CLASSIFY) - .projectId("proj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .status(BatchListResponse.Status.CANCELLED) - .totalItems(0L) - .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .directoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .effectiveAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .errorMessage("error_message") - .failedItems(0L) - .jobRecordId("job_record_id") - .processedItems(0L) - .skippedItems(0L) - .startedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .workflowId("workflow_id") - .build() - ) - .nextPageToken("next_page_token") - .totalSize(0L) - .build() - - assertThat(batchListPageResponse.items()) - .containsExactly( - BatchListResponse.builder() - .id("bjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .jobType(BatchListResponse.JobType.CLASSIFY) - .projectId("proj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .status(BatchListResponse.Status.CANCELLED) - .totalItems(0L) - .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .directoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .effectiveAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .errorMessage("error_message") - .failedItems(0L) - .jobRecordId("job_record_id") - .processedItems(0L) - .skippedItems(0L) - .startedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .workflowId("workflow_id") - .build() - ) - assertThat(batchListPageResponse.nextPageToken()).contains("next_page_token") - assertThat(batchListPageResponse.totalSize()).contains(0L) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val batchListPageResponse = - BatchListPageResponse.builder() - .addItem( - BatchListResponse.builder() - .id("bjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .jobType(BatchListResponse.JobType.CLASSIFY) - .projectId("proj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .status(BatchListResponse.Status.CANCELLED) - .totalItems(0L) - .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .directoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .effectiveAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .errorMessage("error_message") - .failedItems(0L) - .jobRecordId("job_record_id") - .processedItems(0L) - .skippedItems(0L) - .startedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .workflowId("workflow_id") - .build() - ) - .nextPageToken("next_page_token") - .totalSize(0L) - .build() - - val roundtrippedBatchListPageResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(batchListPageResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBatchListPageResponse).isEqualTo(batchListPageResponse) - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListParamsTest.kt deleted file mode 100644 index bde941f..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListParamsTest.kt +++ /dev/null @@ -1,61 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch - -import ai.llamaindex.llamacloud.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BatchListParamsTest { - - @Test - fun create() { - BatchListParams.builder() - .directoryId("directory_id") - .jobType(BatchListParams.JobType.CLASSIFY) - .limit(1L) - .offset(0L) - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .status(BatchListParams.Status.CANCELLED) - .build() - } - - @Test - fun queryParams() { - val params = - BatchListParams.builder() - .directoryId("directory_id") - .jobType(BatchListParams.JobType.CLASSIFY) - .limit(1L) - .offset(0L) - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .status(BatchListParams.Status.CANCELLED) - .build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo( - QueryParams.builder() - .put("directory_id", "directory_id") - .put("job_type", "classify") - .put("limit", "1") - .put("offset", "0") - .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .put("status", "cancelled") - .build() - ) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = BatchListParams.builder().build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListResponseTest.kt deleted file mode 100644 index 739d78c..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchListResponseTest.kt +++ /dev/null @@ -1,94 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch - -import ai.llamaindex.llamacloud.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BatchListResponseTest { - - @Test - fun create() { - val batchListResponse = - BatchListResponse.builder() - .id("bjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .jobType(BatchListResponse.JobType.CLASSIFY) - .projectId("proj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .status(BatchListResponse.Status.CANCELLED) - .totalItems(0L) - .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .directoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .effectiveAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .errorMessage("error_message") - .failedItems(0L) - .jobRecordId("job_record_id") - .processedItems(0L) - .skippedItems(0L) - .startedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .workflowId("workflow_id") - .build() - - assertThat(batchListResponse.id()).isEqualTo("bjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - assertThat(batchListResponse.jobType()).isEqualTo(BatchListResponse.JobType.CLASSIFY) - assertThat(batchListResponse.projectId()) - .isEqualTo("proj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - assertThat(batchListResponse.status()).isEqualTo(BatchListResponse.Status.CANCELLED) - assertThat(batchListResponse.totalItems()).isEqualTo(0L) - assertThat(batchListResponse.completedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(batchListResponse.createdAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(batchListResponse.directoryId()) - .contains("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - assertThat(batchListResponse.effectiveAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(batchListResponse.errorMessage()).contains("error_message") - assertThat(batchListResponse.failedItems()).contains(0L) - assertThat(batchListResponse.jobRecordId()).contains("job_record_id") - assertThat(batchListResponse.processedItems()).contains(0L) - assertThat(batchListResponse.skippedItems()).contains(0L) - assertThat(batchListResponse.startedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(batchListResponse.updatedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(batchListResponse.workflowId()).contains("workflow_id") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val batchListResponse = - BatchListResponse.builder() - .id("bjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .jobType(BatchListResponse.JobType.CLASSIFY) - .projectId("proj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .status(BatchListResponse.Status.CANCELLED) - .totalItems(0L) - .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .directoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .effectiveAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .errorMessage("error_message") - .failedItems(0L) - .jobRecordId("job_record_id") - .processedItems(0L) - .skippedItems(0L) - .startedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .workflowId("workflow_id") - .build() - - val roundtrippedBatchListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(batchListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBatchListResponse).isEqualTo(batchListResponse) - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsParamsTest.kt deleted file mode 100644 index 39db3d6..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsParamsTest.kt +++ /dev/null @@ -1,60 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch.jobitems - -import ai.llamaindex.llamacloud.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class JobItemGetProcessingResultsParamsTest { - - @Test - fun create() { - JobItemGetProcessingResultsParams.builder() - .itemId("item_id") - .jobType(JobItemGetProcessingResultsParams.JobType.CLASSIFY) - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - } - - @Test - fun pathParams() { - val params = JobItemGetProcessingResultsParams.builder().itemId("item_id").build() - - assertThat(params._pathParam(0)).isEqualTo("item_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun queryParams() { - val params = - JobItemGetProcessingResultsParams.builder() - .itemId("item_id") - .jobType(JobItemGetProcessingResultsParams.JobType.CLASSIFY) - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo( - QueryParams.builder() - .put("job_type", "classify") - .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = JobItemGetProcessingResultsParams.builder().itemId("item_id").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsResponseTest.kt deleted file mode 100644 index 592f9bf..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemGetProcessingResultsResponseTest.kt +++ /dev/null @@ -1,877 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch.jobitems - -import ai.llamaindex.llamacloud.core.JsonValue -import ai.llamaindex.llamacloud.core.jsonMapper -import ai.llamaindex.llamacloud.models.parsing.FailPageMode -import ai.llamaindex.llamacloud.models.parsing.ParsingLanguages -import ai.llamaindex.llamacloud.models.parsing.ParsingMode -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.OffsetDateTime -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class JobItemGetProcessingResultsResponseTest { - - @Test - fun create() { - val jobItemGetProcessingResultsResponse = - JobItemGetProcessingResultsResponse.builder() - .itemId("item_id") - .itemName("item_name") - .addProcessingResult( - JobItemGetProcessingResultsResponse.ProcessingResult.builder() - .itemId("item_id") - .jobConfig( - JobItemGetProcessingResultsResponse.ProcessingResult.JobConfig - .BatchParseJobRecordCreate - .builder() - .correlationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .jobName( - JobItemGetProcessingResultsResponse.ProcessingResult.JobConfig - .BatchParseJobRecordCreate - .JobName - .PARSE_RAW_FILE_JOB - ) - .parameters( - JobItemGetProcessingResultsResponse.ProcessingResult.JobConfig - .BatchParseJobRecordCreate - .Parameters - .builder() - .adaptiveLongTable(true) - .aggressiveTableExtraction(true) - .annotateLinks(true) - .annotateRevisions(true) - .autoMode(true) - .autoModeConfigurationJson("auto_mode_configuration_json") - .autoModeTriggerOnImageInPage(true) - .autoModeTriggerOnRegexpInPage( - "auto_mode_trigger_on_regexp_in_page" - ) - .autoModeTriggerOnTableInPage(true) - .autoModeTriggerOnTextInPage( - "auto_mode_trigger_on_text_in_page" - ) - .azureOpenAIApiVersion("azure_openai_api_version") - .azureOpenAIDeploymentName("azure_openai_deployment_name") - .azureOpenAIEndpoint("azure_openai_endpoint") - .azureOpenAIKey("azure_openai_key") - .bboxBottom(0.0) - .bboxLeft(0.0) - .bboxRight(0.0) - .bboxTop(0.0) - .boundingBox("bounding_box") - .compactMarkdownTable(true) - .complementalFormattingInstruction( - "complemental_formatting_instruction" - ) - .confidenceScoreEffort("confidence_score_effort") - .contentGuidelineInstruction( - "content_guideline_instruction" - ) - .continuousMode(true) - .customMetadata( - JobItemGetProcessingResultsResponse.ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .CustomMetadata - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .disableImageExtraction(true) - .disableOcr(true) - .disableReconstruction(true) - .doNotCache(true) - .doNotUnrollColumns(true) - .enableCostOptimizer(true) - .extractCharts(true) - .extractLayout(true) - .extractPrintedPageNumber(true) - .fastMode(true) - .formattingInstruction("formatting_instruction") - .gpt4oApiKey("gpt4o_api_key") - .gpt4oMode(true) - .guessXlsxSheetName(true) - .hideFooters(true) - .hideHeaders(true) - .highResOcr(true) - .htmlMakeAllElementsVisible(true) - .htmlRemoveFixedElements(true) - .htmlRemoveNavigationElements(true) - .httpProxy("http_proxy") - .ignoreDocumentElementsForLayoutDetection(true) - .addImagesToSave( - JobItemGetProcessingResultsResponse.ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .ImagesToSave - .EMBEDDED - ) - .inlineImagesInMarkdown(true) - .inputS3Path("input_s3_path") - .inputS3Region("input_s3_region") - .inputUrl("input_url") - .internalIsScreenshotJob(true) - .invalidateCache(true) - .isFormattingInstruction(true) - .jobTimeoutExtraTimePerPageInSeconds(0.0) - .jobTimeoutInSeconds(0.0) - .keepPageSeparatorWhenMergingTables(true) - .lang("lang") - .addLanguage(ParsingLanguages.ABQ) - .layoutAware(true) - .lineLevelBoundingBox(true) - .markdownTableMultilineHeaderSeparator( - "markdown_table_multiline_header_separator" - ) - .maxPages(0L) - .maxPagesEnforced(0L) - .mergeTablesAcrossPagesInMarkdown(true) - .model("model") - .outlinedTableExtraction(true) - .outputPdfOfDocument(true) - .outputS3PathPrefix("output_s3_path_prefix") - .outputS3Region("output_s3_region") - .outputTablesAsHtml(true) - .outputBucket("outputBucket") - .pageErrorTolerance(0.0) - .pageFooterPrefix("page_footer_prefix") - .pageFooterSuffix("page_footer_suffix") - .pageHeaderPrefix("page_header_prefix") - .pageHeaderSuffix("page_header_suffix") - .pagePrefix("page_prefix") - .pageSeparator("page_separator") - .pageSuffix("page_suffix") - .parseMode(ParsingMode.PARSE_DOCUMENT_WITH_AGENT) - .parsingInstruction("parsing_instruction") - .pipelineId("pipeline_id") - .preciseBoundingBox(true) - .premiumMode(true) - .presentationOutOfBoundsContent(true) - .presentationSkipEmbeddedData(true) - .preserveLayoutAlignmentAcrossPages(true) - .preserveVerySmallText(true) - .preset("preset") - .priority( - JobItemGetProcessingResultsResponse.ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .Priority - .CRITICAL - ) - .projectId("project_id") - .removeHiddenText(true) - .replaceFailedPageMode(FailPageMode.BLANK_PAGE) - .replaceFailedPageWithErrorMessagePrefix( - "replace_failed_page_with_error_message_prefix" - ) - .replaceFailedPageWithErrorMessageSuffix( - "replace_failed_page_with_error_message_suffix" - ) - .resourceInfo( - JobItemGetProcessingResultsResponse.ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .ResourceInfo - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .saveImages(true) - .skipDiagonalText(true) - .specializedChartParsingAgentic(true) - .specializedChartParsingEfficient(true) - .specializedChartParsingPlus(true) - .specializedImageParsing(true) - .spreadsheetExtractSubTables(true) - .spreadsheetForceFormulaComputation(true) - .spreadsheetIncludeHiddenSheets(true) - .strictModeBuggyFont(true) - .strictModeImageExtraction(true) - .strictModeImageOcr(true) - .strictModeReconstruction(true) - .structuredOutput(true) - .structuredOutputJsonSchema("structured_output_json_schema") - .structuredOutputJsonSchemaName( - "structured_output_json_schema_name" - ) - .systemPrompt("system_prompt") - .systemPromptAppend("system_prompt_append") - .takeScreenshot(true) - .targetPages("target_pages") - .tier("tier") - .type( - JobItemGetProcessingResultsResponse.ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .Type - .PARSE - ) - .useVendorMultimodalModel(true) - .userPrompt("user_prompt") - .vendorMultimodalApiKey("vendor_multimodal_api_key") - .vendorMultimodalModelName("vendor_multimodal_model_name") - .version("version") - .addWebhookConfiguration( - JobItemGetProcessingResultsResponse.ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .builder() - .addWebhookEvent( - JobItemGetProcessingResultsResponse - .ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookEvent - .PARSE_SUCCESS - ) - .addWebhookEvent( - JobItemGetProcessingResultsResponse - .ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookEvent - .PARSE_ERROR - ) - .webhookHeaders( - JobItemGetProcessingResultsResponse - .ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookHeaders - .builder() - .putAdditionalProperty( - "Authorization", - JsonValue.from("Bearer sk-..."), - ) - .build() - ) - .webhookOutputFormat("json") - .webhookSigningSecret("whsec_...") - .webhookUrl( - "https://example.com/webhooks/llamacloud" - ) - .build() - ) - .webhookUrl("webhook_url") - .build() - ) - .parentJobExecutionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .partitions( - JobItemGetProcessingResultsResponse.ProcessingResult.JobConfig - .BatchParseJobRecordCreate - .Partitions - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), - ) - .build() - ) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("user_id") - .webhookUrl("webhook_url") - .build() - ) - .jobType( - JobItemGetProcessingResultsResponse.ProcessingResult.JobType.CLASSIFY - ) - .outputS3Path("output_s3_path") - .parametersHash("parameters_hash") - .processedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .resultId("result_id") - .outputMetadata(JsonValue.from(mapOf())) - .build() - ) - .build() - - assertThat(jobItemGetProcessingResultsResponse.itemId()).isEqualTo("item_id") - assertThat(jobItemGetProcessingResultsResponse.itemName()).isEqualTo("item_name") - assertThat(jobItemGetProcessingResultsResponse.processingResults().getOrNull()) - .containsExactly( - JobItemGetProcessingResultsResponse.ProcessingResult.builder() - .itemId("item_id") - .jobConfig( - JobItemGetProcessingResultsResponse.ProcessingResult.JobConfig - .BatchParseJobRecordCreate - .builder() - .correlationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .jobName( - JobItemGetProcessingResultsResponse.ProcessingResult.JobConfig - .BatchParseJobRecordCreate - .JobName - .PARSE_RAW_FILE_JOB - ) - .parameters( - JobItemGetProcessingResultsResponse.ProcessingResult.JobConfig - .BatchParseJobRecordCreate - .Parameters - .builder() - .adaptiveLongTable(true) - .aggressiveTableExtraction(true) - .annotateLinks(true) - .annotateRevisions(true) - .autoMode(true) - .autoModeConfigurationJson("auto_mode_configuration_json") - .autoModeTriggerOnImageInPage(true) - .autoModeTriggerOnRegexpInPage( - "auto_mode_trigger_on_regexp_in_page" - ) - .autoModeTriggerOnTableInPage(true) - .autoModeTriggerOnTextInPage( - "auto_mode_trigger_on_text_in_page" - ) - .azureOpenAIApiVersion("azure_openai_api_version") - .azureOpenAIDeploymentName("azure_openai_deployment_name") - .azureOpenAIEndpoint("azure_openai_endpoint") - .azureOpenAIKey("azure_openai_key") - .bboxBottom(0.0) - .bboxLeft(0.0) - .bboxRight(0.0) - .bboxTop(0.0) - .boundingBox("bounding_box") - .compactMarkdownTable(true) - .complementalFormattingInstruction( - "complemental_formatting_instruction" - ) - .confidenceScoreEffort("confidence_score_effort") - .contentGuidelineInstruction("content_guideline_instruction") - .continuousMode(true) - .customMetadata( - JobItemGetProcessingResultsResponse.ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .CustomMetadata - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .disableImageExtraction(true) - .disableOcr(true) - .disableReconstruction(true) - .doNotCache(true) - .doNotUnrollColumns(true) - .enableCostOptimizer(true) - .extractCharts(true) - .extractLayout(true) - .extractPrintedPageNumber(true) - .fastMode(true) - .formattingInstruction("formatting_instruction") - .gpt4oApiKey("gpt4o_api_key") - .gpt4oMode(true) - .guessXlsxSheetName(true) - .hideFooters(true) - .hideHeaders(true) - .highResOcr(true) - .htmlMakeAllElementsVisible(true) - .htmlRemoveFixedElements(true) - .htmlRemoveNavigationElements(true) - .httpProxy("http_proxy") - .ignoreDocumentElementsForLayoutDetection(true) - .addImagesToSave( - JobItemGetProcessingResultsResponse.ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .ImagesToSave - .EMBEDDED - ) - .inlineImagesInMarkdown(true) - .inputS3Path("input_s3_path") - .inputS3Region("input_s3_region") - .inputUrl("input_url") - .internalIsScreenshotJob(true) - .invalidateCache(true) - .isFormattingInstruction(true) - .jobTimeoutExtraTimePerPageInSeconds(0.0) - .jobTimeoutInSeconds(0.0) - .keepPageSeparatorWhenMergingTables(true) - .lang("lang") - .addLanguage(ParsingLanguages.ABQ) - .layoutAware(true) - .lineLevelBoundingBox(true) - .markdownTableMultilineHeaderSeparator( - "markdown_table_multiline_header_separator" - ) - .maxPages(0L) - .maxPagesEnforced(0L) - .mergeTablesAcrossPagesInMarkdown(true) - .model("model") - .outlinedTableExtraction(true) - .outputPdfOfDocument(true) - .outputS3PathPrefix("output_s3_path_prefix") - .outputS3Region("output_s3_region") - .outputTablesAsHtml(true) - .outputBucket("outputBucket") - .pageErrorTolerance(0.0) - .pageFooterPrefix("page_footer_prefix") - .pageFooterSuffix("page_footer_suffix") - .pageHeaderPrefix("page_header_prefix") - .pageHeaderSuffix("page_header_suffix") - .pagePrefix("page_prefix") - .pageSeparator("page_separator") - .pageSuffix("page_suffix") - .parseMode(ParsingMode.PARSE_DOCUMENT_WITH_AGENT) - .parsingInstruction("parsing_instruction") - .pipelineId("pipeline_id") - .preciseBoundingBox(true) - .premiumMode(true) - .presentationOutOfBoundsContent(true) - .presentationSkipEmbeddedData(true) - .preserveLayoutAlignmentAcrossPages(true) - .preserveVerySmallText(true) - .preset("preset") - .priority( - JobItemGetProcessingResultsResponse.ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .Priority - .CRITICAL - ) - .projectId("project_id") - .removeHiddenText(true) - .replaceFailedPageMode(FailPageMode.BLANK_PAGE) - .replaceFailedPageWithErrorMessagePrefix( - "replace_failed_page_with_error_message_prefix" - ) - .replaceFailedPageWithErrorMessageSuffix( - "replace_failed_page_with_error_message_suffix" - ) - .resourceInfo( - JobItemGetProcessingResultsResponse.ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .ResourceInfo - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .saveImages(true) - .skipDiagonalText(true) - .specializedChartParsingAgentic(true) - .specializedChartParsingEfficient(true) - .specializedChartParsingPlus(true) - .specializedImageParsing(true) - .spreadsheetExtractSubTables(true) - .spreadsheetForceFormulaComputation(true) - .spreadsheetIncludeHiddenSheets(true) - .strictModeBuggyFont(true) - .strictModeImageExtraction(true) - .strictModeImageOcr(true) - .strictModeReconstruction(true) - .structuredOutput(true) - .structuredOutputJsonSchema("structured_output_json_schema") - .structuredOutputJsonSchemaName( - "structured_output_json_schema_name" - ) - .systemPrompt("system_prompt") - .systemPromptAppend("system_prompt_append") - .takeScreenshot(true) - .targetPages("target_pages") - .tier("tier") - .type( - JobItemGetProcessingResultsResponse.ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .Type - .PARSE - ) - .useVendorMultimodalModel(true) - .userPrompt("user_prompt") - .vendorMultimodalApiKey("vendor_multimodal_api_key") - .vendorMultimodalModelName("vendor_multimodal_model_name") - .version("version") - .addWebhookConfiguration( - JobItemGetProcessingResultsResponse.ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .builder() - .addWebhookEvent( - JobItemGetProcessingResultsResponse.ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookEvent - .PARSE_SUCCESS - ) - .addWebhookEvent( - JobItemGetProcessingResultsResponse.ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookEvent - .PARSE_ERROR - ) - .webhookHeaders( - JobItemGetProcessingResultsResponse.ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookHeaders - .builder() - .putAdditionalProperty( - "Authorization", - JsonValue.from("Bearer sk-..."), - ) - .build() - ) - .webhookOutputFormat("json") - .webhookSigningSecret("whsec_...") - .webhookUrl("https://example.com/webhooks/llamacloud") - .build() - ) - .webhookUrl("webhook_url") - .build() - ) - .parentJobExecutionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .partitions( - JobItemGetProcessingResultsResponse.ProcessingResult.JobConfig - .BatchParseJobRecordCreate - .Partitions - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), - ) - .build() - ) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("user_id") - .webhookUrl("webhook_url") - .build() - ) - .jobType(JobItemGetProcessingResultsResponse.ProcessingResult.JobType.CLASSIFY) - .outputS3Path("output_s3_path") - .parametersHash("parameters_hash") - .processedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .resultId("result_id") - .outputMetadata(JsonValue.from(mapOf())) - .build() - ) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val jobItemGetProcessingResultsResponse = - JobItemGetProcessingResultsResponse.builder() - .itemId("item_id") - .itemName("item_name") - .addProcessingResult( - JobItemGetProcessingResultsResponse.ProcessingResult.builder() - .itemId("item_id") - .jobConfig( - JobItemGetProcessingResultsResponse.ProcessingResult.JobConfig - .BatchParseJobRecordCreate - .builder() - .correlationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .jobName( - JobItemGetProcessingResultsResponse.ProcessingResult.JobConfig - .BatchParseJobRecordCreate - .JobName - .PARSE_RAW_FILE_JOB - ) - .parameters( - JobItemGetProcessingResultsResponse.ProcessingResult.JobConfig - .BatchParseJobRecordCreate - .Parameters - .builder() - .adaptiveLongTable(true) - .aggressiveTableExtraction(true) - .annotateLinks(true) - .annotateRevisions(true) - .autoMode(true) - .autoModeConfigurationJson("auto_mode_configuration_json") - .autoModeTriggerOnImageInPage(true) - .autoModeTriggerOnRegexpInPage( - "auto_mode_trigger_on_regexp_in_page" - ) - .autoModeTriggerOnTableInPage(true) - .autoModeTriggerOnTextInPage( - "auto_mode_trigger_on_text_in_page" - ) - .azureOpenAIApiVersion("azure_openai_api_version") - .azureOpenAIDeploymentName("azure_openai_deployment_name") - .azureOpenAIEndpoint("azure_openai_endpoint") - .azureOpenAIKey("azure_openai_key") - .bboxBottom(0.0) - .bboxLeft(0.0) - .bboxRight(0.0) - .bboxTop(0.0) - .boundingBox("bounding_box") - .compactMarkdownTable(true) - .complementalFormattingInstruction( - "complemental_formatting_instruction" - ) - .confidenceScoreEffort("confidence_score_effort") - .contentGuidelineInstruction( - "content_guideline_instruction" - ) - .continuousMode(true) - .customMetadata( - JobItemGetProcessingResultsResponse.ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .CustomMetadata - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .disableImageExtraction(true) - .disableOcr(true) - .disableReconstruction(true) - .doNotCache(true) - .doNotUnrollColumns(true) - .enableCostOptimizer(true) - .extractCharts(true) - .extractLayout(true) - .extractPrintedPageNumber(true) - .fastMode(true) - .formattingInstruction("formatting_instruction") - .gpt4oApiKey("gpt4o_api_key") - .gpt4oMode(true) - .guessXlsxSheetName(true) - .hideFooters(true) - .hideHeaders(true) - .highResOcr(true) - .htmlMakeAllElementsVisible(true) - .htmlRemoveFixedElements(true) - .htmlRemoveNavigationElements(true) - .httpProxy("http_proxy") - .ignoreDocumentElementsForLayoutDetection(true) - .addImagesToSave( - JobItemGetProcessingResultsResponse.ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .ImagesToSave - .EMBEDDED - ) - .inlineImagesInMarkdown(true) - .inputS3Path("input_s3_path") - .inputS3Region("input_s3_region") - .inputUrl("input_url") - .internalIsScreenshotJob(true) - .invalidateCache(true) - .isFormattingInstruction(true) - .jobTimeoutExtraTimePerPageInSeconds(0.0) - .jobTimeoutInSeconds(0.0) - .keepPageSeparatorWhenMergingTables(true) - .lang("lang") - .addLanguage(ParsingLanguages.ABQ) - .layoutAware(true) - .lineLevelBoundingBox(true) - .markdownTableMultilineHeaderSeparator( - "markdown_table_multiline_header_separator" - ) - .maxPages(0L) - .maxPagesEnforced(0L) - .mergeTablesAcrossPagesInMarkdown(true) - .model("model") - .outlinedTableExtraction(true) - .outputPdfOfDocument(true) - .outputS3PathPrefix("output_s3_path_prefix") - .outputS3Region("output_s3_region") - .outputTablesAsHtml(true) - .outputBucket("outputBucket") - .pageErrorTolerance(0.0) - .pageFooterPrefix("page_footer_prefix") - .pageFooterSuffix("page_footer_suffix") - .pageHeaderPrefix("page_header_prefix") - .pageHeaderSuffix("page_header_suffix") - .pagePrefix("page_prefix") - .pageSeparator("page_separator") - .pageSuffix("page_suffix") - .parseMode(ParsingMode.PARSE_DOCUMENT_WITH_AGENT) - .parsingInstruction("parsing_instruction") - .pipelineId("pipeline_id") - .preciseBoundingBox(true) - .premiumMode(true) - .presentationOutOfBoundsContent(true) - .presentationSkipEmbeddedData(true) - .preserveLayoutAlignmentAcrossPages(true) - .preserveVerySmallText(true) - .preset("preset") - .priority( - JobItemGetProcessingResultsResponse.ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .Priority - .CRITICAL - ) - .projectId("project_id") - .removeHiddenText(true) - .replaceFailedPageMode(FailPageMode.BLANK_PAGE) - .replaceFailedPageWithErrorMessagePrefix( - "replace_failed_page_with_error_message_prefix" - ) - .replaceFailedPageWithErrorMessageSuffix( - "replace_failed_page_with_error_message_suffix" - ) - .resourceInfo( - JobItemGetProcessingResultsResponse.ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .ResourceInfo - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .saveImages(true) - .skipDiagonalText(true) - .specializedChartParsingAgentic(true) - .specializedChartParsingEfficient(true) - .specializedChartParsingPlus(true) - .specializedImageParsing(true) - .spreadsheetExtractSubTables(true) - .spreadsheetForceFormulaComputation(true) - .spreadsheetIncludeHiddenSheets(true) - .strictModeBuggyFont(true) - .strictModeImageExtraction(true) - .strictModeImageOcr(true) - .strictModeReconstruction(true) - .structuredOutput(true) - .structuredOutputJsonSchema("structured_output_json_schema") - .structuredOutputJsonSchemaName( - "structured_output_json_schema_name" - ) - .systemPrompt("system_prompt") - .systemPromptAppend("system_prompt_append") - .takeScreenshot(true) - .targetPages("target_pages") - .tier("tier") - .type( - JobItemGetProcessingResultsResponse.ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .Type - .PARSE - ) - .useVendorMultimodalModel(true) - .userPrompt("user_prompt") - .vendorMultimodalApiKey("vendor_multimodal_api_key") - .vendorMultimodalModelName("vendor_multimodal_model_name") - .version("version") - .addWebhookConfiguration( - JobItemGetProcessingResultsResponse.ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .builder() - .addWebhookEvent( - JobItemGetProcessingResultsResponse - .ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookEvent - .PARSE_SUCCESS - ) - .addWebhookEvent( - JobItemGetProcessingResultsResponse - .ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookEvent - .PARSE_ERROR - ) - .webhookHeaders( - JobItemGetProcessingResultsResponse - .ProcessingResult - .JobConfig - .BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookHeaders - .builder() - .putAdditionalProperty( - "Authorization", - JsonValue.from("Bearer sk-..."), - ) - .build() - ) - .webhookOutputFormat("json") - .webhookSigningSecret("whsec_...") - .webhookUrl( - "https://example.com/webhooks/llamacloud" - ) - .build() - ) - .webhookUrl("webhook_url") - .build() - ) - .parentJobExecutionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .partitions( - JobItemGetProcessingResultsResponse.ProcessingResult.JobConfig - .BatchParseJobRecordCreate - .Partitions - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), - ) - .build() - ) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("user_id") - .webhookUrl("webhook_url") - .build() - ) - .jobType( - JobItemGetProcessingResultsResponse.ProcessingResult.JobType.CLASSIFY - ) - .outputS3Path("output_s3_path") - .parametersHash("parameters_hash") - .processedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .resultId("result_id") - .outputMetadata(JsonValue.from(mapOf())) - .build() - ) - .build() - - val roundtrippedJobItemGetProcessingResultsResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(jobItemGetProcessingResultsResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedJobItemGetProcessingResultsResponse) - .isEqualTo(jobItemGetProcessingResultsResponse) - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListPageResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListPageResponseTest.kt deleted file mode 100644 index 023c0ad..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListPageResponseTest.kt +++ /dev/null @@ -1,86 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch.jobitems - -import ai.llamaindex.llamacloud.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.OffsetDateTime -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class JobItemListPageResponseTest { - - @Test - fun create() { - val jobItemListPageResponse = - JobItemListPageResponse.builder() - .addItem( - JobItemListResponse.builder() - .itemId("item_id") - .itemName("item_name") - .status(JobItemListResponse.Status.CANCELLED) - .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .effectiveAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .errorMessage("error_message") - .jobId("job_id") - .jobRecordId("job_record_id") - .skipReason("skip_reason") - .startedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .nextPageToken("next_page_token") - .totalSize(0L) - .build() - - assertThat(jobItemListPageResponse.items().getOrNull()) - .containsExactly( - JobItemListResponse.builder() - .itemId("item_id") - .itemName("item_name") - .status(JobItemListResponse.Status.CANCELLED) - .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .effectiveAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .errorMessage("error_message") - .jobId("job_id") - .jobRecordId("job_record_id") - .skipReason("skip_reason") - .startedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - assertThat(jobItemListPageResponse.nextPageToken()).contains("next_page_token") - assertThat(jobItemListPageResponse.totalSize()).contains(0L) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val jobItemListPageResponse = - JobItemListPageResponse.builder() - .addItem( - JobItemListResponse.builder() - .itemId("item_id") - .itemName("item_name") - .status(JobItemListResponse.Status.CANCELLED) - .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .effectiveAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .errorMessage("error_message") - .jobId("job_id") - .jobRecordId("job_record_id") - .skipReason("skip_reason") - .startedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - ) - .nextPageToken("next_page_token") - .totalSize(0L) - .build() - - val roundtrippedJobItemListPageResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(jobItemListPageResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedJobItemListPageResponse).isEqualTo(jobItemListPageResponse) - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListParamsTest.kt deleted file mode 100644 index 6c18a55..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListParamsTest.kt +++ /dev/null @@ -1,66 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch.jobitems - -import ai.llamaindex.llamacloud.core.http.QueryParams -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class JobItemListParamsTest { - - @Test - fun create() { - JobItemListParams.builder() - .jobId("job_id") - .limit(1L) - .offset(0L) - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .status(JobItemListParams.Status.CANCELLED) - .build() - } - - @Test - fun pathParams() { - val params = JobItemListParams.builder().jobId("job_id").build() - - assertThat(params._pathParam(0)).isEqualTo("job_id") - // out-of-bound path param - assertThat(params._pathParam(1)).isEqualTo("") - } - - @Test - fun queryParams() { - val params = - JobItemListParams.builder() - .jobId("job_id") - .limit(1L) - .offset(0L) - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .status(JobItemListParams.Status.CANCELLED) - .build() - - val queryParams = params._queryParams() - - assertThat(queryParams) - .isEqualTo( - QueryParams.builder() - .put("limit", "1") - .put("offset", "0") - .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .put("status", "cancelled") - .build() - ) - } - - @Test - fun queryParamsWithoutOptionalFields() { - val params = JobItemListParams.builder().jobId("job_id").build() - - val queryParams = params._queryParams() - - assertThat(queryParams).isEqualTo(QueryParams.builder().build()) - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListResponseTest.kt deleted file mode 100644 index 458941f..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/jobitems/JobItemListResponseTest.kt +++ /dev/null @@ -1,69 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.models.beta.batch.jobitems - -import ai.llamaindex.llamacloud.core.jsonMapper -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import java.time.OffsetDateTime -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class JobItemListResponseTest { - - @Test - fun create() { - val jobItemListResponse = - JobItemListResponse.builder() - .itemId("item_id") - .itemName("item_name") - .status(JobItemListResponse.Status.CANCELLED) - .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .effectiveAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .errorMessage("error_message") - .jobId("job_id") - .jobRecordId("job_record_id") - .skipReason("skip_reason") - .startedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - - assertThat(jobItemListResponse.itemId()).isEqualTo("item_id") - assertThat(jobItemListResponse.itemName()).isEqualTo("item_name") - assertThat(jobItemListResponse.status()).isEqualTo(JobItemListResponse.Status.CANCELLED) - assertThat(jobItemListResponse.completedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(jobItemListResponse.effectiveAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - assertThat(jobItemListResponse.errorMessage()).contains("error_message") - assertThat(jobItemListResponse.jobId()).contains("job_id") - assertThat(jobItemListResponse.jobRecordId()).contains("job_record_id") - assertThat(jobItemListResponse.skipReason()).contains("skip_reason") - assertThat(jobItemListResponse.startedAt()) - .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val jobItemListResponse = - JobItemListResponse.builder() - .itemId("item_id") - .itemName("item_name") - .status(JobItemListResponse.Status.CANCELLED) - .completedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .effectiveAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .errorMessage("error_message") - .jobId("job_id") - .jobRecordId("job_record_id") - .skipReason("skip_reason") - .startedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) - .build() - - val roundtrippedJobItemListResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(jobItemListResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedJobItemListResponse).isEqualTo(jobItemListResponse) - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchGetStatusParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCancelParamsTest.kt similarity index 81% rename from llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchGetStatusParamsTest.kt rename to llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCancelParamsTest.kt index 0e69959..548a6e6 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/batch/BatchGetStatusParamsTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCancelParamsTest.kt @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. -package ai.llamaindex.llamacloud.models.beta.batch +package ai.llamaindex.llamacloud.models.parsing import ai.llamaindex.llamacloud.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class BatchGetStatusParamsTest { +internal class ParsingCancelParamsTest { @Test fun create() { - BatchGetStatusParams.builder() + ParsingCancelParams.builder() .jobId("job_id") .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -19,7 +19,7 @@ internal class BatchGetStatusParamsTest { @Test fun pathParams() { - val params = BatchGetStatusParams.builder().jobId("job_id").build() + val params = ParsingCancelParams.builder().jobId("job_id").build() assertThat(params._pathParam(0)).isEqualTo("job_id") // out-of-bound path param @@ -29,7 +29,7 @@ internal class BatchGetStatusParamsTest { @Test fun queryParams() { val params = - BatchGetStatusParams.builder() + ParsingCancelParams.builder() .jobId("job_id") .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -48,7 +48,7 @@ internal class BatchGetStatusParamsTest { @Test fun queryParamsWithoutOptionalFields() { - val params = BatchGetStatusParams.builder().jobId("job_id").build() + val params = ParsingCancelParams.builder().jobId("job_id").build() val queryParams = params._queryParams() diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCancelResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCancelResponseTest.kt new file mode 100644 index 0000000..880be72 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCancelResponseTest.kt @@ -0,0 +1,83 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.parsing + +import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ParsingCancelResponseTest { + + @Test + fun create() { + val parsingCancelResponse = + ParsingCancelResponse.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .projectId("prj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .status(ParsingCancelResponse.Status.CANCELLED) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errorMessage("error_message") + .name("Q4 Financial Report") + .tier("fast") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .userMetadata( + ParsingCancelResponse.UserMetadata.builder() + .putAdditionalProperty("owner", JsonValue.from("jerry")) + .putAdditionalProperty("team", JsonValue.from("research")) + .build() + ) + .build() + + assertThat(parsingCancelResponse.id()).isEqualTo("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + assertThat(parsingCancelResponse.projectId()) + .isEqualTo("prj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + assertThat(parsingCancelResponse.status()).isEqualTo(ParsingCancelResponse.Status.CANCELLED) + assertThat(parsingCancelResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(parsingCancelResponse.errorMessage()).contains("error_message") + assertThat(parsingCancelResponse.name()).contains("Q4 Financial Report") + assertThat(parsingCancelResponse.tier()).contains("fast") + assertThat(parsingCancelResponse.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(parsingCancelResponse.userMetadata()) + .contains( + ParsingCancelResponse.UserMetadata.builder() + .putAdditionalProperty("owner", JsonValue.from("jerry")) + .putAdditionalProperty("team", JsonValue.from("research")) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val parsingCancelResponse = + ParsingCancelResponse.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .projectId("prj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .status(ParsingCancelResponse.Status.CANCELLED) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errorMessage("error_message") + .name("Q4 Financial Report") + .tier("fast") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .userMetadata( + ParsingCancelResponse.UserMetadata.builder() + .putAdditionalProperty("owner", JsonValue.from("jerry")) + .putAdditionalProperty("team", JsonValue.from("research")) + .build() + ) + .build() + + val roundtrippedParsingCancelResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsingCancelResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsingCancelResponse).isEqualTo(parsingCancelResponse) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncTest.kt deleted file mode 100644 index 4bcdfe2..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncTest.kt +++ /dev/null @@ -1,98 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.services.async - -import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClientAsync -import ai.llamaindex.llamacloud.core.JsonValue -import ai.llamaindex.llamacloud.models.batches.BatchCreateParams -import ai.llamaindex.llamacloud.models.batches.BatchGetParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class BatchServiceAsyncTest { - - @Disabled("Mock server tests are disabled") - @Test - fun create() { - val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() - val batchServiceAsync = client.batches() - - val batchFuture = - batchServiceAsync.create( - BatchCreateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config( - BatchCreateParams.Config.builder() - .job( - BatchCreateParams.Config.Job.builder() - .configurationId("cfg-PARSE_AGENTIC") - .type(BatchCreateParams.Config.Job.Type.PARSE_V2) - .build() - ) - .build() - ) - .sourceDirectoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .addWebhookConfigurationId("whc-...") - .addWebhookConfigurationId("whc-...") - .addWebhookConfiguration( - BatchCreateParams.WebhookConfiguration.builder() - .addWebhookEvent( - BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS - ) - .addWebhookEvent( - BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR - ) - .webhookHeaders( - BatchCreateParams.WebhookConfiguration.WebhookHeaders.builder() - .putAdditionalProperty( - "Authorization", - JsonValue.from("Bearer sk-..."), - ) - .build() - ) - .webhookOutputFormat("json") - .webhookSigningSecret("whsec_...") - .webhookUrl("https://example.com/webhooks/llamacloud") - .build() - ) - .build() - ) - - val batch = batchFuture.get() - batch.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun list() { - val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() - val batchServiceAsync = client.batches() - - val pageFuture = batchServiceAsync.list() - - val page = pageFuture.get() - page.response().validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun get() { - val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() - val batchServiceAsync = client.batches() - - val batchFuture = - batchServiceAsync.get( - BatchGetParams.builder() - .batchId("batch_id") - .addExpand("string") - .addExpand("string") - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val batch = batchFuture.get() - batch.validate() - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncTest.kt index 0ff7cd3..d166efe 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncTest.kt @@ -4,6 +4,7 @@ package ai.llamaindex.llamacloud.services.async import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClientAsync import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.models.parsing.ParsingCancelParams import ai.llamaindex.llamacloud.models.parsing.ParsingCreateParams import ai.llamaindex.llamacloud.models.parsing.ParsingGetParams import ai.llamaindex.llamacloud.models.parsing.ParsingLanguages @@ -339,6 +340,25 @@ internal class ParsingServiceAsyncTest { page.response().validate() } + @Disabled("Mock server tests are disabled") + @Test + fun cancel() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val parsingServiceAsync = client.parsing() + + val responseFuture = + parsingServiceAsync.cancel( + ParsingCancelParams.builder() + .jobId("job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + @Disabled("Mock server tests are disabled") @Test fun get() { diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/beta/BatchServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/beta/BatchServiceAsyncTest.kt deleted file mode 100644 index c941a7c..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/beta/BatchServiceAsyncTest.kt +++ /dev/null @@ -1,329 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.services.async.beta - -import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClientAsync -import ai.llamaindex.llamacloud.core.JsonValue -import ai.llamaindex.llamacloud.models.beta.batch.BatchCancelParams -import ai.llamaindex.llamacloud.models.beta.batch.BatchCreateParams -import ai.llamaindex.llamacloud.models.beta.batch.BatchGetStatusParams -import ai.llamaindex.llamacloud.models.parsing.FailPageMode -import ai.llamaindex.llamacloud.models.parsing.ParsingLanguages -import ai.llamaindex.llamacloud.models.parsing.ParsingMode -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class BatchServiceAsyncTest { - - @Disabled("Mock server tests are disabled") - @Test - fun create() { - val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() - val batchServiceAsync = client.beta().batch() - - val batchFuture = - batchServiceAsync.create( - BatchCreateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .temporalNamespace("temporal-namespace") - .jobConfig( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.builder() - .correlationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .jobName( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.JobName - .PARSE_RAW_FILE_JOB - ) - .parameters( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .builder() - .adaptiveLongTable(true) - .aggressiveTableExtraction(true) - .annotateLinks(true) - .annotateRevisions(true) - .autoMode(true) - .autoModeConfigurationJson("auto_mode_configuration_json") - .autoModeTriggerOnImageInPage(true) - .autoModeTriggerOnRegexpInPage( - "auto_mode_trigger_on_regexp_in_page" - ) - .autoModeTriggerOnTableInPage(true) - .autoModeTriggerOnTextInPage( - "auto_mode_trigger_on_text_in_page" - ) - .azureOpenAIApiVersion("azure_openai_api_version") - .azureOpenAIDeploymentName("azure_openai_deployment_name") - .azureOpenAIEndpoint("azure_openai_endpoint") - .azureOpenAIKey("azure_openai_key") - .bboxBottom(0.0) - .bboxLeft(0.0) - .bboxRight(0.0) - .bboxTop(0.0) - .boundingBox("bounding_box") - .compactMarkdownTable(true) - .complementalFormattingInstruction( - "complemental_formatting_instruction" - ) - .confidenceScoreEffort("confidence_score_effort") - .contentGuidelineInstruction("content_guideline_instruction") - .continuousMode(true) - .customMetadata( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .CustomMetadata - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .disableImageExtraction(true) - .disableOcr(true) - .disableReconstruction(true) - .doNotCache(true) - .doNotUnrollColumns(true) - .enableCostOptimizer(true) - .extractCharts(true) - .extractLayout(true) - .extractPrintedPageNumber(true) - .fastMode(true) - .formattingInstruction("formatting_instruction") - .gpt4oApiKey("gpt4o_api_key") - .gpt4oMode(true) - .guessXlsxSheetName(true) - .hideFooters(true) - .hideHeaders(true) - .highResOcr(true) - .htmlMakeAllElementsVisible(true) - .htmlRemoveFixedElements(true) - .htmlRemoveNavigationElements(true) - .httpProxy("http_proxy") - .ignoreDocumentElementsForLayoutDetection(true) - .addImagesToSave( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .ImagesToSave - .EMBEDDED - ) - .inlineImagesInMarkdown(true) - .inputS3Path("input_s3_path") - .inputS3Region("input_s3_region") - .inputUrl("input_url") - .internalIsScreenshotJob(true) - .invalidateCache(true) - .isFormattingInstruction(true) - .jobTimeoutExtraTimePerPageInSeconds(0.0) - .jobTimeoutInSeconds(0.0) - .keepPageSeparatorWhenMergingTables(true) - .lang("lang") - .addLanguage(ParsingLanguages.ABQ) - .layoutAware(true) - .lineLevelBoundingBox(true) - .markdownTableMultilineHeaderSeparator( - "markdown_table_multiline_header_separator" - ) - .maxPages(0L) - .maxPagesEnforced(0L) - .mergeTablesAcrossPagesInMarkdown(true) - .model("model") - .outlinedTableExtraction(true) - .outputPdfOfDocument(true) - .outputS3PathPrefix("output_s3_path_prefix") - .outputS3Region("output_s3_region") - .outputTablesAsHtml(true) - .outputBucket("outputBucket") - .pageErrorTolerance(0.0) - .pageFooterPrefix("page_footer_prefix") - .pageFooterSuffix("page_footer_suffix") - .pageHeaderPrefix("page_header_prefix") - .pageHeaderSuffix("page_header_suffix") - .pagePrefix("page_prefix") - .pageSeparator("page_separator") - .pageSuffix("page_suffix") - .parseMode(ParsingMode.PARSE_DOCUMENT_WITH_AGENT) - .parsingInstruction("parsing_instruction") - .pipelineId("pipeline_id") - .preciseBoundingBox(true) - .premiumMode(true) - .presentationOutOfBoundsContent(true) - .presentationSkipEmbeddedData(true) - .preserveLayoutAlignmentAcrossPages(true) - .preserveVerySmallText(true) - .preset("preset") - .priority( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .Priority - .CRITICAL - ) - .projectId("project_id") - .removeHiddenText(true) - .replaceFailedPageMode(FailPageMode.BLANK_PAGE) - .replaceFailedPageWithErrorMessagePrefix( - "replace_failed_page_with_error_message_prefix" - ) - .replaceFailedPageWithErrorMessageSuffix( - "replace_failed_page_with_error_message_suffix" - ) - .resourceInfo( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .ResourceInfo - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .saveImages(true) - .skipDiagonalText(true) - .specializedChartParsingAgentic(true) - .specializedChartParsingEfficient(true) - .specializedChartParsingPlus(true) - .specializedImageParsing(true) - .spreadsheetExtractSubTables(true) - .spreadsheetForceFormulaComputation(true) - .spreadsheetIncludeHiddenSheets(true) - .strictModeBuggyFont(true) - .strictModeImageExtraction(true) - .strictModeImageOcr(true) - .strictModeReconstruction(true) - .structuredOutput(true) - .structuredOutputJsonSchema("structured_output_json_schema") - .structuredOutputJsonSchemaName( - "structured_output_json_schema_name" - ) - .systemPrompt("system_prompt") - .systemPromptAppend("system_prompt_append") - .takeScreenshot(true) - .targetPages("target_pages") - .tier("tier") - .type( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .Type - .PARSE - ) - .useVendorMultimodalModel(true) - .userPrompt("user_prompt") - .vendorMultimodalApiKey("vendor_multimodal_api_key") - .vendorMultimodalModelName("vendor_multimodal_model_name") - .version("version") - .addWebhookConfiguration( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .builder() - .addWebhookEvent( - BatchCreateParams.JobConfig - .BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookEvent - .PARSE_SUCCESS - ) - .addWebhookEvent( - BatchCreateParams.JobConfig - .BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookEvent - .PARSE_ERROR - ) - .webhookHeaders( - BatchCreateParams.JobConfig - .BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookHeaders - .builder() - .putAdditionalProperty( - "Authorization", - JsonValue.from("Bearer sk-..."), - ) - .build() - ) - .webhookOutputFormat("json") - .webhookSigningSecret("whsec_...") - .webhookUrl("https://example.com/webhooks/llamacloud") - .build() - ) - .webhookUrl("webhook_url") - .build() - ) - .parentJobExecutionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .partitions( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Partitions - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), - ) - .build() - ) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("user_id") - .webhookUrl("webhook_url") - .build() - ) - .continueAsNewThreshold(0L) - .directoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .addItemId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .addItemId("dfl-11111111-2222-3333-4444-555555555555") - .pageSize(1L) - .build() - ) - - val batch = batchFuture.get() - batch.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun list() { - val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() - val batchServiceAsync = client.beta().batch() - - val pageFuture = batchServiceAsync.list() - - val page = pageFuture.get() - page.response().validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun cancel() { - val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() - val batchServiceAsync = client.beta().batch() - - val responseFuture = - batchServiceAsync.cancel( - BatchCancelParams.builder() - .jobId("job_id") - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .temporalNamespace("temporal-namespace") - .reason("reason") - .build() - ) - - val response = responseFuture.get() - response.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun getStatus() { - val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() - val batchServiceAsync = client.beta().batch() - - val responseFuture = - batchServiceAsync.getStatus( - BatchGetStatusParams.builder() - .jobId("job_id") - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val response = responseFuture.get() - response.validate() - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/beta/batch/JobItemServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/beta/batch/JobItemServiceAsyncTest.kt deleted file mode 100644 index cf7b97f..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/beta/batch/JobItemServiceAsyncTest.kt +++ /dev/null @@ -1,43 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.services.async.beta.batch - -import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClientAsync -import ai.llamaindex.llamacloud.models.beta.batch.jobitems.JobItemGetProcessingResultsParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class JobItemServiceAsyncTest { - - @Disabled("Mock server tests are disabled") - @Test - fun list() { - val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() - val jobItemServiceAsync = client.beta().batch().jobItems() - - val pageFuture = jobItemServiceAsync.list("job_id") - - val page = pageFuture.get() - page.response().validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun getProcessingResults() { - val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() - val jobItemServiceAsync = client.beta().batch().jobItems() - - val responseFuture = - jobItemServiceAsync.getProcessingResults( - JobItemGetProcessingResultsParams.builder() - .itemId("item_id") - .jobType(JobItemGetProcessingResultsParams.JobType.CLASSIFY) - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - val response = responseFuture.get() - response.validate() - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceTest.kt deleted file mode 100644 index a0da2cb..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceTest.kt +++ /dev/null @@ -1,95 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.services.blocking - -import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClient -import ai.llamaindex.llamacloud.core.JsonValue -import ai.llamaindex.llamacloud.models.batches.BatchCreateParams -import ai.llamaindex.llamacloud.models.batches.BatchGetParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class BatchServiceTest { - - @Disabled("Mock server tests are disabled") - @Test - fun create() { - val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() - val batchService = client.batches() - - val batch = - batchService.create( - BatchCreateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .config( - BatchCreateParams.Config.builder() - .job( - BatchCreateParams.Config.Job.builder() - .configurationId("cfg-PARSE_AGENTIC") - .type(BatchCreateParams.Config.Job.Type.PARSE_V2) - .build() - ) - .build() - ) - .sourceDirectoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .addWebhookConfigurationId("whc-...") - .addWebhookConfigurationId("whc-...") - .addWebhookConfiguration( - BatchCreateParams.WebhookConfiguration.builder() - .addWebhookEvent( - BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS - ) - .addWebhookEvent( - BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR - ) - .webhookHeaders( - BatchCreateParams.WebhookConfiguration.WebhookHeaders.builder() - .putAdditionalProperty( - "Authorization", - JsonValue.from("Bearer sk-..."), - ) - .build() - ) - .webhookOutputFormat("json") - .webhookSigningSecret("whsec_...") - .webhookUrl("https://example.com/webhooks/llamacloud") - .build() - ) - .build() - ) - - batch.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun list() { - val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() - val batchService = client.batches() - - val page = batchService.list() - - page.response().validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun get() { - val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() - val batchService = client.batches() - - val batch = - batchService.get( - BatchGetParams.builder() - .batchId("batch_id") - .addExpand("string") - .addExpand("string") - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - batch.validate() - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceTest.kt index f82cf17..9f710b4 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceTest.kt @@ -4,6 +4,7 @@ package ai.llamaindex.llamacloud.services.blocking import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClient import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.models.parsing.ParsingCancelParams import ai.llamaindex.llamacloud.models.parsing.ParsingCreateParams import ai.llamaindex.llamacloud.models.parsing.ParsingGetParams import ai.llamaindex.llamacloud.models.parsing.ParsingLanguages @@ -337,6 +338,24 @@ internal class ParsingServiceTest { page.response().validate() } + @Disabled("Mock server tests are disabled") + @Test + fun cancel() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val parsingService = client.parsing() + + val response = + parsingService.cancel( + ParsingCancelParams.builder() + .jobId("job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + response.validate() + } + @Disabled("Mock server tests are disabled") @Test fun get() { diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/BatchServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/BatchServiceTest.kt deleted file mode 100644 index f21fc58..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/BatchServiceTest.kt +++ /dev/null @@ -1,325 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.services.blocking.beta - -import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClient -import ai.llamaindex.llamacloud.core.JsonValue -import ai.llamaindex.llamacloud.models.beta.batch.BatchCancelParams -import ai.llamaindex.llamacloud.models.beta.batch.BatchCreateParams -import ai.llamaindex.llamacloud.models.beta.batch.BatchGetStatusParams -import ai.llamaindex.llamacloud.models.parsing.FailPageMode -import ai.llamaindex.llamacloud.models.parsing.ParsingLanguages -import ai.llamaindex.llamacloud.models.parsing.ParsingMode -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class BatchServiceTest { - - @Disabled("Mock server tests are disabled") - @Test - fun create() { - val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() - val batchService = client.beta().batch() - - val batch = - batchService.create( - BatchCreateParams.builder() - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .temporalNamespace("temporal-namespace") - .jobConfig( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.builder() - .correlationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .jobName( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.JobName - .PARSE_RAW_FILE_JOB - ) - .parameters( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Parameters - .builder() - .adaptiveLongTable(true) - .aggressiveTableExtraction(true) - .annotateLinks(true) - .annotateRevisions(true) - .autoMode(true) - .autoModeConfigurationJson("auto_mode_configuration_json") - .autoModeTriggerOnImageInPage(true) - .autoModeTriggerOnRegexpInPage( - "auto_mode_trigger_on_regexp_in_page" - ) - .autoModeTriggerOnTableInPage(true) - .autoModeTriggerOnTextInPage( - "auto_mode_trigger_on_text_in_page" - ) - .azureOpenAIApiVersion("azure_openai_api_version") - .azureOpenAIDeploymentName("azure_openai_deployment_name") - .azureOpenAIEndpoint("azure_openai_endpoint") - .azureOpenAIKey("azure_openai_key") - .bboxBottom(0.0) - .bboxLeft(0.0) - .bboxRight(0.0) - .bboxTop(0.0) - .boundingBox("bounding_box") - .compactMarkdownTable(true) - .complementalFormattingInstruction( - "complemental_formatting_instruction" - ) - .confidenceScoreEffort("confidence_score_effort") - .contentGuidelineInstruction("content_guideline_instruction") - .continuousMode(true) - .customMetadata( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .CustomMetadata - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .disableImageExtraction(true) - .disableOcr(true) - .disableReconstruction(true) - .doNotCache(true) - .doNotUnrollColumns(true) - .enableCostOptimizer(true) - .extractCharts(true) - .extractLayout(true) - .extractPrintedPageNumber(true) - .fastMode(true) - .formattingInstruction("formatting_instruction") - .gpt4oApiKey("gpt4o_api_key") - .gpt4oMode(true) - .guessXlsxSheetName(true) - .hideFooters(true) - .hideHeaders(true) - .highResOcr(true) - .htmlMakeAllElementsVisible(true) - .htmlRemoveFixedElements(true) - .htmlRemoveNavigationElements(true) - .httpProxy("http_proxy") - .ignoreDocumentElementsForLayoutDetection(true) - .addImagesToSave( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .ImagesToSave - .EMBEDDED - ) - .inlineImagesInMarkdown(true) - .inputS3Path("input_s3_path") - .inputS3Region("input_s3_region") - .inputUrl("input_url") - .internalIsScreenshotJob(true) - .invalidateCache(true) - .isFormattingInstruction(true) - .jobTimeoutExtraTimePerPageInSeconds(0.0) - .jobTimeoutInSeconds(0.0) - .keepPageSeparatorWhenMergingTables(true) - .lang("lang") - .addLanguage(ParsingLanguages.ABQ) - .layoutAware(true) - .lineLevelBoundingBox(true) - .markdownTableMultilineHeaderSeparator( - "markdown_table_multiline_header_separator" - ) - .maxPages(0L) - .maxPagesEnforced(0L) - .mergeTablesAcrossPagesInMarkdown(true) - .model("model") - .outlinedTableExtraction(true) - .outputPdfOfDocument(true) - .outputS3PathPrefix("output_s3_path_prefix") - .outputS3Region("output_s3_region") - .outputTablesAsHtml(true) - .outputBucket("outputBucket") - .pageErrorTolerance(0.0) - .pageFooterPrefix("page_footer_prefix") - .pageFooterSuffix("page_footer_suffix") - .pageHeaderPrefix("page_header_prefix") - .pageHeaderSuffix("page_header_suffix") - .pagePrefix("page_prefix") - .pageSeparator("page_separator") - .pageSuffix("page_suffix") - .parseMode(ParsingMode.PARSE_DOCUMENT_WITH_AGENT) - .parsingInstruction("parsing_instruction") - .pipelineId("pipeline_id") - .preciseBoundingBox(true) - .premiumMode(true) - .presentationOutOfBoundsContent(true) - .presentationSkipEmbeddedData(true) - .preserveLayoutAlignmentAcrossPages(true) - .preserveVerySmallText(true) - .preset("preset") - .priority( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .Priority - .CRITICAL - ) - .projectId("project_id") - .removeHiddenText(true) - .replaceFailedPageMode(FailPageMode.BLANK_PAGE) - .replaceFailedPageWithErrorMessagePrefix( - "replace_failed_page_with_error_message_prefix" - ) - .replaceFailedPageWithErrorMessageSuffix( - "replace_failed_page_with_error_message_suffix" - ) - .resourceInfo( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .ResourceInfo - .builder() - .putAdditionalProperty("foo", JsonValue.from("bar")) - .build() - ) - .saveImages(true) - .skipDiagonalText(true) - .specializedChartParsingAgentic(true) - .specializedChartParsingEfficient(true) - .specializedChartParsingPlus(true) - .specializedImageParsing(true) - .spreadsheetExtractSubTables(true) - .spreadsheetForceFormulaComputation(true) - .spreadsheetIncludeHiddenSheets(true) - .strictModeBuggyFont(true) - .strictModeImageExtraction(true) - .strictModeImageOcr(true) - .strictModeReconstruction(true) - .structuredOutput(true) - .structuredOutputJsonSchema("structured_output_json_schema") - .structuredOutputJsonSchemaName( - "structured_output_json_schema_name" - ) - .systemPrompt("system_prompt") - .systemPromptAppend("system_prompt_append") - .takeScreenshot(true) - .targetPages("target_pages") - .tier("tier") - .type( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .Type - .PARSE - ) - .useVendorMultimodalModel(true) - .userPrompt("user_prompt") - .vendorMultimodalApiKey("vendor_multimodal_api_key") - .vendorMultimodalModelName("vendor_multimodal_model_name") - .version("version") - .addWebhookConfiguration( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .builder() - .addWebhookEvent( - BatchCreateParams.JobConfig - .BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookEvent - .PARSE_SUCCESS - ) - .addWebhookEvent( - BatchCreateParams.JobConfig - .BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookEvent - .PARSE_ERROR - ) - .webhookHeaders( - BatchCreateParams.JobConfig - .BatchParseJobRecordCreate - .Parameters - .WebhookConfiguration - .WebhookHeaders - .builder() - .putAdditionalProperty( - "Authorization", - JsonValue.from("Bearer sk-..."), - ) - .build() - ) - .webhookOutputFormat("json") - .webhookSigningSecret("whsec_...") - .webhookUrl("https://example.com/webhooks/llamacloud") - .build() - ) - .webhookUrl("webhook_url") - .build() - ) - .parentJobExecutionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .partitions( - BatchCreateParams.JobConfig.BatchParseJobRecordCreate.Partitions - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"), - ) - .build() - ) - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .sessionId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .userId("user_id") - .webhookUrl("webhook_url") - .build() - ) - .continueAsNewThreshold(0L) - .directoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .addItemId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") - .addItemId("dfl-11111111-2222-3333-4444-555555555555") - .pageSize(1L) - .build() - ) - - batch.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun list() { - val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() - val batchService = client.beta().batch() - - val page = batchService.list() - - page.response().validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun cancel() { - val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() - val batchService = client.beta().batch() - - val response = - batchService.cancel( - BatchCancelParams.builder() - .jobId("job_id") - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .temporalNamespace("temporal-namespace") - .reason("reason") - .build() - ) - - response.validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun getStatus() { - val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() - val batchService = client.beta().batch() - - val response = - batchService.getStatus( - BatchGetStatusParams.builder() - .jobId("job_id") - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - response.validate() - } -} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/batch/JobItemServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/batch/JobItemServiceTest.kt deleted file mode 100644 index 95c3ee0..0000000 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/batch/JobItemServiceTest.kt +++ /dev/null @@ -1,41 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package ai.llamaindex.llamacloud.services.blocking.beta.batch - -import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClient -import ai.llamaindex.llamacloud.models.beta.batch.jobitems.JobItemGetProcessingResultsParams -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Test - -internal class JobItemServiceTest { - - @Disabled("Mock server tests are disabled") - @Test - fun list() { - val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() - val jobItemService = client.beta().batch().jobItems() - - val page = jobItemService.list("job_id") - - page.response().validate() - } - - @Disabled("Mock server tests are disabled") - @Test - fun getProcessingResults() { - val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() - val jobItemService = client.beta().batch().jobItems() - - val response = - jobItemService.getProcessingResults( - JobItemGetProcessingResultsParams.builder() - .itemId("item_id") - .jobType(JobItemGetProcessingResultsParams.JobType.CLASSIFY) - .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - ) - - response.validate() - } -} diff --git a/llama-cloud-proguard-test/src/test/kotlin/ai/llamaindex/llamacloud/proguard/ProGuardCompatibilityTest.kt b/llama-cloud-proguard-test/src/test/kotlin/ai/llamaindex/llamacloud/proguard/ProGuardCompatibilityTest.kt index 73c1885..bc0d1b7 100644 --- a/llama-cloud-proguard-test/src/test/kotlin/ai/llamaindex/llamacloud/proguard/ProGuardCompatibilityTest.kt +++ b/llama-cloud-proguard-test/src/test/kotlin/ai/llamaindex/llamacloud/proguard/ProGuardCompatibilityTest.kt @@ -55,7 +55,6 @@ internal class ProGuardCompatibilityTest { assertThat(client.parsing()).isNotNull() assertThat(client.extract()).isNotNull() assertThat(client.classifier()).isNotNull() - assertThat(client.batches()).isNotNull() assertThat(client.classify()).isNotNull() assertThat(client.configurations()).isNotNull() assertThat(client.projects()).isNotNull() From b7615f31c8e94c3ad98e7eaddcd576ba33f6ebd2 Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Mon, 3 Aug 2026 23:21:35 +0000 Subject: [PATCH 14/28] LI-8489: restore client.batches (v2) in the published SDK Stainless-Generated-From: db027962fae4edb928d9595979c41e3112984de4 --- .stats.yml | 2 +- .../llamacloud/client/LlamaCloudClient.kt | 5 + .../client/LlamaCloudClientAsync.kt | 5 + .../client/LlamaCloudClientAsyncImpl.kt | 14 + .../llamacloud/client/LlamaCloudClientImpl.kt | 12 + .../models/batches/BatchCreateParams.kt | 2183 +++++++++++++++++ .../models/batches/BatchCreateResponse.kt | 1867 ++++++++++++++ .../models/batches/BatchGetParams.kt | 258 ++ .../models/batches/BatchGetResponse.kt | 1867 ++++++++++++++ .../models/batches/BatchListPage.kt | 130 + .../models/batches/BatchListPageAsync.kt | 145 ++ .../models/batches/BatchListPageResponse.kt | 303 +++ .../models/batches/BatchListParams.kt | 490 ++++ .../models/batches/BatchListResponse.kt | 1867 ++++++++++++++ .../services/async/BatchServiceAsync.kt | 195 ++ .../services/async/BatchServiceAsyncImpl.kt | 178 ++ .../services/blocking/BatchService.kt | 189 ++ .../services/blocking/BatchServiceImpl.kt | 161 ++ .../models/batches/BatchCreateParamsTest.kt | 237 ++ .../models/batches/BatchCreateResponseTest.kt | 125 + .../models/batches/BatchGetParamsTest.kt | 63 + .../models/batches/BatchGetResponseTest.kt | 125 + .../batches/BatchListPageResponseTest.kt | 139 ++ .../models/batches/BatchListParamsTest.kt | 65 + .../models/batches/BatchListResponseTest.kt | 125 + .../services/async/BatchServiceAsyncTest.kt | 98 + .../services/blocking/BatchServiceTest.kt | 95 + .../proguard/ProGuardCompatibilityTest.kt | 1 + 28 files changed, 10943 insertions(+), 1 deletion(-) create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateResponse.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetResponse.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPage.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageAsync.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageResponse.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListResponse.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsync.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncImpl.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchService.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceImpl.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateResponseTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetResponseTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageResponseTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListResponseTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceTest.kt diff --git a/.stats.yml b/.stats.yml index dcc1db9..97e2fbf 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 128 +configured_endpoints: 131 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 0ee14b3..3e7677a 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 @@ -3,6 +3,7 @@ package ai.llamaindex.llamacloud.client import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.services.blocking.BatchService import ai.llamaindex.llamacloud.services.blocking.BetaService import ai.llamaindex.llamacloud.services.blocking.ClassifierService import ai.llamaindex.llamacloud.services.blocking.ClassifyService @@ -64,6 +65,8 @@ interface LlamaCloudClient { fun classifier(): ClassifierService + fun batches(): BatchService + fun classify(): ClassifyService fun configurations(): ConfigurationService @@ -113,6 +116,8 @@ interface LlamaCloudClient { fun classifier(): ClassifierService.WithRawResponse + fun batches(): BatchService.WithRawResponse + fun classify(): ClassifyService.WithRawResponse fun configurations(): ConfigurationService.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 cbb2ea6..32487c4 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 @@ -3,6 +3,7 @@ package ai.llamaindex.llamacloud.client import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.services.async.BatchServiceAsync import ai.llamaindex.llamacloud.services.async.BetaServiceAsync import ai.llamaindex.llamacloud.services.async.ClassifierServiceAsync import ai.llamaindex.llamacloud.services.async.ClassifyServiceAsync @@ -64,6 +65,8 @@ interface LlamaCloudClientAsync { fun classifier(): ClassifierServiceAsync + fun batches(): BatchServiceAsync + fun classify(): ClassifyServiceAsync fun configurations(): ConfigurationServiceAsync @@ -117,6 +120,8 @@ interface LlamaCloudClientAsync { fun classifier(): ClassifierServiceAsync.WithRawResponse + fun batches(): BatchServiceAsync.WithRawResponse + fun classify(): ClassifyServiceAsync.WithRawResponse fun configurations(): ConfigurationServiceAsync.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 d0a4aeb..84dfcbc 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 @@ -4,6 +4,8 @@ package ai.llamaindex.llamacloud.client import ai.llamaindex.llamacloud.core.ClientOptions import ai.llamaindex.llamacloud.core.getPackageVersion +import ai.llamaindex.llamacloud.services.async.BatchServiceAsync +import ai.llamaindex.llamacloud.services.async.BatchServiceAsyncImpl import ai.llamaindex.llamacloud.services.async.BetaServiceAsync import ai.llamaindex.llamacloud.services.async.BetaServiceAsyncImpl import ai.llamaindex.llamacloud.services.async.ClassifierServiceAsync @@ -67,6 +69,10 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam ClassifierServiceAsyncImpl(clientOptionsWithUserAgent) } + private val batches: BatchServiceAsync by lazy { + BatchServiceAsyncImpl(clientOptionsWithUserAgent) + } + private val classify: ClassifyServiceAsync by lazy { ClassifyServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -114,6 +120,8 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam override fun classifier(): ClassifierServiceAsync = classifier + override fun batches(): BatchServiceAsync = batches + override fun classify(): ClassifyServiceAsync = classify override fun configurations(): ConfigurationServiceAsync = configurations @@ -155,6 +163,10 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam ClassifierServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val batches: BatchServiceAsync.WithRawResponse by lazy { + BatchServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + private val classify: ClassifyServiceAsync.WithRawResponse by lazy { ClassifyServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -204,6 +216,8 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam override fun classifier(): ClassifierServiceAsync.WithRawResponse = classifier + override fun batches(): BatchServiceAsync.WithRawResponse = batches + override fun classify(): ClassifyServiceAsync.WithRawResponse = classify override fun configurations(): ConfigurationServiceAsync.WithRawResponse = configurations 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 6b8dd07..df8f4db 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 @@ -4,6 +4,8 @@ package ai.llamaindex.llamacloud.client import ai.llamaindex.llamacloud.core.ClientOptions import ai.llamaindex.llamacloud.core.getPackageVersion +import ai.llamaindex.llamacloud.services.blocking.BatchService +import ai.llamaindex.llamacloud.services.blocking.BatchServiceImpl import ai.llamaindex.llamacloud.services.blocking.BetaService import ai.llamaindex.llamacloud.services.blocking.BetaServiceImpl import ai.llamaindex.llamacloud.services.blocking.ClassifierService @@ -61,6 +63,8 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou ClassifierServiceImpl(clientOptionsWithUserAgent) } + private val batches: BatchService by lazy { BatchServiceImpl(clientOptionsWithUserAgent) } + private val classify: ClassifyService by lazy { ClassifyServiceImpl(clientOptionsWithUserAgent) } @@ -106,6 +110,8 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou override fun classifier(): ClassifierService = classifier + override fun batches(): BatchService = batches + override fun classify(): ClassifyService = classify override fun configurations(): ConfigurationService = configurations @@ -147,6 +153,10 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou ClassifierServiceImpl.WithRawResponseImpl(clientOptions) } + private val batches: BatchService.WithRawResponse by lazy { + BatchServiceImpl.WithRawResponseImpl(clientOptions) + } + private val classify: ClassifyService.WithRawResponse by lazy { ClassifyServiceImpl.WithRawResponseImpl(clientOptions) } @@ -196,6 +206,8 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou override fun classifier(): ClassifierService.WithRawResponse = classifier + override fun batches(): BatchService.WithRawResponse = batches + override fun classify(): ClassifyService.WithRawResponse = classify override fun configurations(): ConfigurationService.WithRawResponse = configurations diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParams.kt new file mode 100644 index 0000000..e88e1bd --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParams.kt @@ -0,0 +1,2183 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.batches + +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.Params +import ai.llamaindex.llamacloud.core.checkKnown +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.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 + +/** + * Create a batch over a source directory and start processing asynchronously. + * + * To be notified as the batch progresses, pass `webhook_configurations` with inline endpoints + * and/or `webhook_configuration_ids` referencing saved configurations. Batches emit `batch.pending` + * on create, `batch.running` once processing starts, and a terminal `batch.success` or + * `batch.error`. + * + * `batch.success` means the batch finished mapping every source file to a job — individual files + * may still have failed, so read `results` (with `expand=results`) for per-file outcomes. + * + * Delivery order across events is not guaranteed; key on the `status` field in the payload rather + * than arrival order. + */ +class BatchCreateParams +private constructor( + private val organizationId: String?, + private val projectId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun organizationId(): Optional = Optional.ofNullable(organizationId) + + fun projectId(): Optional = Optional.ofNullable(projectId) + + /** + * Batch configuration snapshot to apply to this source directory. + * + * @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 = body.config() + + /** + * Directory whose files should be processed. + * + * @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 sourceDirectoryId(): String = body.sourceDirectoryId() + + /** + * IDs of saved webhook configurations to notify for this job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookConfigurationIds(): Optional> = body.webhookConfigurationIds() + + /** + * Outbound webhook endpoints to notify on job status changes + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookConfigurations(): Optional> = body.webhookConfigurations() + + /** + * Returns the raw JSON value of [config]. + * + * Unlike [config], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _config(): JsonField = body._config() + + /** + * Returns the raw JSON value of [sourceDirectoryId]. + * + * Unlike [sourceDirectoryId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _sourceDirectoryId(): JsonField = body._sourceDirectoryId() + + /** + * Returns the raw JSON value of [webhookConfigurationIds]. + * + * Unlike [webhookConfigurationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _webhookConfigurationIds(): JsonField> = body._webhookConfigurationIds() + + /** + * Returns the raw JSON value of [webhookConfigurations]. + * + * Unlike [webhookConfigurations], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _webhookConfigurations(): JsonField> = + body._webhookConfigurations() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BatchCreateParams]. + * + * The following fields are required: + * ```java + * .config() + * .sourceDirectoryId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BatchCreateParams]. */ + class Builder internal constructor() { + + private var organizationId: String? = null + private var projectId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(batchCreateParams: BatchCreateParams) = apply { + organizationId = batchCreateParams.organizationId + projectId = batchCreateParams.projectId + body = batchCreateParams.body.toBuilder() + additionalHeaders = batchCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = batchCreateParams.additionalQueryParams.toBuilder() + } + + 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()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [config] + * - [sourceDirectoryId] + * - [webhookConfigurationIds] + * - [webhookConfigurations] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Batch configuration snapshot to apply to this source directory. */ + fun config(config: Config) = apply { body.config(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 { body.config(config) } + + /** Directory whose files should be processed. */ + fun sourceDirectoryId(sourceDirectoryId: String) = apply { + body.sourceDirectoryId(sourceDirectoryId) + } + + /** + * Sets [Builder.sourceDirectoryId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceDirectoryId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceDirectoryId(sourceDirectoryId: JsonField) = apply { + body.sourceDirectoryId(sourceDirectoryId) + } + + /** IDs of saved webhook configurations to notify for this job. */ + fun webhookConfigurationIds(webhookConfigurationIds: List?) = apply { + body.webhookConfigurationIds(webhookConfigurationIds) + } + + /** + * Alias for calling [Builder.webhookConfigurationIds] with + * `webhookConfigurationIds.orElse(null)`. + */ + fun webhookConfigurationIds(webhookConfigurationIds: Optional>) = + webhookConfigurationIds(webhookConfigurationIds.getOrNull()) + + /** + * Sets [Builder.webhookConfigurationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookConfigurationIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun webhookConfigurationIds(webhookConfigurationIds: JsonField>) = apply { + body.webhookConfigurationIds(webhookConfigurationIds) + } + + /** + * Adds a single [String] to [webhookConfigurationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookConfigurationId(webhookConfigurationId: String) = apply { + body.addWebhookConfigurationId(webhookConfigurationId) + } + + /** Outbound webhook endpoints to notify on job status changes */ + fun webhookConfigurations(webhookConfigurations: List?) = apply { + body.webhookConfigurations(webhookConfigurations) + } + + /** + * Alias for calling [Builder.webhookConfigurations] with + * `webhookConfigurations.orElse(null)`. + */ + fun webhookConfigurations(webhookConfigurations: Optional>) = + webhookConfigurations(webhookConfigurations.getOrNull()) + + /** + * Sets [Builder.webhookConfigurations] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookConfigurations] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun webhookConfigurations(webhookConfigurations: JsonField>) = + apply { + body.webhookConfigurations(webhookConfigurations) + } + + /** + * Adds a single [WebhookConfiguration] to [webhookConfigurations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookConfiguration(webhookConfiguration: WebhookConfiguration) = apply { + body.addWebhookConfiguration(webhookConfiguration) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [BatchCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .config() + * .sourceDirectoryId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BatchCreateParams = + BatchCreateParams( + organizationId, + projectId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + 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() + + /** + * Create a batch over a directory. + * + * Example: { "source_directory_id": "dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "config": { + * "job": { "type": "parse_v2", "configuration_id": "cfg-PARSE_AGENTIC" } }, } + * + * The source is always a directory. Callers upload or attach files to the directory first, then + * this API maps each source directory file to an output job such as a parse job ID. + */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val config: JsonField, + private val sourceDirectoryId: JsonField, + private val webhookConfigurationIds: JsonField>, + private val webhookConfigurations: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("config") @ExcludeMissing config: JsonField = JsonMissing.of(), + @JsonProperty("source_directory_id") + @ExcludeMissing + sourceDirectoryId: JsonField = JsonMissing.of(), + @JsonProperty("webhook_configuration_ids") + @ExcludeMissing + webhookConfigurationIds: JsonField> = JsonMissing.of(), + @JsonProperty("webhook_configurations") + @ExcludeMissing + webhookConfigurations: JsonField> = JsonMissing.of(), + ) : this( + config, + sourceDirectoryId, + webhookConfigurationIds, + webhookConfigurations, + mutableMapOf(), + ) + + /** + * Batch configuration snapshot to apply to this source directory. + * + * @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") + + /** + * Directory whose files should be processed. + * + * @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 sourceDirectoryId(): String = sourceDirectoryId.getRequired("source_directory_id") + + /** + * IDs of saved webhook configurations to notify for this job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookConfigurationIds(): Optional> = + webhookConfigurationIds.getOptional("webhook_configuration_ids") + + /** + * Outbound webhook endpoints to notify on job status changes + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookConfigurations(): Optional> = + webhookConfigurations.getOptional("webhook_configurations") + + /** + * 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 [sourceDirectoryId]. + * + * Unlike [sourceDirectoryId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("source_directory_id") + @ExcludeMissing + fun _sourceDirectoryId(): JsonField = sourceDirectoryId + + /** + * Returns the raw JSON value of [webhookConfigurationIds]. + * + * Unlike [webhookConfigurationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("webhook_configuration_ids") + @ExcludeMissing + fun _webhookConfigurationIds(): JsonField> = webhookConfigurationIds + + /** + * Returns the raw JSON value of [webhookConfigurations]. + * + * Unlike [webhookConfigurations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("webhook_configurations") + @ExcludeMissing + fun _webhookConfigurations(): JsonField> = webhookConfigurations + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .config() + * .sourceDirectoryId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var config: JsonField? = null + private var sourceDirectoryId: JsonField? = null + private var webhookConfigurationIds: JsonField>? = null + private var webhookConfigurations: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + config = body.config + sourceDirectoryId = body.sourceDirectoryId + webhookConfigurationIds = body.webhookConfigurationIds.map { it.toMutableList() } + webhookConfigurations = body.webhookConfigurations.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Batch configuration snapshot to apply to this source directory. */ + 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 } + + /** Directory whose files should be processed. */ + fun sourceDirectoryId(sourceDirectoryId: String) = + sourceDirectoryId(JsonField.of(sourceDirectoryId)) + + /** + * Sets [Builder.sourceDirectoryId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceDirectoryId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceDirectoryId(sourceDirectoryId: JsonField) = apply { + this.sourceDirectoryId = sourceDirectoryId + } + + /** IDs of saved webhook configurations to notify for this job. */ + fun webhookConfigurationIds(webhookConfigurationIds: List?) = + webhookConfigurationIds(JsonField.ofNullable(webhookConfigurationIds)) + + /** + * Alias for calling [Builder.webhookConfigurationIds] with + * `webhookConfigurationIds.orElse(null)`. + */ + fun webhookConfigurationIds(webhookConfigurationIds: Optional>) = + webhookConfigurationIds(webhookConfigurationIds.getOrNull()) + + /** + * Sets [Builder.webhookConfigurationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookConfigurationIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun webhookConfigurationIds(webhookConfigurationIds: JsonField>) = apply { + this.webhookConfigurationIds = webhookConfigurationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [webhookConfigurationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookConfigurationId(webhookConfigurationId: String) = apply { + webhookConfigurationIds = + (webhookConfigurationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("webhookConfigurationIds", it).add(webhookConfigurationId) + } + } + + /** Outbound webhook endpoints to notify on job status changes */ + fun webhookConfigurations(webhookConfigurations: List?) = + webhookConfigurations(JsonField.ofNullable(webhookConfigurations)) + + /** + * Alias for calling [Builder.webhookConfigurations] with + * `webhookConfigurations.orElse(null)`. + */ + fun webhookConfigurations(webhookConfigurations: Optional>) = + webhookConfigurations(webhookConfigurations.getOrNull()) + + /** + * Sets [Builder.webhookConfigurations] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookConfigurations] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun webhookConfigurations( + webhookConfigurations: JsonField> + ) = apply { + this.webhookConfigurations = webhookConfigurations.map { it.toMutableList() } + } + + /** + * Adds a single [WebhookConfiguration] to [webhookConfigurations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookConfiguration(webhookConfiguration: WebhookConfiguration) = apply { + webhookConfigurations = + (webhookConfigurations ?: JsonField.of(mutableListOf())).also { + checkKnown("webhookConfigurations", it).add(webhookConfiguration) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .config() + * .sourceDirectoryId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("config", config), + checkRequired("sourceDirectoryId", sourceDirectoryId), + (webhookConfigurationIds ?: JsonMissing.of()).map { it.toImmutable() }, + (webhookConfigurations ?: JsonMissing.of()).map { it.toImmutable() }, + 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(): Body = apply { + if (validated) { + return@apply + } + + config().validate() + sourceDirectoryId() + webhookConfigurationIds() + webhookConfigurations().ifPresent { it.forEach { 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 = + (config.asKnown().getOrNull()?.validity() ?: 0) + + (if (sourceDirectoryId.asKnown().isPresent) 1 else 0) + + (webhookConfigurationIds.asKnown().getOrNull()?.size ?: 0) + + (webhookConfigurations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + config == other.config && + sourceDirectoryId == other.sourceDirectoryId && + webhookConfigurationIds == other.webhookConfigurationIds && + webhookConfigurations == other.webhookConfigurations && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + config, + sourceDirectoryId, + webhookConfigurationIds, + webhookConfigurations, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{config=$config, sourceDirectoryId=$sourceDirectoryId, webhookConfigurationIds=$webhookConfigurationIds, webhookConfigurations=$webhookConfigurations, additionalProperties=$additionalProperties}" + } + + /** Batch configuration snapshot to apply to this source directory. */ + class Config + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val job: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("job") @ExcludeMissing job: JsonField = JsonMissing.of() + ) : this(job, mutableMapOf()) + + /** + * Job to create for each file in the source directory. + * + * @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 job(): Job = job.getRequired("job") + + /** + * Returns the raw JSON value of [job]. + * + * Unlike [job], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("job") @ExcludeMissing fun _job(): JsonField = job + + @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]. + * + * The following fields are required: + * ```java + * .job() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Config]. */ + class Builder internal constructor() { + + private var job: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(config: Config) = apply { + job = config.job + additionalProperties = config.additionalProperties.toMutableMap() + } + + /** Job to create for each file in the source directory. */ + fun job(job: Job) = job(JsonField.of(job)) + + /** + * Sets [Builder.job] to an arbitrary JSON value. + * + * You should usually call [Builder.job] with a well-typed [Job] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun job(job: JsonField) = apply { this.job = job } + + 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. + * + * The following fields are required: + * ```java + * .job() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Config = + Config(checkRequired("job", job), 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 + } + + job().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 = (job.asKnown().getOrNull()?.validity() ?: 0) + + /** Job to create for each file in the source directory. */ + class Job + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val configurationId: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("configuration_id") + @ExcludeMissing + configurationId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(configurationId, type, mutableMapOf()) + + /** + * Product configuration ID or built-in preset ID matching the job type. + * + * @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 configurationId(): String = configurationId.getRequired("configuration_id") + + /** + * Product job type to run for each source directory file. + * + * @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 type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [configurationId]. + * + * Unlike [configurationId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("configuration_id") + @ExcludeMissing + fun _configurationId(): JsonField = configurationId + + /** + * 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 [Job]. + * + * The following fields are required: + * ```java + * .configurationId() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Job]. */ + class Builder internal constructor() { + + private var configurationId: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(job: Job) = apply { + configurationId = job.configurationId + type = job.type + additionalProperties = job.additionalProperties.toMutableMap() + } + + /** Product configuration ID or built-in preset ID matching the job type. */ + fun configurationId(configurationId: String) = + configurationId(JsonField.of(configurationId)) + + /** + * Sets [Builder.configurationId] to an arbitrary JSON value. + * + * You should usually call [Builder.configurationId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun configurationId(configurationId: JsonField) = apply { + this.configurationId = configurationId + } + + /** Product job type to run for each source directory file. */ + 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 [Job]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .configurationId() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Job = + Job( + checkRequired("configurationId", configurationId), + checkRequired("type", 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(): Job = apply { + if (validated) { + return@apply + } + + configurationId() + type().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 (configurationId.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** Product job type to run for each source directory file. */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PARSE_V2 = of("parse_v2") + + @JvmField val EXTRACT_V2 = of("extract_v2") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + PARSE_V2, + EXTRACT_V2, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PARSE_V2, + EXTRACT_V2, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PARSE_V2 -> Value.PARSE_V2 + EXTRACT_V2 -> Value.EXTRACT_V2 + 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) { + PARSE_V2 -> Known.PARSE_V2 + EXTRACT_V2 -> Known.EXTRACT_V2 + else -> throw LlamaCloudInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws 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(): Type = 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 Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Job && + configurationId == other.configurationId && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(configurationId, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Job{configurationId=$configurationId, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Config && + job == other.job && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(job, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Config{job=$job, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single outbound webhook endpoint. */ + class WebhookConfiguration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val webhookEvents: JsonField>, + private val webhookHeaders: JsonField, + private val webhookOutputFormat: JsonField, + private val webhookSigningSecret: JsonField, + private val webhookUrl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("webhook_events") + @ExcludeMissing + webhookEvents: JsonField> = JsonMissing.of(), + @JsonProperty("webhook_headers") + @ExcludeMissing + webhookHeaders: JsonField = JsonMissing.of(), + @JsonProperty("webhook_output_format") + @ExcludeMissing + webhookOutputFormat: JsonField = JsonMissing.of(), + @JsonProperty("webhook_signing_secret") + @ExcludeMissing + webhookSigningSecret: JsonField = JsonMissing.of(), + @JsonProperty("webhook_url") + @ExcludeMissing + webhookUrl: JsonField = JsonMissing.of(), + ) : this( + webhookEvents, + webhookHeaders, + webhookOutputFormat, + webhookSigningSecret, + webhookUrl, + mutableMapOf(), + ) + + /** + * Events to subscribe to (e.g. 'parse.success', 'extract.error'). If null, all events are + * delivered. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookEvents(): Optional> = + webhookEvents.getOptional("webhook_events") + + /** + * Custom HTTP headers sent with each webhook request (e.g. auth tokens) + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookHeaders(): Optional = + webhookHeaders.getOptional("webhook_headers") + + /** + * Response format sent to the webhook: 'string' (default) or 'json' + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookOutputFormat(): Optional = + webhookOutputFormat.getOptional("webhook_output_format") + + /** + * Shared signing secret used to sign webhook deliveries. When set, each request includes an + * HMAC-SHA256 signature of the request body in the 'LC-Signature' header (value + * 'sha256='). Recompute the HMAC over the raw request body with this secret to verify + * the delivery is authentic. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookSigningSecret(): Optional = + webhookSigningSecret.getOptional("webhook_signing_secret") + + /** + * URL to receive webhook POST notifications + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookUrl(): Optional = webhookUrl.getOptional("webhook_url") + + /** + * Returns the raw JSON value of [webhookEvents]. + * + * Unlike [webhookEvents], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("webhook_events") + @ExcludeMissing + fun _webhookEvents(): JsonField> = webhookEvents + + /** + * Returns the raw JSON value of [webhookHeaders]. + * + * Unlike [webhookHeaders], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("webhook_headers") + @ExcludeMissing + fun _webhookHeaders(): JsonField = webhookHeaders + + /** + * Returns the raw JSON value of [webhookOutputFormat]. + * + * Unlike [webhookOutputFormat], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("webhook_output_format") + @ExcludeMissing + fun _webhookOutputFormat(): JsonField = webhookOutputFormat + + /** + * Returns the raw JSON value of [webhookSigningSecret]. + * + * Unlike [webhookSigningSecret], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("webhook_signing_secret") + @ExcludeMissing + fun _webhookSigningSecret(): JsonField = webhookSigningSecret + + /** + * Returns the raw JSON value of [webhookUrl]. + * + * Unlike [webhookUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("webhook_url") + @ExcludeMissing + fun _webhookUrl(): JsonField = webhookUrl + + @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 [WebhookConfiguration]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebhookConfiguration]. */ + class Builder internal constructor() { + + private var webhookEvents: JsonField>? = null + private var webhookHeaders: JsonField = JsonMissing.of() + private var webhookOutputFormat: JsonField = JsonMissing.of() + private var webhookSigningSecret: JsonField = JsonMissing.of() + private var webhookUrl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webhookConfiguration: WebhookConfiguration) = apply { + webhookEvents = webhookConfiguration.webhookEvents.map { it.toMutableList() } + webhookHeaders = webhookConfiguration.webhookHeaders + webhookOutputFormat = webhookConfiguration.webhookOutputFormat + webhookSigningSecret = webhookConfiguration.webhookSigningSecret + webhookUrl = webhookConfiguration.webhookUrl + additionalProperties = webhookConfiguration.additionalProperties.toMutableMap() + } + + /** + * Events to subscribe to (e.g. 'parse.success', 'extract.error'). If null, all events + * are delivered. + */ + fun webhookEvents(webhookEvents: List?) = + webhookEvents(JsonField.ofNullable(webhookEvents)) + + /** Alias for calling [Builder.webhookEvents] with `webhookEvents.orElse(null)`. */ + fun webhookEvents(webhookEvents: Optional>) = + webhookEvents(webhookEvents.getOrNull()) + + /** + * Sets [Builder.webhookEvents] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookEvents] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun webhookEvents(webhookEvents: JsonField>) = apply { + this.webhookEvents = webhookEvents.map { it.toMutableList() } + } + + /** + * Adds a single [WebhookEvent] to [webhookEvents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookEvent(webhookEvent: WebhookEvent) = apply { + webhookEvents = + (webhookEvents ?: JsonField.of(mutableListOf())).also { + checkKnown("webhookEvents", it).add(webhookEvent) + } + } + + /** Custom HTTP headers sent with each webhook request (e.g. auth tokens) */ + fun webhookHeaders(webhookHeaders: WebhookHeaders?) = + webhookHeaders(JsonField.ofNullable(webhookHeaders)) + + /** Alias for calling [Builder.webhookHeaders] with `webhookHeaders.orElse(null)`. */ + fun webhookHeaders(webhookHeaders: Optional) = + webhookHeaders(webhookHeaders.getOrNull()) + + /** + * Sets [Builder.webhookHeaders] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookHeaders] with a well-typed [WebhookHeaders] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun webhookHeaders(webhookHeaders: JsonField) = apply { + this.webhookHeaders = webhookHeaders + } + + /** Response format sent to the webhook: 'string' (default) or 'json' */ + fun webhookOutputFormat(webhookOutputFormat: String?) = + webhookOutputFormat(JsonField.ofNullable(webhookOutputFormat)) + + /** + * Alias for calling [Builder.webhookOutputFormat] with + * `webhookOutputFormat.orElse(null)`. + */ + fun webhookOutputFormat(webhookOutputFormat: Optional) = + webhookOutputFormat(webhookOutputFormat.getOrNull()) + + /** + * Sets [Builder.webhookOutputFormat] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookOutputFormat] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun webhookOutputFormat(webhookOutputFormat: JsonField) = apply { + this.webhookOutputFormat = webhookOutputFormat + } + + /** + * Shared signing secret used to sign webhook deliveries. When set, each request + * includes an HMAC-SHA256 signature of the request body in the 'LC-Signature' header + * (value 'sha256='). Recompute the HMAC over the raw request body with this secret + * to verify the delivery is authentic. + */ + fun webhookSigningSecret(webhookSigningSecret: String?) = + webhookSigningSecret(JsonField.ofNullable(webhookSigningSecret)) + + /** + * Alias for calling [Builder.webhookSigningSecret] with + * `webhookSigningSecret.orElse(null)`. + */ + fun webhookSigningSecret(webhookSigningSecret: Optional) = + webhookSigningSecret(webhookSigningSecret.getOrNull()) + + /** + * Sets [Builder.webhookSigningSecret] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookSigningSecret] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun webhookSigningSecret(webhookSigningSecret: JsonField) = apply { + this.webhookSigningSecret = webhookSigningSecret + } + + /** URL to receive webhook POST notifications */ + fun webhookUrl(webhookUrl: String?) = webhookUrl(JsonField.ofNullable(webhookUrl)) + + /** Alias for calling [Builder.webhookUrl] with `webhookUrl.orElse(null)`. */ + fun webhookUrl(webhookUrl: Optional) = webhookUrl(webhookUrl.getOrNull()) + + /** + * Sets [Builder.webhookUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun webhookUrl(webhookUrl: JsonField) = apply { this.webhookUrl = webhookUrl } + + 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 [WebhookConfiguration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WebhookConfiguration = + WebhookConfiguration( + (webhookEvents ?: JsonMissing.of()).map { it.toImmutable() }, + webhookHeaders, + webhookOutputFormat, + webhookSigningSecret, + webhookUrl, + 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(): WebhookConfiguration = apply { + if (validated) { + return@apply + } + + webhookEvents().ifPresent { it.forEach { it.validate() } } + webhookHeaders().ifPresent { it.validate() } + webhookOutputFormat() + webhookSigningSecret() + webhookUrl() + 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 = + (webhookEvents.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (webhookHeaders.asKnown().getOrNull()?.validity() ?: 0) + + (if (webhookOutputFormat.asKnown().isPresent) 1 else 0) + + (if (webhookSigningSecret.asKnown().isPresent) 1 else 0) + + (if (webhookUrl.asKnown().isPresent) 1 else 0) + + class WebhookEvent @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 BATCH_CANCELLED = of("batch.cancelled") + + @JvmField val BATCH_ERROR = of("batch.error") + + @JvmField val BATCH_PENDING = of("batch.pending") + + @JvmField val BATCH_RUNNING = of("batch.running") + + @JvmField val BATCH_SUCCESS = of("batch.success") + + @JvmField val CLASSIFY_CANCELLED = of("classify.cancelled") + + @JvmField val CLASSIFY_ERROR = of("classify.error") + + @JvmField val CLASSIFY_PARTIAL_SUCCESS = of("classify.partial_success") + + @JvmField val CLASSIFY_PENDING = of("classify.pending") + + @JvmField val CLASSIFY_RUNNING = of("classify.running") + + @JvmField val CLASSIFY_SUCCESS = of("classify.success") + + @JvmField val EXTRACT_CANCELLED = of("extract.cancelled") + + @JvmField val EXTRACT_ERROR = of("extract.error") + + @JvmField val EXTRACT_PARTIAL_SUCCESS = of("extract.partial_success") + + @JvmField val EXTRACT_PENDING = of("extract.pending") + + @JvmField val EXTRACT_SUCCESS = of("extract.success") + + @JvmField val PARSE_CANCELLED = of("parse.cancelled") + + @JvmField val PARSE_ERROR = of("parse.error") + + @JvmField val PARSE_PARTIAL_SUCCESS = of("parse.partial_success") + + @JvmField val PARSE_PENDING = of("parse.pending") + + @JvmField val PARSE_RUNNING = of("parse.running") + + @JvmField val PARSE_SUCCESS = of("parse.success") + + @JvmField val SHEETS_CANCELLED = of("sheets.cancelled") + + @JvmField val SHEETS_ERROR = of("sheets.error") + + @JvmField val SHEETS_PARTIAL_SUCCESS = of("sheets.partial_success") + + @JvmField val SHEETS_PENDING = of("sheets.pending") + + @JvmField val SHEETS_SUCCESS = of("sheets.success") + + @JvmField val SPLIT_CANCELLED = of("split.cancelled") + + @JvmField val SPLIT_ERROR = of("split.error") + + @JvmField val SPLIT_PENDING = of("split.pending") + + @JvmField val SPLIT_PROCESSING = of("split.processing") + + @JvmField val SPLIT_SUCCESS = of("split.success") + + @JvmField val UNMAPPED_EVENT = of("unmapped_event") + + @JvmStatic fun of(value: String) = WebhookEvent(JsonField.of(value)) + } + + /** An enum containing [WebhookEvent]'s known values. */ + enum class Known { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, + CLASSIFY_CANCELLED, + CLASSIFY_ERROR, + CLASSIFY_PARTIAL_SUCCESS, + CLASSIFY_PENDING, + CLASSIFY_RUNNING, + CLASSIFY_SUCCESS, + EXTRACT_CANCELLED, + EXTRACT_ERROR, + EXTRACT_PARTIAL_SUCCESS, + EXTRACT_PENDING, + EXTRACT_SUCCESS, + PARSE_CANCELLED, + PARSE_ERROR, + PARSE_PARTIAL_SUCCESS, + PARSE_PENDING, + PARSE_RUNNING, + PARSE_SUCCESS, + SHEETS_CANCELLED, + SHEETS_ERROR, + SHEETS_PARTIAL_SUCCESS, + SHEETS_PENDING, + SHEETS_SUCCESS, + SPLIT_CANCELLED, + SPLIT_ERROR, + SPLIT_PENDING, + SPLIT_PROCESSING, + SPLIT_SUCCESS, + UNMAPPED_EVENT, + } + + /** + * An enum containing [WebhookEvent]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [WebhookEvent] 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 { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, + CLASSIFY_CANCELLED, + CLASSIFY_ERROR, + CLASSIFY_PARTIAL_SUCCESS, + CLASSIFY_PENDING, + CLASSIFY_RUNNING, + CLASSIFY_SUCCESS, + EXTRACT_CANCELLED, + EXTRACT_ERROR, + EXTRACT_PARTIAL_SUCCESS, + EXTRACT_PENDING, + EXTRACT_SUCCESS, + PARSE_CANCELLED, + PARSE_ERROR, + PARSE_PARTIAL_SUCCESS, + PARSE_PENDING, + PARSE_RUNNING, + PARSE_SUCCESS, + SHEETS_CANCELLED, + SHEETS_ERROR, + SHEETS_PARTIAL_SUCCESS, + SHEETS_PENDING, + SHEETS_SUCCESS, + SPLIT_CANCELLED, + SPLIT_ERROR, + SPLIT_PENDING, + SPLIT_PROCESSING, + SPLIT_SUCCESS, + UNMAPPED_EVENT, + /** + * An enum member indicating that [WebhookEvent] 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) { + BATCH_CANCELLED -> Value.BATCH_CANCELLED + BATCH_ERROR -> Value.BATCH_ERROR + BATCH_PENDING -> Value.BATCH_PENDING + BATCH_RUNNING -> Value.BATCH_RUNNING + BATCH_SUCCESS -> Value.BATCH_SUCCESS + CLASSIFY_CANCELLED -> Value.CLASSIFY_CANCELLED + CLASSIFY_ERROR -> Value.CLASSIFY_ERROR + CLASSIFY_PARTIAL_SUCCESS -> Value.CLASSIFY_PARTIAL_SUCCESS + CLASSIFY_PENDING -> Value.CLASSIFY_PENDING + CLASSIFY_RUNNING -> Value.CLASSIFY_RUNNING + CLASSIFY_SUCCESS -> Value.CLASSIFY_SUCCESS + EXTRACT_CANCELLED -> Value.EXTRACT_CANCELLED + EXTRACT_ERROR -> Value.EXTRACT_ERROR + EXTRACT_PARTIAL_SUCCESS -> Value.EXTRACT_PARTIAL_SUCCESS + EXTRACT_PENDING -> Value.EXTRACT_PENDING + EXTRACT_SUCCESS -> Value.EXTRACT_SUCCESS + PARSE_CANCELLED -> Value.PARSE_CANCELLED + PARSE_ERROR -> Value.PARSE_ERROR + PARSE_PARTIAL_SUCCESS -> Value.PARSE_PARTIAL_SUCCESS + PARSE_PENDING -> Value.PARSE_PENDING + PARSE_RUNNING -> Value.PARSE_RUNNING + PARSE_SUCCESS -> Value.PARSE_SUCCESS + SHEETS_CANCELLED -> Value.SHEETS_CANCELLED + SHEETS_ERROR -> Value.SHEETS_ERROR + SHEETS_PARTIAL_SUCCESS -> Value.SHEETS_PARTIAL_SUCCESS + SHEETS_PENDING -> Value.SHEETS_PENDING + SHEETS_SUCCESS -> Value.SHEETS_SUCCESS + SPLIT_CANCELLED -> Value.SPLIT_CANCELLED + SPLIT_ERROR -> Value.SPLIT_ERROR + SPLIT_PENDING -> Value.SPLIT_PENDING + SPLIT_PROCESSING -> Value.SPLIT_PROCESSING + SPLIT_SUCCESS -> Value.SPLIT_SUCCESS + UNMAPPED_EVENT -> Value.UNMAPPED_EVENT + 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) { + BATCH_CANCELLED -> Known.BATCH_CANCELLED + BATCH_ERROR -> Known.BATCH_ERROR + BATCH_PENDING -> Known.BATCH_PENDING + BATCH_RUNNING -> Known.BATCH_RUNNING + BATCH_SUCCESS -> Known.BATCH_SUCCESS + CLASSIFY_CANCELLED -> Known.CLASSIFY_CANCELLED + CLASSIFY_ERROR -> Known.CLASSIFY_ERROR + CLASSIFY_PARTIAL_SUCCESS -> Known.CLASSIFY_PARTIAL_SUCCESS + CLASSIFY_PENDING -> Known.CLASSIFY_PENDING + CLASSIFY_RUNNING -> Known.CLASSIFY_RUNNING + CLASSIFY_SUCCESS -> Known.CLASSIFY_SUCCESS + EXTRACT_CANCELLED -> Known.EXTRACT_CANCELLED + EXTRACT_ERROR -> Known.EXTRACT_ERROR + EXTRACT_PARTIAL_SUCCESS -> Known.EXTRACT_PARTIAL_SUCCESS + EXTRACT_PENDING -> Known.EXTRACT_PENDING + EXTRACT_SUCCESS -> Known.EXTRACT_SUCCESS + PARSE_CANCELLED -> Known.PARSE_CANCELLED + PARSE_ERROR -> Known.PARSE_ERROR + PARSE_PARTIAL_SUCCESS -> Known.PARSE_PARTIAL_SUCCESS + PARSE_PENDING -> Known.PARSE_PENDING + PARSE_RUNNING -> Known.PARSE_RUNNING + PARSE_SUCCESS -> Known.PARSE_SUCCESS + SHEETS_CANCELLED -> Known.SHEETS_CANCELLED + SHEETS_ERROR -> Known.SHEETS_ERROR + SHEETS_PARTIAL_SUCCESS -> Known.SHEETS_PARTIAL_SUCCESS + SHEETS_PENDING -> Known.SHEETS_PENDING + SHEETS_SUCCESS -> Known.SHEETS_SUCCESS + SPLIT_CANCELLED -> Known.SPLIT_CANCELLED + SPLIT_ERROR -> Known.SPLIT_ERROR + SPLIT_PENDING -> Known.SPLIT_PENDING + SPLIT_PROCESSING -> Known.SPLIT_PROCESSING + SPLIT_SUCCESS -> Known.SPLIT_SUCCESS + UNMAPPED_EVENT -> Known.UNMAPPED_EVENT + else -> throw LlamaCloudInvalidDataException("Unknown WebhookEvent: $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(): WebhookEvent = 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 WebhookEvent && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Custom HTTP headers sent with each webhook request (e.g. auth tokens) */ + class WebhookHeaders + @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 [WebhookHeaders]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebhookHeaders]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webhookHeaders: WebhookHeaders) = apply { + additionalProperties = webhookHeaders.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 [WebhookHeaders]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WebhookHeaders = WebhookHeaders(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(): WebhookHeaders = 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 WebhookHeaders && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "WebhookHeaders{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WebhookConfiguration && + webhookEvents == other.webhookEvents && + webhookHeaders == other.webhookHeaders && + webhookOutputFormat == other.webhookOutputFormat && + webhookSigningSecret == other.webhookSigningSecret && + webhookUrl == other.webhookUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + webhookEvents, + webhookHeaders, + webhookOutputFormat, + webhookSigningSecret, + webhookUrl, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "WebhookConfiguration{webhookEvents=$webhookEvents, webhookHeaders=$webhookHeaders, webhookOutputFormat=$webhookOutputFormat, webhookSigningSecret=$webhookSigningSecret, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BatchCreateParams && + organizationId == other.organizationId && + projectId == other.projectId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(organizationId, projectId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "BatchCreateParams{organizationId=$organizationId, projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateResponse.kt new file mode 100644 index 0000000..6049883 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateResponse.kt @@ -0,0 +1,1867 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.batches + +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.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.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * A top-level batch. + * + * Example: { "id": "bat-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "project_id": + * "prj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "source_directory_id": + * "dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "config": { "job": { "type": "parse_v2", + * "configuration_id": "cfg-PARSE_AGENTIC" } }, "status": "COMPLETED", "results": + * [ { "source_directory_file_id": "dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "job_reference": { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" }, "error_message": null } ] + * } + * + * Batch-level ``FAILED`` means the orchestration failed and cannot provide a reliable per-file + * result set. ``results`` is only populated when explicitly requested with ``expand=results`` and + * may be ``null`` while a batch is still running. + */ +class BatchCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val config: JsonField, + private val projectId: JsonField, + private val sourceDirectoryId: JsonField, + private val status: JsonField, + private val createdAt: JsonField, + private val results: 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("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), + @JsonProperty("source_directory_id") + @ExcludeMissing + sourceDirectoryId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("results") + @ExcludeMissing + results: JsonField> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this( + id, + config, + projectId, + sourceDirectoryId, + status, + createdAt, + results, + updatedAt, + mutableMapOf(), + ) + + /** + * Unique identifier + * + * @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") + + /** + * Batch configuration snapshot. + * + * @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") + + /** + * Project this batch 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") + + /** + * Directory being processed. + * + * @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 sourceDirectoryId(): String = sourceDirectoryId.getRequired("source_directory_id") + + /** + * Current batch 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(): Status = status.getRequired("status") + + /** + * Creation datetime + * + * @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") + + /** + * Expanded per-file result mappings. Null unless requested with expand=results, or while the + * batch is still running. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun results(): Optional> = results.getOptional("results") + + /** + * Update datetime + * + * @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 [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 [sourceDirectoryId]. + * + * Unlike [sourceDirectoryId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("source_directory_id") + @ExcludeMissing + fun _sourceDirectoryId(): JsonField = sourceDirectoryId + + /** + * 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 [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 [results]. + * + * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("results") @ExcludeMissing fun _results(): JsonField> = results + + /** + * 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 [BatchCreateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .config() + * .projectId() + * .sourceDirectoryId() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BatchCreateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var config: JsonField? = null + private var projectId: JsonField? = null + private var sourceDirectoryId: JsonField? = null + private var status: JsonField? = null + private var createdAt: JsonField = JsonMissing.of() + private var results: JsonField>? = null + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(batchCreateResponse: BatchCreateResponse) = apply { + id = batchCreateResponse.id + config = batchCreateResponse.config + projectId = batchCreateResponse.projectId + sourceDirectoryId = batchCreateResponse.sourceDirectoryId + status = batchCreateResponse.status + createdAt = batchCreateResponse.createdAt + results = batchCreateResponse.results.map { it.toMutableList() } + updatedAt = batchCreateResponse.updatedAt + additionalProperties = batchCreateResponse.additionalProperties.toMutableMap() + } + + /** Unique identifier */ + 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 } + + /** Batch configuration snapshot. */ + 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 } + + /** Project this batch 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 } + + /** Directory being processed. */ + fun sourceDirectoryId(sourceDirectoryId: String) = + sourceDirectoryId(JsonField.of(sourceDirectoryId)) + + /** + * Sets [Builder.sourceDirectoryId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceDirectoryId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceDirectoryId(sourceDirectoryId: JsonField) = apply { + this.sourceDirectoryId = sourceDirectoryId + } + + /** Current batch status. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** Creation datetime */ + 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 } + + /** + * Expanded per-file result mappings. Null unless requested with expand=results, or while + * the batch is still running. + */ + fun results(results: List?) = results(JsonField.ofNullable(results)) + + /** Alias for calling [Builder.results] with `results.orElse(null)`. */ + fun results(results: Optional>) = results(results.getOrNull()) + + /** + * Sets [Builder.results] to an arbitrary JSON value. + * + * You should usually call [Builder.results] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun results(results: JsonField>) = apply { + this.results = results.map { it.toMutableList() } + } + + /** + * Adds a single [Result] to [results]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResult(result: Result) = apply { + results = + (results ?: JsonField.of(mutableListOf())).also { + checkKnown("results", it).add(result) + } + } + + /** Update datetime */ + 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 [BatchCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .config() + * .projectId() + * .sourceDirectoryId() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BatchCreateResponse = + BatchCreateResponse( + checkRequired("id", id), + checkRequired("config", config), + checkRequired("projectId", projectId), + checkRequired("sourceDirectoryId", sourceDirectoryId), + checkRequired("status", status), + createdAt, + (results ?: JsonMissing.of()).map { it.toImmutable() }, + 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(): BatchCreateResponse = apply { + if (validated) { + return@apply + } + + id() + config().validate() + projectId() + sourceDirectoryId() + status().validate() + createdAt() + results().ifPresent { it.forEach { 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) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (sourceDirectoryId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + /** Batch configuration snapshot. */ + class Config + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val job: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("job") @ExcludeMissing job: JsonField = JsonMissing.of() + ) : this(job, mutableMapOf()) + + /** + * Job to create for each file in the source directory. + * + * @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 job(): Job = job.getRequired("job") + + /** + * Returns the raw JSON value of [job]. + * + * Unlike [job], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("job") @ExcludeMissing fun _job(): JsonField = job + + @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]. + * + * The following fields are required: + * ```java + * .job() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Config]. */ + class Builder internal constructor() { + + private var job: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(config: Config) = apply { + job = config.job + additionalProperties = config.additionalProperties.toMutableMap() + } + + /** Job to create for each file in the source directory. */ + fun job(job: Job) = job(JsonField.of(job)) + + /** + * Sets [Builder.job] to an arbitrary JSON value. + * + * You should usually call [Builder.job] with a well-typed [Job] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun job(job: JsonField) = apply { this.job = job } + + 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. + * + * The following fields are required: + * ```java + * .job() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Config = + Config(checkRequired("job", job), 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 + } + + job().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 = (job.asKnown().getOrNull()?.validity() ?: 0) + + /** Job to create for each file in the source directory. */ + class Job + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val configurationId: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("configuration_id") + @ExcludeMissing + configurationId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(configurationId, type, mutableMapOf()) + + /** + * Product configuration ID or built-in preset ID matching the job type. + * + * @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 configurationId(): String = configurationId.getRequired("configuration_id") + + /** + * Product job type to run for each source directory file. + * + * @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 type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [configurationId]. + * + * Unlike [configurationId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("configuration_id") + @ExcludeMissing + fun _configurationId(): JsonField = configurationId + + /** + * 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 [Job]. + * + * The following fields are required: + * ```java + * .configurationId() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Job]. */ + class Builder internal constructor() { + + private var configurationId: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(job: Job) = apply { + configurationId = job.configurationId + type = job.type + additionalProperties = job.additionalProperties.toMutableMap() + } + + /** Product configuration ID or built-in preset ID matching the job type. */ + fun configurationId(configurationId: String) = + configurationId(JsonField.of(configurationId)) + + /** + * Sets [Builder.configurationId] to an arbitrary JSON value. + * + * You should usually call [Builder.configurationId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun configurationId(configurationId: JsonField) = apply { + this.configurationId = configurationId + } + + /** Product job type to run for each source directory file. */ + 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 [Job]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .configurationId() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Job = + Job( + checkRequired("configurationId", configurationId), + checkRequired("type", 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(): Job = apply { + if (validated) { + return@apply + } + + configurationId() + type().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 (configurationId.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** Product job type to run for each source directory file. */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PARSE_V2 = of("parse_v2") + + @JvmField val EXTRACT_V2 = of("extract_v2") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + PARSE_V2, + EXTRACT_V2, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PARSE_V2, + EXTRACT_V2, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PARSE_V2 -> Value.PARSE_V2 + EXTRACT_V2 -> Value.EXTRACT_V2 + 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) { + PARSE_V2 -> Known.PARSE_V2 + EXTRACT_V2 -> Known.EXTRACT_V2 + else -> throw LlamaCloudInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws 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(): Type = 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 Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Job && + configurationId == other.configurationId && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(configurationId, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Job{configurationId=$configurationId, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Config && + job == other.job && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(job, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Config{job=$job, additionalProperties=$additionalProperties}" + } + + /** Current batch status. */ + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CANCELLED = of("CANCELLED") + + @JvmField val COMPLETED = of("COMPLETED") + + @JvmField val FAILED = of("FAILED") + + @JvmField val PENDING = of("PENDING") + + @JvmField val RUNNING = of("RUNNING") + + @JvmField val THROTTLED = of("THROTTLED") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + CANCELLED, + COMPLETED, + FAILED, + PENDING, + RUNNING, + THROTTLED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CANCELLED, + COMPLETED, + FAILED, + PENDING, + RUNNING, + THROTTLED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CANCELLED -> Value.CANCELLED + COMPLETED -> Value.COMPLETED + FAILED -> Value.FAILED + PENDING -> Value.PENDING + RUNNING -> Value.RUNNING + THROTTLED -> Value.THROTTLED + 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) { + CANCELLED -> Known.CANCELLED + COMPLETED -> Known.COMPLETED + FAILED -> Known.FAILED + PENDING -> Known.PENDING + RUNNING -> Known.RUNNING + THROTTLED -> Known.THROTTLED + else -> throw LlamaCloudInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws 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(): Status = 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 Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Result projection for one source directory file in a batch. + * + * Example: { "source_directory_file_id": "dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", + * "job_reference": { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" }, + * "error_message": null } + * + * This is a projection of directory-sync state, not a separate child resource that callers need + * to create. The source directory file ID is the stable correlation key. Underlying job + * progress and failures should be resolved through the referenced product job endpoint. + */ + class Result + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val sourceDirectoryFileId: JsonField, + private val errorMessage: JsonField, + private val jobReference: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("source_directory_file_id") + @ExcludeMissing + sourceDirectoryFileId: JsonField = JsonMissing.of(), + @JsonProperty("error_message") + @ExcludeMissing + errorMessage: JsonField = JsonMissing.of(), + @JsonProperty("job_reference") + @ExcludeMissing + jobReference: JsonField = JsonMissing.of(), + ) : this(sourceDirectoryFileId, errorMessage, jobReference, mutableMapOf()) + + /** + * Source directory file processed by this batch. + * + * @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 sourceDirectoryFileId(): String = + sourceDirectoryFileId.getRequired("source_directory_file_id") + + /** + * Batch-level mapping error if the system could not create or associate a job for this + * source file. + * + * @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") + + /** + * Reference to a job produced by a batch. + * + * Example: { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun jobReference(): Optional = jobReference.getOptional("job_reference") + + /** + * Returns the raw JSON value of [sourceDirectoryFileId]. + * + * Unlike [sourceDirectoryFileId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("source_directory_file_id") + @ExcludeMissing + fun _sourceDirectoryFileId(): JsonField = sourceDirectoryFileId + + /** + * 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 [jobReference]. + * + * Unlike [jobReference], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("job_reference") + @ExcludeMissing + fun _jobReference(): JsonField = jobReference + + @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 [Result]. + * + * The following fields are required: + * ```java + * .sourceDirectoryFileId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Result]. */ + class Builder internal constructor() { + + private var sourceDirectoryFileId: JsonField? = null + private var errorMessage: JsonField = JsonMissing.of() + private var jobReference: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(result: Result) = apply { + sourceDirectoryFileId = result.sourceDirectoryFileId + errorMessage = result.errorMessage + jobReference = result.jobReference + additionalProperties = result.additionalProperties.toMutableMap() + } + + /** Source directory file processed by this batch. */ + fun sourceDirectoryFileId(sourceDirectoryFileId: String) = + sourceDirectoryFileId(JsonField.of(sourceDirectoryFileId)) + + /** + * Sets [Builder.sourceDirectoryFileId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceDirectoryFileId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun sourceDirectoryFileId(sourceDirectoryFileId: JsonField) = apply { + this.sourceDirectoryFileId = sourceDirectoryFileId + } + + /** + * Batch-level mapping error if the system could not create or associate a job for this + * source file. + */ + 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 + } + + /** + * Reference to a job produced by a batch. + * + * Example: { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } + */ + fun jobReference(jobReference: JobReference?) = + jobReference(JsonField.ofNullable(jobReference)) + + /** Alias for calling [Builder.jobReference] with `jobReference.orElse(null)`. */ + fun jobReference(jobReference: Optional) = + jobReference(jobReference.getOrNull()) + + /** + * Sets [Builder.jobReference] to an arbitrary JSON value. + * + * You should usually call [Builder.jobReference] with a well-typed [JobReference] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun jobReference(jobReference: JsonField) = apply { + this.jobReference = jobReference + } + + 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 [Result]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sourceDirectoryFileId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Result = + Result( + checkRequired("sourceDirectoryFileId", sourceDirectoryFileId), + errorMessage, + jobReference, + 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(): Result = apply { + if (validated) { + return@apply + } + + sourceDirectoryFileId() + errorMessage() + jobReference().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 (sourceDirectoryFileId.asKnown().isPresent) 1 else 0) + + (if (errorMessage.asKnown().isPresent) 1 else 0) + + (jobReference.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Reference to a job produced by a batch. + * + * Example: { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } + */ + class JobReference + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(id, type, mutableMapOf()) + + /** + * Job ID, such as a parse 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") + + /** + * Type of job produced for the file. + * + * @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 type(): Type = type.getRequired("type") + + /** + * 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 [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 [JobReference]. + * + * The following fields are required: + * ```java + * .id() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [JobReference]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(jobReference: JobReference) = apply { + id = jobReference.id + type = jobReference.type + additionalProperties = jobReference.additionalProperties.toMutableMap() + } + + /** Job ID, such as a parse 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 } + + /** Type of job produced for the file. */ + 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 [JobReference]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): JobReference = + JobReference( + checkRequired("id", id), + checkRequired("type", 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(): JobReference = apply { + if (validated) { + return@apply + } + + id() + type().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) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** Type of job produced for the file. */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PARSE_V2 = of("parse_v2") + + @JvmField val EXTRACT_V2 = of("extract_v2") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + PARSE_V2, + EXTRACT_V2, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PARSE_V2, + EXTRACT_V2, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PARSE_V2 -> Value.PARSE_V2 + EXTRACT_V2 -> Value.EXTRACT_V2 + 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) { + PARSE_V2 -> Known.PARSE_V2 + EXTRACT_V2 -> Known.EXTRACT_V2 + else -> throw LlamaCloudInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws 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(): Type = 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 Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JobReference && + id == other.id && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "JobReference{id=$id, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Result && + sourceDirectoryFileId == other.sourceDirectoryFileId && + errorMessage == other.errorMessage && + jobReference == other.jobReference && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(sourceDirectoryFileId, errorMessage, jobReference, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Result{sourceDirectoryFileId=$sourceDirectoryFileId, errorMessage=$errorMessage, jobReference=$jobReference, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BatchCreateResponse && + id == other.id && + config == other.config && + projectId == other.projectId && + sourceDirectoryId == other.sourceDirectoryId && + status == other.status && + createdAt == other.createdAt && + results == other.results && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + config, + projectId, + sourceDirectoryId, + status, + createdAt, + results, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BatchCreateResponse{id=$id, config=$config, projectId=$projectId, sourceDirectoryId=$sourceDirectoryId, status=$status, createdAt=$createdAt, results=$results, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetParams.kt new file mode 100644 index 0000000..b9bbb6a --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetParams.kt @@ -0,0 +1,258 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.batches + +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 + +/** Get a batch by ID. */ +class BatchGetParams +private constructor( + private val batchId: String?, + private val expand: List?, + private val organizationId: String?, + private val projectId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun batchId(): Optional = Optional.ofNullable(batchId) + + /** Fields to expand. Supported value: results. */ + fun expand(): Optional> = Optional.ofNullable(expand) + + 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 { + + @JvmStatic fun none(): BatchGetParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [BatchGetParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BatchGetParams]. */ + class Builder internal constructor() { + + private var batchId: String? = null + private var expand: MutableList? = 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(batchGetParams: BatchGetParams) = apply { + batchId = batchGetParams.batchId + expand = batchGetParams.expand?.toMutableList() + organizationId = batchGetParams.organizationId + projectId = batchGetParams.projectId + additionalHeaders = batchGetParams.additionalHeaders.toBuilder() + additionalQueryParams = batchGetParams.additionalQueryParams.toBuilder() + } + + fun batchId(batchId: String?) = apply { this.batchId = batchId } + + /** Alias for calling [Builder.batchId] with `batchId.orElse(null)`. */ + fun batchId(batchId: Optional) = batchId(batchId.getOrNull()) + + /** Fields to expand. Supported value: results. */ + fun expand(expand: List?) = apply { this.expand = expand?.toMutableList() } + + /** Alias for calling [Builder.expand] with `expand.orElse(null)`. */ + fun expand(expand: Optional>) = expand(expand.getOrNull()) + + /** + * Adds a single [String] to [Builder.expand]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExpand(expand: String) = apply { + this.expand = (this.expand ?: mutableListOf()).apply { add(expand) } + } + + 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 [BatchGetParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BatchGetParams = + BatchGetParams( + batchId, + expand?.toImmutable(), + organizationId, + projectId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> batchId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + expand?.forEach { put("expand", it) } + 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 BatchGetParams && + batchId == other.batchId && + expand == other.expand && + organizationId == other.organizationId && + projectId == other.projectId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + batchId, + expand, + organizationId, + projectId, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "BatchGetParams{batchId=$batchId, expand=$expand, organizationId=$organizationId, projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetResponse.kt new file mode 100644 index 0000000..be174a5 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetResponse.kt @@ -0,0 +1,1867 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.batches + +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.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.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * A top-level batch. + * + * Example: { "id": "bat-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "project_id": + * "prj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "source_directory_id": + * "dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "config": { "job": { "type": "parse_v2", + * "configuration_id": "cfg-PARSE_AGENTIC" } }, "status": "COMPLETED", "results": + * [ { "source_directory_file_id": "dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "job_reference": { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" }, "error_message": null } ] + * } + * + * Batch-level ``FAILED`` means the orchestration failed and cannot provide a reliable per-file + * result set. ``results`` is only populated when explicitly requested with ``expand=results`` and + * may be ``null`` while a batch is still running. + */ +class BatchGetResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val config: JsonField, + private val projectId: JsonField, + private val sourceDirectoryId: JsonField, + private val status: JsonField, + private val createdAt: JsonField, + private val results: 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("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), + @JsonProperty("source_directory_id") + @ExcludeMissing + sourceDirectoryId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("results") + @ExcludeMissing + results: JsonField> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this( + id, + config, + projectId, + sourceDirectoryId, + status, + createdAt, + results, + updatedAt, + mutableMapOf(), + ) + + /** + * Unique identifier + * + * @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") + + /** + * Batch configuration snapshot. + * + * @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") + + /** + * Project this batch 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") + + /** + * Directory being processed. + * + * @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 sourceDirectoryId(): String = sourceDirectoryId.getRequired("source_directory_id") + + /** + * Current batch 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(): Status = status.getRequired("status") + + /** + * Creation datetime + * + * @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") + + /** + * Expanded per-file result mappings. Null unless requested with expand=results, or while the + * batch is still running. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun results(): Optional> = results.getOptional("results") + + /** + * Update datetime + * + * @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 [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 [sourceDirectoryId]. + * + * Unlike [sourceDirectoryId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("source_directory_id") + @ExcludeMissing + fun _sourceDirectoryId(): JsonField = sourceDirectoryId + + /** + * 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 [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 [results]. + * + * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("results") @ExcludeMissing fun _results(): JsonField> = results + + /** + * 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 [BatchGetResponse]. + * + * The following fields are required: + * ```java + * .id() + * .config() + * .projectId() + * .sourceDirectoryId() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BatchGetResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var config: JsonField? = null + private var projectId: JsonField? = null + private var sourceDirectoryId: JsonField? = null + private var status: JsonField? = null + private var createdAt: JsonField = JsonMissing.of() + private var results: JsonField>? = null + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(batchGetResponse: BatchGetResponse) = apply { + id = batchGetResponse.id + config = batchGetResponse.config + projectId = batchGetResponse.projectId + sourceDirectoryId = batchGetResponse.sourceDirectoryId + status = batchGetResponse.status + createdAt = batchGetResponse.createdAt + results = batchGetResponse.results.map { it.toMutableList() } + updatedAt = batchGetResponse.updatedAt + additionalProperties = batchGetResponse.additionalProperties.toMutableMap() + } + + /** Unique identifier */ + 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 } + + /** Batch configuration snapshot. */ + 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 } + + /** Project this batch 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 } + + /** Directory being processed. */ + fun sourceDirectoryId(sourceDirectoryId: String) = + sourceDirectoryId(JsonField.of(sourceDirectoryId)) + + /** + * Sets [Builder.sourceDirectoryId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceDirectoryId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceDirectoryId(sourceDirectoryId: JsonField) = apply { + this.sourceDirectoryId = sourceDirectoryId + } + + /** Current batch status. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** Creation datetime */ + 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 } + + /** + * Expanded per-file result mappings. Null unless requested with expand=results, or while + * the batch is still running. + */ + fun results(results: List?) = results(JsonField.ofNullable(results)) + + /** Alias for calling [Builder.results] with `results.orElse(null)`. */ + fun results(results: Optional>) = results(results.getOrNull()) + + /** + * Sets [Builder.results] to an arbitrary JSON value. + * + * You should usually call [Builder.results] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun results(results: JsonField>) = apply { + this.results = results.map { it.toMutableList() } + } + + /** + * Adds a single [Result] to [results]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResult(result: Result) = apply { + results = + (results ?: JsonField.of(mutableListOf())).also { + checkKnown("results", it).add(result) + } + } + + /** Update datetime */ + 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 [BatchGetResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .config() + * .projectId() + * .sourceDirectoryId() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BatchGetResponse = + BatchGetResponse( + checkRequired("id", id), + checkRequired("config", config), + checkRequired("projectId", projectId), + checkRequired("sourceDirectoryId", sourceDirectoryId), + checkRequired("status", status), + createdAt, + (results ?: JsonMissing.of()).map { it.toImmutable() }, + 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(): BatchGetResponse = apply { + if (validated) { + return@apply + } + + id() + config().validate() + projectId() + sourceDirectoryId() + status().validate() + createdAt() + results().ifPresent { it.forEach { 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) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (sourceDirectoryId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + /** Batch configuration snapshot. */ + class Config + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val job: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("job") @ExcludeMissing job: JsonField = JsonMissing.of() + ) : this(job, mutableMapOf()) + + /** + * Job to create for each file in the source directory. + * + * @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 job(): Job = job.getRequired("job") + + /** + * Returns the raw JSON value of [job]. + * + * Unlike [job], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("job") @ExcludeMissing fun _job(): JsonField = job + + @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]. + * + * The following fields are required: + * ```java + * .job() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Config]. */ + class Builder internal constructor() { + + private var job: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(config: Config) = apply { + job = config.job + additionalProperties = config.additionalProperties.toMutableMap() + } + + /** Job to create for each file in the source directory. */ + fun job(job: Job) = job(JsonField.of(job)) + + /** + * Sets [Builder.job] to an arbitrary JSON value. + * + * You should usually call [Builder.job] with a well-typed [Job] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun job(job: JsonField) = apply { this.job = job } + + 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. + * + * The following fields are required: + * ```java + * .job() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Config = + Config(checkRequired("job", job), 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 + } + + job().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 = (job.asKnown().getOrNull()?.validity() ?: 0) + + /** Job to create for each file in the source directory. */ + class Job + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val configurationId: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("configuration_id") + @ExcludeMissing + configurationId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(configurationId, type, mutableMapOf()) + + /** + * Product configuration ID or built-in preset ID matching the job type. + * + * @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 configurationId(): String = configurationId.getRequired("configuration_id") + + /** + * Product job type to run for each source directory file. + * + * @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 type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [configurationId]. + * + * Unlike [configurationId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("configuration_id") + @ExcludeMissing + fun _configurationId(): JsonField = configurationId + + /** + * 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 [Job]. + * + * The following fields are required: + * ```java + * .configurationId() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Job]. */ + class Builder internal constructor() { + + private var configurationId: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(job: Job) = apply { + configurationId = job.configurationId + type = job.type + additionalProperties = job.additionalProperties.toMutableMap() + } + + /** Product configuration ID or built-in preset ID matching the job type. */ + fun configurationId(configurationId: String) = + configurationId(JsonField.of(configurationId)) + + /** + * Sets [Builder.configurationId] to an arbitrary JSON value. + * + * You should usually call [Builder.configurationId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun configurationId(configurationId: JsonField) = apply { + this.configurationId = configurationId + } + + /** Product job type to run for each source directory file. */ + 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 [Job]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .configurationId() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Job = + Job( + checkRequired("configurationId", configurationId), + checkRequired("type", 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(): Job = apply { + if (validated) { + return@apply + } + + configurationId() + type().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 (configurationId.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** Product job type to run for each source directory file. */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PARSE_V2 = of("parse_v2") + + @JvmField val EXTRACT_V2 = of("extract_v2") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + PARSE_V2, + EXTRACT_V2, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PARSE_V2, + EXTRACT_V2, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PARSE_V2 -> Value.PARSE_V2 + EXTRACT_V2 -> Value.EXTRACT_V2 + 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) { + PARSE_V2 -> Known.PARSE_V2 + EXTRACT_V2 -> Known.EXTRACT_V2 + else -> throw LlamaCloudInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws 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(): Type = 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 Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Job && + configurationId == other.configurationId && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(configurationId, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Job{configurationId=$configurationId, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Config && + job == other.job && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(job, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Config{job=$job, additionalProperties=$additionalProperties}" + } + + /** Current batch status. */ + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CANCELLED = of("CANCELLED") + + @JvmField val COMPLETED = of("COMPLETED") + + @JvmField val FAILED = of("FAILED") + + @JvmField val PENDING = of("PENDING") + + @JvmField val RUNNING = of("RUNNING") + + @JvmField val THROTTLED = of("THROTTLED") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + CANCELLED, + COMPLETED, + FAILED, + PENDING, + RUNNING, + THROTTLED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CANCELLED, + COMPLETED, + FAILED, + PENDING, + RUNNING, + THROTTLED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CANCELLED -> Value.CANCELLED + COMPLETED -> Value.COMPLETED + FAILED -> Value.FAILED + PENDING -> Value.PENDING + RUNNING -> Value.RUNNING + THROTTLED -> Value.THROTTLED + 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) { + CANCELLED -> Known.CANCELLED + COMPLETED -> Known.COMPLETED + FAILED -> Known.FAILED + PENDING -> Known.PENDING + RUNNING -> Known.RUNNING + THROTTLED -> Known.THROTTLED + else -> throw LlamaCloudInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws 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(): Status = 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 Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Result projection for one source directory file in a batch. + * + * Example: { "source_directory_file_id": "dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", + * "job_reference": { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" }, + * "error_message": null } + * + * This is a projection of directory-sync state, not a separate child resource that callers need + * to create. The source directory file ID is the stable correlation key. Underlying job + * progress and failures should be resolved through the referenced product job endpoint. + */ + class Result + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val sourceDirectoryFileId: JsonField, + private val errorMessage: JsonField, + private val jobReference: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("source_directory_file_id") + @ExcludeMissing + sourceDirectoryFileId: JsonField = JsonMissing.of(), + @JsonProperty("error_message") + @ExcludeMissing + errorMessage: JsonField = JsonMissing.of(), + @JsonProperty("job_reference") + @ExcludeMissing + jobReference: JsonField = JsonMissing.of(), + ) : this(sourceDirectoryFileId, errorMessage, jobReference, mutableMapOf()) + + /** + * Source directory file processed by this batch. + * + * @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 sourceDirectoryFileId(): String = + sourceDirectoryFileId.getRequired("source_directory_file_id") + + /** + * Batch-level mapping error if the system could not create or associate a job for this + * source file. + * + * @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") + + /** + * Reference to a job produced by a batch. + * + * Example: { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun jobReference(): Optional = jobReference.getOptional("job_reference") + + /** + * Returns the raw JSON value of [sourceDirectoryFileId]. + * + * Unlike [sourceDirectoryFileId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("source_directory_file_id") + @ExcludeMissing + fun _sourceDirectoryFileId(): JsonField = sourceDirectoryFileId + + /** + * 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 [jobReference]. + * + * Unlike [jobReference], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("job_reference") + @ExcludeMissing + fun _jobReference(): JsonField = jobReference + + @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 [Result]. + * + * The following fields are required: + * ```java + * .sourceDirectoryFileId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Result]. */ + class Builder internal constructor() { + + private var sourceDirectoryFileId: JsonField? = null + private var errorMessage: JsonField = JsonMissing.of() + private var jobReference: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(result: Result) = apply { + sourceDirectoryFileId = result.sourceDirectoryFileId + errorMessage = result.errorMessage + jobReference = result.jobReference + additionalProperties = result.additionalProperties.toMutableMap() + } + + /** Source directory file processed by this batch. */ + fun sourceDirectoryFileId(sourceDirectoryFileId: String) = + sourceDirectoryFileId(JsonField.of(sourceDirectoryFileId)) + + /** + * Sets [Builder.sourceDirectoryFileId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceDirectoryFileId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun sourceDirectoryFileId(sourceDirectoryFileId: JsonField) = apply { + this.sourceDirectoryFileId = sourceDirectoryFileId + } + + /** + * Batch-level mapping error if the system could not create or associate a job for this + * source file. + */ + 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 + } + + /** + * Reference to a job produced by a batch. + * + * Example: { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } + */ + fun jobReference(jobReference: JobReference?) = + jobReference(JsonField.ofNullable(jobReference)) + + /** Alias for calling [Builder.jobReference] with `jobReference.orElse(null)`. */ + fun jobReference(jobReference: Optional) = + jobReference(jobReference.getOrNull()) + + /** + * Sets [Builder.jobReference] to an arbitrary JSON value. + * + * You should usually call [Builder.jobReference] with a well-typed [JobReference] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun jobReference(jobReference: JsonField) = apply { + this.jobReference = jobReference + } + + 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 [Result]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sourceDirectoryFileId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Result = + Result( + checkRequired("sourceDirectoryFileId", sourceDirectoryFileId), + errorMessage, + jobReference, + 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(): Result = apply { + if (validated) { + return@apply + } + + sourceDirectoryFileId() + errorMessage() + jobReference().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 (sourceDirectoryFileId.asKnown().isPresent) 1 else 0) + + (if (errorMessage.asKnown().isPresent) 1 else 0) + + (jobReference.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Reference to a job produced by a batch. + * + * Example: { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } + */ + class JobReference + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(id, type, mutableMapOf()) + + /** + * Job ID, such as a parse 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") + + /** + * Type of job produced for the file. + * + * @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 type(): Type = type.getRequired("type") + + /** + * 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 [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 [JobReference]. + * + * The following fields are required: + * ```java + * .id() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [JobReference]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(jobReference: JobReference) = apply { + id = jobReference.id + type = jobReference.type + additionalProperties = jobReference.additionalProperties.toMutableMap() + } + + /** Job ID, such as a parse 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 } + + /** Type of job produced for the file. */ + 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 [JobReference]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): JobReference = + JobReference( + checkRequired("id", id), + checkRequired("type", 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(): JobReference = apply { + if (validated) { + return@apply + } + + id() + type().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) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** Type of job produced for the file. */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PARSE_V2 = of("parse_v2") + + @JvmField val EXTRACT_V2 = of("extract_v2") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + PARSE_V2, + EXTRACT_V2, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PARSE_V2, + EXTRACT_V2, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PARSE_V2 -> Value.PARSE_V2 + EXTRACT_V2 -> Value.EXTRACT_V2 + 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) { + PARSE_V2 -> Known.PARSE_V2 + EXTRACT_V2 -> Known.EXTRACT_V2 + else -> throw LlamaCloudInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws 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(): Type = 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 Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JobReference && + id == other.id && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "JobReference{id=$id, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Result && + sourceDirectoryFileId == other.sourceDirectoryFileId && + errorMessage == other.errorMessage && + jobReference == other.jobReference && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(sourceDirectoryFileId, errorMessage, jobReference, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Result{sourceDirectoryFileId=$sourceDirectoryFileId, errorMessage=$errorMessage, jobReference=$jobReference, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BatchGetResponse && + id == other.id && + config == other.config && + projectId == other.projectId && + sourceDirectoryId == other.sourceDirectoryId && + status == other.status && + createdAt == other.createdAt && + results == other.results && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + config, + projectId, + sourceDirectoryId, + status, + createdAt, + results, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BatchGetResponse{id=$id, config=$config, projectId=$projectId, sourceDirectoryId=$sourceDirectoryId, status=$status, createdAt=$createdAt, results=$results, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPage.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPage.kt new file mode 100644 index 0000000..9220e71 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPage.kt @@ -0,0 +1,130 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.batches + +import ai.llamaindex.llamacloud.core.AutoPager +import ai.llamaindex.llamacloud.core.Page +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.services.blocking.BatchService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see BatchService.list */ +class BatchListPage +private constructor( + private val service: BatchService, + private val params: BatchListParams, + private val response: BatchListPageResponse, +) : Page { + + /** + * Delegates to [BatchListPageResponse], but gracefully handles missing data. + * + * @see BatchListPageResponse.items + */ + override fun items(): List = + response._items().getOptional("items").getOrNull() ?: emptyList() + + /** + * Delegates to [BatchListPageResponse], but gracefully handles missing data. + * + * @see BatchListPageResponse.nextPageToken + */ + fun nextPageToken(): Optional = response._nextPageToken().getOptional("next_page_token") + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageToken().isPresent + + fun nextPageParams(): BatchListParams { + val nextCursor = + nextPageToken().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().pageToken(nextCursor).build() + } + + override fun nextPage(): BatchListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): BatchListParams = params + + /** The response that this page was parsed from. */ + fun response(): BatchListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BatchListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BatchListPage]. */ + class Builder internal constructor() { + + private var service: BatchService? = null + private var params: BatchListParams? = null + private var response: BatchListPageResponse? = null + + @JvmSynthetic + internal fun from(batchListPage: BatchListPage) = apply { + service = batchListPage.service + params = batchListPage.params + response = batchListPage.response + } + + fun service(service: BatchService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: BatchListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: BatchListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [BatchListPage]. + * + * 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(): BatchListPage = + BatchListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BatchListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = "BatchListPage{service=$service, params=$params, response=$response}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageAsync.kt new file mode 100644 index 0000000..fc395df --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageAsync.kt @@ -0,0 +1,145 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.batches + +import ai.llamaindex.llamacloud.core.AutoPagerAsync +import ai.llamaindex.llamacloud.core.PageAsync +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.services.async.BatchServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see BatchServiceAsync.list */ +class BatchListPageAsync +private constructor( + private val service: BatchServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: BatchListParams, + private val response: BatchListPageResponse, +) : PageAsync { + + /** + * Delegates to [BatchListPageResponse], but gracefully handles missing data. + * + * @see BatchListPageResponse.items + */ + override fun items(): List = + response._items().getOptional("items").getOrNull() ?: emptyList() + + /** + * Delegates to [BatchListPageResponse], but gracefully handles missing data. + * + * @see BatchListPageResponse.nextPageToken + */ + fun nextPageToken(): Optional = response._nextPageToken().getOptional("next_page_token") + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageToken().isPresent + + fun nextPageParams(): BatchListParams { + 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(): BatchListParams = params + + /** The response that this page was parsed from. */ + fun response(): BatchListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BatchListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BatchListPageAsync]. */ + class Builder internal constructor() { + + private var service: BatchServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: BatchListParams? = null + private var response: BatchListPageResponse? = null + + @JvmSynthetic + internal fun from(batchListPageAsync: BatchListPageAsync) = apply { + service = batchListPageAsync.service + streamHandlerExecutor = batchListPageAsync.streamHandlerExecutor + params = batchListPageAsync.params + response = batchListPageAsync.response + } + + fun service(service: BatchServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: BatchListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: BatchListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [BatchListPageAsync]. + * + * 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(): BatchListPageAsync = + BatchListPageAsync( + 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 BatchListPageAsync && + 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() = + "BatchListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageResponse.kt new file mode 100644 index 0000000..295de97 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageResponse.kt @@ -0,0 +1,303 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.batches + +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 batches. */ +class BatchListPageResponse +@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 [BatchListPageResponse]. + * + * The following fields are required: + * ```java + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BatchListPageResponse]. */ + 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(batchListPageResponse: BatchListPageResponse) = apply { + items = batchListPageResponse.items.map { it.toMutableList() } + nextPageToken = batchListPageResponse.nextPageToken + totalSize = batchListPageResponse.totalSize + additionalProperties = batchListPageResponse.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 [BatchListResponse] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: BatchListResponse) = 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 [BatchListPageResponse]. + * + * 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(): BatchListPageResponse = + BatchListPageResponse( + 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(): BatchListPageResponse = 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 BatchListPageResponse && + 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() = + "BatchListPageResponse{items=$items, nextPageToken=$nextPageToken, totalSize=$totalSize, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListParams.kt new file mode 100644 index 0000000..b207265 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListParams.kt @@ -0,0 +1,490 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.batches + +import ai.llamaindex.llamacloud.core.Enum +import ai.llamaindex.llamacloud.core.JsonField +import ai.llamaindex.llamacloud.core.Params +import ai.llamaindex.llamacloud.core.http.Headers +import ai.llamaindex.llamacloud.core.http.QueryParams +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 + +/** List batches for the current project. */ +class BatchListParams +private constructor( + private val createdAtOnOrAfter: OffsetDateTime?, + private val createdAtOnOrBefore: OffsetDateTime?, + private val organizationId: String?, + private val pageSize: Long?, + private val pageToken: String?, + private val projectId: String?, + private val sourceDirectoryId: String?, + private val status: Status?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun createdAtOnOrAfter(): Optional = Optional.ofNullable(createdAtOnOrAfter) + + fun createdAtOnOrBefore(): Optional = Optional.ofNullable(createdAtOnOrBefore) + + fun organizationId(): Optional = Optional.ofNullable(organizationId) + + fun pageSize(): Optional = Optional.ofNullable(pageSize) + + fun pageToken(): Optional = Optional.ofNullable(pageToken) + + fun projectId(): Optional = Optional.ofNullable(projectId) + + fun sourceDirectoryId(): Optional = Optional.ofNullable(sourceDirectoryId) + + 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 { + + @JvmStatic fun none(): BatchListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [BatchListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BatchListParams]. */ + class Builder internal constructor() { + + private var createdAtOnOrAfter: OffsetDateTime? = null + private var createdAtOnOrBefore: OffsetDateTime? = null + private var organizationId: String? = null + private var pageSize: Long? = null + private var pageToken: String? = null + private var projectId: String? = null + private var sourceDirectoryId: String? = null + private var status: Status? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(batchListParams: BatchListParams) = apply { + createdAtOnOrAfter = batchListParams.createdAtOnOrAfter + createdAtOnOrBefore = batchListParams.createdAtOnOrBefore + organizationId = batchListParams.organizationId + pageSize = batchListParams.pageSize + pageToken = batchListParams.pageToken + projectId = batchListParams.projectId + sourceDirectoryId = batchListParams.sourceDirectoryId + status = batchListParams.status + additionalHeaders = batchListParams.additionalHeaders.toBuilder() + additionalQueryParams = batchListParams.additionalQueryParams.toBuilder() + } + + fun createdAtOnOrAfter(createdAtOnOrAfter: OffsetDateTime?) = apply { + this.createdAtOnOrAfter = createdAtOnOrAfter + } + + /** + * Alias for calling [Builder.createdAtOnOrAfter] with `createdAtOnOrAfter.orElse(null)`. + */ + fun createdAtOnOrAfter(createdAtOnOrAfter: Optional) = + createdAtOnOrAfter(createdAtOnOrAfter.getOrNull()) + + fun createdAtOnOrBefore(createdAtOnOrBefore: OffsetDateTime?) = apply { + this.createdAtOnOrBefore = createdAtOnOrBefore + } + + /** + * Alias for calling [Builder.createdAtOnOrBefore] with `createdAtOnOrBefore.orElse(null)`. + */ + fun createdAtOnOrBefore(createdAtOnOrBefore: Optional) = + createdAtOnOrBefore(createdAtOnOrBefore.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 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 sourceDirectoryId(sourceDirectoryId: String?) = apply { + this.sourceDirectoryId = sourceDirectoryId + } + + /** Alias for calling [Builder.sourceDirectoryId] with `sourceDirectoryId.orElse(null)`. */ + fun sourceDirectoryId(sourceDirectoryId: Optional) = + sourceDirectoryId(sourceDirectoryId.getOrNull()) + + fun status(status: Status?) = apply { this.status = status } + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional) = status(status.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 [BatchListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BatchListParams = + BatchListParams( + createdAtOnOrAfter, + createdAtOnOrBefore, + organizationId, + pageSize, + pageToken, + projectId, + sourceDirectoryId, + status, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + 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), + ) + } + 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) } + sourceDirectoryId?.let { put("source_directory_id", it) } + status?.let { put("status", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CANCELLED = of("CANCELLED") + + @JvmField val COMPLETED = of("COMPLETED") + + @JvmField val FAILED = of("FAILED") + + @JvmField val PENDING = of("PENDING") + + @JvmField val RUNNING = of("RUNNING") + + @JvmField val THROTTLED = of("THROTTLED") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + CANCELLED, + COMPLETED, + FAILED, + PENDING, + RUNNING, + THROTTLED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CANCELLED, + COMPLETED, + FAILED, + PENDING, + RUNNING, + THROTTLED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CANCELLED -> Value.CANCELLED + COMPLETED -> Value.COMPLETED + FAILED -> Value.FAILED + PENDING -> Value.PENDING + RUNNING -> Value.RUNNING + THROTTLED -> Value.THROTTLED + 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) { + CANCELLED -> Known.CANCELLED + COMPLETED -> Known.COMPLETED + FAILED -> Known.FAILED + PENDING -> Known.PENDING + RUNNING -> Known.RUNNING + THROTTLED -> Known.THROTTLED + else -> throw LlamaCloudInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws 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(): Status = 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 Status && 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 BatchListParams && + createdAtOnOrAfter == other.createdAtOnOrAfter && + createdAtOnOrBefore == other.createdAtOnOrBefore && + organizationId == other.organizationId && + pageSize == other.pageSize && + pageToken == other.pageToken && + projectId == other.projectId && + sourceDirectoryId == other.sourceDirectoryId && + status == other.status && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + createdAtOnOrAfter, + createdAtOnOrBefore, + organizationId, + pageSize, + pageToken, + projectId, + sourceDirectoryId, + status, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "BatchListParams{createdAtOnOrAfter=$createdAtOnOrAfter, createdAtOnOrBefore=$createdAtOnOrBefore, organizationId=$organizationId, pageSize=$pageSize, pageToken=$pageToken, projectId=$projectId, sourceDirectoryId=$sourceDirectoryId, status=$status, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListResponse.kt new file mode 100644 index 0000000..63557d1 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListResponse.kt @@ -0,0 +1,1867 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.batches + +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.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.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * A top-level batch. + * + * Example: { "id": "bat-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "project_id": + * "prj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "source_directory_id": + * "dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "config": { "job": { "type": "parse_v2", + * "configuration_id": "cfg-PARSE_AGENTIC" } }, "status": "COMPLETED", "results": + * [ { "source_directory_file_id": "dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "job_reference": { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" }, "error_message": null } ] + * } + * + * Batch-level ``FAILED`` means the orchestration failed and cannot provide a reliable per-file + * result set. ``results`` is only populated when explicitly requested with ``expand=results`` and + * may be ``null`` while a batch is still running. + */ +class BatchListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val config: JsonField, + private val projectId: JsonField, + private val sourceDirectoryId: JsonField, + private val status: JsonField, + private val createdAt: JsonField, + private val results: 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("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), + @JsonProperty("source_directory_id") + @ExcludeMissing + sourceDirectoryId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("results") + @ExcludeMissing + results: JsonField> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this( + id, + config, + projectId, + sourceDirectoryId, + status, + createdAt, + results, + updatedAt, + mutableMapOf(), + ) + + /** + * Unique identifier + * + * @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") + + /** + * Batch configuration snapshot. + * + * @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") + + /** + * Project this batch 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") + + /** + * Directory being processed. + * + * @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 sourceDirectoryId(): String = sourceDirectoryId.getRequired("source_directory_id") + + /** + * Current batch 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(): Status = status.getRequired("status") + + /** + * Creation datetime + * + * @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") + + /** + * Expanded per-file result mappings. Null unless requested with expand=results, or while the + * batch is still running. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun results(): Optional> = results.getOptional("results") + + /** + * Update datetime + * + * @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 [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 [sourceDirectoryId]. + * + * Unlike [sourceDirectoryId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("source_directory_id") + @ExcludeMissing + fun _sourceDirectoryId(): JsonField = sourceDirectoryId + + /** + * 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 [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 [results]. + * + * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("results") @ExcludeMissing fun _results(): JsonField> = results + + /** + * 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 [BatchListResponse]. + * + * The following fields are required: + * ```java + * .id() + * .config() + * .projectId() + * .sourceDirectoryId() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BatchListResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var config: JsonField? = null + private var projectId: JsonField? = null + private var sourceDirectoryId: JsonField? = null + private var status: JsonField? = null + private var createdAt: JsonField = JsonMissing.of() + private var results: JsonField>? = null + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(batchListResponse: BatchListResponse) = apply { + id = batchListResponse.id + config = batchListResponse.config + projectId = batchListResponse.projectId + sourceDirectoryId = batchListResponse.sourceDirectoryId + status = batchListResponse.status + createdAt = batchListResponse.createdAt + results = batchListResponse.results.map { it.toMutableList() } + updatedAt = batchListResponse.updatedAt + additionalProperties = batchListResponse.additionalProperties.toMutableMap() + } + + /** Unique identifier */ + 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 } + + /** Batch configuration snapshot. */ + 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 } + + /** Project this batch 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 } + + /** Directory being processed. */ + fun sourceDirectoryId(sourceDirectoryId: String) = + sourceDirectoryId(JsonField.of(sourceDirectoryId)) + + /** + * Sets [Builder.sourceDirectoryId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceDirectoryId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceDirectoryId(sourceDirectoryId: JsonField) = apply { + this.sourceDirectoryId = sourceDirectoryId + } + + /** Current batch status. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** Creation datetime */ + 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 } + + /** + * Expanded per-file result mappings. Null unless requested with expand=results, or while + * the batch is still running. + */ + fun results(results: List?) = results(JsonField.ofNullable(results)) + + /** Alias for calling [Builder.results] with `results.orElse(null)`. */ + fun results(results: Optional>) = results(results.getOrNull()) + + /** + * Sets [Builder.results] to an arbitrary JSON value. + * + * You should usually call [Builder.results] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun results(results: JsonField>) = apply { + this.results = results.map { it.toMutableList() } + } + + /** + * Adds a single [Result] to [results]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResult(result: Result) = apply { + results = + (results ?: JsonField.of(mutableListOf())).also { + checkKnown("results", it).add(result) + } + } + + /** Update datetime */ + 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 [BatchListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .config() + * .projectId() + * .sourceDirectoryId() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BatchListResponse = + BatchListResponse( + checkRequired("id", id), + checkRequired("config", config), + checkRequired("projectId", projectId), + checkRequired("sourceDirectoryId", sourceDirectoryId), + checkRequired("status", status), + createdAt, + (results ?: JsonMissing.of()).map { it.toImmutable() }, + 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(): BatchListResponse = apply { + if (validated) { + return@apply + } + + id() + config().validate() + projectId() + sourceDirectoryId() + status().validate() + createdAt() + results().ifPresent { it.forEach { 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) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (sourceDirectoryId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + /** Batch configuration snapshot. */ + class Config + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val job: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("job") @ExcludeMissing job: JsonField = JsonMissing.of() + ) : this(job, mutableMapOf()) + + /** + * Job to create for each file in the source directory. + * + * @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 job(): Job = job.getRequired("job") + + /** + * Returns the raw JSON value of [job]. + * + * Unlike [job], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("job") @ExcludeMissing fun _job(): JsonField = job + + @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]. + * + * The following fields are required: + * ```java + * .job() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Config]. */ + class Builder internal constructor() { + + private var job: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(config: Config) = apply { + job = config.job + additionalProperties = config.additionalProperties.toMutableMap() + } + + /** Job to create for each file in the source directory. */ + fun job(job: Job) = job(JsonField.of(job)) + + /** + * Sets [Builder.job] to an arbitrary JSON value. + * + * You should usually call [Builder.job] with a well-typed [Job] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun job(job: JsonField) = apply { this.job = job } + + 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. + * + * The following fields are required: + * ```java + * .job() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Config = + Config(checkRequired("job", job), 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 + } + + job().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 = (job.asKnown().getOrNull()?.validity() ?: 0) + + /** Job to create for each file in the source directory. */ + class Job + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val configurationId: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("configuration_id") + @ExcludeMissing + configurationId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(configurationId, type, mutableMapOf()) + + /** + * Product configuration ID or built-in preset ID matching the job type. + * + * @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 configurationId(): String = configurationId.getRequired("configuration_id") + + /** + * Product job type to run for each source directory file. + * + * @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 type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [configurationId]. + * + * Unlike [configurationId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("configuration_id") + @ExcludeMissing + fun _configurationId(): JsonField = configurationId + + /** + * 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 [Job]. + * + * The following fields are required: + * ```java + * .configurationId() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Job]. */ + class Builder internal constructor() { + + private var configurationId: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(job: Job) = apply { + configurationId = job.configurationId + type = job.type + additionalProperties = job.additionalProperties.toMutableMap() + } + + /** Product configuration ID or built-in preset ID matching the job type. */ + fun configurationId(configurationId: String) = + configurationId(JsonField.of(configurationId)) + + /** + * Sets [Builder.configurationId] to an arbitrary JSON value. + * + * You should usually call [Builder.configurationId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun configurationId(configurationId: JsonField) = apply { + this.configurationId = configurationId + } + + /** Product job type to run for each source directory file. */ + 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 [Job]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .configurationId() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Job = + Job( + checkRequired("configurationId", configurationId), + checkRequired("type", 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(): Job = apply { + if (validated) { + return@apply + } + + configurationId() + type().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 (configurationId.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** Product job type to run for each source directory file. */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PARSE_V2 = of("parse_v2") + + @JvmField val EXTRACT_V2 = of("extract_v2") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + PARSE_V2, + EXTRACT_V2, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PARSE_V2, + EXTRACT_V2, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PARSE_V2 -> Value.PARSE_V2 + EXTRACT_V2 -> Value.EXTRACT_V2 + 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) { + PARSE_V2 -> Known.PARSE_V2 + EXTRACT_V2 -> Known.EXTRACT_V2 + else -> throw LlamaCloudInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws 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(): Type = 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 Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Job && + configurationId == other.configurationId && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(configurationId, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Job{configurationId=$configurationId, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Config && + job == other.job && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(job, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Config{job=$job, additionalProperties=$additionalProperties}" + } + + /** Current batch status. */ + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CANCELLED = of("CANCELLED") + + @JvmField val COMPLETED = of("COMPLETED") + + @JvmField val FAILED = of("FAILED") + + @JvmField val PENDING = of("PENDING") + + @JvmField val RUNNING = of("RUNNING") + + @JvmField val THROTTLED = of("THROTTLED") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + CANCELLED, + COMPLETED, + FAILED, + PENDING, + RUNNING, + THROTTLED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CANCELLED, + COMPLETED, + FAILED, + PENDING, + RUNNING, + THROTTLED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CANCELLED -> Value.CANCELLED + COMPLETED -> Value.COMPLETED + FAILED -> Value.FAILED + PENDING -> Value.PENDING + RUNNING -> Value.RUNNING + THROTTLED -> Value.THROTTLED + 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) { + CANCELLED -> Known.CANCELLED + COMPLETED -> Known.COMPLETED + FAILED -> Known.FAILED + PENDING -> Known.PENDING + RUNNING -> Known.RUNNING + THROTTLED -> Known.THROTTLED + else -> throw LlamaCloudInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws 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(): Status = 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 Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Result projection for one source directory file in a batch. + * + * Example: { "source_directory_file_id": "dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", + * "job_reference": { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" }, + * "error_message": null } + * + * This is a projection of directory-sync state, not a separate child resource that callers need + * to create. The source directory file ID is the stable correlation key. Underlying job + * progress and failures should be resolved through the referenced product job endpoint. + */ + class Result + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val sourceDirectoryFileId: JsonField, + private val errorMessage: JsonField, + private val jobReference: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("source_directory_file_id") + @ExcludeMissing + sourceDirectoryFileId: JsonField = JsonMissing.of(), + @JsonProperty("error_message") + @ExcludeMissing + errorMessage: JsonField = JsonMissing.of(), + @JsonProperty("job_reference") + @ExcludeMissing + jobReference: JsonField = JsonMissing.of(), + ) : this(sourceDirectoryFileId, errorMessage, jobReference, mutableMapOf()) + + /** + * Source directory file processed by this batch. + * + * @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 sourceDirectoryFileId(): String = + sourceDirectoryFileId.getRequired("source_directory_file_id") + + /** + * Batch-level mapping error if the system could not create or associate a job for this + * source file. + * + * @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") + + /** + * Reference to a job produced by a batch. + * + * Example: { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun jobReference(): Optional = jobReference.getOptional("job_reference") + + /** + * Returns the raw JSON value of [sourceDirectoryFileId]. + * + * Unlike [sourceDirectoryFileId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("source_directory_file_id") + @ExcludeMissing + fun _sourceDirectoryFileId(): JsonField = sourceDirectoryFileId + + /** + * 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 [jobReference]. + * + * Unlike [jobReference], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("job_reference") + @ExcludeMissing + fun _jobReference(): JsonField = jobReference + + @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 [Result]. + * + * The following fields are required: + * ```java + * .sourceDirectoryFileId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Result]. */ + class Builder internal constructor() { + + private var sourceDirectoryFileId: JsonField? = null + private var errorMessage: JsonField = JsonMissing.of() + private var jobReference: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(result: Result) = apply { + sourceDirectoryFileId = result.sourceDirectoryFileId + errorMessage = result.errorMessage + jobReference = result.jobReference + additionalProperties = result.additionalProperties.toMutableMap() + } + + /** Source directory file processed by this batch. */ + fun sourceDirectoryFileId(sourceDirectoryFileId: String) = + sourceDirectoryFileId(JsonField.of(sourceDirectoryFileId)) + + /** + * Sets [Builder.sourceDirectoryFileId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceDirectoryFileId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun sourceDirectoryFileId(sourceDirectoryFileId: JsonField) = apply { + this.sourceDirectoryFileId = sourceDirectoryFileId + } + + /** + * Batch-level mapping error if the system could not create or associate a job for this + * source file. + */ + 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 + } + + /** + * Reference to a job produced by a batch. + * + * Example: { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } + */ + fun jobReference(jobReference: JobReference?) = + jobReference(JsonField.ofNullable(jobReference)) + + /** Alias for calling [Builder.jobReference] with `jobReference.orElse(null)`. */ + fun jobReference(jobReference: Optional) = + jobReference(jobReference.getOrNull()) + + /** + * Sets [Builder.jobReference] to an arbitrary JSON value. + * + * You should usually call [Builder.jobReference] with a well-typed [JobReference] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun jobReference(jobReference: JsonField) = apply { + this.jobReference = jobReference + } + + 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 [Result]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sourceDirectoryFileId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Result = + Result( + checkRequired("sourceDirectoryFileId", sourceDirectoryFileId), + errorMessage, + jobReference, + 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(): Result = apply { + if (validated) { + return@apply + } + + sourceDirectoryFileId() + errorMessage() + jobReference().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 (sourceDirectoryFileId.asKnown().isPresent) 1 else 0) + + (if (errorMessage.asKnown().isPresent) 1 else 0) + + (jobReference.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Reference to a job produced by a batch. + * + * Example: { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } + */ + class JobReference + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(id, type, mutableMapOf()) + + /** + * Job ID, such as a parse 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") + + /** + * Type of job produced for the file. + * + * @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 type(): Type = type.getRequired("type") + + /** + * 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 [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 [JobReference]. + * + * The following fields are required: + * ```java + * .id() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [JobReference]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(jobReference: JobReference) = apply { + id = jobReference.id + type = jobReference.type + additionalProperties = jobReference.additionalProperties.toMutableMap() + } + + /** Job ID, such as a parse 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 } + + /** Type of job produced for the file. */ + 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 [JobReference]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): JobReference = + JobReference( + checkRequired("id", id), + checkRequired("type", 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(): JobReference = apply { + if (validated) { + return@apply + } + + id() + type().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) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** Type of job produced for the file. */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PARSE_V2 = of("parse_v2") + + @JvmField val EXTRACT_V2 = of("extract_v2") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + PARSE_V2, + EXTRACT_V2, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PARSE_V2, + EXTRACT_V2, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PARSE_V2 -> Value.PARSE_V2 + EXTRACT_V2 -> Value.EXTRACT_V2 + 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) { + PARSE_V2 -> Known.PARSE_V2 + EXTRACT_V2 -> Known.EXTRACT_V2 + else -> throw LlamaCloudInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws 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(): Type = 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 Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JobReference && + id == other.id && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "JobReference{id=$id, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Result && + sourceDirectoryFileId == other.sourceDirectoryFileId && + errorMessage == other.errorMessage && + jobReference == other.jobReference && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(sourceDirectoryFileId, errorMessage, jobReference, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Result{sourceDirectoryFileId=$sourceDirectoryFileId, errorMessage=$errorMessage, jobReference=$jobReference, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BatchListResponse && + id == other.id && + config == other.config && + projectId == other.projectId && + sourceDirectoryId == other.sourceDirectoryId && + status == other.status && + createdAt == other.createdAt && + results == other.results && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + config, + projectId, + sourceDirectoryId, + status, + createdAt, + results, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BatchListResponse{id=$id, config=$config, projectId=$projectId, sourceDirectoryId=$sourceDirectoryId, status=$status, createdAt=$createdAt, results=$results, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsync.kt new file mode 100644 index 0000000..d26f2fe --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsync.kt @@ -0,0 +1,195 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.async + +import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.core.RequestOptions +import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.models.batches.BatchCreateParams +import ai.llamaindex.llamacloud.models.batches.BatchCreateResponse +import ai.llamaindex.llamacloud.models.batches.BatchGetParams +import ai.llamaindex.llamacloud.models.batches.BatchGetResponse +import ai.llamaindex.llamacloud.models.batches.BatchListPageAsync +import ai.llamaindex.llamacloud.models.batches.BatchListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface BatchServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BatchServiceAsync + + /** + * Create a batch over a source directory and start processing asynchronously. + * + * To be notified as the batch progresses, pass `webhook_configurations` with inline endpoints + * and/or `webhook_configuration_ids` referencing saved configurations. Batches emit + * `batch.pending` on create, `batch.running` once processing starts, and a terminal + * `batch.success` or `batch.error`. + * + * `batch.success` means the batch finished mapping every source file to a job — individual + * files may still have failed, so read `results` (with `expand=results`) for per-file outcomes. + * + * Delivery order across events is not guaranteed; key on the `status` field in the payload + * rather than arrival order. + */ + fun create(params: BatchCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: BatchCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** List batches for the current project. */ + fun list(): CompletableFuture = list(BatchListParams.none()) + + /** @see list */ + fun list( + params: BatchListParams = BatchListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: BatchListParams = BatchListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(BatchListParams.none(), requestOptions) + + /** Get a batch by ID. */ + fun get(batchId: String): CompletableFuture = + get(batchId, BatchGetParams.none()) + + /** @see get */ + fun get( + batchId: String, + params: BatchGetParams = BatchGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + get(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see get */ + fun get( + batchId: String, + params: BatchGetParams = BatchGetParams.none(), + ): CompletableFuture = get(batchId, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: BatchGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see get */ + fun get(params: BatchGetParams): CompletableFuture = + get(params, RequestOptions.none()) + + /** @see get */ + fun get(batchId: String, requestOptions: RequestOptions): CompletableFuture = + get(batchId, BatchGetParams.none(), requestOptions) + + /** A view of [BatchServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): BatchServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v2/batches`, but is otherwise the same as + * [BatchServiceAsync.create]. + */ + fun create( + params: BatchCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: BatchCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /api/v2/batches`, but is otherwise the same as + * [BatchServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(BatchListParams.none()) + + /** @see list */ + fun list( + params: BatchListParams = BatchListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: BatchListParams = BatchListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(BatchListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v2/batches/{batch_id}`, but is otherwise the + * same as [BatchServiceAsync.get]. + */ + fun get(batchId: String): CompletableFuture> = + get(batchId, BatchGetParams.none()) + + /** @see get */ + fun get( + batchId: String, + params: BatchGetParams = BatchGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + get(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see get */ + fun get( + batchId: String, + params: BatchGetParams = BatchGetParams.none(), + ): CompletableFuture> = + get(batchId, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: BatchGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see get */ + fun get(params: BatchGetParams): CompletableFuture> = + get(params, RequestOptions.none()) + + /** @see get */ + fun get( + batchId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + get(batchId, BatchGetParams.none(), requestOptions) + } +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncImpl.kt new file mode 100644 index 0000000..6eace8b --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncImpl.kt @@ -0,0 +1,178 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.async + +import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.core.RequestOptions +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.core.handlers.errorBodyHandler +import ai.llamaindex.llamacloud.core.handlers.errorHandler +import ai.llamaindex.llamacloud.core.handlers.jsonHandler +import ai.llamaindex.llamacloud.core.http.HttpMethod +import ai.llamaindex.llamacloud.core.http.HttpRequest +import ai.llamaindex.llamacloud.core.http.HttpResponse +import ai.llamaindex.llamacloud.core.http.HttpResponse.Handler +import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.core.http.json +import ai.llamaindex.llamacloud.core.http.parseable +import ai.llamaindex.llamacloud.core.prepareAsync +import ai.llamaindex.llamacloud.models.batches.BatchCreateParams +import ai.llamaindex.llamacloud.models.batches.BatchCreateResponse +import ai.llamaindex.llamacloud.models.batches.BatchGetParams +import ai.llamaindex.llamacloud.models.batches.BatchGetResponse +import ai.llamaindex.llamacloud.models.batches.BatchListPageAsync +import ai.llamaindex.llamacloud.models.batches.BatchListPageResponse +import ai.llamaindex.llamacloud.models.batches.BatchListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class BatchServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + BatchServiceAsync { + + private val withRawResponse: BatchServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BatchServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): BatchServiceAsync = + BatchServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: BatchCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /api/v2/batches + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: BatchListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/v2/batches + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun get( + params: BatchGetParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/v2/batches/{batch_id} + withRawResponse().get(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BatchServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): BatchServiceAsync.WithRawResponse = + BatchServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: BatchCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v2", "batches") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: BatchListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v2", "batches") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + BatchListPageAsync.builder() + .service(BatchServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: BatchGetParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("batchId", params.batchId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v2", "batches", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { getHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchService.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchService.kt new file mode 100644 index 0000000..24634ab --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchService.kt @@ -0,0 +1,189 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.blocking + +import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.core.RequestOptions +import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.models.batches.BatchCreateParams +import ai.llamaindex.llamacloud.models.batches.BatchCreateResponse +import ai.llamaindex.llamacloud.models.batches.BatchGetParams +import ai.llamaindex.llamacloud.models.batches.BatchGetResponse +import ai.llamaindex.llamacloud.models.batches.BatchListPage +import ai.llamaindex.llamacloud.models.batches.BatchListParams +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface BatchService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BatchService + + /** + * Create a batch over a source directory and start processing asynchronously. + * + * To be notified as the batch progresses, pass `webhook_configurations` with inline endpoints + * and/or `webhook_configuration_ids` referencing saved configurations. Batches emit + * `batch.pending` on create, `batch.running` once processing starts, and a terminal + * `batch.success` or `batch.error`. + * + * `batch.success` means the batch finished mapping every source file to a job — individual + * files may still have failed, so read `results` (with `expand=results`) for per-file outcomes. + * + * Delivery order across events is not guaranteed; key on the `status` field in the payload + * rather than arrival order. + */ + fun create(params: BatchCreateParams): BatchCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: BatchCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BatchCreateResponse + + /** List batches for the current project. */ + fun list(): BatchListPage = list(BatchListParams.none()) + + /** @see list */ + fun list( + params: BatchListParams = BatchListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BatchListPage + + /** @see list */ + fun list(params: BatchListParams = BatchListParams.none()): BatchListPage = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): BatchListPage = + list(BatchListParams.none(), requestOptions) + + /** Get a batch by ID. */ + fun get(batchId: String): BatchGetResponse = get(batchId, BatchGetParams.none()) + + /** @see get */ + fun get( + batchId: String, + params: BatchGetParams = BatchGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BatchGetResponse = get(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see get */ + fun get(batchId: String, params: BatchGetParams = BatchGetParams.none()): BatchGetResponse = + get(batchId, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: BatchGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BatchGetResponse + + /** @see get */ + fun get(params: BatchGetParams): BatchGetResponse = get(params, RequestOptions.none()) + + /** @see get */ + fun get(batchId: String, requestOptions: RequestOptions): BatchGetResponse = + get(batchId, BatchGetParams.none(), requestOptions) + + /** A view of [BatchService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BatchService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v2/batches`, but is otherwise the same as + * [BatchService.create]. + */ + @MustBeClosed + fun create(params: BatchCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: BatchCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /api/v2/batches`, but is otherwise the same as + * [BatchService.list]. + */ + @MustBeClosed fun list(): HttpResponseFor = list(BatchListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: BatchListParams = BatchListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list(params: BatchListParams = BatchListParams.none()): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(BatchListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v2/batches/{batch_id}`, but is otherwise the + * same as [BatchService.get]. + */ + @MustBeClosed + fun get(batchId: String): HttpResponseFor = + get(batchId, BatchGetParams.none()) + + /** @see get */ + @MustBeClosed + fun get( + batchId: String, + params: BatchGetParams = BatchGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + get(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see get */ + @MustBeClosed + fun get( + batchId: String, + params: BatchGetParams = BatchGetParams.none(), + ): HttpResponseFor = get(batchId, params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get( + params: BatchGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see get */ + @MustBeClosed + fun get(params: BatchGetParams): HttpResponseFor = + get(params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get( + batchId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = get(batchId, BatchGetParams.none(), requestOptions) + } +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceImpl.kt new file mode 100644 index 0000000..4329ec4 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceImpl.kt @@ -0,0 +1,161 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.blocking + +import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.core.RequestOptions +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.core.handlers.errorBodyHandler +import ai.llamaindex.llamacloud.core.handlers.errorHandler +import ai.llamaindex.llamacloud.core.handlers.jsonHandler +import ai.llamaindex.llamacloud.core.http.HttpMethod +import ai.llamaindex.llamacloud.core.http.HttpRequest +import ai.llamaindex.llamacloud.core.http.HttpResponse +import ai.llamaindex.llamacloud.core.http.HttpResponse.Handler +import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.core.http.json +import ai.llamaindex.llamacloud.core.http.parseable +import ai.llamaindex.llamacloud.core.prepare +import ai.llamaindex.llamacloud.models.batches.BatchCreateParams +import ai.llamaindex.llamacloud.models.batches.BatchCreateResponse +import ai.llamaindex.llamacloud.models.batches.BatchGetParams +import ai.llamaindex.llamacloud.models.batches.BatchGetResponse +import ai.llamaindex.llamacloud.models.batches.BatchListPage +import ai.llamaindex.llamacloud.models.batches.BatchListPageResponse +import ai.llamaindex.llamacloud.models.batches.BatchListParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class BatchServiceImpl internal constructor(private val clientOptions: ClientOptions) : + BatchService { + + private val withRawResponse: BatchService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): BatchService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): BatchService = + BatchServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: BatchCreateParams, + requestOptions: RequestOptions, + ): BatchCreateResponse = + // post /api/v2/batches + withRawResponse().create(params, requestOptions).parse() + + override fun list(params: BatchListParams, requestOptions: RequestOptions): BatchListPage = + // get /api/v2/batches + withRawResponse().list(params, requestOptions).parse() + + override fun get(params: BatchGetParams, requestOptions: RequestOptions): BatchGetResponse = + // get /api/v2/batches/{batch_id} + withRawResponse().get(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + BatchService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): BatchService.WithRawResponse = + BatchServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: BatchCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v2", "batches") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: BatchListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v2", "batches") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + BatchListPage.builder() + .service(BatchServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: BatchGetParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("batchId", params.batchId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v2", "batches", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { getHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParamsTest.kt new file mode 100644 index 0000000..56f4860 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateParamsTest.kt @@ -0,0 +1,237 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.batches + +import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.core.http.QueryParams +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BatchCreateParamsTest { + + @Test + fun create() { + BatchCreateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + BatchCreateParams.Config.builder() + .job( + BatchCreateParams.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchCreateParams.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + .sourceDirectoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") + .addWebhookConfiguration( + BatchCreateParams.WebhookConfiguration.builder() + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS + ) + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR + ) + .webhookHeaders( + BatchCreateParams.WebhookConfiguration.WebhookHeaders.builder() + .putAdditionalProperty("Authorization", JsonValue.from("Bearer sk-...")) + .build() + ) + .webhookOutputFormat("json") + .webhookSigningSecret("whsec_...") + .webhookUrl("https://example.com/webhooks/llamacloud") + .build() + ) + .build() + } + + @Test + fun queryParams() { + val params = + BatchCreateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + BatchCreateParams.Config.builder() + .job( + BatchCreateParams.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchCreateParams.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + .sourceDirectoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") + .addWebhookConfiguration( + BatchCreateParams.WebhookConfiguration.builder() + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS + ) + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR + ) + .webhookHeaders( + BatchCreateParams.WebhookConfiguration.WebhookHeaders.builder() + .putAdditionalProperty( + "Authorization", + JsonValue.from("Bearer sk-..."), + ) + .build() + ) + .webhookOutputFormat("json") + .webhookSigningSecret("whsec_...") + .webhookUrl("https://example.com/webhooks/llamacloud") + .build() + ) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + BatchCreateParams.builder() + .config( + BatchCreateParams.Config.builder() + .job( + BatchCreateParams.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchCreateParams.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + .sourceDirectoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } + + @Test + fun body() { + val params = + BatchCreateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + BatchCreateParams.Config.builder() + .job( + BatchCreateParams.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchCreateParams.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + .sourceDirectoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") + .addWebhookConfiguration( + BatchCreateParams.WebhookConfiguration.builder() + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS + ) + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR + ) + .webhookHeaders( + BatchCreateParams.WebhookConfiguration.WebhookHeaders.builder() + .putAdditionalProperty( + "Authorization", + JsonValue.from("Bearer sk-..."), + ) + .build() + ) + .webhookOutputFormat("json") + .webhookSigningSecret("whsec_...") + .webhookUrl("https://example.com/webhooks/llamacloud") + .build() + ) + .build() + + val body = params._body() + + assertThat(body.config()) + .isEqualTo( + BatchCreateParams.Config.builder() + .job( + BatchCreateParams.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchCreateParams.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + assertThat(body.sourceDirectoryId()).isEqualTo("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + assertThat(body.webhookConfigurationIds().getOrNull()).containsExactly("whc-...", "whc-...") + assertThat(body.webhookConfigurations().getOrNull()) + .containsExactly( + BatchCreateParams.WebhookConfiguration.builder() + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS + ) + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR + ) + .webhookHeaders( + BatchCreateParams.WebhookConfiguration.WebhookHeaders.builder() + .putAdditionalProperty("Authorization", JsonValue.from("Bearer sk-...")) + .build() + ) + .webhookOutputFormat("json") + .webhookSigningSecret("whsec_...") + .webhookUrl("https://example.com/webhooks/llamacloud") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + BatchCreateParams.builder() + .config( + BatchCreateParams.Config.builder() + .job( + BatchCreateParams.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchCreateParams.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + .sourceDirectoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .build() + + val body = params._body() + + assertThat(body.config()) + .isEqualTo( + BatchCreateParams.Config.builder() + .job( + BatchCreateParams.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchCreateParams.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + assertThat(body.sourceDirectoryId()).isEqualTo("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateResponseTest.kt new file mode 100644 index 0000000..9ce81cb --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCreateResponseTest.kt @@ -0,0 +1,125 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.batches + +import ai.llamaindex.llamacloud.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BatchCreateResponseTest { + + @Test + fun create() { + val batchCreateResponse = + BatchCreateResponse.builder() + .id("id") + .config( + BatchCreateResponse.Config.builder() + .job( + BatchCreateResponse.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchCreateResponse.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + .projectId("project_id") + .sourceDirectoryId("source_directory_id") + .status(BatchCreateResponse.Status.CANCELLED) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addResult( + BatchCreateResponse.Result.builder() + .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .errorMessage("error_message") + .jobReference( + BatchCreateResponse.Result.JobReference.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .type(BatchCreateResponse.Result.JobReference.Type.PARSE_V2) + .build() + ) + .build() + ) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(batchCreateResponse.id()).isEqualTo("id") + assertThat(batchCreateResponse.config()) + .isEqualTo( + BatchCreateResponse.Config.builder() + .job( + BatchCreateResponse.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchCreateResponse.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + assertThat(batchCreateResponse.projectId()).isEqualTo("project_id") + assertThat(batchCreateResponse.sourceDirectoryId()).isEqualTo("source_directory_id") + assertThat(batchCreateResponse.status()).isEqualTo(BatchCreateResponse.Status.CANCELLED) + assertThat(batchCreateResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(batchCreateResponse.results().getOrNull()) + .containsExactly( + BatchCreateResponse.Result.builder() + .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .errorMessage("error_message") + .jobReference( + BatchCreateResponse.Result.JobReference.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .type(BatchCreateResponse.Result.JobReference.Type.PARSE_V2) + .build() + ) + .build() + ) + assertThat(batchCreateResponse.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val batchCreateResponse = + BatchCreateResponse.builder() + .id("id") + .config( + BatchCreateResponse.Config.builder() + .job( + BatchCreateResponse.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchCreateResponse.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + .projectId("project_id") + .sourceDirectoryId("source_directory_id") + .status(BatchCreateResponse.Status.CANCELLED) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addResult( + BatchCreateResponse.Result.builder() + .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .errorMessage("error_message") + .jobReference( + BatchCreateResponse.Result.JobReference.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .type(BatchCreateResponse.Result.JobReference.Type.PARSE_V2) + .build() + ) + .build() + ) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedBatchCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(batchCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBatchCreateResponse).isEqualTo(batchCreateResponse) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetParamsTest.kt new file mode 100644 index 0000000..4537206 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetParamsTest.kt @@ -0,0 +1,63 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.batches + +import ai.llamaindex.llamacloud.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BatchGetParamsTest { + + @Test + fun create() { + BatchGetParams.builder() + .batchId("batch_id") + .addExpand("string") + .addExpand("string") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = BatchGetParams.builder().batchId("batch_id").build() + + assertThat(params._pathParam(0)).isEqualTo("batch_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + BatchGetParams.builder() + .batchId("batch_id") + .addExpand("string") + .addExpand("string") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("expand", "string") + .put("expand", "string") + .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = BatchGetParams.builder().batchId("batch_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetResponseTest.kt new file mode 100644 index 0000000..1ad07cf --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchGetResponseTest.kt @@ -0,0 +1,125 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.batches + +import ai.llamaindex.llamacloud.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BatchGetResponseTest { + + @Test + fun create() { + val batchGetResponse = + BatchGetResponse.builder() + .id("id") + .config( + BatchGetResponse.Config.builder() + .job( + BatchGetResponse.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchGetResponse.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + .projectId("project_id") + .sourceDirectoryId("source_directory_id") + .status(BatchGetResponse.Status.CANCELLED) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addResult( + BatchGetResponse.Result.builder() + .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .errorMessage("error_message") + .jobReference( + BatchGetResponse.Result.JobReference.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .type(BatchGetResponse.Result.JobReference.Type.PARSE_V2) + .build() + ) + .build() + ) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(batchGetResponse.id()).isEqualTo("id") + assertThat(batchGetResponse.config()) + .isEqualTo( + BatchGetResponse.Config.builder() + .job( + BatchGetResponse.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchGetResponse.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + assertThat(batchGetResponse.projectId()).isEqualTo("project_id") + assertThat(batchGetResponse.sourceDirectoryId()).isEqualTo("source_directory_id") + assertThat(batchGetResponse.status()).isEqualTo(BatchGetResponse.Status.CANCELLED) + assertThat(batchGetResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(batchGetResponse.results().getOrNull()) + .containsExactly( + BatchGetResponse.Result.builder() + .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .errorMessage("error_message") + .jobReference( + BatchGetResponse.Result.JobReference.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .type(BatchGetResponse.Result.JobReference.Type.PARSE_V2) + .build() + ) + .build() + ) + assertThat(batchGetResponse.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val batchGetResponse = + BatchGetResponse.builder() + .id("id") + .config( + BatchGetResponse.Config.builder() + .job( + BatchGetResponse.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchGetResponse.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + .projectId("project_id") + .sourceDirectoryId("source_directory_id") + .status(BatchGetResponse.Status.CANCELLED) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addResult( + BatchGetResponse.Result.builder() + .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .errorMessage("error_message") + .jobReference( + BatchGetResponse.Result.JobReference.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .type(BatchGetResponse.Result.JobReference.Type.PARSE_V2) + .build() + ) + .build() + ) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedBatchGetResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(batchGetResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBatchGetResponse).isEqualTo(batchGetResponse) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageResponseTest.kt new file mode 100644 index 0000000..15a9057 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListPageResponseTest.kt @@ -0,0 +1,139 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.batches + +import ai.llamaindex.llamacloud.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BatchListPageResponseTest { + + @Test + fun create() { + val batchListPageResponse = + BatchListPageResponse.builder() + .addItem( + BatchListResponse.builder() + .id("id") + .config( + BatchListResponse.Config.builder() + .job( + BatchListResponse.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchListResponse.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + .projectId("project_id") + .sourceDirectoryId("source_directory_id") + .status(BatchListResponse.Status.CANCELLED) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addResult( + BatchListResponse.Result.builder() + .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .errorMessage("error_message") + .jobReference( + BatchListResponse.Result.JobReference.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .type(BatchListResponse.Result.JobReference.Type.PARSE_V2) + .build() + ) + .build() + ) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .nextPageToken("next_page_token") + .totalSize(0L) + .build() + + assertThat(batchListPageResponse.items()) + .containsExactly( + BatchListResponse.builder() + .id("id") + .config( + BatchListResponse.Config.builder() + .job( + BatchListResponse.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchListResponse.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + .projectId("project_id") + .sourceDirectoryId("source_directory_id") + .status(BatchListResponse.Status.CANCELLED) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addResult( + BatchListResponse.Result.builder() + .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .errorMessage("error_message") + .jobReference( + BatchListResponse.Result.JobReference.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .type(BatchListResponse.Result.JobReference.Type.PARSE_V2) + .build() + ) + .build() + ) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(batchListPageResponse.nextPageToken()).contains("next_page_token") + assertThat(batchListPageResponse.totalSize()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val batchListPageResponse = + BatchListPageResponse.builder() + .addItem( + BatchListResponse.builder() + .id("id") + .config( + BatchListResponse.Config.builder() + .job( + BatchListResponse.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchListResponse.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + .projectId("project_id") + .sourceDirectoryId("source_directory_id") + .status(BatchListResponse.Status.CANCELLED) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addResult( + BatchListResponse.Result.builder() + .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .errorMessage("error_message") + .jobReference( + BatchListResponse.Result.JobReference.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .type(BatchListResponse.Result.JobReference.Type.PARSE_V2) + .build() + ) + .build() + ) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .nextPageToken("next_page_token") + .totalSize(0L) + .build() + + val roundtrippedBatchListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(batchListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBatchListPageResponse).isEqualTo(batchListPageResponse) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListParamsTest.kt new file mode 100644 index 0000000..b1423cd --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListParamsTest.kt @@ -0,0 +1,65 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.batches + +import ai.llamaindex.llamacloud.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BatchListParamsTest { + + @Test + fun create() { + BatchListParams.builder() + .createdAtOnOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAtOnOrBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pageSize(0L) + .pageToken("page_token") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sourceDirectoryId("source_directory_id") + .status(BatchListParams.Status.CANCELLED) + .build() + } + + @Test + fun queryParams() { + val params = + BatchListParams.builder() + .createdAtOnOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAtOnOrBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pageSize(0L) + .pageToken("page_token") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .sourceDirectoryId("source_directory_id") + .status(BatchListParams.Status.CANCELLED) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("created_at_on_or_after", "2019-12-27T18:11:19.117Z") + .put("created_at_on_or_before", "2019-12-27T18:11:19.117Z") + .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("page_size", "0") + .put("page_token", "page_token") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("source_directory_id", "source_directory_id") + .put("status", "CANCELLED") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = BatchListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListResponseTest.kt new file mode 100644 index 0000000..27167b9 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchListResponseTest.kt @@ -0,0 +1,125 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.batches + +import ai.llamaindex.llamacloud.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BatchListResponseTest { + + @Test + fun create() { + val batchListResponse = + BatchListResponse.builder() + .id("id") + .config( + BatchListResponse.Config.builder() + .job( + BatchListResponse.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchListResponse.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + .projectId("project_id") + .sourceDirectoryId("source_directory_id") + .status(BatchListResponse.Status.CANCELLED) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addResult( + BatchListResponse.Result.builder() + .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .errorMessage("error_message") + .jobReference( + BatchListResponse.Result.JobReference.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .type(BatchListResponse.Result.JobReference.Type.PARSE_V2) + .build() + ) + .build() + ) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(batchListResponse.id()).isEqualTo("id") + assertThat(batchListResponse.config()) + .isEqualTo( + BatchListResponse.Config.builder() + .job( + BatchListResponse.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchListResponse.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + assertThat(batchListResponse.projectId()).isEqualTo("project_id") + assertThat(batchListResponse.sourceDirectoryId()).isEqualTo("source_directory_id") + assertThat(batchListResponse.status()).isEqualTo(BatchListResponse.Status.CANCELLED) + assertThat(batchListResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(batchListResponse.results().getOrNull()) + .containsExactly( + BatchListResponse.Result.builder() + .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .errorMessage("error_message") + .jobReference( + BatchListResponse.Result.JobReference.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .type(BatchListResponse.Result.JobReference.Type.PARSE_V2) + .build() + ) + .build() + ) + assertThat(batchListResponse.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val batchListResponse = + BatchListResponse.builder() + .id("id") + .config( + BatchListResponse.Config.builder() + .job( + BatchListResponse.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchListResponse.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + .projectId("project_id") + .sourceDirectoryId("source_directory_id") + .status(BatchListResponse.Status.CANCELLED) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addResult( + BatchListResponse.Result.builder() + .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .errorMessage("error_message") + .jobReference( + BatchListResponse.Result.JobReference.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .type(BatchListResponse.Result.JobReference.Type.PARSE_V2) + .build() + ) + .build() + ) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedBatchListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(batchListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBatchListResponse).isEqualTo(batchListResponse) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncTest.kt new file mode 100644 index 0000000..4bcdfe2 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncTest.kt @@ -0,0 +1,98 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.async + +import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClientAsync +import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.models.batches.BatchCreateParams +import ai.llamaindex.llamacloud.models.batches.BatchGetParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class BatchServiceAsyncTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val batchServiceAsync = client.batches() + + val batchFuture = + batchServiceAsync.create( + BatchCreateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + BatchCreateParams.Config.builder() + .job( + BatchCreateParams.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchCreateParams.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + .sourceDirectoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") + .addWebhookConfiguration( + BatchCreateParams.WebhookConfiguration.builder() + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS + ) + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR + ) + .webhookHeaders( + BatchCreateParams.WebhookConfiguration.WebhookHeaders.builder() + .putAdditionalProperty( + "Authorization", + JsonValue.from("Bearer sk-..."), + ) + .build() + ) + .webhookOutputFormat("json") + .webhookSigningSecret("whsec_...") + .webhookUrl("https://example.com/webhooks/llamacloud") + .build() + ) + .build() + ) + + val batch = batchFuture.get() + batch.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val batchServiceAsync = client.batches() + + val pageFuture = batchServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun get() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val batchServiceAsync = client.batches() + + val batchFuture = + batchServiceAsync.get( + BatchGetParams.builder() + .batchId("batch_id") + .addExpand("string") + .addExpand("string") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val batch = batchFuture.get() + batch.validate() + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceTest.kt new file mode 100644 index 0000000..a0da2cb --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceTest.kt @@ -0,0 +1,95 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.blocking + +import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClient +import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.models.batches.BatchCreateParams +import ai.llamaindex.llamacloud.models.batches.BatchGetParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class BatchServiceTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val batchService = client.batches() + + val batch = + batchService.create( + BatchCreateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .config( + BatchCreateParams.Config.builder() + .job( + BatchCreateParams.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchCreateParams.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + .sourceDirectoryId("dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") + .addWebhookConfiguration( + BatchCreateParams.WebhookConfiguration.builder() + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS + ) + .addWebhookEvent( + BatchCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR + ) + .webhookHeaders( + BatchCreateParams.WebhookConfiguration.WebhookHeaders.builder() + .putAdditionalProperty( + "Authorization", + JsonValue.from("Bearer sk-..."), + ) + .build() + ) + .webhookOutputFormat("json") + .webhookSigningSecret("whsec_...") + .webhookUrl("https://example.com/webhooks/llamacloud") + .build() + ) + .build() + ) + + batch.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val batchService = client.batches() + + val page = batchService.list() + + page.response().validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun get() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val batchService = client.batches() + + val batch = + batchService.get( + BatchGetParams.builder() + .batchId("batch_id") + .addExpand("string") + .addExpand("string") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + batch.validate() + } +} diff --git a/llama-cloud-proguard-test/src/test/kotlin/ai/llamaindex/llamacloud/proguard/ProGuardCompatibilityTest.kt b/llama-cloud-proguard-test/src/test/kotlin/ai/llamaindex/llamacloud/proguard/ProGuardCompatibilityTest.kt index bc0d1b7..73c1885 100644 --- a/llama-cloud-proguard-test/src/test/kotlin/ai/llamaindex/llamacloud/proguard/ProGuardCompatibilityTest.kt +++ b/llama-cloud-proguard-test/src/test/kotlin/ai/llamaindex/llamacloud/proguard/ProGuardCompatibilityTest.kt @@ -55,6 +55,7 @@ internal class ProGuardCompatibilityTest { assertThat(client.parsing()).isNotNull() assertThat(client.extract()).isNotNull() assertThat(client.classifier()).isNotNull() + assertThat(client.batches()).isNotNull() assertThat(client.classify()).isNotNull() assertThat(client.configurations()).isNotNull() assertThat(client.projects()).isNotNull() From 33f78b474f9a155ac5295c4d92e3dfba82ef5948 Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Wed, 5 Aug 2026 01:52:32 +0000 Subject: [PATCH 15/28] feat(parse): make the output.pdf artifact opt-in on Parse v2 (output_options.save_output_pdf) (#23510) Stainless-Generated-From: a6cfaf34074b5d2f76e224cc2035a55000a9ed7b --- .../configurations/ParseV2Parameters.kt | 64 ++++++++++++++++++- .../models/parsing/ParsingCreateParams.kt | 64 ++++++++++++++++++- .../configurations/ParseV2ParametersTest.kt | 3 + .../models/parsing/ParsingCreateParamsTest.kt | 4 ++ .../llamacloud/services/ServiceParamsTest.kt | 1 + .../services/async/ParsingServiceAsyncTest.kt | 1 + .../services/blocking/ParsingServiceTest.kt | 1 + 7 files changed, 136 insertions(+), 2 deletions(-) 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 86801f4..c02ef48 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 @@ -3074,6 +3074,7 @@ private constructor( private val granularBboxes: JsonField>, private val imagesToSave: JsonField>, private val markdown: JsonField, + private val saveOutputPdf: JsonField, private val spatialText: JsonField, private val tablesAsSpreadsheet: JsonField, private val additionalProperties: MutableMap, @@ -3096,6 +3097,9 @@ private constructor( @JsonProperty("markdown") @ExcludeMissing markdown: JsonField = JsonMissing.of(), + @JsonProperty("save_output_pdf") + @ExcludeMissing + saveOutputPdf: JsonField = JsonMissing.of(), @JsonProperty("spatial_text") @ExcludeMissing spatialText: JsonField = JsonMissing.of(), @@ -3108,6 +3112,7 @@ private constructor( granularBboxes, imagesToSave, markdown, + saveOutputPdf, spatialText, tablesAsSpreadsheet, mutableMapOf(), @@ -3178,6 +3183,16 @@ private constructor( */ fun markdown(): Optional = markdown.getOptional("markdown") + /** + * Save a PDF copy of the parsed document, retrievable via + * `expand=output_pdf_content_metadata`. Not produced for spreadsheet, plain-text, or audio + * inputs + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun saveOutputPdf(): Optional = saveOutputPdf.getOptional("save_output_pdf") + /** * Spatial text output options for preserving document layout structure * @@ -3242,6 +3257,16 @@ private constructor( */ @JsonProperty("markdown") @ExcludeMissing fun _markdown(): JsonField = markdown + /** + * Returns the raw JSON value of [saveOutputPdf]. + * + * Unlike [saveOutputPdf], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("save_output_pdf") + @ExcludeMissing + fun _saveOutputPdf(): JsonField = saveOutputPdf + /** * Returns the raw JSON value of [spatialText]. * @@ -3287,6 +3312,7 @@ private constructor( private var granularBboxes: JsonField>? = null private var imagesToSave: JsonField>? = null private var markdown: JsonField = JsonMissing.of() + private var saveOutputPdf: JsonField = JsonMissing.of() private var spatialText: JsonField = JsonMissing.of() private var tablesAsSpreadsheet: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -3298,6 +3324,7 @@ private constructor( granularBboxes = outputOptions.granularBboxes.map { it.toMutableList() } imagesToSave = outputOptions.imagesToSave.map { it.toMutableList() } markdown = outputOptions.markdown + saveOutputPdf = outputOptions.saveOutputPdf spatialText = outputOptions.spatialText tablesAsSpreadsheet = outputOptions.tablesAsSpreadsheet additionalProperties = outputOptions.additionalProperties.toMutableMap() @@ -3455,6 +3482,36 @@ private constructor( */ fun markdown(markdown: JsonField) = apply { this.markdown = markdown } + /** + * Save a PDF copy of the parsed document, retrievable via + * `expand=output_pdf_content_metadata`. Not produced for spreadsheet, plain-text, or + * audio inputs + */ + fun saveOutputPdf(saveOutputPdf: Boolean?) = + saveOutputPdf(JsonField.ofNullable(saveOutputPdf)) + + /** + * Alias for [Builder.saveOutputPdf]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun saveOutputPdf(saveOutputPdf: Boolean) = saveOutputPdf(saveOutputPdf as Boolean?) + + /** Alias for calling [Builder.saveOutputPdf] with `saveOutputPdf.orElse(null)`. */ + fun saveOutputPdf(saveOutputPdf: Optional) = + saveOutputPdf(saveOutputPdf.getOrNull()) + + /** + * Sets [Builder.saveOutputPdf] to an arbitrary JSON value. + * + * You should usually call [Builder.saveOutputPdf] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun saveOutputPdf(saveOutputPdf: JsonField) = apply { + this.saveOutputPdf = saveOutputPdf + } + /** Spatial text output options for preserving document layout structure */ fun spatialText(spatialText: SpatialText) = spatialText(JsonField.of(spatialText)) @@ -3515,6 +3572,7 @@ private constructor( (granularBboxes ?: JsonMissing.of()).map { it.toImmutable() }, (imagesToSave ?: JsonMissing.of()).map { it.toImmutable() }, markdown, + saveOutputPdf, spatialText, tablesAsSpreadsheet, additionalProperties.toMutableMap(), @@ -3542,6 +3600,7 @@ private constructor( granularBboxes().ifPresent { it.forEach { it.validate() } } imagesToSave().ifPresent { it.forEach { it.validate() } } markdown().ifPresent { it.validate() } + saveOutputPdf() spatialText().ifPresent { it.validate() } tablesAsSpreadsheet().ifPresent { it.validate() } validated = true @@ -3568,6 +3627,7 @@ private constructor( (granularBboxes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (imagesToSave.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (markdown.asKnown().getOrNull()?.validity() ?: 0) + + (if (saveOutputPdf.asKnown().isPresent) 1 else 0) + (spatialText.asKnown().getOrNull()?.validity() ?: 0) + (tablesAsSpreadsheet.asKnown().getOrNull()?.validity() ?: 0) @@ -5183,6 +5243,7 @@ private constructor( granularBboxes == other.granularBboxes && imagesToSave == other.imagesToSave && markdown == other.markdown && + saveOutputPdf == other.saveOutputPdf && spatialText == other.spatialText && tablesAsSpreadsheet == other.tablesAsSpreadsheet && additionalProperties == other.additionalProperties @@ -5195,6 +5256,7 @@ private constructor( granularBboxes, imagesToSave, markdown, + saveOutputPdf, spatialText, tablesAsSpreadsheet, additionalProperties, @@ -5204,7 +5266,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OutputOptions{additionalOutputs=$additionalOutputs, extractPrintedPageNumber=$extractPrintedPageNumber, granularBboxes=$granularBboxes, imagesToSave=$imagesToSave, markdown=$markdown, spatialText=$spatialText, tablesAsSpreadsheet=$tablesAsSpreadsheet, additionalProperties=$additionalProperties}" + "OutputOptions{additionalOutputs=$additionalOutputs, extractPrintedPageNumber=$extractPrintedPageNumber, granularBboxes=$granularBboxes, imagesToSave=$imagesToSave, markdown=$markdown, saveOutputPdf=$saveOutputPdf, spatialText=$spatialText, tablesAsSpreadsheet=$tablesAsSpreadsheet, additionalProperties=$additionalProperties}" } /** Page selection: limit total pages or specify exact pages to process */ diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt index 80f4e79..1be9703 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt @@ -4279,6 +4279,7 @@ private constructor( private val granularBboxes: JsonField>, private val imagesToSave: JsonField>, private val markdown: JsonField, + private val saveOutputPdf: JsonField, private val spatialText: JsonField, private val tablesAsSpreadsheet: JsonField, private val additionalProperties: MutableMap, @@ -4301,6 +4302,9 @@ private constructor( @JsonProperty("markdown") @ExcludeMissing markdown: JsonField = JsonMissing.of(), + @JsonProperty("save_output_pdf") + @ExcludeMissing + saveOutputPdf: JsonField = JsonMissing.of(), @JsonProperty("spatial_text") @ExcludeMissing spatialText: JsonField = JsonMissing.of(), @@ -4313,6 +4317,7 @@ private constructor( granularBboxes, imagesToSave, markdown, + saveOutputPdf, spatialText, tablesAsSpreadsheet, mutableMapOf(), @@ -4383,6 +4388,16 @@ private constructor( */ fun markdown(): Optional = markdown.getOptional("markdown") + /** + * Save a PDF copy of the parsed document, retrievable via + * `expand=output_pdf_content_metadata`. Not produced for spreadsheet, plain-text, or audio + * inputs + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun saveOutputPdf(): Optional = saveOutputPdf.getOptional("save_output_pdf") + /** * Spatial text output options for preserving document layout structure * @@ -4447,6 +4462,16 @@ private constructor( */ @JsonProperty("markdown") @ExcludeMissing fun _markdown(): JsonField = markdown + /** + * Returns the raw JSON value of [saveOutputPdf]. + * + * Unlike [saveOutputPdf], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("save_output_pdf") + @ExcludeMissing + fun _saveOutputPdf(): JsonField = saveOutputPdf + /** * Returns the raw JSON value of [spatialText]. * @@ -4492,6 +4517,7 @@ private constructor( private var granularBboxes: JsonField>? = null private var imagesToSave: JsonField>? = null private var markdown: JsonField = JsonMissing.of() + private var saveOutputPdf: JsonField = JsonMissing.of() private var spatialText: JsonField = JsonMissing.of() private var tablesAsSpreadsheet: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -4503,6 +4529,7 @@ private constructor( granularBboxes = outputOptions.granularBboxes.map { it.toMutableList() } imagesToSave = outputOptions.imagesToSave.map { it.toMutableList() } markdown = outputOptions.markdown + saveOutputPdf = outputOptions.saveOutputPdf spatialText = outputOptions.spatialText tablesAsSpreadsheet = outputOptions.tablesAsSpreadsheet additionalProperties = outputOptions.additionalProperties.toMutableMap() @@ -4660,6 +4687,36 @@ private constructor( */ fun markdown(markdown: JsonField) = apply { this.markdown = markdown } + /** + * Save a PDF copy of the parsed document, retrievable via + * `expand=output_pdf_content_metadata`. Not produced for spreadsheet, plain-text, or + * audio inputs + */ + fun saveOutputPdf(saveOutputPdf: Boolean?) = + saveOutputPdf(JsonField.ofNullable(saveOutputPdf)) + + /** + * Alias for [Builder.saveOutputPdf]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun saveOutputPdf(saveOutputPdf: Boolean) = saveOutputPdf(saveOutputPdf as Boolean?) + + /** Alias for calling [Builder.saveOutputPdf] with `saveOutputPdf.orElse(null)`. */ + fun saveOutputPdf(saveOutputPdf: Optional) = + saveOutputPdf(saveOutputPdf.getOrNull()) + + /** + * Sets [Builder.saveOutputPdf] to an arbitrary JSON value. + * + * You should usually call [Builder.saveOutputPdf] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun saveOutputPdf(saveOutputPdf: JsonField) = apply { + this.saveOutputPdf = saveOutputPdf + } + /** Spatial text output options for preserving document layout structure */ fun spatialText(spatialText: SpatialText) = spatialText(JsonField.of(spatialText)) @@ -4720,6 +4777,7 @@ private constructor( (granularBboxes ?: JsonMissing.of()).map { it.toImmutable() }, (imagesToSave ?: JsonMissing.of()).map { it.toImmutable() }, markdown, + saveOutputPdf, spatialText, tablesAsSpreadsheet, additionalProperties.toMutableMap(), @@ -4747,6 +4805,7 @@ private constructor( granularBboxes().ifPresent { it.forEach { it.validate() } } imagesToSave().ifPresent { it.forEach { it.validate() } } markdown().ifPresent { it.validate() } + saveOutputPdf() spatialText().ifPresent { it.validate() } tablesAsSpreadsheet().ifPresent { it.validate() } validated = true @@ -4773,6 +4832,7 @@ private constructor( (granularBboxes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (imagesToSave.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (markdown.asKnown().getOrNull()?.validity() ?: 0) + + (if (saveOutputPdf.asKnown().isPresent) 1 else 0) + (spatialText.asKnown().getOrNull()?.validity() ?: 0) + (tablesAsSpreadsheet.asKnown().getOrNull()?.validity() ?: 0) @@ -6388,6 +6448,7 @@ private constructor( granularBboxes == other.granularBboxes && imagesToSave == other.imagesToSave && markdown == other.markdown && + saveOutputPdf == other.saveOutputPdf && spatialText == other.spatialText && tablesAsSpreadsheet == other.tablesAsSpreadsheet && additionalProperties == other.additionalProperties @@ -6400,6 +6461,7 @@ private constructor( granularBboxes, imagesToSave, markdown, + saveOutputPdf, spatialText, tablesAsSpreadsheet, additionalProperties, @@ -6409,7 +6471,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "OutputOptions{additionalOutputs=$additionalOutputs, extractPrintedPageNumber=$extractPrintedPageNumber, granularBboxes=$granularBboxes, imagesToSave=$imagesToSave, markdown=$markdown, spatialText=$spatialText, tablesAsSpreadsheet=$tablesAsSpreadsheet, additionalProperties=$additionalProperties}" + "OutputOptions{additionalOutputs=$additionalOutputs, extractPrintedPageNumber=$extractPrintedPageNumber, granularBboxes=$granularBboxes, imagesToSave=$imagesToSave, markdown=$markdown, saveOutputPdf=$saveOutputPdf, spatialText=$spatialText, tablesAsSpreadsheet=$tablesAsSpreadsheet, additionalProperties=$additionalProperties}" } /** Page selection: limit total pages or specify exact pages to process */ diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/configurations/ParseV2ParametersTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/configurations/ParseV2ParametersTest.kt index 94f15c7..7e566f3 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/configurations/ParseV2ParametersTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/configurations/ParseV2ParametersTest.kt @@ -93,6 +93,7 @@ internal class ParseV2ParametersTest { ) .build() ) + .saveOutputPdf(true) .spatialText( ParseV2Parameters.OutputOptions.SpatialText.builder() .doNotUnrollColumns(true) @@ -380,6 +381,7 @@ internal class ParseV2ParametersTest { ) .build() ) + .saveOutputPdf(true) .spatialText( ParseV2Parameters.OutputOptions.SpatialText.builder() .doNotUnrollColumns(true) @@ -665,6 +667,7 @@ internal class ParseV2ParametersTest { ) .build() ) + .saveOutputPdf(true) .spatialText( ParseV2Parameters.OutputOptions.SpatialText.builder() .doNotUnrollColumns(true) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParamsTest.kt index 6245f16..0265305 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParamsTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParamsTest.kt @@ -95,6 +95,7 @@ internal class ParsingCreateParamsTest { ) .build() ) + .saveOutputPdf(true) .spatialText( ParsingCreateParams.OutputOptions.SpatialText.builder() .doNotUnrollColumns(true) @@ -390,6 +391,7 @@ internal class ParsingCreateParamsTest { ) .build() ) + .saveOutputPdf(true) .spatialText( ParsingCreateParams.OutputOptions.SpatialText.builder() .doNotUnrollColumns(true) @@ -715,6 +717,7 @@ internal class ParsingCreateParamsTest { ) .build() ) + .saveOutputPdf(true) .spatialText( ParsingCreateParams.OutputOptions.SpatialText.builder() .doNotUnrollColumns(true) @@ -1014,6 +1017,7 @@ internal class ParsingCreateParamsTest { ) .build() ) + .saveOutputPdf(true) .spatialText( ParsingCreateParams.OutputOptions.SpatialText.builder() .doNotUnrollColumns(true) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/ServiceParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/ServiceParamsTest.kt index 63ddc8f..54c008b 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/ServiceParamsTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/ServiceParamsTest.kt @@ -152,6 +152,7 @@ internal class ServiceParamsTest { ) .build() ) + .saveOutputPdf(true) .spatialText( ParsingCreateParams.OutputOptions.SpatialText.builder() .doNotUnrollColumns(true) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncTest.kt index d166efe..be5b91a 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncTest.kt @@ -108,6 +108,7 @@ internal class ParsingServiceAsyncTest { ) .build() ) + .saveOutputPdf(true) .spatialText( ParsingCreateParams.OutputOptions.SpatialText.builder() .doNotUnrollColumns(true) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceTest.kt index 9f710b4..094fd4f 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceTest.kt @@ -108,6 +108,7 @@ internal class ParsingServiceTest { ) .build() ) + .saveOutputPdf(true) .spatialText( ParsingCreateParams.OutputOptions.SpatialText.builder() .doNotUnrollColumns(true) From 1d0e3db8a87fc497c10f1bf39ccefc8d147624dd Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Wed, 5 Aug 2026 18:00:15 +0000 Subject: [PATCH 16/28] feat(connector): API + service layer for attaching a subscription to a directory (#23502) Stainless-Generated-From: a6344036ca5a34b85ead30ef8f8b3b8f445aaa54 --- .../beta/directories/DirectoryCreateParams.kt | 107 +++++++++++++++++- .../directories/DirectoryCreateParamsTest.kt | 4 + .../async/beta/DirectoryServiceAsyncTest.kt | 1 + .../blocking/beta/DirectoryServiceTest.kt | 1 + 4 files changed, 110 insertions(+), 3 deletions(-) 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 c3e2b68..14436ae 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 @@ -44,6 +44,14 @@ private constructor( */ fun name(): String = body.name() + /** + * Connector Subscription whose files sync into this directory. Omit for manual uploads. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun connectorSubscriptionId(): Optional = body.connectorSubscriptionId() + /** * Optional description shown to users. * @@ -75,6 +83,14 @@ private constructor( */ fun _name(): JsonField = body._name() + /** + * Returns the raw JSON value of [connectorSubscriptionId]. + * + * Unlike [connectorSubscriptionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _connectorSubscriptionId(): JsonField = body._connectorSubscriptionId() + /** * Returns the raw JSON value of [description]. * @@ -154,9 +170,11 @@ private constructor( * This is generally only useful if you are already constructing the body separately. * Otherwise, it's more convenient to use the top-level setters instead: * - [name] + * - [connectorSubscriptionId] * - [description] * - [systemMetadata] * - [type] + * - etc. */ fun body(body: Body) = apply { this.body = body.toBuilder() } @@ -171,6 +189,29 @@ private constructor( */ fun name(name: JsonField) = apply { body.name(name) } + /** Connector Subscription whose files sync into this directory. Omit for manual uploads. */ + fun connectorSubscriptionId(connectorSubscriptionId: String?) = apply { + body.connectorSubscriptionId(connectorSubscriptionId) + } + + /** + * Alias for calling [Builder.connectorSubscriptionId] with + * `connectorSubscriptionId.orElse(null)`. + */ + fun connectorSubscriptionId(connectorSubscriptionId: Optional) = + connectorSubscriptionId(connectorSubscriptionId.getOrNull()) + + /** + * Sets [Builder.connectorSubscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.connectorSubscriptionId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun connectorSubscriptionId(connectorSubscriptionId: JsonField) = apply { + body.connectorSubscriptionId(connectorSubscriptionId) + } + /** Optional description shown to users. */ fun description(description: String?) = apply { body.description(description) } @@ -374,6 +415,7 @@ private constructor( @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( private val name: JsonField, + private val connectorSubscriptionId: JsonField, private val description: JsonField, private val systemMetadata: JsonField, private val type: JsonField, @@ -383,6 +425,9 @@ private constructor( @JsonCreator private constructor( @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("connector_subscription_id") + @ExcludeMissing + connectorSubscriptionId: JsonField = JsonMissing.of(), @JsonProperty("description") @ExcludeMissing description: JsonField = JsonMissing.of(), @@ -390,7 +435,7 @@ private constructor( @ExcludeMissing systemMetadata: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(name, description, systemMetadata, type, mutableMapOf()) + ) : this(name, connectorSubscriptionId, description, systemMetadata, type, mutableMapOf()) /** * Human-readable name for the directory. @@ -400,6 +445,15 @@ private constructor( */ fun name(): String = name.getRequired("name") + /** + * Connector Subscription whose files sync into this directory. Omit for manual uploads. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun connectorSubscriptionId(): Optional = + connectorSubscriptionId.getOptional("connector_subscription_id") + /** * Optional description shown to users. * @@ -432,6 +486,16 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + /** + * Returns the raw JSON value of [connectorSubscriptionId]. + * + * Unlike [connectorSubscriptionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("connector_subscription_id") + @ExcludeMissing + fun _connectorSubscriptionId(): JsonField = connectorSubscriptionId + /** * Returns the raw JSON value of [description]. * @@ -487,6 +551,7 @@ private constructor( class Builder internal constructor() { private var name: JsonField? = null + private var connectorSubscriptionId: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() private var systemMetadata: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -495,6 +560,7 @@ private constructor( @JvmSynthetic internal fun from(body: Body) = apply { name = body.name + connectorSubscriptionId = body.connectorSubscriptionId description = body.description systemMetadata = body.systemMetadata type = body.type @@ -513,6 +579,30 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } + /** + * Connector Subscription whose files sync into this directory. Omit for manual uploads. + */ + fun connectorSubscriptionId(connectorSubscriptionId: String?) = + connectorSubscriptionId(JsonField.ofNullable(connectorSubscriptionId)) + + /** + * Alias for calling [Builder.connectorSubscriptionId] with + * `connectorSubscriptionId.orElse(null)`. + */ + fun connectorSubscriptionId(connectorSubscriptionId: Optional) = + connectorSubscriptionId(connectorSubscriptionId.getOrNull()) + + /** + * Sets [Builder.connectorSubscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.connectorSubscriptionId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun connectorSubscriptionId(connectorSubscriptionId: JsonField) = apply { + this.connectorSubscriptionId = connectorSubscriptionId + } + /** Optional description shown to users. */ fun description(description: String?) = description(JsonField.ofNullable(description)) @@ -595,6 +685,7 @@ private constructor( fun build(): Body = Body( checkRequired("name", name), + connectorSubscriptionId, description, systemMetadata, type, @@ -619,6 +710,7 @@ private constructor( } name() + connectorSubscriptionId() description() systemMetadata().ifPresent { it.validate() } type().ifPresent { it.validate() } @@ -642,6 +734,7 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) + + (if (connectorSubscriptionId.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + (systemMetadata.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) @@ -653,6 +746,7 @@ private constructor( return other is Body && name == other.name && + connectorSubscriptionId == other.connectorSubscriptionId && description == other.description && systemMetadata == other.systemMetadata && type == other.type && @@ -660,13 +754,20 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(name, description, systemMetadata, type, additionalProperties) + Objects.hash( + name, + connectorSubscriptionId, + description, + systemMetadata, + type, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "Body{name=$name, description=$description, systemMetadata=$systemMetadata, type=$type, additionalProperties=$additionalProperties}" + "Body{name=$name, connectorSubscriptionId=$connectorSubscriptionId, description=$description, systemMetadata=$systemMetadata, type=$type, additionalProperties=$additionalProperties}" } /** Reserved system-managed metadata. */ diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryCreateParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryCreateParamsTest.kt index 37b810c..dbdd827 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryCreateParamsTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryCreateParamsTest.kt @@ -15,6 +15,7 @@ internal class DirectoryCreateParamsTest { .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("x") + .connectorSubscriptionId("csub-abc123") .description("description") .systemMetadata( DirectoryCreateParams.SystemMetadata.builder() @@ -32,6 +33,7 @@ internal class DirectoryCreateParamsTest { .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("x") + .connectorSubscriptionId("csub-abc123") .description("description") .systemMetadata( DirectoryCreateParams.SystemMetadata.builder() @@ -68,6 +70,7 @@ internal class DirectoryCreateParamsTest { .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("x") + .connectorSubscriptionId("csub-abc123") .description("description") .systemMetadata( DirectoryCreateParams.SystemMetadata.builder() @@ -80,6 +83,7 @@ internal class DirectoryCreateParamsTest { val body = params._body() assertThat(body.name()).isEqualTo("x") + assertThat(body.connectorSubscriptionId()).contains("csub-abc123") assertThat(body.description()).contains("description") assertThat(body.systemMetadata()) .contains( diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/beta/DirectoryServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/beta/DirectoryServiceAsyncTest.kt index 184e0ff..39f3609 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/beta/DirectoryServiceAsyncTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/beta/DirectoryServiceAsyncTest.kt @@ -25,6 +25,7 @@ internal class DirectoryServiceAsyncTest { .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("x") + .connectorSubscriptionId("csub-abc123") .description("description") .systemMetadata( DirectoryCreateParams.SystemMetadata.builder() diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/DirectoryServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/DirectoryServiceTest.kt index 23fc3d8..6580905 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/DirectoryServiceTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/beta/DirectoryServiceTest.kt @@ -25,6 +25,7 @@ internal class DirectoryServiceTest { .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .name("x") + .connectorSubscriptionId("csub-abc123") .description("description") .systemMetadata( DirectoryCreateParams.SystemMetadata.builder() From 44c9bc3d373c35f190e2be2aaf3cb217b131dfee Mon Sep 17 00:00:00 2001 From: Yong Date: Thu, 6 Aug 2026 18:37:49 -0700 Subject: [PATCH 17/28] ci: back-sync as the CI bot, and drop the human-attributed cron (#6) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Since 2026-07-23 every back-sync push has been rejected: ! [remote rejected] production/main -> stlc/from-prod (refusing to allow a GitHub App to create or update workflow .github/workflows/release-doctor.yml without `workflows` permission) The PAT-retirement commits on production put .github/workflows changes into production/main. GITHUB_TOKEN can never carry those back — workflows is not a grantable scope in a permissions: block — so the branch, and with it the whole back-sync, has been stuck for 60 consecutive runs. Push and open the PR with a second CI_BOT app token scoped to this repo and carrying permission-workflows: write, stop persisting GITHUB_TOKEN on origin, and narrow the workflow's own permissions to contents: read, which is all checkout needs. Also drop the schedule: trigger. GitHub attributes cron runs to whoever last edited the schedule: block, so these were running under an unrelated account; the cadence moves to the central dispatcher in run-llama/stainless. Claude-Session: https://claude.ai/code/session_01WfHtqy5RiA44MuSdChGxck Co-authored-by: Claude Opus 5 (1M context) --- .../workflows/stlc-sync-from-production.yml | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/.github/workflows/stlc-sync-from-production.yml b/.github/workflows/stlc-sync-from-production.yml index 5f2a363..42ea09d 100644 --- a/.github/workflows/stlc-sync-from-production.yml +++ b/.github/workflows/stlc-sync-from-production.yml @@ -4,12 +4,16 @@ on: schedule: # A poll, not a release — tune to how often releases/contributions land on # production. Every few hours is plenty; daily is fine. + # + # Retained while the central dispatcher in run-llama/stainless is verified. + # Both fire for now; the concurrency group below collapses the overlap. This + # cron is removed in a follow-up once dispatched runs are confirmed to be + # attributed to the CI bot rather than to a person. - cron: '17 */6 * * *' workflow_dispatch: {} permissions: - contents: write # push the back-sync branch on staging - pull-requests: write # open/merge the back-sync PR on staging + contents: read # checkout only — the push and the PR use the CI_BOT app token concurrency: group: stlc-sync-from-production @@ -21,8 +25,6 @@ jobs: if: github.repository == 'run-llama/llamacloud-prod-java' env: PRODUCTION_REPO: run-llama/llama-parse-java - # The built-in token writes the branch + PR on this (staging) repo. - GH_TOKEN: ${{ github.token }} steps: - name: Generate production-repo token (CI_BOT GitHub App, read-only) id: prod-token @@ -34,10 +36,24 @@ jobs: repositories: llama-parse-java permission-contents: read + - name: Generate staging-repo token (CI_BOT GitHub App) + id: staging-token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ secrets.CI_BOT_APP_ID }} + private-key: ${{ secrets.CI_BOT_PRIVATE_KEY }} + # owner/repositories omitted: the token scopes to this repository. + permission-contents: write + permission-pull-requests: write + # production/main carries .github/workflows changes; GITHUB_TOKEN can + # never push those. + permission-workflows: write + - name: Check out staging uses: actions/checkout@v6 with: fetch-depth: 0 + persist-credentials: false - name: Fetch production main env: @@ -64,10 +80,17 @@ jobs: - name: Push production main to the back-sync branch on staging if: steps.diff.outputs.behind == 'true' - run: git push origin production/main:refs/heads/stlc/from-prod --force + env: + STAGING_REPO_TOKEN: ${{ steps.staging-token.outputs.token }} + run: | + git push \ + "https://x-access-token:${STAGING_REPO_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" \ + production/main:refs/heads/stlc/from-prod --force - name: Open or update the back-sync PR on staging if: steps.diff.outputs.behind == 'true' + env: + GH_TOKEN: ${{ steps.staging-token.outputs.token }} run: | EXISTING_PR=$(gh pr list --head stlc/from-prod --base main --state open --json number --jq '.[0].number') if [ -z "${EXISTING_PR}" ]; then From 0fab12a0787d5cc2c36f2c799c2df8bb84c30b5c Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Fri, 7 Aug 2026 05:37:24 +0000 Subject: [PATCH 18/28] feat(parse,extract): add expand=usage returning credits billed per job (#23709) Stainless-Generated-From: c0c753a198e80b7568101744c73200ad7d959b96 --- .../models/extract/ExtractGetParams.kt | 7 +- .../llamacloud/models/extract/ExtractV2Job.kt | 328 +++++++++++++++++- .../models/parsing/ParsingCancelResponse.kt | 202 ++++++++++- .../models/parsing/ParsingCreateResponse.kt | 202 ++++++++++- .../models/parsing/ParsingGetParams.kt | 7 +- .../models/parsing/ParsingGetResponse.kt | 209 ++++++++++- .../models/parsing/ParsingListResponse.kt | 202 ++++++++++- .../services/async/ExtractServiceAsync.kt | 3 +- .../services/async/ParsingServiceAsync.kt | 3 +- .../services/blocking/ExtractService.kt | 3 +- .../services/blocking/ParsingService.kt | 3 +- .../extract/ExtractV2JobQueryResponseTest.kt | 21 ++ .../models/extract/ExtractV2JobTest.kt | 22 ++ .../parsing/ParsingCancelResponseTest.kt | 4 + .../parsing/ParsingCreateResponseTest.kt | 4 + .../models/parsing/ParsingGetResponseTest.kt | 3 + .../parsing/ParsingListPageResponseTest.kt | 3 + .../models/parsing/ParsingListResponseTest.kt | 4 + 18 files changed, 1214 insertions(+), 16 deletions(-) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractGetParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractGetParams.kt index 1fca656..f307337 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractGetParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractGetParams.kt @@ -14,7 +14,8 @@ import kotlin.jvm.optionals.getOrNull * Get a single extraction job by ID. * * Returns the job status and results when complete. Use `expand=configuration` to include the full - * configuration used, and `expand=extract_metadata` for per-field metadata. + * configuration used, `expand=extract_metadata` for per-field metadata, and `expand=usage` for + * credits billed against the job. */ class ExtractGetParams private constructor( @@ -28,7 +29,7 @@ private constructor( fun jobId(): Optional = Optional.ofNullable(jobId) - /** Additional fields to include: configuration, extract_metadata */ + /** Additional fields to include: configuration, extract_metadata, usage */ fun expand(): Optional> = Optional.ofNullable(expand) fun organizationId(): Optional = Optional.ofNullable(organizationId) @@ -76,7 +77,7 @@ private constructor( /** Alias for calling [Builder.jobId] with `jobId.orElse(null)`. */ fun jobId(jobId: Optional) = jobId(jobId.getOrNull()) - /** Additional fields to include: configuration, extract_metadata */ + /** Additional fields to include: configuration, extract_metadata, usage */ fun expand(expand: List?) = apply { this.expand = expand?.toMutableList() } /** Alias for calling [Builder.expand] with `expand.orElse(null)`. */ diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2Job.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2Job.kt index 04bec40..f145cdf 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2Job.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2Job.kt @@ -46,6 +46,7 @@ private constructor( private val extractMetadata: JsonField, private val extractResult: JsonField, private val metadata: JsonField, + private val usage: JsonField, private val additionalProperties: MutableMap, ) { @@ -77,6 +78,7 @@ private constructor( @ExcludeMissing extractResult: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("usage") @ExcludeMissing usage: JsonField = JsonMissing.of(), ) : this( id, createdAt, @@ -90,6 +92,7 @@ private constructor( extractMetadata, extractResult, metadata, + usage, mutableMapOf(), ) @@ -196,6 +199,17 @@ private constructor( */ fun metadata(): Optional = metadata.getOptional("metadata") + /** + * Usage recorded against an extract job. + * + * A parse job can back several extract jobs, so each of them reports that same parse cost in + * its total. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun usage(): Optional = usage.getOptional("usage") + /** * Returns the raw JSON value of [id]. * @@ -294,6 +308,13 @@ private constructor( */ @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + /** + * Returns the raw JSON value of [usage]. + * + * Unlike [usage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("usage") @ExcludeMissing fun _usage(): JsonField = usage + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -339,6 +360,7 @@ private constructor( private var extractMetadata: JsonField = JsonMissing.of() private var extractResult: JsonField = JsonMissing.of() private var metadata: JsonField = JsonMissing.of() + private var usage: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -355,6 +377,7 @@ private constructor( extractMetadata = extractV2Job.extractMetadata extractResult = extractV2Job.extractResult metadata = extractV2Job.metadata + usage = extractV2Job.usage additionalProperties = extractV2Job.additionalProperties.toMutableMap() } @@ -561,6 +584,25 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** + * Usage recorded against an extract job. + * + * A parse job can back several extract jobs, so each of them reports that same parse cost + * in its total. + */ + fun usage(usage: Usage?) = usage(JsonField.ofNullable(usage)) + + /** Alias for calling [Builder.usage] with `usage.orElse(null)`. */ + fun usage(usage: Optional) = usage(usage.getOrNull()) + + /** + * Sets [Builder.usage] to an arbitrary JSON value. + * + * You should usually call [Builder.usage] with a well-typed [Usage] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun usage(usage: JsonField) = apply { this.usage = usage } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -611,6 +653,7 @@ private constructor( extractMetadata, extractResult, metadata, + usage, additionalProperties.toMutableMap(), ) } @@ -642,6 +685,7 @@ private constructor( extractMetadata().ifPresent { it.validate() } extractResult().ifPresent { it.validate() } metadata().ifPresent { it.validate() } + usage().ifPresent { it.validate() } validated = true } @@ -671,7 +715,8 @@ private constructor( (if (errorMessage.asKnown().isPresent) 1 else 0) + (extractMetadata.asKnown().getOrNull()?.validity() ?: 0) + (extractResult.asKnown().getOrNull()?.validity() ?: 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (usage.asKnown().getOrNull()?.validity() ?: 0) /** * Extracted data conforming to the data_schema. Returns a single object for per_doc, or an @@ -1303,6 +1348,283 @@ private constructor( "Metadata{usage=$usage, additionalProperties=$additionalProperties}" } + /** + * Usage recorded against an extract job. + * + * A parse job can back several extract jobs, so each of them reports that same parse cost in + * its total. + */ + class Usage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val credits: JsonField, + private val extractCredits: JsonField, + private val parseCredits: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credits") @ExcludeMissing credits: JsonField = JsonMissing.of(), + @JsonProperty("extract_credits") + @ExcludeMissing + extractCredits: JsonField = JsonMissing.of(), + @JsonProperty("parse_credits") + @ExcludeMissing + parseCredits: JsonField = JsonMissing.of(), + ) : this(credits, extractCredits, parseCredits, mutableMapOf()) + + /** + * Total credits billed against this job. Null until billing has recorded it. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun credits(): Optional = credits.getOptional("credits") + + /** + * Credits billed for the extraction itself + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun extractCredits(): Optional = extractCredits.getOptional("extract_credits") + + /** + * Credits billed against the parse job backing this extract job + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun parseCredits(): Optional = parseCredits.getOptional("parse_credits") + + /** + * Returns the raw JSON value of [credits]. + * + * Unlike [credits], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credits") @ExcludeMissing fun _credits(): JsonField = credits + + /** + * Returns the raw JSON value of [extractCredits]. + * + * Unlike [extractCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("extract_credits") + @ExcludeMissing + fun _extractCredits(): JsonField = extractCredits + + /** + * Returns the raw JSON value of [parseCredits]. + * + * Unlike [parseCredits], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("parse_credits") + @ExcludeMissing + fun _parseCredits(): JsonField = parseCredits + + @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 [Usage]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Usage]. */ + class Builder internal constructor() { + + private var credits: JsonField = JsonMissing.of() + private var extractCredits: JsonField = JsonMissing.of() + private var parseCredits: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usage: Usage) = apply { + credits = usage.credits + extractCredits = usage.extractCredits + parseCredits = usage.parseCredits + additionalProperties = usage.additionalProperties.toMutableMap() + } + + /** Total credits billed against this job. Null until billing has recorded it. */ + fun credits(credits: Double?) = credits(JsonField.ofNullable(credits)) + + /** + * Alias for [Builder.credits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun credits(credits: Double) = credits(credits as Double?) + + /** Alias for calling [Builder.credits] with `credits.orElse(null)`. */ + fun credits(credits: Optional) = credits(credits.getOrNull()) + + /** + * Sets [Builder.credits] to an arbitrary JSON value. + * + * You should usually call [Builder.credits] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun credits(credits: JsonField) = apply { this.credits = credits } + + /** Credits billed for the extraction itself */ + fun extractCredits(extractCredits: Double?) = + extractCredits(JsonField.ofNullable(extractCredits)) + + /** + * Alias for [Builder.extractCredits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun extractCredits(extractCredits: Double) = extractCredits(extractCredits as Double?) + + /** Alias for calling [Builder.extractCredits] with `extractCredits.orElse(null)`. */ + fun extractCredits(extractCredits: Optional) = + extractCredits(extractCredits.getOrNull()) + + /** + * Sets [Builder.extractCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.extractCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun extractCredits(extractCredits: JsonField) = apply { + this.extractCredits = extractCredits + } + + /** Credits billed against the parse job backing this extract job */ + fun parseCredits(parseCredits: Double?) = + parseCredits(JsonField.ofNullable(parseCredits)) + + /** + * Alias for [Builder.parseCredits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun parseCredits(parseCredits: Double) = parseCredits(parseCredits as Double?) + + /** Alias for calling [Builder.parseCredits] with `parseCredits.orElse(null)`. */ + fun parseCredits(parseCredits: Optional) = + parseCredits(parseCredits.getOrNull()) + + /** + * Sets [Builder.parseCredits] to an arbitrary JSON value. + * + * You should usually call [Builder.parseCredits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun parseCredits(parseCredits: JsonField) = apply { + this.parseCredits = parseCredits + } + + 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 [Usage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Usage = + Usage(credits, extractCredits, parseCredits, 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(): Usage = apply { + if (validated) { + return@apply + } + + credits() + extractCredits() + parseCredits() + 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 (credits.asKnown().isPresent) 1 else 0) + + (if (extractCredits.asKnown().isPresent) 1 else 0) + + (if (parseCredits.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Usage && + credits == other.credits && + extractCredits == other.extractCredits && + parseCredits == other.parseCredits && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(credits, extractCredits, parseCredits, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Usage{credits=$credits, extractCredits=$extractCredits, parseCredits=$parseCredits, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1321,6 +1643,7 @@ private constructor( extractMetadata == other.extractMetadata && extractResult == other.extractResult && metadata == other.metadata && + usage == other.usage && additionalProperties == other.additionalProperties } @@ -1338,6 +1661,7 @@ private constructor( extractMetadata, extractResult, metadata, + usage, additionalProperties, ) } @@ -1345,5 +1669,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ExtractV2Job{id=$id, createdAt=$createdAt, fileInput=$fileInput, projectId=$projectId, status=$status, updatedAt=$updatedAt, configuration=$configuration, configurationId=$configurationId, errorMessage=$errorMessage, extractMetadata=$extractMetadata, extractResult=$extractResult, metadata=$metadata, additionalProperties=$additionalProperties}" + "ExtractV2Job{id=$id, createdAt=$createdAt, fileInput=$fileInput, projectId=$projectId, status=$status, updatedAt=$updatedAt, configuration=$configuration, configurationId=$configurationId, errorMessage=$errorMessage, extractMetadata=$extractMetadata, extractResult=$extractResult, metadata=$metadata, usage=$usage, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCancelResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCancelResponse.kt index 7237fff..eebeb2b 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCancelResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCancelResponse.kt @@ -32,6 +32,7 @@ private constructor( private val name: JsonField, private val tier: JsonField, private val updatedAt: JsonField, + private val usage: JsonField, private val userMetadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -52,6 +53,7 @@ private constructor( @JsonProperty("updated_at") @ExcludeMissing updatedAt: JsonField = JsonMissing.of(), + @JsonProperty("usage") @ExcludeMissing usage: JsonField = JsonMissing.of(), @JsonProperty("user_metadata") @ExcludeMissing userMetadata: JsonField = JsonMissing.of(), @@ -64,6 +66,7 @@ private constructor( name, tier, updatedAt, + usage, userMetadata, mutableMapOf(), ) @@ -132,6 +135,14 @@ private constructor( */ fun updatedAt(): Optional = updatedAt.getOptional("updated_at") + /** + * Usage recorded against a job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun usage(): Optional = usage.getOptional("usage") + /** * Key/value tags associated with this job. * @@ -202,6 +213,13 @@ private constructor( @ExcludeMissing fun _updatedAt(): JsonField = updatedAt + /** + * Returns the raw JSON value of [usage]. + * + * Unlike [usage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("usage") @ExcludeMissing fun _usage(): JsonField = usage + /** * Returns the raw JSON value of [userMetadata]. * @@ -249,6 +267,7 @@ private constructor( private var name: JsonField = JsonMissing.of() private var tier: JsonField = JsonMissing.of() private var updatedAt: JsonField = JsonMissing.of() + private var usage: JsonField = JsonMissing.of() private var userMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -262,6 +281,7 @@ private constructor( name = parsingCancelResponse.name tier = parsingCancelResponse.tier updatedAt = parsingCancelResponse.updatedAt + usage = parsingCancelResponse.usage userMetadata = parsingCancelResponse.userMetadata additionalProperties = parsingCancelResponse.additionalProperties.toMutableMap() } @@ -375,6 +395,20 @@ private constructor( */ fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + /** Usage recorded against a job. */ + fun usage(usage: Usage?) = usage(JsonField.ofNullable(usage)) + + /** Alias for calling [Builder.usage] with `usage.orElse(null)`. */ + fun usage(usage: Optional) = usage(usage.getOrNull()) + + /** + * Sets [Builder.usage] to an arbitrary JSON value. + * + * You should usually call [Builder.usage] with a well-typed [Usage] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun usage(usage: JsonField) = apply { this.usage = usage } + /** Key/value tags associated with this job. */ fun userMetadata(userMetadata: UserMetadata?) = userMetadata(JsonField.ofNullable(userMetadata)) @@ -437,6 +471,7 @@ private constructor( name, tier, updatedAt, + usage, userMetadata, additionalProperties.toMutableMap(), ) @@ -465,6 +500,7 @@ private constructor( name() tier() updatedAt() + usage().ifPresent { it.validate() } userMetadata().ifPresent { it.validate() } validated = true } @@ -492,6 +528,7 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (tier.asKnown().isPresent) 1 else 0) + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (usage.asKnown().getOrNull()?.validity() ?: 0) + (userMetadata.asKnown().getOrNull()?.validity() ?: 0) /** Current job status: PENDING, RUNNING, COMPLETED, FAILED, or CANCELLED */ @@ -649,6 +686,167 @@ private constructor( override fun toString() = value.toString() } + /** Usage recorded against a job. */ + class Usage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val credits: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credits") @ExcludeMissing credits: JsonField = JsonMissing.of() + ) : this(credits, mutableMapOf()) + + /** + * Total credits billed against this job. Null until billing has recorded it. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun credits(): Optional = credits.getOptional("credits") + + /** + * Returns the raw JSON value of [credits]. + * + * Unlike [credits], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credits") @ExcludeMissing fun _credits(): JsonField = credits + + @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 [Usage]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Usage]. */ + class Builder internal constructor() { + + private var credits: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usage: Usage) = apply { + credits = usage.credits + additionalProperties = usage.additionalProperties.toMutableMap() + } + + /** Total credits billed against this job. Null until billing has recorded it. */ + fun credits(credits: Double?) = credits(JsonField.ofNullable(credits)) + + /** + * Alias for [Builder.credits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun credits(credits: Double) = credits(credits as Double?) + + /** Alias for calling [Builder.credits] with `credits.orElse(null)`. */ + fun credits(credits: Optional) = credits(credits.getOrNull()) + + /** + * Sets [Builder.credits] to an arbitrary JSON value. + * + * You should usually call [Builder.credits] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun credits(credits: JsonField) = apply { this.credits = credits } + + 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 [Usage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Usage = Usage(credits, 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(): Usage = apply { + if (validated) { + return@apply + } + + credits() + 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 (credits.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Usage && + credits == other.credits && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(credits, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Usage{credits=$credits, additionalProperties=$additionalProperties}" + } + /** Key/value tags associated with this job. */ class UserMetadata @JsonCreator @@ -772,6 +970,7 @@ private constructor( name == other.name && tier == other.tier && updatedAt == other.updatedAt && + usage == other.usage && userMetadata == other.userMetadata && additionalProperties == other.additionalProperties } @@ -786,6 +985,7 @@ private constructor( name, tier, updatedAt, + usage, userMetadata, additionalProperties, ) @@ -794,5 +994,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ParsingCancelResponse{id=$id, projectId=$projectId, status=$status, createdAt=$createdAt, errorMessage=$errorMessage, name=$name, tier=$tier, updatedAt=$updatedAt, userMetadata=$userMetadata, additionalProperties=$additionalProperties}" + "ParsingCancelResponse{id=$id, projectId=$projectId, status=$status, createdAt=$createdAt, errorMessage=$errorMessage, name=$name, tier=$tier, updatedAt=$updatedAt, usage=$usage, userMetadata=$userMetadata, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateResponse.kt index 4ca39f6..6f5f3c0 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateResponse.kt @@ -32,6 +32,7 @@ private constructor( private val name: JsonField, private val tier: JsonField, private val updatedAt: JsonField, + private val usage: JsonField, private val userMetadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -52,6 +53,7 @@ private constructor( @JsonProperty("updated_at") @ExcludeMissing updatedAt: JsonField = JsonMissing.of(), + @JsonProperty("usage") @ExcludeMissing usage: JsonField = JsonMissing.of(), @JsonProperty("user_metadata") @ExcludeMissing userMetadata: JsonField = JsonMissing.of(), @@ -64,6 +66,7 @@ private constructor( name, tier, updatedAt, + usage, userMetadata, mutableMapOf(), ) @@ -132,6 +135,14 @@ private constructor( */ fun updatedAt(): Optional = updatedAt.getOptional("updated_at") + /** + * Usage recorded against a job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun usage(): Optional = usage.getOptional("usage") + /** * Key/value tags associated with this job. * @@ -202,6 +213,13 @@ private constructor( @ExcludeMissing fun _updatedAt(): JsonField = updatedAt + /** + * Returns the raw JSON value of [usage]. + * + * Unlike [usage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("usage") @ExcludeMissing fun _usage(): JsonField = usage + /** * Returns the raw JSON value of [userMetadata]. * @@ -249,6 +267,7 @@ private constructor( private var name: JsonField = JsonMissing.of() private var tier: JsonField = JsonMissing.of() private var updatedAt: JsonField = JsonMissing.of() + private var usage: JsonField = JsonMissing.of() private var userMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -262,6 +281,7 @@ private constructor( name = parsingCreateResponse.name tier = parsingCreateResponse.tier updatedAt = parsingCreateResponse.updatedAt + usage = parsingCreateResponse.usage userMetadata = parsingCreateResponse.userMetadata additionalProperties = parsingCreateResponse.additionalProperties.toMutableMap() } @@ -375,6 +395,20 @@ private constructor( */ fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + /** Usage recorded against a job. */ + fun usage(usage: Usage?) = usage(JsonField.ofNullable(usage)) + + /** Alias for calling [Builder.usage] with `usage.orElse(null)`. */ + fun usage(usage: Optional) = usage(usage.getOrNull()) + + /** + * Sets [Builder.usage] to an arbitrary JSON value. + * + * You should usually call [Builder.usage] with a well-typed [Usage] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun usage(usage: JsonField) = apply { this.usage = usage } + /** Key/value tags associated with this job. */ fun userMetadata(userMetadata: UserMetadata?) = userMetadata(JsonField.ofNullable(userMetadata)) @@ -437,6 +471,7 @@ private constructor( name, tier, updatedAt, + usage, userMetadata, additionalProperties.toMutableMap(), ) @@ -465,6 +500,7 @@ private constructor( name() tier() updatedAt() + usage().ifPresent { it.validate() } userMetadata().ifPresent { it.validate() } validated = true } @@ -492,6 +528,7 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (tier.asKnown().isPresent) 1 else 0) + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (usage.asKnown().getOrNull()?.validity() ?: 0) + (userMetadata.asKnown().getOrNull()?.validity() ?: 0) /** Current job status: PENDING, RUNNING, COMPLETED, FAILED, or CANCELLED */ @@ -649,6 +686,167 @@ private constructor( override fun toString() = value.toString() } + /** Usage recorded against a job. */ + class Usage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val credits: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credits") @ExcludeMissing credits: JsonField = JsonMissing.of() + ) : this(credits, mutableMapOf()) + + /** + * Total credits billed against this job. Null until billing has recorded it. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun credits(): Optional = credits.getOptional("credits") + + /** + * Returns the raw JSON value of [credits]. + * + * Unlike [credits], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credits") @ExcludeMissing fun _credits(): JsonField = credits + + @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 [Usage]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Usage]. */ + class Builder internal constructor() { + + private var credits: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usage: Usage) = apply { + credits = usage.credits + additionalProperties = usage.additionalProperties.toMutableMap() + } + + /** Total credits billed against this job. Null until billing has recorded it. */ + fun credits(credits: Double?) = credits(JsonField.ofNullable(credits)) + + /** + * Alias for [Builder.credits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun credits(credits: Double) = credits(credits as Double?) + + /** Alias for calling [Builder.credits] with `credits.orElse(null)`. */ + fun credits(credits: Optional) = credits(credits.getOrNull()) + + /** + * Sets [Builder.credits] to an arbitrary JSON value. + * + * You should usually call [Builder.credits] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun credits(credits: JsonField) = apply { this.credits = credits } + + 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 [Usage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Usage = Usage(credits, 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(): Usage = apply { + if (validated) { + return@apply + } + + credits() + 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 (credits.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Usage && + credits == other.credits && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(credits, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Usage{credits=$credits, additionalProperties=$additionalProperties}" + } + /** Key/value tags associated with this job. */ class UserMetadata @JsonCreator @@ -772,6 +970,7 @@ private constructor( name == other.name && tier == other.tier && updatedAt == other.updatedAt && + usage == other.usage && userMetadata == other.userMetadata && additionalProperties == other.additionalProperties } @@ -786,6 +985,7 @@ private constructor( name, tier, updatedAt, + usage, userMetadata, additionalProperties, ) @@ -794,5 +994,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ParsingCreateResponse{id=$id, projectId=$projectId, status=$status, createdAt=$createdAt, errorMessage=$errorMessage, name=$name, tier=$tier, updatedAt=$updatedAt, userMetadata=$userMetadata, additionalProperties=$additionalProperties}" + "ParsingCreateResponse{id=$id, projectId=$projectId, status=$status, createdAt=$createdAt, errorMessage=$errorMessage, name=$name, tier=$tier, updatedAt=$updatedAt, usage=$usage, userMetadata=$userMetadata, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetParams.kt index 085644b..93f0393 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetParams.kt @@ -17,7 +17,8 @@ import kotlin.jvm.optionals.getOrNull * - `text` — plain text output * - `markdown` — markdown output * - `items` — structured page-by-page output - * - `job_metadata` — usage and processing details + * - `job_metadata` — processing details + * - `usage` — credits billed against the job * * Content metadata fields (e.g. `text_content_metadata`) return presigned URLs for downloading * large results. @@ -36,7 +37,7 @@ private constructor( fun jobId(): Optional = Optional.ofNullable(jobId) /** - * Fields to include: text, markdown, items, metadata, forms, job_metadata, + * Fields to include: text, markdown, items, metadata, forms, job_metadata, usage, * text_content_metadata, markdown_content_metadata, items_content_metadata, * metadata_content_metadata, forms_content_metadata, raw_words_content_metadata, * xlsx_content_metadata, output_pdf_content_metadata, images_content_metadata. Metadata fields @@ -95,7 +96,7 @@ private constructor( fun jobId(jobId: Optional) = jobId(jobId.getOrNull()) /** - * Fields to include: text, markdown, items, metadata, forms, job_metadata, + * Fields to include: text, markdown, items, metadata, forms, job_metadata, usage, * text_content_metadata, markdown_content_metadata, items_content_metadata, * metadata_content_metadata, forms_content_metadata, raw_words_content_metadata, * xlsx_content_metadata, output_pdf_content_metadata, images_content_metadata. Metadata diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponse.kt index cfc2dcf..df11bdb 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponse.kt @@ -658,6 +658,7 @@ private constructor( private val name: JsonField, private val tier: JsonField, private val updatedAt: JsonField, + private val usage: JsonField, private val userMetadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -680,6 +681,7 @@ private constructor( @JsonProperty("updated_at") @ExcludeMissing updatedAt: JsonField = JsonMissing.of(), + @JsonProperty("usage") @ExcludeMissing usage: JsonField = JsonMissing.of(), @JsonProperty("user_metadata") @ExcludeMissing userMetadata: JsonField = JsonMissing.of(), @@ -692,6 +694,7 @@ private constructor( name, tier, updatedAt, + usage, userMetadata, mutableMapOf(), ) @@ -760,6 +763,14 @@ private constructor( */ fun updatedAt(): Optional = updatedAt.getOptional("updated_at") + /** + * Usage recorded against a job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun usage(): Optional = usage.getOptional("usage") + /** * Key/value tags associated with this job. * @@ -831,6 +842,13 @@ private constructor( @ExcludeMissing fun _updatedAt(): JsonField = updatedAt + /** + * Returns the raw JSON value of [usage]. + * + * Unlike [usage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("usage") @ExcludeMissing fun _usage(): JsonField = usage + /** * Returns the raw JSON value of [userMetadata]. * @@ -879,6 +897,7 @@ private constructor( private var name: JsonField = JsonMissing.of() private var tier: JsonField = JsonMissing.of() private var updatedAt: JsonField = JsonMissing.of() + private var usage: JsonField = JsonMissing.of() private var userMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -892,6 +911,7 @@ private constructor( name = job.name tier = job.tier updatedAt = job.updatedAt + usage = job.usage userMetadata = job.userMetadata additionalProperties = job.additionalProperties.toMutableMap() } @@ -1015,6 +1035,21 @@ private constructor( this.updatedAt = updatedAt } + /** Usage recorded against a job. */ + fun usage(usage: Usage?) = usage(JsonField.ofNullable(usage)) + + /** Alias for calling [Builder.usage] with `usage.orElse(null)`. */ + fun usage(usage: Optional) = usage(usage.getOrNull()) + + /** + * Sets [Builder.usage] to an arbitrary JSON value. + * + * You should usually call [Builder.usage] with a well-typed [Usage] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun usage(usage: JsonField) = apply { this.usage = usage } + /** Key/value tags associated with this job. */ fun userMetadata(userMetadata: UserMetadata?) = userMetadata(JsonField.ofNullable(userMetadata)) @@ -1077,6 +1112,7 @@ private constructor( name, tier, updatedAt, + usage, userMetadata, additionalProperties.toMutableMap(), ) @@ -1106,6 +1142,7 @@ private constructor( name() tier() updatedAt() + usage().ifPresent { it.validate() } userMetadata().ifPresent { it.validate() } validated = true } @@ -1134,6 +1171,7 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (tier.asKnown().isPresent) 1 else 0) + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (usage.asKnown().getOrNull()?.validity() ?: 0) + (userMetadata.asKnown().getOrNull()?.validity() ?: 0) /** Current job status: PENDING, RUNNING, COMPLETED, FAILED, or CANCELLED */ @@ -1294,6 +1332,173 @@ private constructor( override fun toString() = value.toString() } + /** Usage recorded against a job. */ + class Usage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val credits: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credits") + @ExcludeMissing + credits: JsonField = JsonMissing.of() + ) : this(credits, mutableMapOf()) + + /** + * Total credits billed against this job. Null until billing has recorded it. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun credits(): Optional = credits.getOptional("credits") + + /** + * Returns the raw JSON value of [credits]. + * + * Unlike [credits], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credits") @ExcludeMissing fun _credits(): JsonField = credits + + @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 [Usage]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Usage]. */ + class Builder internal constructor() { + + private var credits: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usage: Usage) = apply { + credits = usage.credits + additionalProperties = usage.additionalProperties.toMutableMap() + } + + /** Total credits billed against this job. Null until billing has recorded it. */ + fun credits(credits: Double?) = credits(JsonField.ofNullable(credits)) + + /** + * Alias for [Builder.credits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun credits(credits: Double) = credits(credits as Double?) + + /** Alias for calling [Builder.credits] with `credits.orElse(null)`. */ + fun credits(credits: Optional) = credits(credits.getOrNull()) + + /** + * Sets [Builder.credits] to an arbitrary JSON value. + * + * You should usually call [Builder.credits] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun credits(credits: JsonField) = apply { this.credits = credits } + + 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 [Usage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Usage = Usage(credits, 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(): Usage = apply { + if (validated) { + return@apply + } + + credits() + 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 (credits.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Usage && + credits == other.credits && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(credits, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Usage{credits=$credits, additionalProperties=$additionalProperties}" + } + /** Key/value tags associated with this job. */ class UserMetadata @JsonCreator @@ -1421,6 +1626,7 @@ private constructor( name == other.name && tier == other.tier && updatedAt == other.updatedAt && + usage == other.usage && userMetadata == other.userMetadata && additionalProperties == other.additionalProperties } @@ -1435,6 +1641,7 @@ private constructor( name, tier, updatedAt, + usage, userMetadata, additionalProperties, ) @@ -1443,7 +1650,7 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Job{id=$id, projectId=$projectId, status=$status, createdAt=$createdAt, errorMessage=$errorMessage, name=$name, tier=$tier, updatedAt=$updatedAt, userMetadata=$userMetadata, additionalProperties=$additionalProperties}" + "Job{id=$id, projectId=$projectId, status=$status, createdAt=$createdAt, errorMessage=$errorMessage, name=$name, tier=$tier, updatedAt=$updatedAt, usage=$usage, userMetadata=$userMetadata, additionalProperties=$additionalProperties}" } /** Per-page form analysis results (one entry per page). */ diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListResponse.kt index f8879cc..22634b6 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListResponse.kt @@ -32,6 +32,7 @@ private constructor( private val name: JsonField, private val tier: JsonField, private val updatedAt: JsonField, + private val usage: JsonField, private val userMetadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -52,6 +53,7 @@ private constructor( @JsonProperty("updated_at") @ExcludeMissing updatedAt: JsonField = JsonMissing.of(), + @JsonProperty("usage") @ExcludeMissing usage: JsonField = JsonMissing.of(), @JsonProperty("user_metadata") @ExcludeMissing userMetadata: JsonField = JsonMissing.of(), @@ -64,6 +66,7 @@ private constructor( name, tier, updatedAt, + usage, userMetadata, mutableMapOf(), ) @@ -132,6 +135,14 @@ private constructor( */ fun updatedAt(): Optional = updatedAt.getOptional("updated_at") + /** + * Usage recorded against a job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun usage(): Optional = usage.getOptional("usage") + /** * Key/value tags associated with this job. * @@ -202,6 +213,13 @@ private constructor( @ExcludeMissing fun _updatedAt(): JsonField = updatedAt + /** + * Returns the raw JSON value of [usage]. + * + * Unlike [usage], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("usage") @ExcludeMissing fun _usage(): JsonField = usage + /** * Returns the raw JSON value of [userMetadata]. * @@ -249,6 +267,7 @@ private constructor( private var name: JsonField = JsonMissing.of() private var tier: JsonField = JsonMissing.of() private var updatedAt: JsonField = JsonMissing.of() + private var usage: JsonField = JsonMissing.of() private var userMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -262,6 +281,7 @@ private constructor( name = parsingListResponse.name tier = parsingListResponse.tier updatedAt = parsingListResponse.updatedAt + usage = parsingListResponse.usage userMetadata = parsingListResponse.userMetadata additionalProperties = parsingListResponse.additionalProperties.toMutableMap() } @@ -375,6 +395,20 @@ private constructor( */ fun updatedAt(updatedAt: JsonField) = apply { this.updatedAt = updatedAt } + /** Usage recorded against a job. */ + fun usage(usage: Usage?) = usage(JsonField.ofNullable(usage)) + + /** Alias for calling [Builder.usage] with `usage.orElse(null)`. */ + fun usage(usage: Optional) = usage(usage.getOrNull()) + + /** + * Sets [Builder.usage] to an arbitrary JSON value. + * + * You should usually call [Builder.usage] with a well-typed [Usage] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun usage(usage: JsonField) = apply { this.usage = usage } + /** Key/value tags associated with this job. */ fun userMetadata(userMetadata: UserMetadata?) = userMetadata(JsonField.ofNullable(userMetadata)) @@ -437,6 +471,7 @@ private constructor( name, tier, updatedAt, + usage, userMetadata, additionalProperties.toMutableMap(), ) @@ -465,6 +500,7 @@ private constructor( name() tier() updatedAt() + usage().ifPresent { it.validate() } userMetadata().ifPresent { it.validate() } validated = true } @@ -492,6 +528,7 @@ private constructor( (if (name.asKnown().isPresent) 1 else 0) + (if (tier.asKnown().isPresent) 1 else 0) + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (usage.asKnown().getOrNull()?.validity() ?: 0) + (userMetadata.asKnown().getOrNull()?.validity() ?: 0) /** Current job status: PENDING, RUNNING, COMPLETED, FAILED, or CANCELLED */ @@ -649,6 +686,167 @@ private constructor( override fun toString() = value.toString() } + /** Usage recorded against a job. */ + class Usage + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val credits: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("credits") @ExcludeMissing credits: JsonField = JsonMissing.of() + ) : this(credits, mutableMapOf()) + + /** + * Total credits billed against this job. Null until billing has recorded it. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun credits(): Optional = credits.getOptional("credits") + + /** + * Returns the raw JSON value of [credits]. + * + * Unlike [credits], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("credits") @ExcludeMissing fun _credits(): JsonField = credits + + @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 [Usage]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Usage]. */ + class Builder internal constructor() { + + private var credits: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(usage: Usage) = apply { + credits = usage.credits + additionalProperties = usage.additionalProperties.toMutableMap() + } + + /** Total credits billed against this job. Null until billing has recorded it. */ + fun credits(credits: Double?) = credits(JsonField.ofNullable(credits)) + + /** + * Alias for [Builder.credits]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun credits(credits: Double) = credits(credits as Double?) + + /** Alias for calling [Builder.credits] with `credits.orElse(null)`. */ + fun credits(credits: Optional) = credits(credits.getOrNull()) + + /** + * Sets [Builder.credits] to an arbitrary JSON value. + * + * You should usually call [Builder.credits] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun credits(credits: JsonField) = apply { this.credits = credits } + + 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 [Usage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Usage = Usage(credits, 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(): Usage = apply { + if (validated) { + return@apply + } + + credits() + 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 (credits.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Usage && + credits == other.credits && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(credits, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Usage{credits=$credits, additionalProperties=$additionalProperties}" + } + /** Key/value tags associated with this job. */ class UserMetadata @JsonCreator @@ -772,6 +970,7 @@ private constructor( name == other.name && tier == other.tier && updatedAt == other.updatedAt && + usage == other.usage && userMetadata == other.userMetadata && additionalProperties == other.additionalProperties } @@ -786,6 +985,7 @@ private constructor( name, tier, updatedAt, + usage, userMetadata, additionalProperties, ) @@ -794,5 +994,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ParsingListResponse{id=$id, projectId=$projectId, status=$status, createdAt=$createdAt, errorMessage=$errorMessage, name=$name, tier=$tier, updatedAt=$updatedAt, userMetadata=$userMetadata, additionalProperties=$additionalProperties}" + "ParsingListResponse{id=$id, projectId=$projectId, status=$status, createdAt=$createdAt, errorMessage=$errorMessage, name=$name, tier=$tier, updatedAt=$updatedAt, usage=$usage, userMetadata=$userMetadata, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsync.kt index dd7216b..f24996d 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsync.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsync.kt @@ -170,7 +170,8 @@ interface ExtractServiceAsync { * Get a single extraction job by ID. * * Returns the job status and results when complete. Use `expand=configuration` to include the - * full configuration used, and `expand=extract_metadata` for per-field metadata. + * full configuration used, `expand=extract_metadata` for per-field metadata, and `expand=usage` + * for credits billed against the job. */ fun get(jobId: String): CompletableFuture = get(jobId, ExtractGetParams.none()) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsync.kt index 8c9439a..780b507 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsync.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsync.kt @@ -124,7 +124,8 @@ interface ParsingServiceAsync { * - `text` — plain text output * - `markdown` — markdown output * - `items` — structured page-by-page output - * - `job_metadata` — usage and processing details + * - `job_metadata` — processing details + * - `usage` — credits billed against the job * * Content metadata fields (e.g. `text_content_metadata`) return presigned URLs for downloading * large results. diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractService.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractService.kt index f277610..9a903ec 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractService.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractService.kt @@ -161,7 +161,8 @@ interface ExtractService { * Get a single extraction job by ID. * * Returns the job status and results when complete. Use `expand=configuration` to include the - * full configuration used, and `expand=extract_metadata` for per-field metadata. + * full configuration used, `expand=extract_metadata` for per-field metadata, and `expand=usage` + * for credits billed against the job. */ fun get(jobId: String): ExtractV2Job = get(jobId, ExtractGetParams.none()) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingService.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingService.kt index 330d76b..b121260 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingService.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingService.kt @@ -118,7 +118,8 @@ interface ParsingService { * - `text` — plain text output * - `markdown` — markdown output * - `items` — structured page-by-page output - * - `job_metadata` — usage and processing details + * - `job_metadata` — processing details + * - `usage` — credits billed against the job * * Content metadata fields (e.g. `text_content_metadata`) return presigned URLs for downloading * large results. diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobQueryResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobQueryResponseTest.kt index c550275..e2d42c8 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobQueryResponseTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobQueryResponseTest.kt @@ -150,6 +150,13 @@ internal class ExtractV2JobQueryResponseTest { ) .build() ) + .usage( + ExtractV2Job.Usage.builder() + .credits(30.0) + .extractCredits(45.0) + .parseCredits(30.0) + .build() + ) .build() ) .nextPageToken("next_page_token") @@ -292,6 +299,13 @@ internal class ExtractV2JobQueryResponseTest { ) .build() ) + .usage( + ExtractV2Job.Usage.builder() + .credits(30.0) + .extractCredits(45.0) + .parseCredits(30.0) + .build() + ) .build() ) assertThat(extractV2JobQueryResponse.nextPageToken()).contains("next_page_token") @@ -438,6 +452,13 @@ internal class ExtractV2JobQueryResponseTest { ) .build() ) + .usage( + ExtractV2Job.Usage.builder() + .credits(30.0) + .extractCredits(45.0) + .parseCredits(30.0) + .build() + ) .build() ) .nextPageToken("next_page_token") diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobTest.kt index 5648f0a..52fad3a 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobTest.kt @@ -142,6 +142,13 @@ internal class ExtractV2JobTest { ) .build() ) + .usage( + ExtractV2Job.Usage.builder() + .credits(30.0) + .extractCredits(45.0) + .parseCredits(30.0) + .build() + ) .build() assertThat(extractV2Job.id()).isEqualTo("ext-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") @@ -277,6 +284,14 @@ internal class ExtractV2JobTest { ) .build() ) + assertThat(extractV2Job.usage()) + .contains( + ExtractV2Job.Usage.builder() + .credits(30.0) + .extractCredits(45.0) + .parseCredits(30.0) + .build() + ) } @Test @@ -411,6 +426,13 @@ internal class ExtractV2JobTest { ) .build() ) + .usage( + ExtractV2Job.Usage.builder() + .credits(30.0) + .extractCredits(45.0) + .parseCredits(30.0) + .build() + ) .build() val roundtrippedExtractV2Job = diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCancelResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCancelResponseTest.kt index 880be72..8b5de33 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCancelResponseTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCancelResponseTest.kt @@ -23,6 +23,7 @@ internal class ParsingCancelResponseTest { .name("Q4 Financial Report") .tier("fast") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .usage(ParsingCancelResponse.Usage.builder().credits(30.0).build()) .userMetadata( ParsingCancelResponse.UserMetadata.builder() .putAdditionalProperty("owner", JsonValue.from("jerry")) @@ -42,6 +43,8 @@ internal class ParsingCancelResponseTest { assertThat(parsingCancelResponse.tier()).contains("fast") assertThat(parsingCancelResponse.updatedAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(parsingCancelResponse.usage()) + .contains(ParsingCancelResponse.Usage.builder().credits(30.0).build()) assertThat(parsingCancelResponse.userMetadata()) .contains( ParsingCancelResponse.UserMetadata.builder() @@ -64,6 +67,7 @@ internal class ParsingCancelResponseTest { .name("Q4 Financial Report") .tier("fast") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .usage(ParsingCancelResponse.Usage.builder().credits(30.0).build()) .userMetadata( ParsingCancelResponse.UserMetadata.builder() .putAdditionalProperty("owner", JsonValue.from("jerry")) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateResponseTest.kt index e4794a8..b2e5a83 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateResponseTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateResponseTest.kt @@ -23,6 +23,7 @@ internal class ParsingCreateResponseTest { .name("Q4 Financial Report") .tier("fast") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .usage(ParsingCreateResponse.Usage.builder().credits(30.0).build()) .userMetadata( ParsingCreateResponse.UserMetadata.builder() .putAdditionalProperty("owner", JsonValue.from("jerry")) @@ -42,6 +43,8 @@ internal class ParsingCreateResponseTest { assertThat(parsingCreateResponse.tier()).contains("fast") assertThat(parsingCreateResponse.updatedAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(parsingCreateResponse.usage()) + .contains(ParsingCreateResponse.Usage.builder().credits(30.0).build()) assertThat(parsingCreateResponse.userMetadata()) .contains( ParsingCreateResponse.UserMetadata.builder() @@ -64,6 +67,7 @@ internal class ParsingCreateResponseTest { .name("Q4 Financial Report") .tier("fast") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .usage(ParsingCreateResponse.Usage.builder().credits(30.0).build()) .userMetadata( ParsingCreateResponse.UserMetadata.builder() .putAdditionalProperty("owner", JsonValue.from("jerry")) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponseTest.kt index df75633..8f17f38 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponseTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponseTest.kt @@ -25,6 +25,7 @@ internal class ParsingGetResponseTest { .name("Q4 Financial Report") .tier("fast") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .usage(ParsingGetResponse.Job.Usage.builder().credits(30.0).build()) .userMetadata( ParsingGetResponse.Job.UserMetadata.builder() .putAdditionalProperty("owner", JsonValue.from("jerry")) @@ -287,6 +288,7 @@ internal class ParsingGetResponseTest { .name("Q4 Financial Report") .tier("fast") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .usage(ParsingGetResponse.Job.Usage.builder().credits(30.0).build()) .userMetadata( ParsingGetResponse.Job.UserMetadata.builder() .putAdditionalProperty("owner", JsonValue.from("jerry")) @@ -552,6 +554,7 @@ internal class ParsingGetResponseTest { .name("Q4 Financial Report") .tier("fast") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .usage(ParsingGetResponse.Job.Usage.builder().credits(30.0).build()) .userMetadata( ParsingGetResponse.Job.UserMetadata.builder() .putAdditionalProperty("owner", JsonValue.from("jerry")) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListPageResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListPageResponseTest.kt index a44908d..e550ae6 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListPageResponseTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListPageResponseTest.kt @@ -25,6 +25,7 @@ internal class ParsingListPageResponseTest { .name("Q4 Financial Report") .tier("fast") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .usage(ParsingListResponse.Usage.builder().credits(30.0).build()) .userMetadata( ParsingListResponse.UserMetadata.builder() .putAdditionalProperty("owner", JsonValue.from("jerry")) @@ -48,6 +49,7 @@ internal class ParsingListPageResponseTest { .name("Q4 Financial Report") .tier("fast") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .usage(ParsingListResponse.Usage.builder().credits(30.0).build()) .userMetadata( ParsingListResponse.UserMetadata.builder() .putAdditionalProperty("owner", JsonValue.from("jerry")) @@ -75,6 +77,7 @@ internal class ParsingListPageResponseTest { .name("Q4 Financial Report") .tier("fast") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .usage(ParsingListResponse.Usage.builder().credits(30.0).build()) .userMetadata( ParsingListResponse.UserMetadata.builder() .putAdditionalProperty("owner", JsonValue.from("jerry")) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListResponseTest.kt index 7f104ab..fc4f2de 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListResponseTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListResponseTest.kt @@ -23,6 +23,7 @@ internal class ParsingListResponseTest { .name("Q4 Financial Report") .tier("fast") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .usage(ParsingListResponse.Usage.builder().credits(30.0).build()) .userMetadata( ParsingListResponse.UserMetadata.builder() .putAdditionalProperty("owner", JsonValue.from("jerry")) @@ -42,6 +43,8 @@ internal class ParsingListResponseTest { assertThat(parsingListResponse.tier()).contains("fast") assertThat(parsingListResponse.updatedAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(parsingListResponse.usage()) + .contains(ParsingListResponse.Usage.builder().credits(30.0).build()) assertThat(parsingListResponse.userMetadata()) .contains( ParsingListResponse.UserMetadata.builder() @@ -64,6 +67,7 @@ internal class ParsingListResponseTest { .name("Q4 Financial Report") .tier("fast") .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .usage(ParsingListResponse.Usage.builder().credits(30.0).build()) .userMetadata( ParsingListResponse.UserMetadata.builder() .putAdditionalProperty("owner", JsonValue.from("jerry")) From 4566f9b6ccdd4607ac1341ecb22b6c6ccd9d115f Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Fri, 7 Aug 2026 12:48:19 +0000 Subject: [PATCH 19/28] Build SDK Stainless-Generated-From: 458d60953e3d208b0ea1e10247099da88b6b9ed0 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8713008..a37b86a 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.4.0) -[![javadoc](https://javadoc.io/badge2/ai.llamaindex.llamacloud/llama-cloud/1.4.0/javadoc.svg)](https://javadoc.io/doc/ai.llamaindex.llamacloud/llama-cloud/1.3.0) +[![javadoc](https://javadoc.io/badge2/ai.llamaindex.llamacloud/llama-cloud/1.4.0/javadoc.svg)](https://javadoc.io/doc/ai.llamaindex.llamacloud/llama-cloud/1.4.0) From 4ec91a6c4f2c6933deef6bf16f4be27e909463ce Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Fri, 7 Aug 2026 16:01:35 +0000 Subject: [PATCH 20/28] docs(parse): shorten the images_to_save field description (#23807) Stainless-Generated-From: 05404ea4d29d0c4b57f83645ba32ee1a147953ab --- .../configurations/ParseV2Parameters.kt | 20 +++++++++++-------- .../models/parsing/ParsingCreateParams.kt | 20 +++++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-) 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 c02ef48..134d4f2 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 @@ -3165,9 +3165,9 @@ private constructor( granularBboxes.getOptional("granular_bboxes") /** - * Image categories to extract and save. Options: 'screenshot' (full page renders useful for - * visual QA), 'embedded' (images found within the document), 'layout' (cropped regions from - * layout detection like figures and diagrams). Empty list saves no images + * Image categories to save: 'screenshot' (full page renders), 'embedded' (images found + * within the document), 'layout' (cropped figures and diagrams). Defaults to saving + * 'layout' when the output links to cropped images; pass [] to save none * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -3440,12 +3440,16 @@ private constructor( } /** - * Image categories to extract and save. Options: 'screenshot' (full page renders useful - * for visual QA), 'embedded' (images found within the document), 'layout' (cropped - * regions from layout detection like figures and diagrams). Empty list saves no images + * Image categories to save: 'screenshot' (full page renders), 'embedded' (images found + * within the document), 'layout' (cropped figures and diagrams). Defaults to saving + * 'layout' when the output links to cropped images; pass [] to save none */ - fun imagesToSave(imagesToSave: List) = - imagesToSave(JsonField.of(imagesToSave)) + fun imagesToSave(imagesToSave: List?) = + imagesToSave(JsonField.ofNullable(imagesToSave)) + + /** Alias for calling [Builder.imagesToSave] with `imagesToSave.orElse(null)`. */ + fun imagesToSave(imagesToSave: Optional>) = + imagesToSave(imagesToSave.getOrNull()) /** * Sets [Builder.imagesToSave] to an arbitrary JSON value. diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt index 1be9703..1268e80 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt @@ -4370,9 +4370,9 @@ private constructor( granularBboxes.getOptional("granular_bboxes") /** - * Image categories to extract and save. Options: 'screenshot' (full page renders useful for - * visual QA), 'embedded' (images found within the document), 'layout' (cropped regions from - * layout detection like figures and diagrams). Empty list saves no images + * Image categories to save: 'screenshot' (full page renders), 'embedded' (images found + * within the document), 'layout' (cropped figures and diagrams). Defaults to saving + * 'layout' when the output links to cropped images; pass [] to save none * * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). @@ -4645,12 +4645,16 @@ private constructor( } /** - * Image categories to extract and save. Options: 'screenshot' (full page renders useful - * for visual QA), 'embedded' (images found within the document), 'layout' (cropped - * regions from layout detection like figures and diagrams). Empty list saves no images + * Image categories to save: 'screenshot' (full page renders), 'embedded' (images found + * within the document), 'layout' (cropped figures and diagrams). Defaults to saving + * 'layout' when the output links to cropped images; pass [] to save none */ - fun imagesToSave(imagesToSave: List) = - imagesToSave(JsonField.of(imagesToSave)) + fun imagesToSave(imagesToSave: List?) = + imagesToSave(JsonField.ofNullable(imagesToSave)) + + /** Alias for calling [Builder.imagesToSave] with `imagesToSave.orElse(null)`. */ + fun imagesToSave(imagesToSave: Optional>) = + imagesToSave(imagesToSave.getOrNull()) /** * Sets [Builder.imagesToSave] to an arbitrary JSON value. From 44e227e605f9d1e3e327307d0ed56ae1dcfb4c88 Mon Sep 17 00:00:00 2001 From: Yong Date: Fri, 7 Aug 2026 09:36:35 -0700 Subject: [PATCH 21/28] ci: drop the back-sync cron now that the bot dispatcher is proven (#8) Verified 2026-08-07 by running both trigger paths side by side on this repo: workflow_dispatch runs are attributed to llama-org-ci-bot[bot], scheduled runs to a maintainer who has left the org. The dispatcher in run-llama/stainless covers this workflow, so the cron only produced a duplicate run under a departed user's name. --- .github/workflows/stlc-sync-from-production.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/stlc-sync-from-production.yml b/.github/workflows/stlc-sync-from-production.yml index 42ea09d..5fd2b2b 100644 --- a/.github/workflows/stlc-sync-from-production.yml +++ b/.github/workflows/stlc-sync-from-production.yml @@ -1,15 +1,11 @@ name: Sync from production on: - schedule: - # A poll, not a release — tune to how often releases/contributions land on - # production. Every few hours is plenty; daily is fine. - # - # Retained while the central dispatcher in run-llama/stainless is verified. - # Both fire for now; the concurrency group below collapses the overlap. This - # cron is removed in a follow-up once dispatched runs are confirmed to be - # attributed to the CI bot rather than to a person. - - cron: '17 */6 * * *' + # Cadence lives in run-llama/stainless .github/workflows/stlc-dispatch-backsync.yml, + # which dispatches this workflow with a CI_BOT App installation token. A `schedule:` + # here would fire it a second time and attribute that run to whoever last edited the + # cron. Verified 2026-08-07 by running both paths side by side: dispatched runs show + # llama-org-ci-bot[bot], scheduled runs showed a maintainer who had left the org. workflow_dispatch: {} permissions: From 211f3ad930ab6ac915bd79914335198e55e5d82c Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Fri, 7 Aug 2026 22:21:24 +0000 Subject: [PATCH 22/28] LI-8754: surface split GA, webhook configs, v2 cancel and parse versions in the SDKs Stainless-Generated-From: fb6401d426ad2da859e1be1764a8caeb38084a7a --- .stats.yml | 2 +- .../llamacloud/client/LlamaCloudClient.kt | 10 + .../client/LlamaCloudClientAsync.kt | 10 + .../client/LlamaCloudClientAsyncImpl.kt | 28 + .../llamacloud/client/LlamaCloudClientImpl.kt | 26 + .../models/batches/BatchCancelParams.kt | 273 ++ .../models/batches/BatchCancelResponse.kt | 1867 +++++++++++++ .../models/classify/ClassifyCancelParams.kt | 273 ++ .../models/classify/ClassifyCancelResponse.kt | 1054 ++++++++ .../models/extract/ExtractCancelParams.kt | 273 ++ .../parsing/ParsingListVersionsParams.kt | 172 ++ .../parsing/ParsingListVersionsResponse.kt | 1441 ++++++++++ .../DocumentGetStatusCountsParams.kt | 267 ++ .../DocumentGetStatusCountsResponse.kt | 508 ++++ .../models/split/SplitCancelParams.kt | 274 ++ .../models/split/SplitCancelResponse.kt | 1253 +++++++++ .../models/split/SplitCreateParams.kt | 2388 +++++++++++++++++ .../models/split/SplitCreateResponse.kt | 1253 +++++++++ .../models/split/SplitDeleteParams.kt | 268 ++ .../models/split/SplitDeleteResponse.kt | 121 + .../llamacloud/models/split/SplitGetParams.kt | 232 ++ .../models/split/SplitGetResponse.kt | 1253 +++++++++ .../llamacloud/models/split/SplitListPage.kt | 130 + .../models/split/SplitListPageAsync.kt | 145 + .../models/split/SplitListPageResponse.kt | 303 +++ .../models/split/SplitListParams.kt | 500 ++++ .../models/split/SplitListResponse.kt | 1253 +++++++++ .../webhookconfigs/WebhookConfigCreate.kt | 997 +++++++ .../WebhookConfigCreateParams.kt | 256 ++ .../WebhookConfigDeleteParams.kt | 271 ++ .../webhookconfigs/WebhookConfigListParams.kt | 208 ++ .../webhookconfigs/WebhookConfigResponse.kt | 1183 ++++++++ .../WebhookConfigRetrieveParams.kt | 228 ++ .../WebhookConfigUpdateParams.kt | 1442 ++++++++++ .../services/async/BatchServiceAsync.kt | 83 + .../services/async/BatchServiceAsyncImpl.kt | 43 + .../services/async/ClassifyServiceAsync.kt | 83 + .../async/ClassifyServiceAsyncImpl.kt | 43 + .../services/async/ExtractServiceAsync.kt | 77 + .../services/async/ExtractServiceAsyncImpl.kt | 42 + .../services/async/ParsingServiceAsync.kt | 48 + .../services/async/ParsingServiceAsyncImpl.kt | 39 + .../services/async/SplitServiceAsync.kt | 346 +++ .../services/async/SplitServiceAsyncImpl.kt | 264 ++ .../async/WebhookConfigServiceAsync.kt | 371 +++ .../async/WebhookConfigServiceAsyncImpl.kt | 245 ++ .../async/pipelines/DocumentServiceAsync.kt | 103 + .../pipelines/DocumentServiceAsyncImpl.kt | 51 + .../services/blocking/BatchService.kt | 81 + .../services/blocking/BatchServiceImpl.kt | 40 + .../services/blocking/ClassifyService.kt | 81 + .../services/blocking/ClassifyServiceImpl.kt | 40 + .../services/blocking/ExtractService.kt | 76 + .../services/blocking/ExtractServiceImpl.kt | 36 + .../services/blocking/ParsingService.kt | 49 + .../services/blocking/ParsingServiceImpl.kt | 36 + .../services/blocking/SplitService.kt | 339 +++ .../services/blocking/SplitServiceImpl.kt | 241 ++ .../services/blocking/WebhookConfigService.kt | 371 +++ .../blocking/WebhookConfigServiceImpl.kt | 227 ++ .../blocking/pipelines/DocumentService.kt | 104 + .../blocking/pipelines/DocumentServiceImpl.kt | 48 + .../models/batches/BatchCancelParamsTest.kt | 57 + .../models/batches/BatchCancelResponseTest.kt | 125 + .../classify/ClassifyCancelParamsTest.kt | 57 + .../classify/ClassifyCancelResponseTest.kt | 153 ++ .../models/extract/ExtractCancelParamsTest.kt | 57 + .../parsing/ParsingListVersionsParamsTest.kt | 13 + .../ParsingListVersionsResponseTest.kt | 51 + .../DocumentGetStatusCountsParamsTest.kt | 66 + .../DocumentGetStatusCountsResponseTest.kt | 71 + .../models/split/SplitCancelParamsTest.kt | 57 + .../models/split/SplitCancelResponseTest.kt | 136 + .../models/split/SplitCreateParamsTest.kt | 229 ++ .../models/split/SplitCreateResponseTest.kt | 136 + .../models/split/SplitDeleteParamsTest.kt | 57 + .../models/split/SplitDeleteResponseTest.kt | 30 + .../models/split/SplitGetParamsTest.kt | 57 + .../models/split/SplitGetResponseTest.kt | 136 + .../models/split/SplitListPageResponseTest.kt | 148 + .../models/split/SplitListParamsTest.kt | 68 + .../models/split/SplitListResponseTest.kt | 136 + .../WebhookConfigCreateParamsTest.kt | 150 ++ .../webhookconfigs/WebhookConfigCreateTest.kt | 73 + .../WebhookConfigDeleteParamsTest.kt | 57 + .../WebhookConfigListParamsTest.kt | 46 + .../WebhookConfigResponseTest.kt | 82 + .../WebhookConfigRetrieveParamsTest.kt | 57 + .../WebhookConfigUpdateParamsTest.kt | 118 + .../services/async/BatchServiceAsyncTest.kt | 20 + .../async/ClassifyServiceAsyncTest.kt | 20 + .../services/async/ExtractServiceAsyncTest.kt | 20 + .../services/async/ParsingServiceAsyncTest.kt | 12 + .../services/async/SplitServiceAsyncTest.kt | 143 + .../async/WebhookConfigServiceAsyncTest.kt | 135 + .../pipelines/DocumentServiceAsyncTest.kt | 21 + .../services/blocking/BatchServiceTest.kt | 19 + .../services/blocking/ClassifyServiceTest.kt | 19 + .../services/blocking/ExtractServiceTest.kt | 19 + .../services/blocking/ParsingServiceTest.kt | 11 + .../services/blocking/SplitServiceTest.kt | 138 + .../blocking/WebhookConfigServiceTest.kt | 128 + .../blocking/pipelines/DocumentServiceTest.kt | 20 + .../proguard/ProGuardCompatibilityTest.kt | 2 + 104 files changed, 26918 insertions(+), 1 deletion(-) create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCancelParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCancelResponse.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCancelParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCancelResponse.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractCancelParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsResponse.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/pipelines/documents/DocumentGetStatusCountsParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/pipelines/documents/DocumentGetStatusCountsResponse.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitCancelParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitCancelResponse.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitCreateParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitCreateResponse.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitDeleteParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitDeleteResponse.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitGetParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitGetResponse.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitListPage.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitListPageAsync.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitListPageResponse.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitListParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitListResponse.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigCreate.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigCreateParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigDeleteParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigListParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigResponse.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigRetrieveParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigUpdateParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/SplitServiceAsync.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/SplitServiceAsyncImpl.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/WebhookConfigServiceAsync.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/WebhookConfigServiceAsyncImpl.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/SplitService.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/SplitServiceImpl.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/WebhookConfigService.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/WebhookConfigServiceImpl.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCancelParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCancelResponseTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCancelParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCancelResponseTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractCancelParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsResponseTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/documents/DocumentGetStatusCountsParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/documents/DocumentGetStatusCountsResponseTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitCancelParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitCancelResponseTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitCreateParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitCreateResponseTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitDeleteParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitDeleteResponseTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitGetParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitGetResponseTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitListPageResponseTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitListParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitListResponseTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigCreateParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigCreateTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigDeleteParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigListParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigResponseTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigRetrieveParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigUpdateParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/SplitServiceAsyncTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/WebhookConfigServiceAsyncTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/SplitServiceTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/WebhookConfigServiceTest.kt diff --git a/.stats.yml b/.stats.yml index 97e2fbf..953d452 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 131 +configured_endpoints: 146 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 3e7677a..304e7fd 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 @@ -17,6 +17,8 @@ import ai.llamaindex.llamacloud.services.blocking.PipelineService import ai.llamaindex.llamacloud.services.blocking.ProjectService import ai.llamaindex.llamacloud.services.blocking.RetrieverService import ai.llamaindex.llamacloud.services.blocking.SheetService +import ai.llamaindex.llamacloud.services.blocking.SplitService +import ai.llamaindex.llamacloud.services.blocking.WebhookConfigService import java.util.function.Consumer /** @@ -59,6 +61,8 @@ interface LlamaCloudClient { fun sheets(): SheetService + fun split(): SplitService + fun parsing(): ParsingService fun extract(): ExtractService @@ -71,6 +75,8 @@ interface LlamaCloudClient { fun configurations(): ConfigurationService + fun webhookConfigs(): WebhookConfigService + fun projects(): ProjectService fun dataSinks(): DataSinkService @@ -110,6 +116,8 @@ interface LlamaCloudClient { fun sheets(): SheetService.WithRawResponse + fun split(): SplitService.WithRawResponse + fun parsing(): ParsingService.WithRawResponse fun extract(): ExtractService.WithRawResponse @@ -122,6 +130,8 @@ interface LlamaCloudClient { fun configurations(): ConfigurationService.WithRawResponse + fun webhookConfigs(): WebhookConfigService.WithRawResponse + fun projects(): ProjectService.WithRawResponse fun dataSinks(): DataSinkService.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 32487c4..565d45d 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 @@ -17,6 +17,8 @@ import ai.llamaindex.llamacloud.services.async.PipelineServiceAsync import ai.llamaindex.llamacloud.services.async.ProjectServiceAsync import ai.llamaindex.llamacloud.services.async.RetrieverServiceAsync import ai.llamaindex.llamacloud.services.async.SheetServiceAsync +import ai.llamaindex.llamacloud.services.async.SplitServiceAsync +import ai.llamaindex.llamacloud.services.async.WebhookConfigServiceAsync import java.util.function.Consumer /** @@ -59,6 +61,8 @@ interface LlamaCloudClientAsync { fun sheets(): SheetServiceAsync + fun split(): SplitServiceAsync + fun parsing(): ParsingServiceAsync fun extract(): ExtractServiceAsync @@ -71,6 +75,8 @@ interface LlamaCloudClientAsync { fun configurations(): ConfigurationServiceAsync + fun webhookConfigs(): WebhookConfigServiceAsync + fun projects(): ProjectServiceAsync fun dataSinks(): DataSinkServiceAsync @@ -114,6 +120,8 @@ interface LlamaCloudClientAsync { fun sheets(): SheetServiceAsync.WithRawResponse + fun split(): SplitServiceAsync.WithRawResponse + fun parsing(): ParsingServiceAsync.WithRawResponse fun extract(): ExtractServiceAsync.WithRawResponse @@ -126,6 +134,8 @@ interface LlamaCloudClientAsync { fun configurations(): ConfigurationServiceAsync.WithRawResponse + fun webhookConfigs(): WebhookConfigServiceAsync.WithRawResponse + fun projects(): ProjectServiceAsync.WithRawResponse fun dataSinks(): DataSinkServiceAsync.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 84dfcbc..3587fb4 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 @@ -32,6 +32,10 @@ import ai.llamaindex.llamacloud.services.async.RetrieverServiceAsync import ai.llamaindex.llamacloud.services.async.RetrieverServiceAsyncImpl import ai.llamaindex.llamacloud.services.async.SheetServiceAsync import ai.llamaindex.llamacloud.services.async.SheetServiceAsyncImpl +import ai.llamaindex.llamacloud.services.async.SplitServiceAsync +import ai.llamaindex.llamacloud.services.async.SplitServiceAsyncImpl +import ai.llamaindex.llamacloud.services.async.WebhookConfigServiceAsync +import ai.llamaindex.llamacloud.services.async.WebhookConfigServiceAsyncImpl import java.util.function.Consumer class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : LlamaCloudClientAsync { @@ -57,6 +61,10 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam SheetServiceAsyncImpl(clientOptionsWithUserAgent) } + private val split: SplitServiceAsync by lazy { + SplitServiceAsyncImpl(clientOptionsWithUserAgent) + } + private val parsing: ParsingServiceAsync by lazy { ParsingServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -81,6 +89,10 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam ConfigurationServiceAsyncImpl(clientOptionsWithUserAgent) } + private val webhookConfigs: WebhookConfigServiceAsync by lazy { + WebhookConfigServiceAsyncImpl(clientOptionsWithUserAgent) + } + private val projects: ProjectServiceAsync by lazy { ProjectServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -114,6 +126,8 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam override fun sheets(): SheetServiceAsync = sheets + override fun split(): SplitServiceAsync = split + override fun parsing(): ParsingServiceAsync = parsing override fun extract(): ExtractServiceAsync = extract @@ -126,6 +140,8 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam override fun configurations(): ConfigurationServiceAsync = configurations + override fun webhookConfigs(): WebhookConfigServiceAsync = webhookConfigs + override fun projects(): ProjectServiceAsync = projects override fun dataSinks(): DataSinkServiceAsync = dataSinks @@ -151,6 +167,10 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam SheetServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val split: SplitServiceAsync.WithRawResponse by lazy { + SplitServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + private val parsing: ParsingServiceAsync.WithRawResponse by lazy { ParsingServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -175,6 +195,10 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam ConfigurationServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val webhookConfigs: WebhookConfigServiceAsync.WithRawResponse by lazy { + WebhookConfigServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + private val projects: ProjectServiceAsync.WithRawResponse by lazy { ProjectServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -210,6 +234,8 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam override fun sheets(): SheetServiceAsync.WithRawResponse = sheets + override fun split(): SplitServiceAsync.WithRawResponse = split + override fun parsing(): ParsingServiceAsync.WithRawResponse = parsing override fun extract(): ExtractServiceAsync.WithRawResponse = extract @@ -222,6 +248,8 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam override fun configurations(): ConfigurationServiceAsync.WithRawResponse = configurations + override fun webhookConfigs(): WebhookConfigServiceAsync.WithRawResponse = webhookConfigs + override fun projects(): ProjectServiceAsync.WithRawResponse = projects override fun dataSinks(): DataSinkServiceAsync.WithRawResponse = dataSinks 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 df8f4db..891f102 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 @@ -32,6 +32,10 @@ import ai.llamaindex.llamacloud.services.blocking.RetrieverService import ai.llamaindex.llamacloud.services.blocking.RetrieverServiceImpl import ai.llamaindex.llamacloud.services.blocking.SheetService import ai.llamaindex.llamacloud.services.blocking.SheetServiceImpl +import ai.llamaindex.llamacloud.services.blocking.SplitService +import ai.llamaindex.llamacloud.services.blocking.SplitServiceImpl +import ai.llamaindex.llamacloud.services.blocking.WebhookConfigService +import ai.llamaindex.llamacloud.services.blocking.WebhookConfigServiceImpl import java.util.function.Consumer class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaCloudClient { @@ -55,6 +59,8 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou private val sheets: SheetService by lazy { SheetServiceImpl(clientOptionsWithUserAgent) } + private val split: SplitService by lazy { SplitServiceImpl(clientOptionsWithUserAgent) } + private val parsing: ParsingService by lazy { ParsingServiceImpl(clientOptionsWithUserAgent) } private val extract: ExtractService by lazy { ExtractServiceImpl(clientOptionsWithUserAgent) } @@ -73,6 +79,10 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou ConfigurationServiceImpl(clientOptionsWithUserAgent) } + private val webhookConfigs: WebhookConfigService by lazy { + WebhookConfigServiceImpl(clientOptionsWithUserAgent) + } + private val projects: ProjectService by lazy { ProjectServiceImpl(clientOptionsWithUserAgent) } private val dataSinks: DataSinkService by lazy { @@ -104,6 +114,8 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou override fun sheets(): SheetService = sheets + override fun split(): SplitService = split + override fun parsing(): ParsingService = parsing override fun extract(): ExtractService = extract @@ -116,6 +128,8 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou override fun configurations(): ConfigurationService = configurations + override fun webhookConfigs(): WebhookConfigService = webhookConfigs + override fun projects(): ProjectService = projects override fun dataSinks(): DataSinkService = dataSinks @@ -141,6 +155,10 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou SheetServiceImpl.WithRawResponseImpl(clientOptions) } + private val split: SplitService.WithRawResponse by lazy { + SplitServiceImpl.WithRawResponseImpl(clientOptions) + } + private val parsing: ParsingService.WithRawResponse by lazy { ParsingServiceImpl.WithRawResponseImpl(clientOptions) } @@ -165,6 +183,10 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou ConfigurationServiceImpl.WithRawResponseImpl(clientOptions) } + private val webhookConfigs: WebhookConfigService.WithRawResponse by lazy { + WebhookConfigServiceImpl.WithRawResponseImpl(clientOptions) + } + private val projects: ProjectService.WithRawResponse by lazy { ProjectServiceImpl.WithRawResponseImpl(clientOptions) } @@ -200,6 +222,8 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou override fun sheets(): SheetService.WithRawResponse = sheets + override fun split(): SplitService.WithRawResponse = split + override fun parsing(): ParsingService.WithRawResponse = parsing override fun extract(): ExtractService.WithRawResponse = extract @@ -212,6 +236,8 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou override fun configurations(): ConfigurationService.WithRawResponse = configurations + override fun webhookConfigs(): WebhookConfigService.WithRawResponse = webhookConfigs + override fun projects(): ProjectService.WithRawResponse = projects override fun dataSinks(): DataSinkService.WithRawResponse = dataSinks diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCancelParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCancelParams.kt new file mode 100644 index 0000000..c2f9441 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCancelParams.kt @@ -0,0 +1,273 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.batches + +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 + +/** + * Cancel a running batch. + * + * Returns immediately; the batch reaches `CANCELLED` once processing stops. Files that already + * finished keep their results. A batch in a terminal status cannot be cancelled. + */ +class BatchCancelParams +private constructor( + private val batchId: String?, + private val organizationId: String?, + private val projectId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun batchId(): Optional = Optional.ofNullable(batchId) + + 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(): BatchCancelParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [BatchCancelParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BatchCancelParams]. */ + class Builder internal constructor() { + + private var batchId: 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(batchCancelParams: BatchCancelParams) = apply { + batchId = batchCancelParams.batchId + organizationId = batchCancelParams.organizationId + projectId = batchCancelParams.projectId + additionalHeaders = batchCancelParams.additionalHeaders.toBuilder() + additionalQueryParams = batchCancelParams.additionalQueryParams.toBuilder() + additionalBodyProperties = batchCancelParams.additionalBodyProperties.toMutableMap() + } + + fun batchId(batchId: String?) = apply { this.batchId = batchId } + + /** Alias for calling [Builder.batchId] with `batchId.orElse(null)`. */ + fun batchId(batchId: Optional) = batchId(batchId.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 [BatchCancelParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): BatchCancelParams = + BatchCancelParams( + batchId, + organizationId, + projectId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> batchId ?: "" + 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 BatchCancelParams && + batchId == other.batchId && + organizationId == other.organizationId && + projectId == other.projectId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + batchId, + organizationId, + projectId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "BatchCancelParams{batchId=$batchId, organizationId=$organizationId, projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCancelResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCancelResponse.kt new file mode 100644 index 0000000..14de9f2 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCancelResponse.kt @@ -0,0 +1,1867 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.batches + +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.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.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * A top-level batch. + * + * Example: { "id": "bat-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "project_id": + * "prj-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "source_directory_id": + * "dir-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "config": { "job": { "type": "parse_v2", + * "configuration_id": "cfg-PARSE_AGENTIC" } }, "status": "COMPLETED", "results": + * [ { "source_directory_file_id": "dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", "job_reference": { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" }, "error_message": null } ] + * } + * + * Batch-level ``FAILED`` means the orchestration failed and cannot provide a reliable per-file + * result set. ``results`` is only populated when explicitly requested with ``expand=results`` and + * may be ``null`` while a batch is still running. + */ +class BatchCancelResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val config: JsonField, + private val projectId: JsonField, + private val sourceDirectoryId: JsonField, + private val status: JsonField, + private val createdAt: JsonField, + private val results: 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("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), + @JsonProperty("source_directory_id") + @ExcludeMissing + sourceDirectoryId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("results") + @ExcludeMissing + results: JsonField> = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this( + id, + config, + projectId, + sourceDirectoryId, + status, + createdAt, + results, + updatedAt, + mutableMapOf(), + ) + + /** + * Unique identifier + * + * @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") + + /** + * Batch configuration snapshot. + * + * @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") + + /** + * Project this batch 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") + + /** + * Directory being processed. + * + * @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 sourceDirectoryId(): String = sourceDirectoryId.getRequired("source_directory_id") + + /** + * Current batch 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(): Status = status.getRequired("status") + + /** + * Creation datetime + * + * @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") + + /** + * Expanded per-file result mappings. Null unless requested with expand=results, or while the + * batch is still running. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun results(): Optional> = results.getOptional("results") + + /** + * Update datetime + * + * @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 [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 [sourceDirectoryId]. + * + * Unlike [sourceDirectoryId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("source_directory_id") + @ExcludeMissing + fun _sourceDirectoryId(): JsonField = sourceDirectoryId + + /** + * 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 [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 [results]. + * + * Unlike [results], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("results") @ExcludeMissing fun _results(): JsonField> = results + + /** + * 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 [BatchCancelResponse]. + * + * The following fields are required: + * ```java + * .id() + * .config() + * .projectId() + * .sourceDirectoryId() + * .status() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BatchCancelResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var config: JsonField? = null + private var projectId: JsonField? = null + private var sourceDirectoryId: JsonField? = null + private var status: JsonField? = null + private var createdAt: JsonField = JsonMissing.of() + private var results: JsonField>? = null + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(batchCancelResponse: BatchCancelResponse) = apply { + id = batchCancelResponse.id + config = batchCancelResponse.config + projectId = batchCancelResponse.projectId + sourceDirectoryId = batchCancelResponse.sourceDirectoryId + status = batchCancelResponse.status + createdAt = batchCancelResponse.createdAt + results = batchCancelResponse.results.map { it.toMutableList() } + updatedAt = batchCancelResponse.updatedAt + additionalProperties = batchCancelResponse.additionalProperties.toMutableMap() + } + + /** Unique identifier */ + 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 } + + /** Batch configuration snapshot. */ + 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 } + + /** Project this batch 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 } + + /** Directory being processed. */ + fun sourceDirectoryId(sourceDirectoryId: String) = + sourceDirectoryId(JsonField.of(sourceDirectoryId)) + + /** + * Sets [Builder.sourceDirectoryId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceDirectoryId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun sourceDirectoryId(sourceDirectoryId: JsonField) = apply { + this.sourceDirectoryId = sourceDirectoryId + } + + /** Current batch status. */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** Creation datetime */ + 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 } + + /** + * Expanded per-file result mappings. Null unless requested with expand=results, or while + * the batch is still running. + */ + fun results(results: List?) = results(JsonField.ofNullable(results)) + + /** Alias for calling [Builder.results] with `results.orElse(null)`. */ + fun results(results: Optional>) = results(results.getOrNull()) + + /** + * Sets [Builder.results] to an arbitrary JSON value. + * + * You should usually call [Builder.results] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun results(results: JsonField>) = apply { + this.results = results.map { it.toMutableList() } + } + + /** + * Adds a single [Result] to [results]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResult(result: Result) = apply { + results = + (results ?: JsonField.of(mutableListOf())).also { + checkKnown("results", it).add(result) + } + } + + /** Update datetime */ + 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 [BatchCancelResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .config() + * .projectId() + * .sourceDirectoryId() + * .status() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BatchCancelResponse = + BatchCancelResponse( + checkRequired("id", id), + checkRequired("config", config), + checkRequired("projectId", projectId), + checkRequired("sourceDirectoryId", sourceDirectoryId), + checkRequired("status", status), + createdAt, + (results ?: JsonMissing.of()).map { it.toImmutable() }, + 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(): BatchCancelResponse = apply { + if (validated) { + return@apply + } + + id() + config().validate() + projectId() + sourceDirectoryId() + status().validate() + createdAt() + results().ifPresent { it.forEach { 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) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (sourceDirectoryId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (results.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + /** Batch configuration snapshot. */ + class Config + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val job: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("job") @ExcludeMissing job: JsonField = JsonMissing.of() + ) : this(job, mutableMapOf()) + + /** + * Job to create for each file in the source directory. + * + * @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 job(): Job = job.getRequired("job") + + /** + * Returns the raw JSON value of [job]. + * + * Unlike [job], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("job") @ExcludeMissing fun _job(): JsonField = job + + @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]. + * + * The following fields are required: + * ```java + * .job() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Config]. */ + class Builder internal constructor() { + + private var job: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(config: Config) = apply { + job = config.job + additionalProperties = config.additionalProperties.toMutableMap() + } + + /** Job to create for each file in the source directory. */ + fun job(job: Job) = job(JsonField.of(job)) + + /** + * Sets [Builder.job] to an arbitrary JSON value. + * + * You should usually call [Builder.job] with a well-typed [Job] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun job(job: JsonField) = apply { this.job = job } + + 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. + * + * The following fields are required: + * ```java + * .job() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Config = + Config(checkRequired("job", job), 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 + } + + job().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 = (job.asKnown().getOrNull()?.validity() ?: 0) + + /** Job to create for each file in the source directory. */ + class Job + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val configurationId: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("configuration_id") + @ExcludeMissing + configurationId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(configurationId, type, mutableMapOf()) + + /** + * Product configuration ID or built-in preset ID matching the job type. + * + * @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 configurationId(): String = configurationId.getRequired("configuration_id") + + /** + * Product job type to run for each source directory file. + * + * @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 type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [configurationId]. + * + * Unlike [configurationId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("configuration_id") + @ExcludeMissing + fun _configurationId(): JsonField = configurationId + + /** + * 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 [Job]. + * + * The following fields are required: + * ```java + * .configurationId() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Job]. */ + class Builder internal constructor() { + + private var configurationId: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(job: Job) = apply { + configurationId = job.configurationId + type = job.type + additionalProperties = job.additionalProperties.toMutableMap() + } + + /** Product configuration ID or built-in preset ID matching the job type. */ + fun configurationId(configurationId: String) = + configurationId(JsonField.of(configurationId)) + + /** + * Sets [Builder.configurationId] to an arbitrary JSON value. + * + * You should usually call [Builder.configurationId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun configurationId(configurationId: JsonField) = apply { + this.configurationId = configurationId + } + + /** Product job type to run for each source directory file. */ + 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 [Job]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .configurationId() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Job = + Job( + checkRequired("configurationId", configurationId), + checkRequired("type", 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(): Job = apply { + if (validated) { + return@apply + } + + configurationId() + type().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 (configurationId.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** Product job type to run for each source directory file. */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PARSE_V2 = of("parse_v2") + + @JvmField val EXTRACT_V2 = of("extract_v2") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + PARSE_V2, + EXTRACT_V2, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PARSE_V2, + EXTRACT_V2, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PARSE_V2 -> Value.PARSE_V2 + EXTRACT_V2 -> Value.EXTRACT_V2 + 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) { + PARSE_V2 -> Known.PARSE_V2 + EXTRACT_V2 -> Known.EXTRACT_V2 + else -> throw LlamaCloudInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws 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(): Type = 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 Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Job && + configurationId == other.configurationId && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(configurationId, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Job{configurationId=$configurationId, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Config && + job == other.job && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(job, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Config{job=$job, additionalProperties=$additionalProperties}" + } + + /** Current batch status. */ + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CANCELLED = of("CANCELLED") + + @JvmField val COMPLETED = of("COMPLETED") + + @JvmField val FAILED = of("FAILED") + + @JvmField val PENDING = of("PENDING") + + @JvmField val RUNNING = of("RUNNING") + + @JvmField val THROTTLED = of("THROTTLED") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + CANCELLED, + COMPLETED, + FAILED, + PENDING, + RUNNING, + THROTTLED, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CANCELLED, + COMPLETED, + FAILED, + PENDING, + RUNNING, + THROTTLED, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CANCELLED -> Value.CANCELLED + COMPLETED -> Value.COMPLETED + FAILED -> Value.FAILED + PENDING -> Value.PENDING + RUNNING -> Value.RUNNING + THROTTLED -> Value.THROTTLED + 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) { + CANCELLED -> Known.CANCELLED + COMPLETED -> Known.COMPLETED + FAILED -> Known.FAILED + PENDING -> Known.PENDING + RUNNING -> Known.RUNNING + THROTTLED -> Known.THROTTLED + else -> throw LlamaCloudInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws 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(): Status = 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 Status && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** + * Result projection for one source directory file in a batch. + * + * Example: { "source_directory_file_id": "dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", + * "job_reference": { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" }, + * "error_message": null } + * + * This is a projection of directory-sync state, not a separate child resource that callers need + * to create. The source directory file ID is the stable correlation key. Underlying job + * progress and failures should be resolved through the referenced product job endpoint. + */ + class Result + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val sourceDirectoryFileId: JsonField, + private val errorMessage: JsonField, + private val jobReference: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("source_directory_file_id") + @ExcludeMissing + sourceDirectoryFileId: JsonField = JsonMissing.of(), + @JsonProperty("error_message") + @ExcludeMissing + errorMessage: JsonField = JsonMissing.of(), + @JsonProperty("job_reference") + @ExcludeMissing + jobReference: JsonField = JsonMissing.of(), + ) : this(sourceDirectoryFileId, errorMessage, jobReference, mutableMapOf()) + + /** + * Source directory file processed by this batch. + * + * @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 sourceDirectoryFileId(): String = + sourceDirectoryFileId.getRequired("source_directory_file_id") + + /** + * Batch-level mapping error if the system could not create or associate a job for this + * source file. + * + * @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") + + /** + * Reference to a job produced by a batch. + * + * Example: { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun jobReference(): Optional = jobReference.getOptional("job_reference") + + /** + * Returns the raw JSON value of [sourceDirectoryFileId]. + * + * Unlike [sourceDirectoryFileId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("source_directory_file_id") + @ExcludeMissing + fun _sourceDirectoryFileId(): JsonField = sourceDirectoryFileId + + /** + * 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 [jobReference]. + * + * Unlike [jobReference], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("job_reference") + @ExcludeMissing + fun _jobReference(): JsonField = jobReference + + @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 [Result]. + * + * The following fields are required: + * ```java + * .sourceDirectoryFileId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Result]. */ + class Builder internal constructor() { + + private var sourceDirectoryFileId: JsonField? = null + private var errorMessage: JsonField = JsonMissing.of() + private var jobReference: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(result: Result) = apply { + sourceDirectoryFileId = result.sourceDirectoryFileId + errorMessage = result.errorMessage + jobReference = result.jobReference + additionalProperties = result.additionalProperties.toMutableMap() + } + + /** Source directory file processed by this batch. */ + fun sourceDirectoryFileId(sourceDirectoryFileId: String) = + sourceDirectoryFileId(JsonField.of(sourceDirectoryFileId)) + + /** + * Sets [Builder.sourceDirectoryFileId] to an arbitrary JSON value. + * + * You should usually call [Builder.sourceDirectoryFileId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun sourceDirectoryFileId(sourceDirectoryFileId: JsonField) = apply { + this.sourceDirectoryFileId = sourceDirectoryFileId + } + + /** + * Batch-level mapping error if the system could not create or associate a job for this + * source file. + */ + 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 + } + + /** + * Reference to a job produced by a batch. + * + * Example: { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } + */ + fun jobReference(jobReference: JobReference?) = + jobReference(JsonField.ofNullable(jobReference)) + + /** Alias for calling [Builder.jobReference] with `jobReference.orElse(null)`. */ + fun jobReference(jobReference: Optional) = + jobReference(jobReference.getOrNull()) + + /** + * Sets [Builder.jobReference] to an arbitrary JSON value. + * + * You should usually call [Builder.jobReference] with a well-typed [JobReference] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun jobReference(jobReference: JsonField) = apply { + this.jobReference = jobReference + } + + 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 [Result]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .sourceDirectoryFileId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Result = + Result( + checkRequired("sourceDirectoryFileId", sourceDirectoryFileId), + errorMessage, + jobReference, + 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(): Result = apply { + if (validated) { + return@apply + } + + sourceDirectoryFileId() + errorMessage() + jobReference().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 (sourceDirectoryFileId.asKnown().isPresent) 1 else 0) + + (if (errorMessage.asKnown().isPresent) 1 else 0) + + (jobReference.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Reference to a job produced by a batch. + * + * Example: { "type": "parse_v2", "id": "pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee" } + */ + class JobReference + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val id: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(id, type, mutableMapOf()) + + /** + * Job ID, such as a parse 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") + + /** + * Type of job produced for the file. + * + * @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 type(): Type = type.getRequired("type") + + /** + * 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 [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 [JobReference]. + * + * The following fields are required: + * ```java + * .id() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [JobReference]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(jobReference: JobReference) = apply { + id = jobReference.id + type = jobReference.type + additionalProperties = jobReference.additionalProperties.toMutableMap() + } + + /** Job ID, such as a parse 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 } + + /** Type of job produced for the file. */ + 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 [JobReference]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): JobReference = + JobReference( + checkRequired("id", id), + checkRequired("type", 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(): JobReference = apply { + if (validated) { + return@apply + } + + id() + type().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) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** Type of job produced for the file. */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val PARSE_V2 = of("parse_v2") + + @JvmField val EXTRACT_V2 = of("extract_v2") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + PARSE_V2, + EXTRACT_V2, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + PARSE_V2, + EXTRACT_V2, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PARSE_V2 -> Value.PARSE_V2 + EXTRACT_V2 -> Value.EXTRACT_V2 + 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) { + PARSE_V2 -> Known.PARSE_V2 + EXTRACT_V2 -> Known.EXTRACT_V2 + else -> throw LlamaCloudInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws 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(): Type = 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 Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JobReference && + id == other.id && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(id, type, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "JobReference{id=$id, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Result && + sourceDirectoryFileId == other.sourceDirectoryFileId && + errorMessage == other.errorMessage && + jobReference == other.jobReference && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(sourceDirectoryFileId, errorMessage, jobReference, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Result{sourceDirectoryFileId=$sourceDirectoryFileId, errorMessage=$errorMessage, jobReference=$jobReference, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is BatchCancelResponse && + id == other.id && + config == other.config && + projectId == other.projectId && + sourceDirectoryId == other.sourceDirectoryId && + status == other.status && + createdAt == other.createdAt && + results == other.results && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + config, + projectId, + sourceDirectoryId, + status, + createdAt, + results, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BatchCancelResponse{id=$id, config=$config, projectId=$projectId, sourceDirectoryId=$sourceDirectoryId, status=$status, createdAt=$createdAt, results=$results, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCancelParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCancelParams.kt new file mode 100644 index 0000000..c697389 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCancelParams.kt @@ -0,0 +1,273 @@ +// 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 + +/** + * Cancel a running classify job. + * + * Stops processing and marks the job as CANCELLED. Returns the updated job. Jobs already in a + * terminal state (COMPLETED, FAILED, CANCELLED) cannot be cancelled. + */ +class ClassifyCancelParams +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(): ClassifyCancelParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ClassifyCancelParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ClassifyCancelParams]. */ + 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(classifyCancelParams: ClassifyCancelParams) = apply { + jobId = classifyCancelParams.jobId + organizationId = classifyCancelParams.organizationId + projectId = classifyCancelParams.projectId + additionalHeaders = classifyCancelParams.additionalHeaders.toBuilder() + additionalQueryParams = classifyCancelParams.additionalQueryParams.toBuilder() + additionalBodyProperties = classifyCancelParams.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 [ClassifyCancelParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ClassifyCancelParams = + ClassifyCancelParams( + 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 ClassifyCancelParams && + 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() = + "ClassifyCancelParams{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/ClassifyCancelResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCancelResponse.kt new file mode 100644 index 0000000..2f8ec00 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCancelResponse.kt @@ -0,0 +1,1054 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.classify + +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.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 + +/** Response for a classify job. */ +class ClassifyCancelResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val configuration: JsonField, + private val documentInputType: JsonField, + private val fileInput: JsonField, + private val projectId: JsonField, + private val status: JsonField, + private val userId: JsonField, + private val configurationId: JsonField, + private val createdAt: JsonField, + private val errorMessage: JsonField, + private val parseJobId: JsonField, + private val result: JsonField, + private val transactionId: JsonField, + private val updatedAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("configuration") + @ExcludeMissing + configuration: JsonField = JsonMissing.of(), + @JsonProperty("document_input_type") + @ExcludeMissing + documentInputType: JsonField = JsonMissing.of(), + @JsonProperty("file_input") @ExcludeMissing fileInput: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing userId: JsonField = JsonMissing.of(), + @JsonProperty("configuration_id") + @ExcludeMissing + configurationId: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("error_message") + @ExcludeMissing + errorMessage: JsonField = JsonMissing.of(), + @JsonProperty("parse_job_id") + @ExcludeMissing + parseJobId: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("transaction_id") + @ExcludeMissing + transactionId: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this( + id, + configuration, + documentInputType, + fileInput, + projectId, + status, + userId, + configurationId, + createdAt, + errorMessage, + parseJobId, + result, + transactionId, + updatedAt, + mutableMapOf(), + ) + + /** + * Unique identifier + * + * @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") + + /** + * Classify configuration used for this 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 configuration(): ClassifyConfiguration = configuration.getRequired("configuration") + + /** + * Whether the input was a file or parse job (FILE or PARSE_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 documentInputType(): DocumentInputType = + documentInputType.getRequired("document_input_type") + + /** + * ID of the input file or parse 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 fileInput(): String = fileInput.getRequired("file_input") + + /** + * Project this job 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") + + /** + * Current job status: PENDING, RUNNING, COMPLETED, or FAILED + * + * @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(): Status = status.getRequired("status") + + /** + * User who created this 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 userId(): String = userId.getRequired("user_id") + + /** + * Product configuration ID + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun configurationId(): Optional = configurationId.getOptional("configuration_id") + + /** + * Creation datetime + * + * @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") + + /** + * Error message if job failed + * + * @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") + + /** + * Associated parse job ID + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun parseJobId(): Optional = parseJobId.getOptional("parse_job_id") + + /** + * Result of classifying a document. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun result(): Optional = result.getOptional("result") + + /** + * Idempotency key + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transactionId(): Optional = transactionId.getOptional("transaction_id") + + /** + * Update datetime + * + * @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 [configuration]. + * + * Unlike [configuration], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("configuration") + @ExcludeMissing + fun _configuration(): JsonField = configuration + + /** + * Returns the raw JSON value of [documentInputType]. + * + * Unlike [documentInputType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("document_input_type") + @ExcludeMissing + fun _documentInputType(): JsonField = documentInputType + + /** + * Returns the raw JSON value of [fileInput]. + * + * Unlike [fileInput], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("file_input") @ExcludeMissing fun _fileInput(): JsonField = fileInput + + /** + * 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 [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + + /** + * Returns the raw JSON value of [configurationId]. + * + * Unlike [configurationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("configuration_id") + @ExcludeMissing + fun _configurationId(): JsonField = configurationId + + /** + * 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 [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 [parseJobId]. + * + * Unlike [parseJobId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("parse_job_id") @ExcludeMissing fun _parseJobId(): JsonField = parseJobId + + /** + * Returns the raw JSON value of [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [transactionId]. + * + * Unlike [transactionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("transaction_id") + @ExcludeMissing + fun _transactionId(): JsonField = transactionId + + /** + * 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 [ClassifyCancelResponse]. + * + * The following fields are required: + * ```java + * .id() + * .configuration() + * .documentInputType() + * .fileInput() + * .projectId() + * .status() + * .userId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ClassifyCancelResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var configuration: JsonField? = null + private var documentInputType: JsonField? = null + private var fileInput: JsonField? = null + private var projectId: JsonField? = null + private var status: JsonField? = null + private var userId: JsonField? = null + private var configurationId: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var errorMessage: JsonField = JsonMissing.of() + private var parseJobId: JsonField = JsonMissing.of() + private var result: JsonField = JsonMissing.of() + private var transactionId: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(classifyCancelResponse: ClassifyCancelResponse) = apply { + id = classifyCancelResponse.id + configuration = classifyCancelResponse.configuration + documentInputType = classifyCancelResponse.documentInputType + fileInput = classifyCancelResponse.fileInput + projectId = classifyCancelResponse.projectId + status = classifyCancelResponse.status + userId = classifyCancelResponse.userId + configurationId = classifyCancelResponse.configurationId + createdAt = classifyCancelResponse.createdAt + errorMessage = classifyCancelResponse.errorMessage + parseJobId = classifyCancelResponse.parseJobId + result = classifyCancelResponse.result + transactionId = classifyCancelResponse.transactionId + updatedAt = classifyCancelResponse.updatedAt + additionalProperties = classifyCancelResponse.additionalProperties.toMutableMap() + } + + /** Unique identifier */ + 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 } + + /** Classify configuration used for this job */ + fun configuration(configuration: ClassifyConfiguration) = + configuration(JsonField.of(configuration)) + + /** + * Sets [Builder.configuration] to an arbitrary JSON value. + * + * You should usually call [Builder.configuration] with a well-typed [ClassifyConfiguration] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun configuration(configuration: JsonField) = apply { + this.configuration = configuration + } + + /** Whether the input was a file or parse job (FILE or PARSE_JOB) */ + fun documentInputType(documentInputType: DocumentInputType) = + documentInputType(JsonField.of(documentInputType)) + + /** + * Sets [Builder.documentInputType] to an arbitrary JSON value. + * + * You should usually call [Builder.documentInputType] with a well-typed [DocumentInputType] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun documentInputType(documentInputType: JsonField) = apply { + this.documentInputType = documentInputType + } + + /** ID of the input file or parse job */ + fun fileInput(fileInput: String) = fileInput(JsonField.of(fileInput)) + + /** + * Sets [Builder.fileInput] to an arbitrary JSON value. + * + * You should usually call [Builder.fileInput] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun fileInput(fileInput: JsonField) = apply { this.fileInput = fileInput } + + /** Project this job 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 } + + /** Current job status: PENDING, RUNNING, COMPLETED, or FAILED */ + fun status(status: Status) = status(JsonField.of(status)) + + /** + * Sets [Builder.status] to an arbitrary JSON value. + * + * You should usually call [Builder.status] with a well-typed [Status] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun status(status: JsonField) = apply { this.status = status } + + /** User who created this job */ + fun userId(userId: String) = userId(JsonField.of(userId)) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun userId(userId: JsonField) = apply { this.userId = userId } + + /** Product configuration ID */ + fun configurationId(configurationId: String?) = + configurationId(JsonField.ofNullable(configurationId)) + + /** Alias for calling [Builder.configurationId] with `configurationId.orElse(null)`. */ + fun configurationId(configurationId: Optional) = + configurationId(configurationId.getOrNull()) + + /** + * Sets [Builder.configurationId] to an arbitrary JSON value. + * + * You should usually call [Builder.configurationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun configurationId(configurationId: JsonField) = apply { + this.configurationId = configurationId + } + + /** Creation datetime */ + 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 } + + /** Error message if job failed */ + 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 + } + + /** Associated parse job ID */ + fun parseJobId(parseJobId: String?) = parseJobId(JsonField.ofNullable(parseJobId)) + + /** Alias for calling [Builder.parseJobId] with `parseJobId.orElse(null)`. */ + fun parseJobId(parseJobId: Optional) = parseJobId(parseJobId.getOrNull()) + + /** + * Sets [Builder.parseJobId] to an arbitrary JSON value. + * + * You should usually call [Builder.parseJobId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun parseJobId(parseJobId: JsonField) = apply { this.parseJobId = parseJobId } + + /** Result of classifying a document. */ + fun result(result: ClassifyResult?) = result(JsonField.ofNullable(result)) + + /** Alias for calling [Builder.result] with `result.orElse(null)`. */ + fun result(result: Optional) = result(result.getOrNull()) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [ClassifyResult] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun result(result: JsonField) = apply { this.result = result } + + /** Idempotency key */ + fun transactionId(transactionId: String?) = + transactionId(JsonField.ofNullable(transactionId)) + + /** Alias for calling [Builder.transactionId] with `transactionId.orElse(null)`. */ + fun transactionId(transactionId: Optional) = + transactionId(transactionId.getOrNull()) + + /** + * Sets [Builder.transactionId] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun transactionId(transactionId: JsonField) = apply { + this.transactionId = transactionId + } + + /** Update datetime */ + 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 [ClassifyCancelResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .configuration() + * .documentInputType() + * .fileInput() + * .projectId() + * .status() + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ClassifyCancelResponse = + ClassifyCancelResponse( + checkRequired("id", id), + checkRequired("configuration", configuration), + checkRequired("documentInputType", documentInputType), + checkRequired("fileInput", fileInput), + checkRequired("projectId", projectId), + checkRequired("status", status), + checkRequired("userId", userId), + configurationId, + createdAt, + errorMessage, + parseJobId, + result, + transactionId, + 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(): ClassifyCancelResponse = apply { + if (validated) { + return@apply + } + + id() + configuration().validate() + documentInputType().validate() + fileInput() + projectId() + status().validate() + userId() + configurationId() + createdAt() + errorMessage() + parseJobId() + result().ifPresent { it.validate() } + transactionId() + 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) + + (configuration.asKnown().getOrNull()?.validity() ?: 0) + + (documentInputType.asKnown().getOrNull()?.validity() ?: 0) + + (if (fileInput.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (status.asKnown().getOrNull()?.validity() ?: 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (if (configurationId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (errorMessage.asKnown().isPresent) 1 else 0) + + (if (parseJobId.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (if (transactionId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + /** Whether the input was a file or parse job (FILE or PARSE_JOB) */ + class DocumentInputType @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 FILE_ID = of("file_id") + + @JvmField val PARSE_JOB_ID = of("parse_job_id") + + @JvmField val URL = of("url") + + @JvmStatic fun of(value: String) = DocumentInputType(JsonField.of(value)) + } + + /** An enum containing [DocumentInputType]'s known values. */ + enum class Known { + FILE_ID, + PARSE_JOB_ID, + URL, + } + + /** + * An enum containing [DocumentInputType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DocumentInputType] 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 { + FILE_ID, + PARSE_JOB_ID, + URL, + /** + * An enum member indicating that [DocumentInputType] 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) { + FILE_ID -> Value.FILE_ID + PARSE_JOB_ID -> Value.PARSE_JOB_ID + URL -> Value.URL + 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) { + FILE_ID -> Known.FILE_ID + PARSE_JOB_ID -> Known.PARSE_JOB_ID + URL -> Known.URL + else -> throw LlamaCloudInvalidDataException("Unknown DocumentInputType: $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(): DocumentInputType = 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 DocumentInputType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Current job status: PENDING, RUNNING, COMPLETED, or FAILED */ + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val COMPLETED = of("COMPLETED") + + @JvmField val FAILED = of("FAILED") + + @JvmField val PENDING = of("PENDING") + + @JvmField val RUNNING = of("RUNNING") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + COMPLETED, + FAILED, + PENDING, + RUNNING, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + COMPLETED, + FAILED, + PENDING, + RUNNING, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + COMPLETED -> Value.COMPLETED + FAILED -> Value.FAILED + PENDING -> Value.PENDING + RUNNING -> Value.RUNNING + 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) { + COMPLETED -> Known.COMPLETED + FAILED -> Known.FAILED + PENDING -> Known.PENDING + RUNNING -> Known.RUNNING + else -> throw LlamaCloudInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws 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(): Status = 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 Status && 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 ClassifyCancelResponse && + id == other.id && + configuration == other.configuration && + documentInputType == other.documentInputType && + fileInput == other.fileInput && + projectId == other.projectId && + status == other.status && + userId == other.userId && + configurationId == other.configurationId && + createdAt == other.createdAt && + errorMessage == other.errorMessage && + parseJobId == other.parseJobId && + result == other.result && + transactionId == other.transactionId && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + configuration, + documentInputType, + fileInput, + projectId, + status, + userId, + configurationId, + createdAt, + errorMessage, + parseJobId, + result, + transactionId, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ClassifyCancelResponse{id=$id, configuration=$configuration, documentInputType=$documentInputType, fileInput=$fileInput, projectId=$projectId, status=$status, userId=$userId, configurationId=$configurationId, createdAt=$createdAt, errorMessage=$errorMessage, parseJobId=$parseJobId, result=$result, transactionId=$transactionId, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractCancelParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractCancelParams.kt new file mode 100644 index 0000000..76722be --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractCancelParams.kt @@ -0,0 +1,273 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.extract + +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 + +/** + * Cancel a running extraction job. + * + * Stops processing and marks the job as CANCELLED. Returns the updated job. Jobs already in a + * terminal state (COMPLETED, FAILED, CANCELLED) cannot be cancelled. + */ +class ExtractCancelParams +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(): ExtractCancelParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [ExtractCancelParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ExtractCancelParams]. */ + 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(extractCancelParams: ExtractCancelParams) = apply { + jobId = extractCancelParams.jobId + organizationId = extractCancelParams.organizationId + projectId = extractCancelParams.projectId + additionalHeaders = extractCancelParams.additionalHeaders.toBuilder() + additionalQueryParams = extractCancelParams.additionalQueryParams.toBuilder() + additionalBodyProperties = extractCancelParams.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 [ExtractCancelParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ExtractCancelParams = + ExtractCancelParams( + 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 ExtractCancelParams && + 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() = + "ExtractCancelParams{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/parsing/ParsingListVersionsParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsParams.kt new file mode 100644 index 0000000..26fbc59 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsParams.kt @@ -0,0 +1,172 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.parsing + +import ai.llamaindex.llamacloud.core.Params +import ai.llamaindex.llamacloud.core.http.Headers +import ai.llamaindex.llamacloud.core.http.QueryParams +import java.util.Objects + +/** List the parse versions accepted by each tier. */ +class ParsingListVersionsParams +private constructor( + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** 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(): ParsingListVersionsParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [ParsingListVersionsParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ParsingListVersionsParams]. */ + class Builder internal constructor() { + + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(parsingListVersionsParams: ParsingListVersionsParams) = apply { + additionalHeaders = parsingListVersionsParams.additionalHeaders.toBuilder() + additionalQueryParams = parsingListVersionsParams.additionalQueryParams.toBuilder() + } + + 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 [ParsingListVersionsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): ParsingListVersionsParams = + ParsingListVersionsParams(additionalHeaders.build(), additionalQueryParams.build()) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is ParsingListVersionsParams && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(additionalHeaders, additionalQueryParams) + + override fun toString() = + "ParsingListVersionsParams{additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsResponse.kt new file mode 100644 index 0000000..8be9a9c --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsResponse.kt @@ -0,0 +1,1441 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.parsing + +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.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 kotlin.jvm.optionals.getOrNull + +/** Versions accepted by the parse API, grouped by tier. */ +class ParsingListVersionsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val agentic: JsonField>, + private val agenticPlus: JsonField>, + private val costEffective: JsonField>, + private val fast: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("agentic") + @ExcludeMissing + agentic: JsonField> = JsonMissing.of(), + @JsonProperty("agentic_plus") + @ExcludeMissing + agenticPlus: JsonField> = JsonMissing.of(), + @JsonProperty("cost_effective") + @ExcludeMissing + costEffective: JsonField> = JsonMissing.of(), + @JsonProperty("fast") @ExcludeMissing fast: JsonField> = JsonMissing.of(), + ) : this(agentic, agenticPlus, costEffective, fast, mutableMapOf()) + + /** + * Versions for the agentic tier + * + * @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 agentic(): List = agentic.getRequired("agentic") + + /** + * Versions for the agentic_plus tier + * + * @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 agenticPlus(): List = agenticPlus.getRequired("agentic_plus") + + /** + * Versions for the cost_effective tier + * + * @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 costEffective(): List = costEffective.getRequired("cost_effective") + + /** + * Versions for the fast tier + * + * @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 fast(): List = fast.getRequired("fast") + + /** + * Returns the raw JSON value of [agentic]. + * + * Unlike [agentic], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("agentic") @ExcludeMissing fun _agentic(): JsonField> = agentic + + /** + * Returns the raw JSON value of [agenticPlus]. + * + * Unlike [agenticPlus], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("agentic_plus") + @ExcludeMissing + fun _agenticPlus(): JsonField> = agenticPlus + + /** + * Returns the raw JSON value of [costEffective]. + * + * Unlike [costEffective], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("cost_effective") + @ExcludeMissing + fun _costEffective(): JsonField> = costEffective + + /** + * Returns the raw JSON value of [fast]. + * + * Unlike [fast], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("fast") @ExcludeMissing fun _fast(): JsonField> = fast + + @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 [ParsingListVersionsResponse]. + * + * The following fields are required: + * ```java + * .agentic() + * .agenticPlus() + * .costEffective() + * .fast() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ParsingListVersionsResponse]. */ + class Builder internal constructor() { + + private var agentic: JsonField>? = null + private var agenticPlus: JsonField>? = null + private var costEffective: JsonField>? = null + private var fast: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(parsingListVersionsResponse: ParsingListVersionsResponse) = apply { + agentic = parsingListVersionsResponse.agentic.map { it.toMutableList() } + agenticPlus = parsingListVersionsResponse.agenticPlus.map { it.toMutableList() } + costEffective = parsingListVersionsResponse.costEffective.map { it.toMutableList() } + fast = parsingListVersionsResponse.fast.map { it.toMutableList() } + additionalProperties = parsingListVersionsResponse.additionalProperties.toMutableMap() + } + + /** Versions for the agentic tier */ + fun agentic(agentic: List) = agentic(JsonField.of(agentic)) + + /** + * Sets [Builder.agentic] to an arbitrary JSON value. + * + * You should usually call [Builder.agentic] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun agentic(agentic: JsonField>) = apply { + this.agentic = agentic.map { it.toMutableList() } + } + + /** + * Adds a single [Agentic] to [Builder.agentic]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAgentic(agentic: Agentic) = apply { + this.agentic = + (this.agentic ?: JsonField.of(mutableListOf())).also { + checkKnown("agentic", it).add(agentic) + } + } + + /** Versions for the agentic_plus tier */ + fun agenticPlus(agenticPlus: List) = agenticPlus(JsonField.of(agenticPlus)) + + /** + * Sets [Builder.agenticPlus] to an arbitrary JSON value. + * + * You should usually call [Builder.agenticPlus] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun agenticPlus(agenticPlus: JsonField>) = apply { + this.agenticPlus = agenticPlus.map { it.toMutableList() } + } + + /** + * Adds a single [AgenticPlus] to [Builder.agenticPlus]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAgenticPlus(agenticPlus: AgenticPlus) = apply { + this.agenticPlus = + (this.agenticPlus ?: JsonField.of(mutableListOf())).also { + checkKnown("agenticPlus", it).add(agenticPlus) + } + } + + /** Versions for the cost_effective tier */ + fun costEffective(costEffective: List) = + costEffective(JsonField.of(costEffective)) + + /** + * Sets [Builder.costEffective] to an arbitrary JSON value. + * + * You should usually call [Builder.costEffective] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun costEffective(costEffective: JsonField>) = apply { + this.costEffective = costEffective.map { it.toMutableList() } + } + + /** + * Adds a single [CostEffective] to [Builder.costEffective]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCostEffective(costEffective: CostEffective) = apply { + this.costEffective = + (this.costEffective ?: JsonField.of(mutableListOf())).also { + checkKnown("costEffective", it).add(costEffective) + } + } + + /** Versions for the fast tier */ + fun fast(fast: List) = fast(JsonField.of(fast)) + + /** + * Sets [Builder.fast] to an arbitrary JSON value. + * + * You should usually call [Builder.fast] with a well-typed `List` value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fast(fast: JsonField>) = apply { + this.fast = fast.map { it.toMutableList() } + } + + /** + * Adds a single [Fast] to [Builder.fast]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addFast(fast: Fast) = apply { + this.fast = + (this.fast ?: JsonField.of(mutableListOf())).also { + checkKnown("fast", it).add(fast) + } + } + + 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 [ParsingListVersionsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .agentic() + * .agenticPlus() + * .costEffective() + * .fast() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ParsingListVersionsResponse = + ParsingListVersionsResponse( + checkRequired("agentic", agentic).map { it.toImmutable() }, + checkRequired("agenticPlus", agenticPlus).map { it.toImmutable() }, + checkRequired("costEffective", costEffective).map { it.toImmutable() }, + checkRequired("fast", fast).map { it.toImmutable() }, + 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(): ParsingListVersionsResponse = apply { + if (validated) { + return@apply + } + + agentic().forEach { it.validate() } + agenticPlus().forEach { it.validate() } + costEffective().forEach { it.validate() } + fast().forEach { 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 = + (agentic.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (agenticPlus.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (costEffective.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (fast.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Agentic @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 _2026_07_24 = of("2026-07-24") + + @JvmField val _2026_07_23 = of("2026-07-23") + + @JvmField val _2026_07_15 = of("2026-07-15") + + @JvmField val _2026_06_18 = of("2026-06-18") + + @JvmField val _2026_06_11 = of("2026-06-11") + + @JvmField val _2026_06_04 = of("2026-06-04") + + @JvmField val _2026_06_01 = of("2026-06-01") + + @JvmField val _2026_05_26 = of("2026-05-26") + + @JvmField val _2026_05_21 = of("2026-05-21") + + @JvmField val _2026_05_20 = of("2026-05-20") + + @JvmField val _2026_05_19 = of("2026-05-19") + + @JvmField val _2026_05_13 = of("2026-05-13") + + @JvmField val _2026_05_11 = of("2026-05-11") + + @JvmField val _2026_05_06 = of("2026-05-06") + + @JvmField val _2026_05_04 = of("2026-05-04") + + @JvmField val _2026_04_27 = of("2026-04-27") + + @JvmField val _2026_04_22 = of("2026-04-22") + + @JvmField val _2026_04_09 = of("2026-04-09") + + @JvmField val _2026_04_06 = of("2026-04-06") + + @JvmField val _2026_04_02 = of("2026-04-02") + + @JvmField val _2026_03_31 = of("2026-03-31") + + @JvmField val _2026_03_30 = of("2026-03-30") + + @JvmField val _2026_03_27 = of("2026-03-27") + + @JvmField val _2026_03_25 = of("2026-03-25") + + @JvmField val _2026_03_23 = of("2026-03-23") + + @JvmField val _2026_03_22 = of("2026-03-22") + + @JvmField val _2026_03_20 = of("2026-03-20") + + @JvmField val _2026_03_11 = of("2026-03-11") + + @JvmField val _2026_03_10 = of("2026-03-10") + + @JvmField val _2026_03_09 = of("2026-03-09") + + @JvmField val _2026_03_03 = of("2026-03-03") + + @JvmField val _2026_03_02 = of("2026-03-02") + + @JvmField val _2026_02_26 = of("2026-02-26") + + @JvmField val _2026_02_24 = of("2026-02-24") + + @JvmField val _2026_01_30 = of("2026-01-30") + + @JvmField val _2026_01_22 = of("2026-01-22") + + @JvmField val _2026_01_21 = of("2026-01-21") + + @JvmField val _2026_01_16 = of("2026-01-16") + + @JvmField val _2026_01_08 = of("2026-01-08") + + @JvmField val _2025_12_31 = of("2025-12-31") + + @JvmField val _2025_12_18 = of("2025-12-18") + + @JvmField val _2025_12_11 = of("2025-12-11") + + @JvmStatic fun of(value: String) = Agentic(JsonField.of(value)) + } + + /** An enum containing [Agentic]'s known values. */ + enum class Known { + _2026_07_24, + _2026_07_23, + _2026_07_15, + _2026_06_18, + _2026_06_11, + _2026_06_04, + _2026_06_01, + _2026_05_26, + _2026_05_21, + _2026_05_20, + _2026_05_19, + _2026_05_13, + _2026_05_11, + _2026_05_06, + _2026_05_04, + _2026_04_27, + _2026_04_22, + _2026_04_09, + _2026_04_06, + _2026_04_02, + _2026_03_31, + _2026_03_30, + _2026_03_27, + _2026_03_25, + _2026_03_23, + _2026_03_22, + _2026_03_20, + _2026_03_11, + _2026_03_10, + _2026_03_09, + _2026_03_03, + _2026_03_02, + _2026_02_26, + _2026_02_24, + _2026_01_30, + _2026_01_22, + _2026_01_21, + _2026_01_16, + _2026_01_08, + _2025_12_31, + _2025_12_18, + _2025_12_11, + } + + /** + * An enum containing [Agentic]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Agentic] 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 { + _2026_07_24, + _2026_07_23, + _2026_07_15, + _2026_06_18, + _2026_06_11, + _2026_06_04, + _2026_06_01, + _2026_05_26, + _2026_05_21, + _2026_05_20, + _2026_05_19, + _2026_05_13, + _2026_05_11, + _2026_05_06, + _2026_05_04, + _2026_04_27, + _2026_04_22, + _2026_04_09, + _2026_04_06, + _2026_04_02, + _2026_03_31, + _2026_03_30, + _2026_03_27, + _2026_03_25, + _2026_03_23, + _2026_03_22, + _2026_03_20, + _2026_03_11, + _2026_03_10, + _2026_03_09, + _2026_03_03, + _2026_03_02, + _2026_02_26, + _2026_02_24, + _2026_01_30, + _2026_01_22, + _2026_01_21, + _2026_01_16, + _2026_01_08, + _2025_12_31, + _2025_12_18, + _2025_12_11, + /** An enum member indicating that [Agentic] 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) { + _2026_07_24 -> Value._2026_07_24 + _2026_07_23 -> Value._2026_07_23 + _2026_07_15 -> Value._2026_07_15 + _2026_06_18 -> Value._2026_06_18 + _2026_06_11 -> Value._2026_06_11 + _2026_06_04 -> Value._2026_06_04 + _2026_06_01 -> Value._2026_06_01 + _2026_05_26 -> Value._2026_05_26 + _2026_05_21 -> Value._2026_05_21 + _2026_05_20 -> Value._2026_05_20 + _2026_05_19 -> Value._2026_05_19 + _2026_05_13 -> Value._2026_05_13 + _2026_05_11 -> Value._2026_05_11 + _2026_05_06 -> Value._2026_05_06 + _2026_05_04 -> Value._2026_05_04 + _2026_04_27 -> Value._2026_04_27 + _2026_04_22 -> Value._2026_04_22 + _2026_04_09 -> Value._2026_04_09 + _2026_04_06 -> Value._2026_04_06 + _2026_04_02 -> Value._2026_04_02 + _2026_03_31 -> Value._2026_03_31 + _2026_03_30 -> Value._2026_03_30 + _2026_03_27 -> Value._2026_03_27 + _2026_03_25 -> Value._2026_03_25 + _2026_03_23 -> Value._2026_03_23 + _2026_03_22 -> Value._2026_03_22 + _2026_03_20 -> Value._2026_03_20 + _2026_03_11 -> Value._2026_03_11 + _2026_03_10 -> Value._2026_03_10 + _2026_03_09 -> Value._2026_03_09 + _2026_03_03 -> Value._2026_03_03 + _2026_03_02 -> Value._2026_03_02 + _2026_02_26 -> Value._2026_02_26 + _2026_02_24 -> Value._2026_02_24 + _2026_01_30 -> Value._2026_01_30 + _2026_01_22 -> Value._2026_01_22 + _2026_01_21 -> Value._2026_01_21 + _2026_01_16 -> Value._2026_01_16 + _2026_01_08 -> Value._2026_01_08 + _2025_12_31 -> Value._2025_12_31 + _2025_12_18 -> Value._2025_12_18 + _2025_12_11 -> Value._2025_12_11 + 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) { + _2026_07_24 -> Known._2026_07_24 + _2026_07_23 -> Known._2026_07_23 + _2026_07_15 -> Known._2026_07_15 + _2026_06_18 -> Known._2026_06_18 + _2026_06_11 -> Known._2026_06_11 + _2026_06_04 -> Known._2026_06_04 + _2026_06_01 -> Known._2026_06_01 + _2026_05_26 -> Known._2026_05_26 + _2026_05_21 -> Known._2026_05_21 + _2026_05_20 -> Known._2026_05_20 + _2026_05_19 -> Known._2026_05_19 + _2026_05_13 -> Known._2026_05_13 + _2026_05_11 -> Known._2026_05_11 + _2026_05_06 -> Known._2026_05_06 + _2026_05_04 -> Known._2026_05_04 + _2026_04_27 -> Known._2026_04_27 + _2026_04_22 -> Known._2026_04_22 + _2026_04_09 -> Known._2026_04_09 + _2026_04_06 -> Known._2026_04_06 + _2026_04_02 -> Known._2026_04_02 + _2026_03_31 -> Known._2026_03_31 + _2026_03_30 -> Known._2026_03_30 + _2026_03_27 -> Known._2026_03_27 + _2026_03_25 -> Known._2026_03_25 + _2026_03_23 -> Known._2026_03_23 + _2026_03_22 -> Known._2026_03_22 + _2026_03_20 -> Known._2026_03_20 + _2026_03_11 -> Known._2026_03_11 + _2026_03_10 -> Known._2026_03_10 + _2026_03_09 -> Known._2026_03_09 + _2026_03_03 -> Known._2026_03_03 + _2026_03_02 -> Known._2026_03_02 + _2026_02_26 -> Known._2026_02_26 + _2026_02_24 -> Known._2026_02_24 + _2026_01_30 -> Known._2026_01_30 + _2026_01_22 -> Known._2026_01_22 + _2026_01_21 -> Known._2026_01_21 + _2026_01_16 -> Known._2026_01_16 + _2026_01_08 -> Known._2026_01_08 + _2025_12_31 -> Known._2025_12_31 + _2025_12_18 -> Known._2025_12_18 + _2025_12_11 -> Known._2025_12_11 + else -> throw LlamaCloudInvalidDataException("Unknown Agentic: $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(): Agentic = 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 Agentic && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class AgenticPlus @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 _2026_07_08 = of("2026-07-08") + + @JvmField val _2026_06_18 = of("2026-06-18") + + @JvmField val _2026_06_11 = of("2026-06-11") + + @JvmField val _2026_06_04 = of("2026-06-04") + + @JvmField val _2026_06_01 = of("2026-06-01") + + @JvmField val _2026_05_26 = of("2026-05-26") + + @JvmField val _2026_05_21 = of("2026-05-21") + + @JvmField val _2026_05_20 = of("2026-05-20") + + @JvmField val _2026_05_19 = of("2026-05-19") + + @JvmField val _2026_05_11 = of("2026-05-11") + + @JvmField val _2026_05_06 = of("2026-05-06") + + @JvmField val _2026_05_04 = of("2026-05-04") + + @JvmField val _2026_05_01 = of("2026-05-01") + + @JvmField val _2026_04_27 = of("2026-04-27") + + @JvmField val _2026_04_19 = of("2026-04-19") + + @JvmField val _2026_04_14 = of("2026-04-14") + + @JvmField val _2026_04_09 = of("2026-04-09") + + @JvmField val _2026_04_02 = of("2026-04-02") + + @JvmField val _2026_03_31 = of("2026-03-31") + + @JvmField val _2026_03_26 = of("2026-03-26") + + @JvmField val _2026_03_25 = of("2026-03-25") + + @JvmField val _2026_03_22 = of("2026-03-22") + + @JvmField val _2026_03_20 = of("2026-03-20") + + @JvmField val _2026_03_17 = of("2026-03-17") + + @JvmField val _2026_03_12 = of("2026-03-12") + + @JvmField val _2026_03_10 = of("2026-03-10") + + @JvmField val _2026_03_09 = of("2026-03-09") + + @JvmField val _2026_03_02 = of("2026-03-02") + + @JvmField val _2026_02_26 = of("2026-02-26") + + @JvmField val _2026_02_24 = of("2026-02-24") + + @JvmField val _2026_01_30 = of("2026-01-30") + + @JvmField val _2026_01_29 = of("2026-01-29") + + @JvmField val _2026_01_24 = of("2026-01-24") + + @JvmField val _2026_01_22 = of("2026-01-22") + + @JvmField val _2026_01_21 = of("2026-01-21") + + @JvmField val _2026_01_16 = of("2026-01-16") + + @JvmField val _2025_12_31 = of("2025-12-31") + + @JvmField val _2025_12_18 = of("2025-12-18") + + @JvmField val _2025_12_11 = of("2025-12-11") + + @JvmStatic fun of(value: String) = AgenticPlus(JsonField.of(value)) + } + + /** An enum containing [AgenticPlus]'s known values. */ + enum class Known { + _2026_07_08, + _2026_06_18, + _2026_06_11, + _2026_06_04, + _2026_06_01, + _2026_05_26, + _2026_05_21, + _2026_05_20, + _2026_05_19, + _2026_05_11, + _2026_05_06, + _2026_05_04, + _2026_05_01, + _2026_04_27, + _2026_04_19, + _2026_04_14, + _2026_04_09, + _2026_04_02, + _2026_03_31, + _2026_03_26, + _2026_03_25, + _2026_03_22, + _2026_03_20, + _2026_03_17, + _2026_03_12, + _2026_03_10, + _2026_03_09, + _2026_03_02, + _2026_02_26, + _2026_02_24, + _2026_01_30, + _2026_01_29, + _2026_01_24, + _2026_01_22, + _2026_01_21, + _2026_01_16, + _2025_12_31, + _2025_12_18, + _2025_12_11, + } + + /** + * An enum containing [AgenticPlus]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AgenticPlus] 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 { + _2026_07_08, + _2026_06_18, + _2026_06_11, + _2026_06_04, + _2026_06_01, + _2026_05_26, + _2026_05_21, + _2026_05_20, + _2026_05_19, + _2026_05_11, + _2026_05_06, + _2026_05_04, + _2026_05_01, + _2026_04_27, + _2026_04_19, + _2026_04_14, + _2026_04_09, + _2026_04_02, + _2026_03_31, + _2026_03_26, + _2026_03_25, + _2026_03_22, + _2026_03_20, + _2026_03_17, + _2026_03_12, + _2026_03_10, + _2026_03_09, + _2026_03_02, + _2026_02_26, + _2026_02_24, + _2026_01_30, + _2026_01_29, + _2026_01_24, + _2026_01_22, + _2026_01_21, + _2026_01_16, + _2025_12_31, + _2025_12_18, + _2025_12_11, + /** + * An enum member indicating that [AgenticPlus] 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) { + _2026_07_08 -> Value._2026_07_08 + _2026_06_18 -> Value._2026_06_18 + _2026_06_11 -> Value._2026_06_11 + _2026_06_04 -> Value._2026_06_04 + _2026_06_01 -> Value._2026_06_01 + _2026_05_26 -> Value._2026_05_26 + _2026_05_21 -> Value._2026_05_21 + _2026_05_20 -> Value._2026_05_20 + _2026_05_19 -> Value._2026_05_19 + _2026_05_11 -> Value._2026_05_11 + _2026_05_06 -> Value._2026_05_06 + _2026_05_04 -> Value._2026_05_04 + _2026_05_01 -> Value._2026_05_01 + _2026_04_27 -> Value._2026_04_27 + _2026_04_19 -> Value._2026_04_19 + _2026_04_14 -> Value._2026_04_14 + _2026_04_09 -> Value._2026_04_09 + _2026_04_02 -> Value._2026_04_02 + _2026_03_31 -> Value._2026_03_31 + _2026_03_26 -> Value._2026_03_26 + _2026_03_25 -> Value._2026_03_25 + _2026_03_22 -> Value._2026_03_22 + _2026_03_20 -> Value._2026_03_20 + _2026_03_17 -> Value._2026_03_17 + _2026_03_12 -> Value._2026_03_12 + _2026_03_10 -> Value._2026_03_10 + _2026_03_09 -> Value._2026_03_09 + _2026_03_02 -> Value._2026_03_02 + _2026_02_26 -> Value._2026_02_26 + _2026_02_24 -> Value._2026_02_24 + _2026_01_30 -> Value._2026_01_30 + _2026_01_29 -> Value._2026_01_29 + _2026_01_24 -> Value._2026_01_24 + _2026_01_22 -> Value._2026_01_22 + _2026_01_21 -> Value._2026_01_21 + _2026_01_16 -> Value._2026_01_16 + _2025_12_31 -> Value._2025_12_31 + _2025_12_18 -> Value._2025_12_18 + _2025_12_11 -> Value._2025_12_11 + 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) { + _2026_07_08 -> Known._2026_07_08 + _2026_06_18 -> Known._2026_06_18 + _2026_06_11 -> Known._2026_06_11 + _2026_06_04 -> Known._2026_06_04 + _2026_06_01 -> Known._2026_06_01 + _2026_05_26 -> Known._2026_05_26 + _2026_05_21 -> Known._2026_05_21 + _2026_05_20 -> Known._2026_05_20 + _2026_05_19 -> Known._2026_05_19 + _2026_05_11 -> Known._2026_05_11 + _2026_05_06 -> Known._2026_05_06 + _2026_05_04 -> Known._2026_05_04 + _2026_05_01 -> Known._2026_05_01 + _2026_04_27 -> Known._2026_04_27 + _2026_04_19 -> Known._2026_04_19 + _2026_04_14 -> Known._2026_04_14 + _2026_04_09 -> Known._2026_04_09 + _2026_04_02 -> Known._2026_04_02 + _2026_03_31 -> Known._2026_03_31 + _2026_03_26 -> Known._2026_03_26 + _2026_03_25 -> Known._2026_03_25 + _2026_03_22 -> Known._2026_03_22 + _2026_03_20 -> Known._2026_03_20 + _2026_03_17 -> Known._2026_03_17 + _2026_03_12 -> Known._2026_03_12 + _2026_03_10 -> Known._2026_03_10 + _2026_03_09 -> Known._2026_03_09 + _2026_03_02 -> Known._2026_03_02 + _2026_02_26 -> Known._2026_02_26 + _2026_02_24 -> Known._2026_02_24 + _2026_01_30 -> Known._2026_01_30 + _2026_01_29 -> Known._2026_01_29 + _2026_01_24 -> Known._2026_01_24 + _2026_01_22 -> Known._2026_01_22 + _2026_01_21 -> Known._2026_01_21 + _2026_01_16 -> Known._2026_01_16 + _2025_12_31 -> Known._2025_12_31 + _2025_12_18 -> Known._2025_12_18 + _2025_12_11 -> Known._2025_12_11 + else -> throw LlamaCloudInvalidDataException("Unknown AgenticPlus: $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(): AgenticPlus = 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 AgenticPlus && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class CostEffective @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 _2026_07_23 = of("2026-07-23") + + @JvmField val _2026_06_26 = of("2026-06-26") + + @JvmField val _2026_06_18 = of("2026-06-18") + + @JvmField val _2026_06_17 = of("2026-06-17") + + @JvmField val _2026_06_11 = of("2026-06-11") + + @JvmField val _2026_06_08 = of("2026-06-08") + + @JvmField val _2026_06_05 = of("2026-06-05") + + @JvmField val _2026_05_28 = of("2026-05-28") + + @JvmField val _2026_04_09 = of("2026-04-09") + + @JvmField val _2026_03_31 = of("2026-03-31") + + @JvmField val _2026_03_27 = of("2026-03-27") + + @JvmField val _2026_03_25 = of("2026-03-25") + + @JvmStatic fun of(value: String) = CostEffective(JsonField.of(value)) + } + + /** An enum containing [CostEffective]'s known values. */ + enum class Known { + _2026_07_23, + _2026_06_26, + _2026_06_18, + _2026_06_17, + _2026_06_11, + _2026_06_08, + _2026_06_05, + _2026_05_28, + _2026_04_09, + _2026_03_31, + _2026_03_27, + _2026_03_25, + } + + /** + * An enum containing [CostEffective]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [CostEffective] 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 { + _2026_07_23, + _2026_06_26, + _2026_06_18, + _2026_06_17, + _2026_06_11, + _2026_06_08, + _2026_06_05, + _2026_05_28, + _2026_04_09, + _2026_03_31, + _2026_03_27, + _2026_03_25, + /** + * An enum member indicating that [CostEffective] 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) { + _2026_07_23 -> Value._2026_07_23 + _2026_06_26 -> Value._2026_06_26 + _2026_06_18 -> Value._2026_06_18 + _2026_06_17 -> Value._2026_06_17 + _2026_06_11 -> Value._2026_06_11 + _2026_06_08 -> Value._2026_06_08 + _2026_06_05 -> Value._2026_06_05 + _2026_05_28 -> Value._2026_05_28 + _2026_04_09 -> Value._2026_04_09 + _2026_03_31 -> Value._2026_03_31 + _2026_03_27 -> Value._2026_03_27 + _2026_03_25 -> Value._2026_03_25 + 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) { + _2026_07_23 -> Known._2026_07_23 + _2026_06_26 -> Known._2026_06_26 + _2026_06_18 -> Known._2026_06_18 + _2026_06_17 -> Known._2026_06_17 + _2026_06_11 -> Known._2026_06_11 + _2026_06_08 -> Known._2026_06_08 + _2026_06_05 -> Known._2026_06_05 + _2026_05_28 -> Known._2026_05_28 + _2026_04_09 -> Known._2026_04_09 + _2026_03_31 -> Known._2026_03_31 + _2026_03_27 -> Known._2026_03_27 + _2026_03_25 -> Known._2026_03_25 + else -> throw LlamaCloudInvalidDataException("Unknown CostEffective: $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(): CostEffective = 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 CostEffective && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Fast @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 _2026_06_15 = of("2026-06-15") + + @JvmField val _2025_12_11 = of("2025-12-11") + + @JvmStatic fun of(value: String) = Fast(JsonField.of(value)) + } + + /** An enum containing [Fast]'s known values. */ + enum class Known { + _2026_06_15, + _2025_12_11, + } + + /** + * An enum containing [Fast]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Fast] 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 { + _2026_06_15, + _2025_12_11, + /** An enum member indicating that [Fast] 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) { + _2026_06_15 -> Value._2026_06_15 + _2025_12_11 -> Value._2025_12_11 + 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) { + _2026_06_15 -> Known._2026_06_15 + _2025_12_11 -> Known._2025_12_11 + else -> throw LlamaCloudInvalidDataException("Unknown Fast: $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(): Fast = 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 Fast && 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 ParsingListVersionsResponse && + agentic == other.agentic && + agenticPlus == other.agenticPlus && + costEffective == other.costEffective && + fast == other.fast && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(agentic, agenticPlus, costEffective, fast, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ParsingListVersionsResponse{agentic=$agentic, agenticPlus=$agenticPlus, costEffective=$costEffective, fast=$fast, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/pipelines/documents/DocumentGetStatusCountsParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/pipelines/documents/DocumentGetStatusCountsParams.kt new file mode 100644 index 0000000..e57753b --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/pipelines/documents/DocumentGetStatusCountsParams.kt @@ -0,0 +1,267 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.pipelines.documents + +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 + +/** + * Count the documents in a pipeline, grouped by ingestion status. + * + * Counts reflect each document's last recorded status rather than a freshly computed one, so a + * document that changed status in the last few moments may still be counted under its previous one. + * Use `GET /pipelines/{pipeline_id}/documents/{document_id}/status` when a single document's status + * has to be up to the moment. + */ +@Deprecated("deprecated") +class DocumentGetStatusCountsParams +private constructor( + private val pipelineId: String?, + private val dataSourceId: String?, + private val fileId: String?, + private val onlyDirectUpload: Boolean?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun pipelineId(): Optional = Optional.ofNullable(pipelineId) + + fun dataSourceId(): Optional = Optional.ofNullable(dataSourceId) + + fun fileId(): Optional = Optional.ofNullable(fileId) + + fun onlyDirectUpload(): Optional = Optional.ofNullable(onlyDirectUpload) + + /** 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(): DocumentGetStatusCountsParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [DocumentGetStatusCountsParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DocumentGetStatusCountsParams]. */ + class Builder internal constructor() { + + private var pipelineId: String? = null + private var dataSourceId: String? = null + private var fileId: String? = null + private var onlyDirectUpload: Boolean? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(documentGetStatusCountsParams: DocumentGetStatusCountsParams) = apply { + pipelineId = documentGetStatusCountsParams.pipelineId + dataSourceId = documentGetStatusCountsParams.dataSourceId + fileId = documentGetStatusCountsParams.fileId + onlyDirectUpload = documentGetStatusCountsParams.onlyDirectUpload + additionalHeaders = documentGetStatusCountsParams.additionalHeaders.toBuilder() + additionalQueryParams = documentGetStatusCountsParams.additionalQueryParams.toBuilder() + } + + fun pipelineId(pipelineId: String?) = apply { this.pipelineId = pipelineId } + + /** Alias for calling [Builder.pipelineId] with `pipelineId.orElse(null)`. */ + fun pipelineId(pipelineId: Optional) = pipelineId(pipelineId.getOrNull()) + + fun dataSourceId(dataSourceId: String?) = apply { this.dataSourceId = dataSourceId } + + /** Alias for calling [Builder.dataSourceId] with `dataSourceId.orElse(null)`. */ + fun dataSourceId(dataSourceId: Optional) = dataSourceId(dataSourceId.getOrNull()) + + fun fileId(fileId: String?) = apply { this.fileId = fileId } + + /** Alias for calling [Builder.fileId] with `fileId.orElse(null)`. */ + fun fileId(fileId: Optional) = fileId(fileId.getOrNull()) + + fun onlyDirectUpload(onlyDirectUpload: Boolean?) = apply { + this.onlyDirectUpload = onlyDirectUpload + } + + /** + * Alias for [Builder.onlyDirectUpload]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun onlyDirectUpload(onlyDirectUpload: Boolean) = + onlyDirectUpload(onlyDirectUpload as Boolean?) + + /** Alias for calling [Builder.onlyDirectUpload] with `onlyDirectUpload.orElse(null)`. */ + fun onlyDirectUpload(onlyDirectUpload: Optional) = + onlyDirectUpload(onlyDirectUpload.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 [DocumentGetStatusCountsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): DocumentGetStatusCountsParams = + DocumentGetStatusCountsParams( + pipelineId, + dataSourceId, + fileId, + onlyDirectUpload, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> pipelineId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + dataSourceId?.let { put("data_source_id", it) } + fileId?.let { put("file_id", it) } + onlyDirectUpload?.let { put("only_direct_upload", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DocumentGetStatusCountsParams && + pipelineId == other.pipelineId && + dataSourceId == other.dataSourceId && + fileId == other.fileId && + onlyDirectUpload == other.onlyDirectUpload && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + pipelineId, + dataSourceId, + fileId, + onlyDirectUpload, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "DocumentGetStatusCountsParams{pipelineId=$pipelineId, dataSourceId=$dataSourceId, fileId=$fileId, onlyDirectUpload=$onlyDirectUpload, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/pipelines/documents/DocumentGetStatusCountsResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/pipelines/documents/DocumentGetStatusCountsResponse.kt new file mode 100644 index 0000000..c9decba --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/pipelines/documents/DocumentGetStatusCountsResponse.kt @@ -0,0 +1,508 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.pipelines.documents + +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.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** Counts of the documents in a pipeline, grouped by ingestion status. */ +class DocumentGetStatusCountsResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val counts: JsonField, + private val pipelineId: JsonField, + private val totalCount: JsonField, + private val dataSourceId: JsonField, + private val fileId: JsonField, + private val onlyDirectUpload: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("counts") @ExcludeMissing counts: JsonField = JsonMissing.of(), + @JsonProperty("pipeline_id") + @ExcludeMissing + pipelineId: JsonField = JsonMissing.of(), + @JsonProperty("total_count") @ExcludeMissing totalCount: JsonField = JsonMissing.of(), + @JsonProperty("data_source_id") + @ExcludeMissing + dataSourceId: JsonField = JsonMissing.of(), + @JsonProperty("file_id") @ExcludeMissing fileId: JsonField = JsonMissing.of(), + @JsonProperty("only_direct_upload") + @ExcludeMissing + onlyDirectUpload: JsonField = JsonMissing.of(), + ) : this(counts, pipelineId, totalCount, dataSourceId, fileId, onlyDirectUpload, mutableMapOf()) + + /** + * Number of documents per ingestion status; every status is present. + * + * @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 counts(): Counts = counts.getRequired("counts") + + /** + * ID of the pipeline the documents belong 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 pipelineId(): String = pipelineId.getRequired("pipeline_id") + + /** + * Total number of documents counted. + * + * @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 totalCount(): Long = totalCount.getRequired("total_count") + + /** + * Data source the counts were restricted to. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun dataSourceId(): Optional = dataSourceId.getOptional("data_source_id") + + /** + * File the counts were restricted to. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fileId(): Optional = fileId.getOptional("file_id") + + /** + * Whether only directly uploaded documents were counted. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun onlyDirectUpload(): Optional = onlyDirectUpload.getOptional("only_direct_upload") + + /** + * Returns the raw JSON value of [counts]. + * + * Unlike [counts], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("counts") @ExcludeMissing fun _counts(): JsonField = counts + + /** + * Returns the raw JSON value of [pipelineId]. + * + * Unlike [pipelineId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pipeline_id") @ExcludeMissing fun _pipelineId(): JsonField = pipelineId + + /** + * Returns the raw JSON value of [totalCount]. + * + * Unlike [totalCount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_count") @ExcludeMissing fun _totalCount(): JsonField = totalCount + + /** + * Returns the raw JSON value of [dataSourceId]. + * + * Unlike [dataSourceId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("data_source_id") + @ExcludeMissing + fun _dataSourceId(): JsonField = dataSourceId + + /** + * Returns the raw JSON value of [fileId]. + * + * Unlike [fileId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("file_id") @ExcludeMissing fun _fileId(): JsonField = fileId + + /** + * Returns the raw JSON value of [onlyDirectUpload]. + * + * Unlike [onlyDirectUpload], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("only_direct_upload") + @ExcludeMissing + fun _onlyDirectUpload(): JsonField = onlyDirectUpload + + @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 + * [DocumentGetStatusCountsResponse]. + * + * The following fields are required: + * ```java + * .counts() + * .pipelineId() + * .totalCount() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [DocumentGetStatusCountsResponse]. */ + class Builder internal constructor() { + + private var counts: JsonField? = null + private var pipelineId: JsonField? = null + private var totalCount: JsonField? = null + private var dataSourceId: JsonField = JsonMissing.of() + private var fileId: JsonField = JsonMissing.of() + private var onlyDirectUpload: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(documentGetStatusCountsResponse: DocumentGetStatusCountsResponse) = + apply { + counts = documentGetStatusCountsResponse.counts + pipelineId = documentGetStatusCountsResponse.pipelineId + totalCount = documentGetStatusCountsResponse.totalCount + dataSourceId = documentGetStatusCountsResponse.dataSourceId + fileId = documentGetStatusCountsResponse.fileId + onlyDirectUpload = documentGetStatusCountsResponse.onlyDirectUpload + additionalProperties = + documentGetStatusCountsResponse.additionalProperties.toMutableMap() + } + + /** Number of documents per ingestion status; every status is present. */ + fun counts(counts: Counts) = counts(JsonField.of(counts)) + + /** + * Sets [Builder.counts] to an arbitrary JSON value. + * + * You should usually call [Builder.counts] with a well-typed [Counts] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun counts(counts: JsonField) = apply { this.counts = counts } + + /** ID of the pipeline the documents belong to. */ + fun pipelineId(pipelineId: String) = pipelineId(JsonField.of(pipelineId)) + + /** + * Sets [Builder.pipelineId] to an arbitrary JSON value. + * + * You should usually call [Builder.pipelineId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pipelineId(pipelineId: JsonField) = apply { this.pipelineId = pipelineId } + + /** Total number of documents counted. */ + fun totalCount(totalCount: Long) = totalCount(JsonField.of(totalCount)) + + /** + * Sets [Builder.totalCount] to an arbitrary JSON value. + * + * You should usually call [Builder.totalCount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun totalCount(totalCount: JsonField) = apply { this.totalCount = totalCount } + + /** Data source the counts were restricted to. */ + fun dataSourceId(dataSourceId: String?) = dataSourceId(JsonField.ofNullable(dataSourceId)) + + /** Alias for calling [Builder.dataSourceId] with `dataSourceId.orElse(null)`. */ + fun dataSourceId(dataSourceId: Optional) = dataSourceId(dataSourceId.getOrNull()) + + /** + * Sets [Builder.dataSourceId] to an arbitrary JSON value. + * + * You should usually call [Builder.dataSourceId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun dataSourceId(dataSourceId: JsonField) = apply { + this.dataSourceId = dataSourceId + } + + /** File the counts were restricted to. */ + fun fileId(fileId: String?) = fileId(JsonField.ofNullable(fileId)) + + /** Alias for calling [Builder.fileId] with `fileId.orElse(null)`. */ + fun fileId(fileId: Optional) = fileId(fileId.getOrNull()) + + /** + * Sets [Builder.fileId] to an arbitrary JSON value. + * + * You should usually call [Builder.fileId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fileId(fileId: JsonField) = apply { this.fileId = fileId } + + /** Whether only directly uploaded documents were counted. */ + fun onlyDirectUpload(onlyDirectUpload: Boolean) = + onlyDirectUpload(JsonField.of(onlyDirectUpload)) + + /** + * Sets [Builder.onlyDirectUpload] to an arbitrary JSON value. + * + * You should usually call [Builder.onlyDirectUpload] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun onlyDirectUpload(onlyDirectUpload: JsonField) = apply { + this.onlyDirectUpload = onlyDirectUpload + } + + 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 [DocumentGetStatusCountsResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .counts() + * .pipelineId() + * .totalCount() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): DocumentGetStatusCountsResponse = + DocumentGetStatusCountsResponse( + checkRequired("counts", counts), + checkRequired("pipelineId", pipelineId), + checkRequired("totalCount", totalCount), + dataSourceId, + fileId, + onlyDirectUpload, + 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(): DocumentGetStatusCountsResponse = apply { + if (validated) { + return@apply + } + + counts().validate() + pipelineId() + totalCount() + dataSourceId() + fileId() + onlyDirectUpload() + 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 = + (counts.asKnown().getOrNull()?.validity() ?: 0) + + (if (pipelineId.asKnown().isPresent) 1 else 0) + + (if (totalCount.asKnown().isPresent) 1 else 0) + + (if (dataSourceId.asKnown().isPresent) 1 else 0) + + (if (fileId.asKnown().isPresent) 1 else 0) + + (if (onlyDirectUpload.asKnown().isPresent) 1 else 0) + + /** Number of documents per ingestion status; every status is present. */ + class Counts + @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 [Counts]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Counts]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(counts: Counts) = apply { + additionalProperties = counts.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 [Counts]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Counts = Counts(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(): Counts = 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 Counts && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "Counts{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DocumentGetStatusCountsResponse && + counts == other.counts && + pipelineId == other.pipelineId && + totalCount == other.totalCount && + dataSourceId == other.dataSourceId && + fileId == other.fileId && + onlyDirectUpload == other.onlyDirectUpload && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + counts, + pipelineId, + totalCount, + dataSourceId, + fileId, + onlyDirectUpload, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "DocumentGetStatusCountsResponse{counts=$counts, pipelineId=$pipelineId, totalCount=$totalCount, dataSourceId=$dataSourceId, fileId=$fileId, onlyDirectUpload=$onlyDirectUpload, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitCancelParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitCancelParams.kt new file mode 100644 index 0000000..d874784 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitCancelParams.kt @@ -0,0 +1,274 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +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 + +/** + * Cancel a running split job. + * + * Requests cancellation; the job transitions to CANCELLED asynchronously once processing stops. + * Returns the job, which may still be in its current non-terminal state. Jobs already in a terminal + * state (COMPLETED, FAILED, CANCELLED) cannot be cancelled. + */ +class SplitCancelParams +private constructor( + private val splitJobId: String?, + private val organizationId: String?, + private val projectId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun splitJobId(): Optional = Optional.ofNullable(splitJobId) + + 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(): SplitCancelParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SplitCancelParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SplitCancelParams]. */ + class Builder internal constructor() { + + private var splitJobId: 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(splitCancelParams: SplitCancelParams) = apply { + splitJobId = splitCancelParams.splitJobId + organizationId = splitCancelParams.organizationId + projectId = splitCancelParams.projectId + additionalHeaders = splitCancelParams.additionalHeaders.toBuilder() + additionalQueryParams = splitCancelParams.additionalQueryParams.toBuilder() + additionalBodyProperties = splitCancelParams.additionalBodyProperties.toMutableMap() + } + + fun splitJobId(splitJobId: String?) = apply { this.splitJobId = splitJobId } + + /** Alias for calling [Builder.splitJobId] with `splitJobId.orElse(null)`. */ + fun splitJobId(splitJobId: Optional) = splitJobId(splitJobId.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 [SplitCancelParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SplitCancelParams = + SplitCancelParams( + splitJobId, + organizationId, + projectId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> splitJobId ?: "" + 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 SplitCancelParams && + splitJobId == other.splitJobId && + organizationId == other.organizationId && + projectId == other.projectId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + splitJobId, + organizationId, + projectId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "SplitCancelParams{splitJobId=$splitJobId, organizationId=$organizationId, projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitCancelResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitCancelResponse.kt new file mode 100644 index 0000000..030ef79 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitCancelResponse.kt @@ -0,0 +1,1253 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +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.checkKnown +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.core.toImmutable +import ai.llamaindex.llamacloud.errors.LlamaCloudInvalidDataException +import ai.llamaindex.llamacloud.models.beta.split.SplitCategory +import ai.llamaindex.llamacloud.models.beta.split.SplitResultResponse +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 split job. */ +class SplitCancelResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val categories: JsonField>, + private val documentInputType: JsonField, + private val fileInput: JsonField, + private val projectId: JsonField, + private val status: JsonField, + private val userId: JsonField, + private val configurationId: JsonField, + private val createdAt: JsonField, + private val errorMessage: JsonField, + private val result: JsonField, + private val splittingStrategy: JsonField, + private val transactionId: JsonField, + private val updatedAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("categories") + @ExcludeMissing + categories: JsonField> = JsonMissing.of(), + @JsonProperty("document_input_type") + @ExcludeMissing + documentInputType: JsonField = JsonMissing.of(), + @JsonProperty("file_input") @ExcludeMissing fileInput: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing userId: JsonField = JsonMissing.of(), + @JsonProperty("configuration_id") + @ExcludeMissing + configurationId: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("error_message") + @ExcludeMissing + errorMessage: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("splitting_strategy") + @ExcludeMissing + splittingStrategy: JsonField = JsonMissing.of(), + @JsonProperty("transaction_id") + @ExcludeMissing + transactionId: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this( + id, + categories, + documentInputType, + fileInput, + projectId, + status, + userId, + configurationId, + createdAt, + errorMessage, + result, + splittingStrategy, + transactionId, + updatedAt, + mutableMapOf(), + ) + + /** + * Unique identifier for the split 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") + + /** + * Categories used for splitting. + * + * @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 categories(): List = categories.getRequired("categories") + + /** + * Whether the input was a file or parse 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 documentInputType(): DocumentInputType = + documentInputType.getRequired("document_input_type") + + /** + * File ID or parse 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 fileInput(): String = fileInput.getRequired("file_input") + + /** + * Project this job 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") + + /** + * Current job status. Valid values are: pending, processing, completed, failed, cancelled. + * + * @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") + + /** + * User who created this 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 userId(): String = userId.getRequired("user_id") + + /** + * Split configuration ID used for this job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun configurationId(): Optional = configurationId.getOptional("configuration_id") + + /** + * Creation datetime + * + * @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") + + /** + * Error message if the job failed. + * + * @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") + + /** + * Result of a completed split job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun result(): Optional = result.getOptional("result") + + /** + * Strategy used for splitting. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun splittingStrategy(): Optional = + splittingStrategy.getOptional("splitting_strategy") + + /** + * Idempotency key scoped to the project, if one was provided. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transactionId(): Optional = transactionId.getOptional("transaction_id") + + /** + * Update datetime + * + * @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 [categories]. + * + * Unlike [categories], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("categories") + @ExcludeMissing + fun _categories(): JsonField> = categories + + /** + * Returns the raw JSON value of [documentInputType]. + * + * Unlike [documentInputType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("document_input_type") + @ExcludeMissing + fun _documentInputType(): JsonField = documentInputType + + /** + * Returns the raw JSON value of [fileInput]. + * + * Unlike [fileInput], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("file_input") @ExcludeMissing fun _fileInput(): JsonField = fileInput + + /** + * 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 [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + + /** + * Returns the raw JSON value of [configurationId]. + * + * Unlike [configurationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("configuration_id") + @ExcludeMissing + fun _configurationId(): JsonField = configurationId + + /** + * 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 [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 [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [splittingStrategy]. + * + * Unlike [splittingStrategy], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("splitting_strategy") + @ExcludeMissing + fun _splittingStrategy(): JsonField = splittingStrategy + + /** + * Returns the raw JSON value of [transactionId]. + * + * Unlike [transactionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("transaction_id") + @ExcludeMissing + fun _transactionId(): JsonField = transactionId + + /** + * 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 [SplitCancelResponse]. + * + * The following fields are required: + * ```java + * .id() + * .categories() + * .documentInputType() + * .fileInput() + * .projectId() + * .status() + * .userId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SplitCancelResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var categories: JsonField>? = null + private var documentInputType: JsonField? = null + private var fileInput: JsonField? = null + private var projectId: JsonField? = null + private var status: JsonField? = null + private var userId: JsonField? = null + private var configurationId: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var errorMessage: JsonField = JsonMissing.of() + private var result: JsonField = JsonMissing.of() + private var splittingStrategy: JsonField = JsonMissing.of() + private var transactionId: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(splitCancelResponse: SplitCancelResponse) = apply { + id = splitCancelResponse.id + categories = splitCancelResponse.categories.map { it.toMutableList() } + documentInputType = splitCancelResponse.documentInputType + fileInput = splitCancelResponse.fileInput + projectId = splitCancelResponse.projectId + status = splitCancelResponse.status + userId = splitCancelResponse.userId + configurationId = splitCancelResponse.configurationId + createdAt = splitCancelResponse.createdAt + errorMessage = splitCancelResponse.errorMessage + result = splitCancelResponse.result + splittingStrategy = splitCancelResponse.splittingStrategy + transactionId = splitCancelResponse.transactionId + updatedAt = splitCancelResponse.updatedAt + additionalProperties = splitCancelResponse.additionalProperties.toMutableMap() + } + + /** Unique identifier for the split 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 } + + /** Categories used for splitting. */ + fun categories(categories: List) = categories(JsonField.of(categories)) + + /** + * Sets [Builder.categories] to an arbitrary JSON value. + * + * You should usually call [Builder.categories] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun categories(categories: JsonField>) = apply { + this.categories = categories.map { it.toMutableList() } + } + + /** + * Adds a single [SplitCategory] to [categories]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCategory(category: SplitCategory) = apply { + categories = + (categories ?: JsonField.of(mutableListOf())).also { + checkKnown("categories", it).add(category) + } + } + + /** Whether the input was a file or parse job */ + fun documentInputType(documentInputType: DocumentInputType) = + documentInputType(JsonField.of(documentInputType)) + + /** + * Sets [Builder.documentInputType] to an arbitrary JSON value. + * + * You should usually call [Builder.documentInputType] with a well-typed [DocumentInputType] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun documentInputType(documentInputType: JsonField) = apply { + this.documentInputType = documentInputType + } + + /** File ID or parse job ID */ + fun fileInput(fileInput: String) = fileInput(JsonField.of(fileInput)) + + /** + * Sets [Builder.fileInput] to an arbitrary JSON value. + * + * You should usually call [Builder.fileInput] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun fileInput(fileInput: JsonField) = apply { this.fileInput = fileInput } + + /** Project this job 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 } + + /** + * Current job status. Valid values are: pending, processing, completed, failed, cancelled. + */ + 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 } + + /** User who created this job. */ + fun userId(userId: String) = userId(JsonField.of(userId)) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun userId(userId: JsonField) = apply { this.userId = userId } + + /** Split configuration ID used for this job. */ + fun configurationId(configurationId: String?) = + configurationId(JsonField.ofNullable(configurationId)) + + /** Alias for calling [Builder.configurationId] with `configurationId.orElse(null)`. */ + fun configurationId(configurationId: Optional) = + configurationId(configurationId.getOrNull()) + + /** + * Sets [Builder.configurationId] to an arbitrary JSON value. + * + * You should usually call [Builder.configurationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun configurationId(configurationId: JsonField) = apply { + this.configurationId = configurationId + } + + /** Creation datetime */ + 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 } + + /** Error message if the job failed. */ + 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 + } + + /** Result of a completed split job. */ + fun result(result: SplitResultResponse?) = result(JsonField.ofNullable(result)) + + /** Alias for calling [Builder.result] with `result.orElse(null)`. */ + fun result(result: Optional) = result(result.getOrNull()) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [SplitResultResponse] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun result(result: JsonField) = apply { this.result = result } + + /** Strategy used for splitting. */ + fun splittingStrategy(splittingStrategy: SplittingStrategy) = + splittingStrategy(JsonField.of(splittingStrategy)) + + /** + * Sets [Builder.splittingStrategy] to an arbitrary JSON value. + * + * You should usually call [Builder.splittingStrategy] with a well-typed [SplittingStrategy] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun splittingStrategy(splittingStrategy: JsonField) = apply { + this.splittingStrategy = splittingStrategy + } + + /** Idempotency key scoped to the project, if one was provided. */ + fun transactionId(transactionId: String?) = + transactionId(JsonField.ofNullable(transactionId)) + + /** Alias for calling [Builder.transactionId] with `transactionId.orElse(null)`. */ + fun transactionId(transactionId: Optional) = + transactionId(transactionId.getOrNull()) + + /** + * Sets [Builder.transactionId] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun transactionId(transactionId: JsonField) = apply { + this.transactionId = transactionId + } + + /** Update datetime */ + 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 [SplitCancelResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .categories() + * .documentInputType() + * .fileInput() + * .projectId() + * .status() + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SplitCancelResponse = + SplitCancelResponse( + checkRequired("id", id), + checkRequired("categories", categories).map { it.toImmutable() }, + checkRequired("documentInputType", documentInputType), + checkRequired("fileInput", fileInput), + checkRequired("projectId", projectId), + checkRequired("status", status), + checkRequired("userId", userId), + configurationId, + createdAt, + errorMessage, + result, + splittingStrategy, + transactionId, + 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(): SplitCancelResponse = apply { + if (validated) { + return@apply + } + + id() + categories().forEach { it.validate() } + documentInputType().validate() + fileInput() + projectId() + status() + userId() + configurationId() + createdAt() + errorMessage() + result().ifPresent { it.validate() } + splittingStrategy().ifPresent { it.validate() } + transactionId() + 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) + + (categories.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (documentInputType.asKnown().getOrNull()?.validity() ?: 0) + + (if (fileInput.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (if (configurationId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (errorMessage.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (splittingStrategy.asKnown().getOrNull()?.validity() ?: 0) + + (if (transactionId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + /** Whether the input was a file or parse job */ + class DocumentInputType @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 FILE_ID = of("file_id") + + @JvmField val PARSE_JOB_ID = of("parse_job_id") + + @JvmField val URL = of("url") + + @JvmStatic fun of(value: String) = DocumentInputType(JsonField.of(value)) + } + + /** An enum containing [DocumentInputType]'s known values. */ + enum class Known { + FILE_ID, + PARSE_JOB_ID, + URL, + } + + /** + * An enum containing [DocumentInputType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DocumentInputType] 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 { + FILE_ID, + PARSE_JOB_ID, + URL, + /** + * An enum member indicating that [DocumentInputType] 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) { + FILE_ID -> Value.FILE_ID + PARSE_JOB_ID -> Value.PARSE_JOB_ID + URL -> Value.URL + 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) { + FILE_ID -> Known.FILE_ID + PARSE_JOB_ID -> Known.PARSE_JOB_ID + URL -> Known.URL + else -> throw LlamaCloudInvalidDataException("Unknown DocumentInputType: $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(): DocumentInputType = 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 DocumentInputType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Strategy used for splitting. */ + class SplittingStrategy + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowUncategorized: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allow_uncategorized") + @ExcludeMissing + allowUncategorized: JsonField = JsonMissing.of() + ) : this(allowUncategorized, mutableMapOf()) + + /** + * Controls handling of pages that don't match any category. 'include': pages can be grouped + * as 'uncategorized' and included in results. 'forbid': all pages must be assigned to a + * defined category. 'omit': pages can be classified as 'uncategorized' but are excluded + * from results. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun allowUncategorized(): Optional = + allowUncategorized.getOptional("allow_uncategorized") + + /** + * Returns the raw JSON value of [allowUncategorized]. + * + * Unlike [allowUncategorized], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allow_uncategorized") + @ExcludeMissing + fun _allowUncategorized(): JsonField = allowUncategorized + + @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 [SplittingStrategy]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SplittingStrategy]. */ + class Builder internal constructor() { + + private var allowUncategorized: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(splittingStrategy: SplittingStrategy) = apply { + allowUncategorized = splittingStrategy.allowUncategorized + additionalProperties = splittingStrategy.additionalProperties.toMutableMap() + } + + /** + * Controls handling of pages that don't match any category. 'include': pages can be + * grouped as 'uncategorized' and included in results. 'forbid': all pages must be + * assigned to a defined category. 'omit': pages can be classified as 'uncategorized' + * but are excluded from results. + */ + fun allowUncategorized(allowUncategorized: AllowUncategorized) = + allowUncategorized(JsonField.of(allowUncategorized)) + + /** + * Sets [Builder.allowUncategorized] to an arbitrary JSON value. + * + * You should usually call [Builder.allowUncategorized] with a well-typed + * [AllowUncategorized] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allowUncategorized(allowUncategorized: JsonField) = apply { + this.allowUncategorized = allowUncategorized + } + + 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 [SplittingStrategy]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SplittingStrategy = + SplittingStrategy(allowUncategorized, 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(): SplittingStrategy = apply { + if (validated) { + return@apply + } + + allowUncategorized().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 = (allowUncategorized.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Controls handling of pages that don't match any category. 'include': pages can be grouped + * as 'uncategorized' and included in results. 'forbid': all pages must be assigned to a + * defined category. 'omit': pages can be classified as 'uncategorized' but are excluded + * from results. + */ + class AllowUncategorized + @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 FORBID = of("forbid") + + @JvmField val INCLUDE = of("include") + + @JvmField val OMIT = of("omit") + + @JvmStatic fun of(value: String) = AllowUncategorized(JsonField.of(value)) + } + + /** An enum containing [AllowUncategorized]'s known values. */ + enum class Known { + FORBID, + INCLUDE, + OMIT, + } + + /** + * An enum containing [AllowUncategorized]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AllowUncategorized] 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 { + FORBID, + INCLUDE, + OMIT, + /** + * An enum member indicating that [AllowUncategorized] 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) { + FORBID -> Value.FORBID + INCLUDE -> Value.INCLUDE + OMIT -> Value.OMIT + 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) { + FORBID -> Known.FORBID + INCLUDE -> Known.INCLUDE + OMIT -> Known.OMIT + else -> + throw LlamaCloudInvalidDataException("Unknown AllowUncategorized: $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(): AllowUncategorized = 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 AllowUncategorized && 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 SplittingStrategy && + allowUncategorized == other.allowUncategorized && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(allowUncategorized, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SplittingStrategy{allowUncategorized=$allowUncategorized, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SplitCancelResponse && + id == other.id && + categories == other.categories && + documentInputType == other.documentInputType && + fileInput == other.fileInput && + projectId == other.projectId && + status == other.status && + userId == other.userId && + configurationId == other.configurationId && + createdAt == other.createdAt && + errorMessage == other.errorMessage && + result == other.result && + splittingStrategy == other.splittingStrategy && + transactionId == other.transactionId && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + categories, + documentInputType, + fileInput, + projectId, + status, + userId, + configurationId, + createdAt, + errorMessage, + result, + splittingStrategy, + transactionId, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SplitCancelResponse{id=$id, categories=$categories, documentInputType=$documentInputType, fileInput=$fileInput, projectId=$projectId, status=$status, userId=$userId, configurationId=$configurationId, createdAt=$createdAt, errorMessage=$errorMessage, result=$result, splittingStrategy=$splittingStrategy, transactionId=$transactionId, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitCreateParams.kt new file mode 100644 index 0000000..6b2193f --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitCreateParams.kt @@ -0,0 +1,2388 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +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.Params +import ai.llamaindex.llamacloud.core.checkKnown +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 ai.llamaindex.llamacloud.models.beta.split.SplitCategory +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 + +/** Create a document split job. */ +class SplitCreateParams +private constructor( + private val organizationId: String?, + private val projectId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun organizationId(): Optional = Optional.ofNullable(organizationId) + + fun projectId(): Optional = Optional.ofNullable(projectId) + + /** + * File ID or parse 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 fileInput(): String = body.fileInput() + + /** + * Split configuration with categories and splitting strategy. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun configuration(): Optional = body.configuration() + + /** + * Saved configuration ID + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun configurationId(): Optional = body.configurationId() + + /** + * Idempotency key scoped to the project. Reusing a key returns the original job; the new + * request body is ignored. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transactionId(): Optional = body.transactionId() + + /** + * IDs of saved webhook configurations to notify for this job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookConfigurationIds(): Optional> = body.webhookConfigurationIds() + + /** + * Outbound webhook endpoints to notify on job status changes + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookConfigurations(): Optional> = body.webhookConfigurations() + + /** + * Returns the raw JSON value of [fileInput]. + * + * Unlike [fileInput], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _fileInput(): JsonField = body._fileInput() + + /** + * Returns the raw JSON value of [configuration]. + * + * Unlike [configuration], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _configuration(): JsonField = body._configuration() + + /** + * Returns the raw JSON value of [configurationId]. + * + * Unlike [configurationId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _configurationId(): JsonField = body._configurationId() + + /** + * Returns the raw JSON value of [transactionId]. + * + * Unlike [transactionId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _transactionId(): JsonField = body._transactionId() + + /** + * Returns the raw JSON value of [webhookConfigurationIds]. + * + * Unlike [webhookConfigurationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + fun _webhookConfigurationIds(): JsonField> = body._webhookConfigurationIds() + + /** + * Returns the raw JSON value of [webhookConfigurations]. + * + * Unlike [webhookConfigurations], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _webhookConfigurations(): JsonField> = + body._webhookConfigurations() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SplitCreateParams]. + * + * The following fields are required: + * ```java + * .fileInput() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SplitCreateParams]. */ + class Builder internal constructor() { + + private var organizationId: String? = null + private var projectId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(splitCreateParams: SplitCreateParams) = apply { + organizationId = splitCreateParams.organizationId + projectId = splitCreateParams.projectId + body = splitCreateParams.body.toBuilder() + additionalHeaders = splitCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = splitCreateParams.additionalQueryParams.toBuilder() + } + + 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()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [fileInput] + * - [configuration] + * - [configurationId] + * - [transactionId] + * - [webhookConfigurationIds] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** File ID or parse job ID */ + fun fileInput(fileInput: String) = apply { body.fileInput(fileInput) } + + /** + * Sets [Builder.fileInput] to an arbitrary JSON value. + * + * You should usually call [Builder.fileInput] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun fileInput(fileInput: JsonField) = apply { body.fileInput(fileInput) } + + /** Split configuration with categories and splitting strategy. */ + fun configuration(configuration: Configuration?) = apply { + body.configuration(configuration) + } + + /** Alias for calling [Builder.configuration] with `configuration.orElse(null)`. */ + fun configuration(configuration: Optional) = + configuration(configuration.getOrNull()) + + /** + * Sets [Builder.configuration] to an arbitrary JSON value. + * + * You should usually call [Builder.configuration] with a well-typed [Configuration] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun configuration(configuration: JsonField) = apply { + body.configuration(configuration) + } + + /** Saved configuration ID */ + fun configurationId(configurationId: String?) = apply { + body.configurationId(configurationId) + } + + /** Alias for calling [Builder.configurationId] with `configurationId.orElse(null)`. */ + fun configurationId(configurationId: Optional) = + configurationId(configurationId.getOrNull()) + + /** + * Sets [Builder.configurationId] to an arbitrary JSON value. + * + * You should usually call [Builder.configurationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun configurationId(configurationId: JsonField) = apply { + body.configurationId(configurationId) + } + + /** + * Idempotency key scoped to the project. Reusing a key returns the original job; the new + * request body is ignored. + */ + fun transactionId(transactionId: String?) = apply { body.transactionId(transactionId) } + + /** Alias for calling [Builder.transactionId] with `transactionId.orElse(null)`. */ + fun transactionId(transactionId: Optional) = + transactionId(transactionId.getOrNull()) + + /** + * Sets [Builder.transactionId] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun transactionId(transactionId: JsonField) = apply { + body.transactionId(transactionId) + } + + /** IDs of saved webhook configurations to notify for this job. */ + fun webhookConfigurationIds(webhookConfigurationIds: List?) = apply { + body.webhookConfigurationIds(webhookConfigurationIds) + } + + /** + * Alias for calling [Builder.webhookConfigurationIds] with + * `webhookConfigurationIds.orElse(null)`. + */ + fun webhookConfigurationIds(webhookConfigurationIds: Optional>) = + webhookConfigurationIds(webhookConfigurationIds.getOrNull()) + + /** + * Sets [Builder.webhookConfigurationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookConfigurationIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun webhookConfigurationIds(webhookConfigurationIds: JsonField>) = apply { + body.webhookConfigurationIds(webhookConfigurationIds) + } + + /** + * Adds a single [String] to [webhookConfigurationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookConfigurationId(webhookConfigurationId: String) = apply { + body.addWebhookConfigurationId(webhookConfigurationId) + } + + /** Outbound webhook endpoints to notify on job status changes */ + fun webhookConfigurations(webhookConfigurations: List?) = apply { + body.webhookConfigurations(webhookConfigurations) + } + + /** + * Alias for calling [Builder.webhookConfigurations] with + * `webhookConfigurations.orElse(null)`. + */ + fun webhookConfigurations(webhookConfigurations: Optional>) = + webhookConfigurations(webhookConfigurations.getOrNull()) + + /** + * Sets [Builder.webhookConfigurations] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookConfigurations] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun webhookConfigurations(webhookConfigurations: JsonField>) = + apply { + body.webhookConfigurations(webhookConfigurations) + } + + /** + * Adds a single [WebhookConfiguration] to [webhookConfigurations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookConfiguration(webhookConfiguration: WebhookConfiguration) = apply { + body.addWebhookConfiguration(webhookConfiguration) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [SplitCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fileInput() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SplitCreateParams = + SplitCreateParams( + organizationId, + projectId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + 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() + + /** Create a split job. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val fileInput: JsonField, + private val configuration: JsonField, + private val configurationId: JsonField, + private val transactionId: JsonField, + private val webhookConfigurationIds: JsonField>, + private val webhookConfigurations: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("file_input") + @ExcludeMissing + fileInput: JsonField = JsonMissing.of(), + @JsonProperty("configuration") + @ExcludeMissing + configuration: JsonField = JsonMissing.of(), + @JsonProperty("configuration_id") + @ExcludeMissing + configurationId: JsonField = JsonMissing.of(), + @JsonProperty("transaction_id") + @ExcludeMissing + transactionId: JsonField = JsonMissing.of(), + @JsonProperty("webhook_configuration_ids") + @ExcludeMissing + webhookConfigurationIds: JsonField> = JsonMissing.of(), + @JsonProperty("webhook_configurations") + @ExcludeMissing + webhookConfigurations: JsonField> = JsonMissing.of(), + ) : this( + fileInput, + configuration, + configurationId, + transactionId, + webhookConfigurationIds, + webhookConfigurations, + mutableMapOf(), + ) + + /** + * File ID or parse 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 fileInput(): String = fileInput.getRequired("file_input") + + /** + * Split configuration with categories and splitting strategy. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun configuration(): Optional = configuration.getOptional("configuration") + + /** + * Saved configuration ID + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun configurationId(): Optional = configurationId.getOptional("configuration_id") + + /** + * Idempotency key scoped to the project. Reusing a key returns the original job; the new + * request body is ignored. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun transactionId(): Optional = transactionId.getOptional("transaction_id") + + /** + * IDs of saved webhook configurations to notify for this job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookConfigurationIds(): Optional> = + webhookConfigurationIds.getOptional("webhook_configuration_ids") + + /** + * Outbound webhook endpoints to notify on job status changes + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookConfigurations(): Optional> = + webhookConfigurations.getOptional("webhook_configurations") + + /** + * Returns the raw JSON value of [fileInput]. + * + * Unlike [fileInput], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("file_input") @ExcludeMissing fun _fileInput(): JsonField = fileInput + + /** + * Returns the raw JSON value of [configuration]. + * + * Unlike [configuration], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("configuration") + @ExcludeMissing + fun _configuration(): JsonField = configuration + + /** + * Returns the raw JSON value of [configurationId]. + * + * Unlike [configurationId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("configuration_id") + @ExcludeMissing + fun _configurationId(): JsonField = configurationId + + /** + * Returns the raw JSON value of [transactionId]. + * + * Unlike [transactionId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transaction_id") + @ExcludeMissing + fun _transactionId(): JsonField = transactionId + + /** + * Returns the raw JSON value of [webhookConfigurationIds]. + * + * Unlike [webhookConfigurationIds], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("webhook_configuration_ids") + @ExcludeMissing + fun _webhookConfigurationIds(): JsonField> = webhookConfigurationIds + + /** + * Returns the raw JSON value of [webhookConfigurations]. + * + * Unlike [webhookConfigurations], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("webhook_configurations") + @ExcludeMissing + fun _webhookConfigurations(): JsonField> = webhookConfigurations + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .fileInput() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var fileInput: JsonField? = null + private var configuration: JsonField = JsonMissing.of() + private var configurationId: JsonField = JsonMissing.of() + private var transactionId: JsonField = JsonMissing.of() + private var webhookConfigurationIds: JsonField>? = null + private var webhookConfigurations: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + fileInput = body.fileInput + configuration = body.configuration + configurationId = body.configurationId + transactionId = body.transactionId + webhookConfigurationIds = body.webhookConfigurationIds.map { it.toMutableList() } + webhookConfigurations = body.webhookConfigurations.map { it.toMutableList() } + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** File ID or parse job ID */ + fun fileInput(fileInput: String) = fileInput(JsonField.of(fileInput)) + + /** + * Sets [Builder.fileInput] to an arbitrary JSON value. + * + * You should usually call [Builder.fileInput] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun fileInput(fileInput: JsonField) = apply { this.fileInput = fileInput } + + /** Split configuration with categories and splitting strategy. */ + fun configuration(configuration: Configuration?) = + configuration(JsonField.ofNullable(configuration)) + + /** Alias for calling [Builder.configuration] with `configuration.orElse(null)`. */ + fun configuration(configuration: Optional) = + configuration(configuration.getOrNull()) + + /** + * Sets [Builder.configuration] to an arbitrary JSON value. + * + * You should usually call [Builder.configuration] with a well-typed [Configuration] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun configuration(configuration: JsonField) = apply { + this.configuration = configuration + } + + /** Saved configuration ID */ + fun configurationId(configurationId: String?) = + configurationId(JsonField.ofNullable(configurationId)) + + /** Alias for calling [Builder.configurationId] with `configurationId.orElse(null)`. */ + fun configurationId(configurationId: Optional) = + configurationId(configurationId.getOrNull()) + + /** + * Sets [Builder.configurationId] to an arbitrary JSON value. + * + * You should usually call [Builder.configurationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun configurationId(configurationId: JsonField) = apply { + this.configurationId = configurationId + } + + /** + * Idempotency key scoped to the project. Reusing a key returns the original job; the + * new request body is ignored. + */ + fun transactionId(transactionId: String?) = + transactionId(JsonField.ofNullable(transactionId)) + + /** Alias for calling [Builder.transactionId] with `transactionId.orElse(null)`. */ + fun transactionId(transactionId: Optional) = + transactionId(transactionId.getOrNull()) + + /** + * Sets [Builder.transactionId] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun transactionId(transactionId: JsonField) = apply { + this.transactionId = transactionId + } + + /** IDs of saved webhook configurations to notify for this job. */ + fun webhookConfigurationIds(webhookConfigurationIds: List?) = + webhookConfigurationIds(JsonField.ofNullable(webhookConfigurationIds)) + + /** + * Alias for calling [Builder.webhookConfigurationIds] with + * `webhookConfigurationIds.orElse(null)`. + */ + fun webhookConfigurationIds(webhookConfigurationIds: Optional>) = + webhookConfigurationIds(webhookConfigurationIds.getOrNull()) + + /** + * Sets [Builder.webhookConfigurationIds] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookConfigurationIds] with a well-typed + * `List` value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun webhookConfigurationIds(webhookConfigurationIds: JsonField>) = apply { + this.webhookConfigurationIds = webhookConfigurationIds.map { it.toMutableList() } + } + + /** + * Adds a single [String] to [webhookConfigurationIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookConfigurationId(webhookConfigurationId: String) = apply { + webhookConfigurationIds = + (webhookConfigurationIds ?: JsonField.of(mutableListOf())).also { + checkKnown("webhookConfigurationIds", it).add(webhookConfigurationId) + } + } + + /** Outbound webhook endpoints to notify on job status changes */ + fun webhookConfigurations(webhookConfigurations: List?) = + webhookConfigurations(JsonField.ofNullable(webhookConfigurations)) + + /** + * Alias for calling [Builder.webhookConfigurations] with + * `webhookConfigurations.orElse(null)`. + */ + fun webhookConfigurations(webhookConfigurations: Optional>) = + webhookConfigurations(webhookConfigurations.getOrNull()) + + /** + * Sets [Builder.webhookConfigurations] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookConfigurations] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun webhookConfigurations( + webhookConfigurations: JsonField> + ) = apply { + this.webhookConfigurations = webhookConfigurations.map { it.toMutableList() } + } + + /** + * Adds a single [WebhookConfiguration] to [webhookConfigurations]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookConfiguration(webhookConfiguration: WebhookConfiguration) = apply { + webhookConfigurations = + (webhookConfigurations ?: JsonField.of(mutableListOf())).also { + checkKnown("webhookConfigurations", it).add(webhookConfiguration) + } + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .fileInput() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("fileInput", fileInput), + configuration, + configurationId, + transactionId, + (webhookConfigurationIds ?: JsonMissing.of()).map { it.toImmutable() }, + (webhookConfigurations ?: JsonMissing.of()).map { it.toImmutable() }, + 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(): Body = apply { + if (validated) { + return@apply + } + + fileInput() + configuration().ifPresent { it.validate() } + configurationId() + transactionId() + webhookConfigurationIds() + webhookConfigurations().ifPresent { it.forEach { 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 (fileInput.asKnown().isPresent) 1 else 0) + + (configuration.asKnown().getOrNull()?.validity() ?: 0) + + (if (configurationId.asKnown().isPresent) 1 else 0) + + (if (transactionId.asKnown().isPresent) 1 else 0) + + (webhookConfigurationIds.asKnown().getOrNull()?.size ?: 0) + + (webhookConfigurations.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + fileInput == other.fileInput && + configuration == other.configuration && + configurationId == other.configurationId && + transactionId == other.transactionId && + webhookConfigurationIds == other.webhookConfigurationIds && + webhookConfigurations == other.webhookConfigurations && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + fileInput, + configuration, + configurationId, + transactionId, + webhookConfigurationIds, + webhookConfigurations, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{fileInput=$fileInput, configuration=$configuration, configurationId=$configurationId, transactionId=$transactionId, webhookConfigurationIds=$webhookConfigurationIds, webhookConfigurations=$webhookConfigurations, additionalProperties=$additionalProperties}" + } + + /** Split configuration with categories and splitting strategy. */ + class Configuration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val categories: JsonField>, + private val splittingStrategy: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("categories") + @ExcludeMissing + categories: JsonField> = JsonMissing.of(), + @JsonProperty("splitting_strategy") + @ExcludeMissing + splittingStrategy: JsonField = JsonMissing.of(), + ) : this(categories, splittingStrategy, mutableMapOf()) + + /** + * Categories to split documents into. + * + * @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 categories(): List = categories.getRequired("categories") + + /** + * Strategy for splitting documents. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun splittingStrategy(): Optional = + splittingStrategy.getOptional("splitting_strategy") + + /** + * Returns the raw JSON value of [categories]. + * + * Unlike [categories], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("categories") + @ExcludeMissing + fun _categories(): JsonField> = categories + + /** + * Returns the raw JSON value of [splittingStrategy]. + * + * Unlike [splittingStrategy], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("splitting_strategy") + @ExcludeMissing + fun _splittingStrategy(): JsonField = splittingStrategy + + @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 [Configuration]. + * + * The following fields are required: + * ```java + * .categories() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Configuration]. */ + class Builder internal constructor() { + + private var categories: JsonField>? = null + private var splittingStrategy: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(configuration: Configuration) = apply { + categories = configuration.categories.map { it.toMutableList() } + splittingStrategy = configuration.splittingStrategy + additionalProperties = configuration.additionalProperties.toMutableMap() + } + + /** Categories to split documents into. */ + fun categories(categories: List) = categories(JsonField.of(categories)) + + /** + * Sets [Builder.categories] to an arbitrary JSON value. + * + * You should usually call [Builder.categories] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun categories(categories: JsonField>) = apply { + this.categories = categories.map { it.toMutableList() } + } + + /** + * Adds a single [SplitCategory] to [categories]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCategory(category: SplitCategory) = apply { + categories = + (categories ?: JsonField.of(mutableListOf())).also { + checkKnown("categories", it).add(category) + } + } + + /** Strategy for splitting documents. */ + fun splittingStrategy(splittingStrategy: SplittingStrategy) = + splittingStrategy(JsonField.of(splittingStrategy)) + + /** + * Sets [Builder.splittingStrategy] to an arbitrary JSON value. + * + * You should usually call [Builder.splittingStrategy] with a well-typed + * [SplittingStrategy] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun splittingStrategy(splittingStrategy: JsonField) = apply { + this.splittingStrategy = splittingStrategy + } + + 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 [Configuration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .categories() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Configuration = + Configuration( + checkRequired("categories", categories).map { it.toImmutable() }, + splittingStrategy, + 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(): Configuration = apply { + if (validated) { + return@apply + } + + categories().forEach { it.validate() } + splittingStrategy().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 = + (categories.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (splittingStrategy.asKnown().getOrNull()?.validity() ?: 0) + + /** Strategy for splitting documents. */ + class SplittingStrategy + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowUncategorized: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allow_uncategorized") + @ExcludeMissing + allowUncategorized: JsonField = JsonMissing.of() + ) : this(allowUncategorized, mutableMapOf()) + + /** + * Controls handling of pages that don't match any category. 'include': pages can be + * grouped as 'uncategorized' and included in results. 'forbid': all pages must be + * assigned to a defined category. 'omit': pages can be classified as 'uncategorized' + * but are excluded from results. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun allowUncategorized(): Optional = + allowUncategorized.getOptional("allow_uncategorized") + + /** + * Returns the raw JSON value of [allowUncategorized]. + * + * Unlike [allowUncategorized], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allow_uncategorized") + @ExcludeMissing + fun _allowUncategorized(): JsonField = allowUncategorized + + @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 [SplittingStrategy]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SplittingStrategy]. */ + class Builder internal constructor() { + + private var allowUncategorized: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(splittingStrategy: SplittingStrategy) = apply { + allowUncategorized = splittingStrategy.allowUncategorized + additionalProperties = splittingStrategy.additionalProperties.toMutableMap() + } + + /** + * Controls handling of pages that don't match any category. 'include': pages can be + * grouped as 'uncategorized' and included in results. 'forbid': all pages must be + * assigned to a defined category. 'omit': pages can be classified as + * 'uncategorized' but are excluded from results. + */ + fun allowUncategorized(allowUncategorized: AllowUncategorized) = + allowUncategorized(JsonField.of(allowUncategorized)) + + /** + * Sets [Builder.allowUncategorized] to an arbitrary JSON value. + * + * You should usually call [Builder.allowUncategorized] with a well-typed + * [AllowUncategorized] value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun allowUncategorized(allowUncategorized: JsonField) = apply { + this.allowUncategorized = allowUncategorized + } + + 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 [SplittingStrategy]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SplittingStrategy = + SplittingStrategy(allowUncategorized, 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(): SplittingStrategy = apply { + if (validated) { + return@apply + } + + allowUncategorized().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 = + (allowUncategorized.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Controls handling of pages that don't match any category. 'include': pages can be + * grouped as 'uncategorized' and included in results. 'forbid': all pages must be + * assigned to a defined category. 'omit': pages can be classified as 'uncategorized' + * but are excluded from results. + */ + class AllowUncategorized + @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 FORBID = of("forbid") + + @JvmField val INCLUDE = of("include") + + @JvmField val OMIT = of("omit") + + @JvmStatic fun of(value: String) = AllowUncategorized(JsonField.of(value)) + } + + /** An enum containing [AllowUncategorized]'s known values. */ + enum class Known { + FORBID, + INCLUDE, + OMIT, + } + + /** + * An enum containing [AllowUncategorized]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AllowUncategorized] 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 { + FORBID, + INCLUDE, + OMIT, + /** + * An enum member indicating that [AllowUncategorized] 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) { + FORBID -> Value.FORBID + INCLUDE -> Value.INCLUDE + OMIT -> Value.OMIT + 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) { + FORBID -> Known.FORBID + INCLUDE -> Known.INCLUDE + OMIT -> Known.OMIT + else -> + throw LlamaCloudInvalidDataException( + "Unknown AllowUncategorized: $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(): AllowUncategorized = 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 AllowUncategorized && 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 SplittingStrategy && + allowUncategorized == other.allowUncategorized && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(allowUncategorized, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SplittingStrategy{allowUncategorized=$allowUncategorized, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Configuration && + categories == other.categories && + splittingStrategy == other.splittingStrategy && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(categories, splittingStrategy, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Configuration{categories=$categories, splittingStrategy=$splittingStrategy, additionalProperties=$additionalProperties}" + } + + /** Configuration for a single outbound webhook endpoint. */ + class WebhookConfiguration + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val webhookEvents: JsonField>, + private val webhookHeaders: JsonField, + private val webhookOutputFormat: JsonField, + private val webhookSigningSecret: JsonField, + private val webhookUrl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("webhook_events") + @ExcludeMissing + webhookEvents: JsonField> = JsonMissing.of(), + @JsonProperty("webhook_headers") + @ExcludeMissing + webhookHeaders: JsonField = JsonMissing.of(), + @JsonProperty("webhook_output_format") + @ExcludeMissing + webhookOutputFormat: JsonField = JsonMissing.of(), + @JsonProperty("webhook_signing_secret") + @ExcludeMissing + webhookSigningSecret: JsonField = JsonMissing.of(), + @JsonProperty("webhook_url") + @ExcludeMissing + webhookUrl: JsonField = JsonMissing.of(), + ) : this( + webhookEvents, + webhookHeaders, + webhookOutputFormat, + webhookSigningSecret, + webhookUrl, + mutableMapOf(), + ) + + /** + * Events to subscribe to (e.g. 'parse.success', 'extract.error'). If null, all events are + * delivered. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookEvents(): Optional> = + webhookEvents.getOptional("webhook_events") + + /** + * Custom HTTP headers sent with each webhook request (e.g. auth tokens) + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookHeaders(): Optional = + webhookHeaders.getOptional("webhook_headers") + + /** + * Response format sent to the webhook: 'string' (default) or 'json' + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookOutputFormat(): Optional = + webhookOutputFormat.getOptional("webhook_output_format") + + /** + * Shared signing secret used to sign webhook deliveries. When set, each request includes an + * HMAC-SHA256 signature of the request body in the 'LC-Signature' header (value + * 'sha256='). Recompute the HMAC over the raw request body with this secret to verify + * the delivery is authentic. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookSigningSecret(): Optional = + webhookSigningSecret.getOptional("webhook_signing_secret") + + /** + * URL to receive webhook POST notifications + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookUrl(): Optional = webhookUrl.getOptional("webhook_url") + + /** + * Returns the raw JSON value of [webhookEvents]. + * + * Unlike [webhookEvents], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("webhook_events") + @ExcludeMissing + fun _webhookEvents(): JsonField> = webhookEvents + + /** + * Returns the raw JSON value of [webhookHeaders]. + * + * Unlike [webhookHeaders], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("webhook_headers") + @ExcludeMissing + fun _webhookHeaders(): JsonField = webhookHeaders + + /** + * Returns the raw JSON value of [webhookOutputFormat]. + * + * Unlike [webhookOutputFormat], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("webhook_output_format") + @ExcludeMissing + fun _webhookOutputFormat(): JsonField = webhookOutputFormat + + /** + * Returns the raw JSON value of [webhookSigningSecret]. + * + * Unlike [webhookSigningSecret], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("webhook_signing_secret") + @ExcludeMissing + fun _webhookSigningSecret(): JsonField = webhookSigningSecret + + /** + * Returns the raw JSON value of [webhookUrl]. + * + * Unlike [webhookUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("webhook_url") + @ExcludeMissing + fun _webhookUrl(): JsonField = webhookUrl + + @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 [WebhookConfiguration]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebhookConfiguration]. */ + class Builder internal constructor() { + + private var webhookEvents: JsonField>? = null + private var webhookHeaders: JsonField = JsonMissing.of() + private var webhookOutputFormat: JsonField = JsonMissing.of() + private var webhookSigningSecret: JsonField = JsonMissing.of() + private var webhookUrl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webhookConfiguration: WebhookConfiguration) = apply { + webhookEvents = webhookConfiguration.webhookEvents.map { it.toMutableList() } + webhookHeaders = webhookConfiguration.webhookHeaders + webhookOutputFormat = webhookConfiguration.webhookOutputFormat + webhookSigningSecret = webhookConfiguration.webhookSigningSecret + webhookUrl = webhookConfiguration.webhookUrl + additionalProperties = webhookConfiguration.additionalProperties.toMutableMap() + } + + /** + * Events to subscribe to (e.g. 'parse.success', 'extract.error'). If null, all events + * are delivered. + */ + fun webhookEvents(webhookEvents: List?) = + webhookEvents(JsonField.ofNullable(webhookEvents)) + + /** Alias for calling [Builder.webhookEvents] with `webhookEvents.orElse(null)`. */ + fun webhookEvents(webhookEvents: Optional>) = + webhookEvents(webhookEvents.getOrNull()) + + /** + * Sets [Builder.webhookEvents] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookEvents] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun webhookEvents(webhookEvents: JsonField>) = apply { + this.webhookEvents = webhookEvents.map { it.toMutableList() } + } + + /** + * Adds a single [WebhookEvent] to [webhookEvents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookEvent(webhookEvent: WebhookEvent) = apply { + webhookEvents = + (webhookEvents ?: JsonField.of(mutableListOf())).also { + checkKnown("webhookEvents", it).add(webhookEvent) + } + } + + /** Custom HTTP headers sent with each webhook request (e.g. auth tokens) */ + fun webhookHeaders(webhookHeaders: WebhookHeaders?) = + webhookHeaders(JsonField.ofNullable(webhookHeaders)) + + /** Alias for calling [Builder.webhookHeaders] with `webhookHeaders.orElse(null)`. */ + fun webhookHeaders(webhookHeaders: Optional) = + webhookHeaders(webhookHeaders.getOrNull()) + + /** + * Sets [Builder.webhookHeaders] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookHeaders] with a well-typed [WebhookHeaders] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun webhookHeaders(webhookHeaders: JsonField) = apply { + this.webhookHeaders = webhookHeaders + } + + /** Response format sent to the webhook: 'string' (default) or 'json' */ + fun webhookOutputFormat(webhookOutputFormat: String?) = + webhookOutputFormat(JsonField.ofNullable(webhookOutputFormat)) + + /** + * Alias for calling [Builder.webhookOutputFormat] with + * `webhookOutputFormat.orElse(null)`. + */ + fun webhookOutputFormat(webhookOutputFormat: Optional) = + webhookOutputFormat(webhookOutputFormat.getOrNull()) + + /** + * Sets [Builder.webhookOutputFormat] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookOutputFormat] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun webhookOutputFormat(webhookOutputFormat: JsonField) = apply { + this.webhookOutputFormat = webhookOutputFormat + } + + /** + * Shared signing secret used to sign webhook deliveries. When set, each request + * includes an HMAC-SHA256 signature of the request body in the 'LC-Signature' header + * (value 'sha256='). Recompute the HMAC over the raw request body with this secret + * to verify the delivery is authentic. + */ + fun webhookSigningSecret(webhookSigningSecret: String?) = + webhookSigningSecret(JsonField.ofNullable(webhookSigningSecret)) + + /** + * Alias for calling [Builder.webhookSigningSecret] with + * `webhookSigningSecret.orElse(null)`. + */ + fun webhookSigningSecret(webhookSigningSecret: Optional) = + webhookSigningSecret(webhookSigningSecret.getOrNull()) + + /** + * Sets [Builder.webhookSigningSecret] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookSigningSecret] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun webhookSigningSecret(webhookSigningSecret: JsonField) = apply { + this.webhookSigningSecret = webhookSigningSecret + } + + /** URL to receive webhook POST notifications */ + fun webhookUrl(webhookUrl: String?) = webhookUrl(JsonField.ofNullable(webhookUrl)) + + /** Alias for calling [Builder.webhookUrl] with `webhookUrl.orElse(null)`. */ + fun webhookUrl(webhookUrl: Optional) = webhookUrl(webhookUrl.getOrNull()) + + /** + * Sets [Builder.webhookUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun webhookUrl(webhookUrl: JsonField) = apply { this.webhookUrl = webhookUrl } + + 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 [WebhookConfiguration]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WebhookConfiguration = + WebhookConfiguration( + (webhookEvents ?: JsonMissing.of()).map { it.toImmutable() }, + webhookHeaders, + webhookOutputFormat, + webhookSigningSecret, + webhookUrl, + 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(): WebhookConfiguration = apply { + if (validated) { + return@apply + } + + webhookEvents().ifPresent { it.forEach { it.validate() } } + webhookHeaders().ifPresent { it.validate() } + webhookOutputFormat() + webhookSigningSecret() + webhookUrl() + 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 = + (webhookEvents.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (webhookHeaders.asKnown().getOrNull()?.validity() ?: 0) + + (if (webhookOutputFormat.asKnown().isPresent) 1 else 0) + + (if (webhookSigningSecret.asKnown().isPresent) 1 else 0) + + (if (webhookUrl.asKnown().isPresent) 1 else 0) + + class WebhookEvent @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 BATCH_CANCELLED = of("batch.cancelled") + + @JvmField val BATCH_ERROR = of("batch.error") + + @JvmField val BATCH_PENDING = of("batch.pending") + + @JvmField val BATCH_RUNNING = of("batch.running") + + @JvmField val BATCH_SUCCESS = of("batch.success") + + @JvmField val CLASSIFY_CANCELLED = of("classify.cancelled") + + @JvmField val CLASSIFY_ERROR = of("classify.error") + + @JvmField val CLASSIFY_PARTIAL_SUCCESS = of("classify.partial_success") + + @JvmField val CLASSIFY_PENDING = of("classify.pending") + + @JvmField val CLASSIFY_RUNNING = of("classify.running") + + @JvmField val CLASSIFY_SUCCESS = of("classify.success") + + @JvmField val EXTRACT_CANCELLED = of("extract.cancelled") + + @JvmField val EXTRACT_ERROR = of("extract.error") + + @JvmField val EXTRACT_PARTIAL_SUCCESS = of("extract.partial_success") + + @JvmField val EXTRACT_PENDING = of("extract.pending") + + @JvmField val EXTRACT_SUCCESS = of("extract.success") + + @JvmField val PARSE_CANCELLED = of("parse.cancelled") + + @JvmField val PARSE_ERROR = of("parse.error") + + @JvmField val PARSE_PARTIAL_SUCCESS = of("parse.partial_success") + + @JvmField val PARSE_PENDING = of("parse.pending") + + @JvmField val PARSE_RUNNING = of("parse.running") + + @JvmField val PARSE_SUCCESS = of("parse.success") + + @JvmField val SHEETS_CANCELLED = of("sheets.cancelled") + + @JvmField val SHEETS_ERROR = of("sheets.error") + + @JvmField val SHEETS_PARTIAL_SUCCESS = of("sheets.partial_success") + + @JvmField val SHEETS_PENDING = of("sheets.pending") + + @JvmField val SHEETS_SUCCESS = of("sheets.success") + + @JvmField val SPLIT_CANCELLED = of("split.cancelled") + + @JvmField val SPLIT_ERROR = of("split.error") + + @JvmField val SPLIT_PENDING = of("split.pending") + + @JvmField val SPLIT_PROCESSING = of("split.processing") + + @JvmField val SPLIT_SUCCESS = of("split.success") + + @JvmField val UNMAPPED_EVENT = of("unmapped_event") + + @JvmStatic fun of(value: String) = WebhookEvent(JsonField.of(value)) + } + + /** An enum containing [WebhookEvent]'s known values. */ + enum class Known { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, + CLASSIFY_CANCELLED, + CLASSIFY_ERROR, + CLASSIFY_PARTIAL_SUCCESS, + CLASSIFY_PENDING, + CLASSIFY_RUNNING, + CLASSIFY_SUCCESS, + EXTRACT_CANCELLED, + EXTRACT_ERROR, + EXTRACT_PARTIAL_SUCCESS, + EXTRACT_PENDING, + EXTRACT_SUCCESS, + PARSE_CANCELLED, + PARSE_ERROR, + PARSE_PARTIAL_SUCCESS, + PARSE_PENDING, + PARSE_RUNNING, + PARSE_SUCCESS, + SHEETS_CANCELLED, + SHEETS_ERROR, + SHEETS_PARTIAL_SUCCESS, + SHEETS_PENDING, + SHEETS_SUCCESS, + SPLIT_CANCELLED, + SPLIT_ERROR, + SPLIT_PENDING, + SPLIT_PROCESSING, + SPLIT_SUCCESS, + UNMAPPED_EVENT, + } + + /** + * An enum containing [WebhookEvent]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [WebhookEvent] 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 { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, + CLASSIFY_CANCELLED, + CLASSIFY_ERROR, + CLASSIFY_PARTIAL_SUCCESS, + CLASSIFY_PENDING, + CLASSIFY_RUNNING, + CLASSIFY_SUCCESS, + EXTRACT_CANCELLED, + EXTRACT_ERROR, + EXTRACT_PARTIAL_SUCCESS, + EXTRACT_PENDING, + EXTRACT_SUCCESS, + PARSE_CANCELLED, + PARSE_ERROR, + PARSE_PARTIAL_SUCCESS, + PARSE_PENDING, + PARSE_RUNNING, + PARSE_SUCCESS, + SHEETS_CANCELLED, + SHEETS_ERROR, + SHEETS_PARTIAL_SUCCESS, + SHEETS_PENDING, + SHEETS_SUCCESS, + SPLIT_CANCELLED, + SPLIT_ERROR, + SPLIT_PENDING, + SPLIT_PROCESSING, + SPLIT_SUCCESS, + UNMAPPED_EVENT, + /** + * An enum member indicating that [WebhookEvent] 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) { + BATCH_CANCELLED -> Value.BATCH_CANCELLED + BATCH_ERROR -> Value.BATCH_ERROR + BATCH_PENDING -> Value.BATCH_PENDING + BATCH_RUNNING -> Value.BATCH_RUNNING + BATCH_SUCCESS -> Value.BATCH_SUCCESS + CLASSIFY_CANCELLED -> Value.CLASSIFY_CANCELLED + CLASSIFY_ERROR -> Value.CLASSIFY_ERROR + CLASSIFY_PARTIAL_SUCCESS -> Value.CLASSIFY_PARTIAL_SUCCESS + CLASSIFY_PENDING -> Value.CLASSIFY_PENDING + CLASSIFY_RUNNING -> Value.CLASSIFY_RUNNING + CLASSIFY_SUCCESS -> Value.CLASSIFY_SUCCESS + EXTRACT_CANCELLED -> Value.EXTRACT_CANCELLED + EXTRACT_ERROR -> Value.EXTRACT_ERROR + EXTRACT_PARTIAL_SUCCESS -> Value.EXTRACT_PARTIAL_SUCCESS + EXTRACT_PENDING -> Value.EXTRACT_PENDING + EXTRACT_SUCCESS -> Value.EXTRACT_SUCCESS + PARSE_CANCELLED -> Value.PARSE_CANCELLED + PARSE_ERROR -> Value.PARSE_ERROR + PARSE_PARTIAL_SUCCESS -> Value.PARSE_PARTIAL_SUCCESS + PARSE_PENDING -> Value.PARSE_PENDING + PARSE_RUNNING -> Value.PARSE_RUNNING + PARSE_SUCCESS -> Value.PARSE_SUCCESS + SHEETS_CANCELLED -> Value.SHEETS_CANCELLED + SHEETS_ERROR -> Value.SHEETS_ERROR + SHEETS_PARTIAL_SUCCESS -> Value.SHEETS_PARTIAL_SUCCESS + SHEETS_PENDING -> Value.SHEETS_PENDING + SHEETS_SUCCESS -> Value.SHEETS_SUCCESS + SPLIT_CANCELLED -> Value.SPLIT_CANCELLED + SPLIT_ERROR -> Value.SPLIT_ERROR + SPLIT_PENDING -> Value.SPLIT_PENDING + SPLIT_PROCESSING -> Value.SPLIT_PROCESSING + SPLIT_SUCCESS -> Value.SPLIT_SUCCESS + UNMAPPED_EVENT -> Value.UNMAPPED_EVENT + 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) { + BATCH_CANCELLED -> Known.BATCH_CANCELLED + BATCH_ERROR -> Known.BATCH_ERROR + BATCH_PENDING -> Known.BATCH_PENDING + BATCH_RUNNING -> Known.BATCH_RUNNING + BATCH_SUCCESS -> Known.BATCH_SUCCESS + CLASSIFY_CANCELLED -> Known.CLASSIFY_CANCELLED + CLASSIFY_ERROR -> Known.CLASSIFY_ERROR + CLASSIFY_PARTIAL_SUCCESS -> Known.CLASSIFY_PARTIAL_SUCCESS + CLASSIFY_PENDING -> Known.CLASSIFY_PENDING + CLASSIFY_RUNNING -> Known.CLASSIFY_RUNNING + CLASSIFY_SUCCESS -> Known.CLASSIFY_SUCCESS + EXTRACT_CANCELLED -> Known.EXTRACT_CANCELLED + EXTRACT_ERROR -> Known.EXTRACT_ERROR + EXTRACT_PARTIAL_SUCCESS -> Known.EXTRACT_PARTIAL_SUCCESS + EXTRACT_PENDING -> Known.EXTRACT_PENDING + EXTRACT_SUCCESS -> Known.EXTRACT_SUCCESS + PARSE_CANCELLED -> Known.PARSE_CANCELLED + PARSE_ERROR -> Known.PARSE_ERROR + PARSE_PARTIAL_SUCCESS -> Known.PARSE_PARTIAL_SUCCESS + PARSE_PENDING -> Known.PARSE_PENDING + PARSE_RUNNING -> Known.PARSE_RUNNING + PARSE_SUCCESS -> Known.PARSE_SUCCESS + SHEETS_CANCELLED -> Known.SHEETS_CANCELLED + SHEETS_ERROR -> Known.SHEETS_ERROR + SHEETS_PARTIAL_SUCCESS -> Known.SHEETS_PARTIAL_SUCCESS + SHEETS_PENDING -> Known.SHEETS_PENDING + SHEETS_SUCCESS -> Known.SHEETS_SUCCESS + SPLIT_CANCELLED -> Known.SPLIT_CANCELLED + SPLIT_ERROR -> Known.SPLIT_ERROR + SPLIT_PENDING -> Known.SPLIT_PENDING + SPLIT_PROCESSING -> Known.SPLIT_PROCESSING + SPLIT_SUCCESS -> Known.SPLIT_SUCCESS + UNMAPPED_EVENT -> Known.UNMAPPED_EVENT + else -> throw LlamaCloudInvalidDataException("Unknown WebhookEvent: $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(): WebhookEvent = 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 WebhookEvent && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Custom HTTP headers sent with each webhook request (e.g. auth tokens) */ + class WebhookHeaders + @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 [WebhookHeaders]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebhookHeaders]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webhookHeaders: WebhookHeaders) = apply { + additionalProperties = webhookHeaders.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 [WebhookHeaders]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WebhookHeaders = WebhookHeaders(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(): WebhookHeaders = 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 WebhookHeaders && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "WebhookHeaders{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is WebhookConfiguration && + webhookEvents == other.webhookEvents && + webhookHeaders == other.webhookHeaders && + webhookOutputFormat == other.webhookOutputFormat && + webhookSigningSecret == other.webhookSigningSecret && + webhookUrl == other.webhookUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + webhookEvents, + webhookHeaders, + webhookOutputFormat, + webhookSigningSecret, + webhookUrl, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "WebhookConfiguration{webhookEvents=$webhookEvents, webhookHeaders=$webhookHeaders, webhookOutputFormat=$webhookOutputFormat, webhookSigningSecret=$webhookSigningSecret, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SplitCreateParams && + organizationId == other.organizationId && + projectId == other.projectId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(organizationId, projectId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "SplitCreateParams{organizationId=$organizationId, projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitCreateResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitCreateResponse.kt new file mode 100644 index 0000000..264690c --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitCreateResponse.kt @@ -0,0 +1,1253 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +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.checkKnown +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.core.toImmutable +import ai.llamaindex.llamacloud.errors.LlamaCloudInvalidDataException +import ai.llamaindex.llamacloud.models.beta.split.SplitCategory +import ai.llamaindex.llamacloud.models.beta.split.SplitResultResponse +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 split job. */ +class SplitCreateResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val categories: JsonField>, + private val documentInputType: JsonField, + private val fileInput: JsonField, + private val projectId: JsonField, + private val status: JsonField, + private val userId: JsonField, + private val configurationId: JsonField, + private val createdAt: JsonField, + private val errorMessage: JsonField, + private val result: JsonField, + private val splittingStrategy: JsonField, + private val transactionId: JsonField, + private val updatedAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("categories") + @ExcludeMissing + categories: JsonField> = JsonMissing.of(), + @JsonProperty("document_input_type") + @ExcludeMissing + documentInputType: JsonField = JsonMissing.of(), + @JsonProperty("file_input") @ExcludeMissing fileInput: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing userId: JsonField = JsonMissing.of(), + @JsonProperty("configuration_id") + @ExcludeMissing + configurationId: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("error_message") + @ExcludeMissing + errorMessage: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("splitting_strategy") + @ExcludeMissing + splittingStrategy: JsonField = JsonMissing.of(), + @JsonProperty("transaction_id") + @ExcludeMissing + transactionId: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this( + id, + categories, + documentInputType, + fileInput, + projectId, + status, + userId, + configurationId, + createdAt, + errorMessage, + result, + splittingStrategy, + transactionId, + updatedAt, + mutableMapOf(), + ) + + /** + * Unique identifier for the split 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") + + /** + * Categories used for splitting. + * + * @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 categories(): List = categories.getRequired("categories") + + /** + * Whether the input was a file or parse 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 documentInputType(): DocumentInputType = + documentInputType.getRequired("document_input_type") + + /** + * File ID or parse 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 fileInput(): String = fileInput.getRequired("file_input") + + /** + * Project this job 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") + + /** + * Current job status. Valid values are: pending, processing, completed, failed, cancelled. + * + * @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") + + /** + * User who created this 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 userId(): String = userId.getRequired("user_id") + + /** + * Split configuration ID used for this job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun configurationId(): Optional = configurationId.getOptional("configuration_id") + + /** + * Creation datetime + * + * @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") + + /** + * Error message if the job failed. + * + * @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") + + /** + * Result of a completed split job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun result(): Optional = result.getOptional("result") + + /** + * Strategy used for splitting. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun splittingStrategy(): Optional = + splittingStrategy.getOptional("splitting_strategy") + + /** + * Idempotency key scoped to the project, if one was provided. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transactionId(): Optional = transactionId.getOptional("transaction_id") + + /** + * Update datetime + * + * @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 [categories]. + * + * Unlike [categories], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("categories") + @ExcludeMissing + fun _categories(): JsonField> = categories + + /** + * Returns the raw JSON value of [documentInputType]. + * + * Unlike [documentInputType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("document_input_type") + @ExcludeMissing + fun _documentInputType(): JsonField = documentInputType + + /** + * Returns the raw JSON value of [fileInput]. + * + * Unlike [fileInput], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("file_input") @ExcludeMissing fun _fileInput(): JsonField = fileInput + + /** + * 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 [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + + /** + * Returns the raw JSON value of [configurationId]. + * + * Unlike [configurationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("configuration_id") + @ExcludeMissing + fun _configurationId(): JsonField = configurationId + + /** + * 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 [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 [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [splittingStrategy]. + * + * Unlike [splittingStrategy], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("splitting_strategy") + @ExcludeMissing + fun _splittingStrategy(): JsonField = splittingStrategy + + /** + * Returns the raw JSON value of [transactionId]. + * + * Unlike [transactionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("transaction_id") + @ExcludeMissing + fun _transactionId(): JsonField = transactionId + + /** + * 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 [SplitCreateResponse]. + * + * The following fields are required: + * ```java + * .id() + * .categories() + * .documentInputType() + * .fileInput() + * .projectId() + * .status() + * .userId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SplitCreateResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var categories: JsonField>? = null + private var documentInputType: JsonField? = null + private var fileInput: JsonField? = null + private var projectId: JsonField? = null + private var status: JsonField? = null + private var userId: JsonField? = null + private var configurationId: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var errorMessage: JsonField = JsonMissing.of() + private var result: JsonField = JsonMissing.of() + private var splittingStrategy: JsonField = JsonMissing.of() + private var transactionId: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(splitCreateResponse: SplitCreateResponse) = apply { + id = splitCreateResponse.id + categories = splitCreateResponse.categories.map { it.toMutableList() } + documentInputType = splitCreateResponse.documentInputType + fileInput = splitCreateResponse.fileInput + projectId = splitCreateResponse.projectId + status = splitCreateResponse.status + userId = splitCreateResponse.userId + configurationId = splitCreateResponse.configurationId + createdAt = splitCreateResponse.createdAt + errorMessage = splitCreateResponse.errorMessage + result = splitCreateResponse.result + splittingStrategy = splitCreateResponse.splittingStrategy + transactionId = splitCreateResponse.transactionId + updatedAt = splitCreateResponse.updatedAt + additionalProperties = splitCreateResponse.additionalProperties.toMutableMap() + } + + /** Unique identifier for the split 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 } + + /** Categories used for splitting. */ + fun categories(categories: List) = categories(JsonField.of(categories)) + + /** + * Sets [Builder.categories] to an arbitrary JSON value. + * + * You should usually call [Builder.categories] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun categories(categories: JsonField>) = apply { + this.categories = categories.map { it.toMutableList() } + } + + /** + * Adds a single [SplitCategory] to [categories]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCategory(category: SplitCategory) = apply { + categories = + (categories ?: JsonField.of(mutableListOf())).also { + checkKnown("categories", it).add(category) + } + } + + /** Whether the input was a file or parse job */ + fun documentInputType(documentInputType: DocumentInputType) = + documentInputType(JsonField.of(documentInputType)) + + /** + * Sets [Builder.documentInputType] to an arbitrary JSON value. + * + * You should usually call [Builder.documentInputType] with a well-typed [DocumentInputType] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun documentInputType(documentInputType: JsonField) = apply { + this.documentInputType = documentInputType + } + + /** File ID or parse job ID */ + fun fileInput(fileInput: String) = fileInput(JsonField.of(fileInput)) + + /** + * Sets [Builder.fileInput] to an arbitrary JSON value. + * + * You should usually call [Builder.fileInput] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun fileInput(fileInput: JsonField) = apply { this.fileInput = fileInput } + + /** Project this job 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 } + + /** + * Current job status. Valid values are: pending, processing, completed, failed, cancelled. + */ + 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 } + + /** User who created this job. */ + fun userId(userId: String) = userId(JsonField.of(userId)) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun userId(userId: JsonField) = apply { this.userId = userId } + + /** Split configuration ID used for this job. */ + fun configurationId(configurationId: String?) = + configurationId(JsonField.ofNullable(configurationId)) + + /** Alias for calling [Builder.configurationId] with `configurationId.orElse(null)`. */ + fun configurationId(configurationId: Optional) = + configurationId(configurationId.getOrNull()) + + /** + * Sets [Builder.configurationId] to an arbitrary JSON value. + * + * You should usually call [Builder.configurationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun configurationId(configurationId: JsonField) = apply { + this.configurationId = configurationId + } + + /** Creation datetime */ + 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 } + + /** Error message if the job failed. */ + 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 + } + + /** Result of a completed split job. */ + fun result(result: SplitResultResponse?) = result(JsonField.ofNullable(result)) + + /** Alias for calling [Builder.result] with `result.orElse(null)`. */ + fun result(result: Optional) = result(result.getOrNull()) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [SplitResultResponse] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun result(result: JsonField) = apply { this.result = result } + + /** Strategy used for splitting. */ + fun splittingStrategy(splittingStrategy: SplittingStrategy) = + splittingStrategy(JsonField.of(splittingStrategy)) + + /** + * Sets [Builder.splittingStrategy] to an arbitrary JSON value. + * + * You should usually call [Builder.splittingStrategy] with a well-typed [SplittingStrategy] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun splittingStrategy(splittingStrategy: JsonField) = apply { + this.splittingStrategy = splittingStrategy + } + + /** Idempotency key scoped to the project, if one was provided. */ + fun transactionId(transactionId: String?) = + transactionId(JsonField.ofNullable(transactionId)) + + /** Alias for calling [Builder.transactionId] with `transactionId.orElse(null)`. */ + fun transactionId(transactionId: Optional) = + transactionId(transactionId.getOrNull()) + + /** + * Sets [Builder.transactionId] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun transactionId(transactionId: JsonField) = apply { + this.transactionId = transactionId + } + + /** Update datetime */ + 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 [SplitCreateResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .categories() + * .documentInputType() + * .fileInput() + * .projectId() + * .status() + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SplitCreateResponse = + SplitCreateResponse( + checkRequired("id", id), + checkRequired("categories", categories).map { it.toImmutable() }, + checkRequired("documentInputType", documentInputType), + checkRequired("fileInput", fileInput), + checkRequired("projectId", projectId), + checkRequired("status", status), + checkRequired("userId", userId), + configurationId, + createdAt, + errorMessage, + result, + splittingStrategy, + transactionId, + 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(): SplitCreateResponse = apply { + if (validated) { + return@apply + } + + id() + categories().forEach { it.validate() } + documentInputType().validate() + fileInput() + projectId() + status() + userId() + configurationId() + createdAt() + errorMessage() + result().ifPresent { it.validate() } + splittingStrategy().ifPresent { it.validate() } + transactionId() + 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) + + (categories.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (documentInputType.asKnown().getOrNull()?.validity() ?: 0) + + (if (fileInput.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (if (configurationId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (errorMessage.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (splittingStrategy.asKnown().getOrNull()?.validity() ?: 0) + + (if (transactionId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + /** Whether the input was a file or parse job */ + class DocumentInputType @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 FILE_ID = of("file_id") + + @JvmField val PARSE_JOB_ID = of("parse_job_id") + + @JvmField val URL = of("url") + + @JvmStatic fun of(value: String) = DocumentInputType(JsonField.of(value)) + } + + /** An enum containing [DocumentInputType]'s known values. */ + enum class Known { + FILE_ID, + PARSE_JOB_ID, + URL, + } + + /** + * An enum containing [DocumentInputType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DocumentInputType] 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 { + FILE_ID, + PARSE_JOB_ID, + URL, + /** + * An enum member indicating that [DocumentInputType] 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) { + FILE_ID -> Value.FILE_ID + PARSE_JOB_ID -> Value.PARSE_JOB_ID + URL -> Value.URL + 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) { + FILE_ID -> Known.FILE_ID + PARSE_JOB_ID -> Known.PARSE_JOB_ID + URL -> Known.URL + else -> throw LlamaCloudInvalidDataException("Unknown DocumentInputType: $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(): DocumentInputType = 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 DocumentInputType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Strategy used for splitting. */ + class SplittingStrategy + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowUncategorized: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allow_uncategorized") + @ExcludeMissing + allowUncategorized: JsonField = JsonMissing.of() + ) : this(allowUncategorized, mutableMapOf()) + + /** + * Controls handling of pages that don't match any category. 'include': pages can be grouped + * as 'uncategorized' and included in results. 'forbid': all pages must be assigned to a + * defined category. 'omit': pages can be classified as 'uncategorized' but are excluded + * from results. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun allowUncategorized(): Optional = + allowUncategorized.getOptional("allow_uncategorized") + + /** + * Returns the raw JSON value of [allowUncategorized]. + * + * Unlike [allowUncategorized], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allow_uncategorized") + @ExcludeMissing + fun _allowUncategorized(): JsonField = allowUncategorized + + @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 [SplittingStrategy]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SplittingStrategy]. */ + class Builder internal constructor() { + + private var allowUncategorized: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(splittingStrategy: SplittingStrategy) = apply { + allowUncategorized = splittingStrategy.allowUncategorized + additionalProperties = splittingStrategy.additionalProperties.toMutableMap() + } + + /** + * Controls handling of pages that don't match any category. 'include': pages can be + * grouped as 'uncategorized' and included in results. 'forbid': all pages must be + * assigned to a defined category. 'omit': pages can be classified as 'uncategorized' + * but are excluded from results. + */ + fun allowUncategorized(allowUncategorized: AllowUncategorized) = + allowUncategorized(JsonField.of(allowUncategorized)) + + /** + * Sets [Builder.allowUncategorized] to an arbitrary JSON value. + * + * You should usually call [Builder.allowUncategorized] with a well-typed + * [AllowUncategorized] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allowUncategorized(allowUncategorized: JsonField) = apply { + this.allowUncategorized = allowUncategorized + } + + 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 [SplittingStrategy]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SplittingStrategy = + SplittingStrategy(allowUncategorized, 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(): SplittingStrategy = apply { + if (validated) { + return@apply + } + + allowUncategorized().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 = (allowUncategorized.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Controls handling of pages that don't match any category. 'include': pages can be grouped + * as 'uncategorized' and included in results. 'forbid': all pages must be assigned to a + * defined category. 'omit': pages can be classified as 'uncategorized' but are excluded + * from results. + */ + class AllowUncategorized + @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 FORBID = of("forbid") + + @JvmField val INCLUDE = of("include") + + @JvmField val OMIT = of("omit") + + @JvmStatic fun of(value: String) = AllowUncategorized(JsonField.of(value)) + } + + /** An enum containing [AllowUncategorized]'s known values. */ + enum class Known { + FORBID, + INCLUDE, + OMIT, + } + + /** + * An enum containing [AllowUncategorized]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AllowUncategorized] 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 { + FORBID, + INCLUDE, + OMIT, + /** + * An enum member indicating that [AllowUncategorized] 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) { + FORBID -> Value.FORBID + INCLUDE -> Value.INCLUDE + OMIT -> Value.OMIT + 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) { + FORBID -> Known.FORBID + INCLUDE -> Known.INCLUDE + OMIT -> Known.OMIT + else -> + throw LlamaCloudInvalidDataException("Unknown AllowUncategorized: $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(): AllowUncategorized = 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 AllowUncategorized && 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 SplittingStrategy && + allowUncategorized == other.allowUncategorized && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(allowUncategorized, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SplittingStrategy{allowUncategorized=$allowUncategorized, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SplitCreateResponse && + id == other.id && + categories == other.categories && + documentInputType == other.documentInputType && + fileInput == other.fileInput && + projectId == other.projectId && + status == other.status && + userId == other.userId && + configurationId == other.configurationId && + createdAt == other.createdAt && + errorMessage == other.errorMessage && + result == other.result && + splittingStrategy == other.splittingStrategy && + transactionId == other.transactionId && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + categories, + documentInputType, + fileInput, + projectId, + status, + userId, + configurationId, + createdAt, + errorMessage, + result, + splittingStrategy, + transactionId, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SplitCreateResponse{id=$id, categories=$categories, documentInputType=$documentInputType, fileInput=$fileInput, projectId=$projectId, status=$status, userId=$userId, configurationId=$configurationId, createdAt=$createdAt, errorMessage=$errorMessage, result=$result, splittingStrategy=$splittingStrategy, transactionId=$transactionId, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitDeleteParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitDeleteParams.kt new file mode 100644 index 0000000..fee2306 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitDeleteParams.kt @@ -0,0 +1,268 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +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 split job and its results. */ +class SplitDeleteParams +private constructor( + private val splitJobId: String?, + private val organizationId: String?, + private val projectId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun splitJobId(): Optional = Optional.ofNullable(splitJobId) + + 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(): SplitDeleteParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SplitDeleteParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SplitDeleteParams]. */ + class Builder internal constructor() { + + private var splitJobId: 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(splitDeleteParams: SplitDeleteParams) = apply { + splitJobId = splitDeleteParams.splitJobId + organizationId = splitDeleteParams.organizationId + projectId = splitDeleteParams.projectId + additionalHeaders = splitDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = splitDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = splitDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun splitJobId(splitJobId: String?) = apply { this.splitJobId = splitJobId } + + /** Alias for calling [Builder.splitJobId] with `splitJobId.orElse(null)`. */ + fun splitJobId(splitJobId: Optional) = splitJobId(splitJobId.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 [SplitDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SplitDeleteParams = + SplitDeleteParams( + splitJobId, + organizationId, + projectId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> splitJobId ?: "" + 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 SplitDeleteParams && + splitJobId == other.splitJobId && + organizationId == other.organizationId && + projectId == other.projectId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + splitJobId, + organizationId, + projectId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "SplitDeleteParams{splitJobId=$splitJobId, organizationId=$organizationId, projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitDeleteResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitDeleteResponse.kt new file mode 100644 index 0000000..f34a3c1 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitDeleteResponse.kt @@ -0,0 +1,121 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +import ai.llamaindex.llamacloud.core.ExcludeMissing +import ai.llamaindex.llamacloud.core.JsonValue +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 java.util.Collections +import java.util.Objects + +class SplitDeleteResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @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 [SplitDeleteResponse]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SplitDeleteResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(splitDeleteResponse: SplitDeleteResponse) = apply { + additionalProperties = splitDeleteResponse.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 [SplitDeleteResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SplitDeleteResponse = SplitDeleteResponse(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(): SplitDeleteResponse = 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 = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SplitDeleteResponse && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "SplitDeleteResponse{additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitGetParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitGetParams.kt new file mode 100644 index 0000000..1f2d97c --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitGetParams.kt @@ -0,0 +1,232 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +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 + +/** Get a document split job. */ +class SplitGetParams +private constructor( + private val splitJobId: String?, + private val organizationId: String?, + private val projectId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun splitJobId(): Optional = Optional.ofNullable(splitJobId) + + 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 { + + @JvmStatic fun none(): SplitGetParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SplitGetParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SplitGetParams]. */ + class Builder internal constructor() { + + private var splitJobId: 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(splitGetParams: SplitGetParams) = apply { + splitJobId = splitGetParams.splitJobId + organizationId = splitGetParams.organizationId + projectId = splitGetParams.projectId + additionalHeaders = splitGetParams.additionalHeaders.toBuilder() + additionalQueryParams = splitGetParams.additionalQueryParams.toBuilder() + } + + fun splitJobId(splitJobId: String?) = apply { this.splitJobId = splitJobId } + + /** Alias for calling [Builder.splitJobId] with `splitJobId.orElse(null)`. */ + fun splitJobId(splitJobId: Optional) = splitJobId(splitJobId.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) + } + + /** + * Returns an immutable instance of [SplitGetParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SplitGetParams = + SplitGetParams( + splitJobId, + organizationId, + projectId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> splitJobId ?: "" + 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 SplitGetParams && + splitJobId == other.splitJobId && + organizationId == other.organizationId && + projectId == other.projectId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + splitJobId, + organizationId, + projectId, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "SplitGetParams{splitJobId=$splitJobId, organizationId=$organizationId, projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitGetResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitGetResponse.kt new file mode 100644 index 0000000..191dc5d --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitGetResponse.kt @@ -0,0 +1,1253 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +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.checkKnown +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.core.toImmutable +import ai.llamaindex.llamacloud.errors.LlamaCloudInvalidDataException +import ai.llamaindex.llamacloud.models.beta.split.SplitCategory +import ai.llamaindex.llamacloud.models.beta.split.SplitResultResponse +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 split job. */ +class SplitGetResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val categories: JsonField>, + private val documentInputType: JsonField, + private val fileInput: JsonField, + private val projectId: JsonField, + private val status: JsonField, + private val userId: JsonField, + private val configurationId: JsonField, + private val createdAt: JsonField, + private val errorMessage: JsonField, + private val result: JsonField, + private val splittingStrategy: JsonField, + private val transactionId: JsonField, + private val updatedAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("categories") + @ExcludeMissing + categories: JsonField> = JsonMissing.of(), + @JsonProperty("document_input_type") + @ExcludeMissing + documentInputType: JsonField = JsonMissing.of(), + @JsonProperty("file_input") @ExcludeMissing fileInput: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing userId: JsonField = JsonMissing.of(), + @JsonProperty("configuration_id") + @ExcludeMissing + configurationId: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("error_message") + @ExcludeMissing + errorMessage: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("splitting_strategy") + @ExcludeMissing + splittingStrategy: JsonField = JsonMissing.of(), + @JsonProperty("transaction_id") + @ExcludeMissing + transactionId: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this( + id, + categories, + documentInputType, + fileInput, + projectId, + status, + userId, + configurationId, + createdAt, + errorMessage, + result, + splittingStrategy, + transactionId, + updatedAt, + mutableMapOf(), + ) + + /** + * Unique identifier for the split 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") + + /** + * Categories used for splitting. + * + * @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 categories(): List = categories.getRequired("categories") + + /** + * Whether the input was a file or parse 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 documentInputType(): DocumentInputType = + documentInputType.getRequired("document_input_type") + + /** + * File ID or parse 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 fileInput(): String = fileInput.getRequired("file_input") + + /** + * Project this job 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") + + /** + * Current job status. Valid values are: pending, processing, completed, failed, cancelled. + * + * @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") + + /** + * User who created this 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 userId(): String = userId.getRequired("user_id") + + /** + * Split configuration ID used for this job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun configurationId(): Optional = configurationId.getOptional("configuration_id") + + /** + * Creation datetime + * + * @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") + + /** + * Error message if the job failed. + * + * @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") + + /** + * Result of a completed split job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun result(): Optional = result.getOptional("result") + + /** + * Strategy used for splitting. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun splittingStrategy(): Optional = + splittingStrategy.getOptional("splitting_strategy") + + /** + * Idempotency key scoped to the project, if one was provided. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transactionId(): Optional = transactionId.getOptional("transaction_id") + + /** + * Update datetime + * + * @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 [categories]. + * + * Unlike [categories], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("categories") + @ExcludeMissing + fun _categories(): JsonField> = categories + + /** + * Returns the raw JSON value of [documentInputType]. + * + * Unlike [documentInputType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("document_input_type") + @ExcludeMissing + fun _documentInputType(): JsonField = documentInputType + + /** + * Returns the raw JSON value of [fileInput]. + * + * Unlike [fileInput], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("file_input") @ExcludeMissing fun _fileInput(): JsonField = fileInput + + /** + * 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 [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + + /** + * Returns the raw JSON value of [configurationId]. + * + * Unlike [configurationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("configuration_id") + @ExcludeMissing + fun _configurationId(): JsonField = configurationId + + /** + * 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 [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 [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [splittingStrategy]. + * + * Unlike [splittingStrategy], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("splitting_strategy") + @ExcludeMissing + fun _splittingStrategy(): JsonField = splittingStrategy + + /** + * Returns the raw JSON value of [transactionId]. + * + * Unlike [transactionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("transaction_id") + @ExcludeMissing + fun _transactionId(): JsonField = transactionId + + /** + * 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 [SplitGetResponse]. + * + * The following fields are required: + * ```java + * .id() + * .categories() + * .documentInputType() + * .fileInput() + * .projectId() + * .status() + * .userId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SplitGetResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var categories: JsonField>? = null + private var documentInputType: JsonField? = null + private var fileInput: JsonField? = null + private var projectId: JsonField? = null + private var status: JsonField? = null + private var userId: JsonField? = null + private var configurationId: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var errorMessage: JsonField = JsonMissing.of() + private var result: JsonField = JsonMissing.of() + private var splittingStrategy: JsonField = JsonMissing.of() + private var transactionId: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(splitGetResponse: SplitGetResponse) = apply { + id = splitGetResponse.id + categories = splitGetResponse.categories.map { it.toMutableList() } + documentInputType = splitGetResponse.documentInputType + fileInput = splitGetResponse.fileInput + projectId = splitGetResponse.projectId + status = splitGetResponse.status + userId = splitGetResponse.userId + configurationId = splitGetResponse.configurationId + createdAt = splitGetResponse.createdAt + errorMessage = splitGetResponse.errorMessage + result = splitGetResponse.result + splittingStrategy = splitGetResponse.splittingStrategy + transactionId = splitGetResponse.transactionId + updatedAt = splitGetResponse.updatedAt + additionalProperties = splitGetResponse.additionalProperties.toMutableMap() + } + + /** Unique identifier for the split 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 } + + /** Categories used for splitting. */ + fun categories(categories: List) = categories(JsonField.of(categories)) + + /** + * Sets [Builder.categories] to an arbitrary JSON value. + * + * You should usually call [Builder.categories] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun categories(categories: JsonField>) = apply { + this.categories = categories.map { it.toMutableList() } + } + + /** + * Adds a single [SplitCategory] to [categories]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCategory(category: SplitCategory) = apply { + categories = + (categories ?: JsonField.of(mutableListOf())).also { + checkKnown("categories", it).add(category) + } + } + + /** Whether the input was a file or parse job */ + fun documentInputType(documentInputType: DocumentInputType) = + documentInputType(JsonField.of(documentInputType)) + + /** + * Sets [Builder.documentInputType] to an arbitrary JSON value. + * + * You should usually call [Builder.documentInputType] with a well-typed [DocumentInputType] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun documentInputType(documentInputType: JsonField) = apply { + this.documentInputType = documentInputType + } + + /** File ID or parse job ID */ + fun fileInput(fileInput: String) = fileInput(JsonField.of(fileInput)) + + /** + * Sets [Builder.fileInput] to an arbitrary JSON value. + * + * You should usually call [Builder.fileInput] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun fileInput(fileInput: JsonField) = apply { this.fileInput = fileInput } + + /** Project this job 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 } + + /** + * Current job status. Valid values are: pending, processing, completed, failed, cancelled. + */ + 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 } + + /** User who created this job. */ + fun userId(userId: String) = userId(JsonField.of(userId)) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun userId(userId: JsonField) = apply { this.userId = userId } + + /** Split configuration ID used for this job. */ + fun configurationId(configurationId: String?) = + configurationId(JsonField.ofNullable(configurationId)) + + /** Alias for calling [Builder.configurationId] with `configurationId.orElse(null)`. */ + fun configurationId(configurationId: Optional) = + configurationId(configurationId.getOrNull()) + + /** + * Sets [Builder.configurationId] to an arbitrary JSON value. + * + * You should usually call [Builder.configurationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun configurationId(configurationId: JsonField) = apply { + this.configurationId = configurationId + } + + /** Creation datetime */ + 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 } + + /** Error message if the job failed. */ + 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 + } + + /** Result of a completed split job. */ + fun result(result: SplitResultResponse?) = result(JsonField.ofNullable(result)) + + /** Alias for calling [Builder.result] with `result.orElse(null)`. */ + fun result(result: Optional) = result(result.getOrNull()) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [SplitResultResponse] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun result(result: JsonField) = apply { this.result = result } + + /** Strategy used for splitting. */ + fun splittingStrategy(splittingStrategy: SplittingStrategy) = + splittingStrategy(JsonField.of(splittingStrategy)) + + /** + * Sets [Builder.splittingStrategy] to an arbitrary JSON value. + * + * You should usually call [Builder.splittingStrategy] with a well-typed [SplittingStrategy] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun splittingStrategy(splittingStrategy: JsonField) = apply { + this.splittingStrategy = splittingStrategy + } + + /** Idempotency key scoped to the project, if one was provided. */ + fun transactionId(transactionId: String?) = + transactionId(JsonField.ofNullable(transactionId)) + + /** Alias for calling [Builder.transactionId] with `transactionId.orElse(null)`. */ + fun transactionId(transactionId: Optional) = + transactionId(transactionId.getOrNull()) + + /** + * Sets [Builder.transactionId] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun transactionId(transactionId: JsonField) = apply { + this.transactionId = transactionId + } + + /** Update datetime */ + 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 [SplitGetResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .categories() + * .documentInputType() + * .fileInput() + * .projectId() + * .status() + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SplitGetResponse = + SplitGetResponse( + checkRequired("id", id), + checkRequired("categories", categories).map { it.toImmutable() }, + checkRequired("documentInputType", documentInputType), + checkRequired("fileInput", fileInput), + checkRequired("projectId", projectId), + checkRequired("status", status), + checkRequired("userId", userId), + configurationId, + createdAt, + errorMessage, + result, + splittingStrategy, + transactionId, + 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(): SplitGetResponse = apply { + if (validated) { + return@apply + } + + id() + categories().forEach { it.validate() } + documentInputType().validate() + fileInput() + projectId() + status() + userId() + configurationId() + createdAt() + errorMessage() + result().ifPresent { it.validate() } + splittingStrategy().ifPresent { it.validate() } + transactionId() + 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) + + (categories.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (documentInputType.asKnown().getOrNull()?.validity() ?: 0) + + (if (fileInput.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (if (configurationId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (errorMessage.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (splittingStrategy.asKnown().getOrNull()?.validity() ?: 0) + + (if (transactionId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + /** Whether the input was a file or parse job */ + class DocumentInputType @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 FILE_ID = of("file_id") + + @JvmField val PARSE_JOB_ID = of("parse_job_id") + + @JvmField val URL = of("url") + + @JvmStatic fun of(value: String) = DocumentInputType(JsonField.of(value)) + } + + /** An enum containing [DocumentInputType]'s known values. */ + enum class Known { + FILE_ID, + PARSE_JOB_ID, + URL, + } + + /** + * An enum containing [DocumentInputType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DocumentInputType] 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 { + FILE_ID, + PARSE_JOB_ID, + URL, + /** + * An enum member indicating that [DocumentInputType] 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) { + FILE_ID -> Value.FILE_ID + PARSE_JOB_ID -> Value.PARSE_JOB_ID + URL -> Value.URL + 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) { + FILE_ID -> Known.FILE_ID + PARSE_JOB_ID -> Known.PARSE_JOB_ID + URL -> Known.URL + else -> throw LlamaCloudInvalidDataException("Unknown DocumentInputType: $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(): DocumentInputType = 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 DocumentInputType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Strategy used for splitting. */ + class SplittingStrategy + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowUncategorized: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allow_uncategorized") + @ExcludeMissing + allowUncategorized: JsonField = JsonMissing.of() + ) : this(allowUncategorized, mutableMapOf()) + + /** + * Controls handling of pages that don't match any category. 'include': pages can be grouped + * as 'uncategorized' and included in results. 'forbid': all pages must be assigned to a + * defined category. 'omit': pages can be classified as 'uncategorized' but are excluded + * from results. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun allowUncategorized(): Optional = + allowUncategorized.getOptional("allow_uncategorized") + + /** + * Returns the raw JSON value of [allowUncategorized]. + * + * Unlike [allowUncategorized], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allow_uncategorized") + @ExcludeMissing + fun _allowUncategorized(): JsonField = allowUncategorized + + @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 [SplittingStrategy]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SplittingStrategy]. */ + class Builder internal constructor() { + + private var allowUncategorized: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(splittingStrategy: SplittingStrategy) = apply { + allowUncategorized = splittingStrategy.allowUncategorized + additionalProperties = splittingStrategy.additionalProperties.toMutableMap() + } + + /** + * Controls handling of pages that don't match any category. 'include': pages can be + * grouped as 'uncategorized' and included in results. 'forbid': all pages must be + * assigned to a defined category. 'omit': pages can be classified as 'uncategorized' + * but are excluded from results. + */ + fun allowUncategorized(allowUncategorized: AllowUncategorized) = + allowUncategorized(JsonField.of(allowUncategorized)) + + /** + * Sets [Builder.allowUncategorized] to an arbitrary JSON value. + * + * You should usually call [Builder.allowUncategorized] with a well-typed + * [AllowUncategorized] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allowUncategorized(allowUncategorized: JsonField) = apply { + this.allowUncategorized = allowUncategorized + } + + 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 [SplittingStrategy]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SplittingStrategy = + SplittingStrategy(allowUncategorized, 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(): SplittingStrategy = apply { + if (validated) { + return@apply + } + + allowUncategorized().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 = (allowUncategorized.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Controls handling of pages that don't match any category. 'include': pages can be grouped + * as 'uncategorized' and included in results. 'forbid': all pages must be assigned to a + * defined category. 'omit': pages can be classified as 'uncategorized' but are excluded + * from results. + */ + class AllowUncategorized + @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 FORBID = of("forbid") + + @JvmField val INCLUDE = of("include") + + @JvmField val OMIT = of("omit") + + @JvmStatic fun of(value: String) = AllowUncategorized(JsonField.of(value)) + } + + /** An enum containing [AllowUncategorized]'s known values. */ + enum class Known { + FORBID, + INCLUDE, + OMIT, + } + + /** + * An enum containing [AllowUncategorized]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AllowUncategorized] 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 { + FORBID, + INCLUDE, + OMIT, + /** + * An enum member indicating that [AllowUncategorized] 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) { + FORBID -> Value.FORBID + INCLUDE -> Value.INCLUDE + OMIT -> Value.OMIT + 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) { + FORBID -> Known.FORBID + INCLUDE -> Known.INCLUDE + OMIT -> Known.OMIT + else -> + throw LlamaCloudInvalidDataException("Unknown AllowUncategorized: $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(): AllowUncategorized = 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 AllowUncategorized && 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 SplittingStrategy && + allowUncategorized == other.allowUncategorized && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(allowUncategorized, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SplittingStrategy{allowUncategorized=$allowUncategorized, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SplitGetResponse && + id == other.id && + categories == other.categories && + documentInputType == other.documentInputType && + fileInput == other.fileInput && + projectId == other.projectId && + status == other.status && + userId == other.userId && + configurationId == other.configurationId && + createdAt == other.createdAt && + errorMessage == other.errorMessage && + result == other.result && + splittingStrategy == other.splittingStrategy && + transactionId == other.transactionId && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + categories, + documentInputType, + fileInput, + projectId, + status, + userId, + configurationId, + createdAt, + errorMessage, + result, + splittingStrategy, + transactionId, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SplitGetResponse{id=$id, categories=$categories, documentInputType=$documentInputType, fileInput=$fileInput, projectId=$projectId, status=$status, userId=$userId, configurationId=$configurationId, createdAt=$createdAt, errorMessage=$errorMessage, result=$result, splittingStrategy=$splittingStrategy, transactionId=$transactionId, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitListPage.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitListPage.kt new file mode 100644 index 0000000..db341c2 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitListPage.kt @@ -0,0 +1,130 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +import ai.llamaindex.llamacloud.core.AutoPager +import ai.llamaindex.llamacloud.core.Page +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.services.blocking.SplitService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see SplitService.list */ +class SplitListPage +private constructor( + private val service: SplitService, + private val params: SplitListParams, + private val response: SplitListPageResponse, +) : Page { + + /** + * Delegates to [SplitListPageResponse], but gracefully handles missing data. + * + * @see SplitListPageResponse.items + */ + override fun items(): List = + response._items().getOptional("items").getOrNull() ?: emptyList() + + /** + * Delegates to [SplitListPageResponse], but gracefully handles missing data. + * + * @see SplitListPageResponse.nextPageToken + */ + fun nextPageToken(): Optional = response._nextPageToken().getOptional("next_page_token") + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageToken().isPresent + + fun nextPageParams(): SplitListParams { + val nextCursor = + nextPageToken().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().pageToken(nextCursor).build() + } + + override fun nextPage(): SplitListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): SplitListParams = params + + /** The response that this page was parsed from. */ + fun response(): SplitListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SplitListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SplitListPage]. */ + class Builder internal constructor() { + + private var service: SplitService? = null + private var params: SplitListParams? = null + private var response: SplitListPageResponse? = null + + @JvmSynthetic + internal fun from(splitListPage: SplitListPage) = apply { + service = splitListPage.service + params = splitListPage.params + response = splitListPage.response + } + + fun service(service: SplitService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: SplitListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: SplitListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [SplitListPage]. + * + * 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(): SplitListPage = + SplitListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SplitListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = "SplitListPage{service=$service, params=$params, response=$response}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitListPageAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitListPageAsync.kt new file mode 100644 index 0000000..6a4af58 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitListPageAsync.kt @@ -0,0 +1,145 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +import ai.llamaindex.llamacloud.core.AutoPagerAsync +import ai.llamaindex.llamacloud.core.PageAsync +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.services.async.SplitServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see SplitServiceAsync.list */ +class SplitListPageAsync +private constructor( + private val service: SplitServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: SplitListParams, + private val response: SplitListPageResponse, +) : PageAsync { + + /** + * Delegates to [SplitListPageResponse], but gracefully handles missing data. + * + * @see SplitListPageResponse.items + */ + override fun items(): List = + response._items().getOptional("items").getOrNull() ?: emptyList() + + /** + * Delegates to [SplitListPageResponse], but gracefully handles missing data. + * + * @see SplitListPageResponse.nextPageToken + */ + fun nextPageToken(): Optional = response._nextPageToken().getOptional("next_page_token") + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageToken().isPresent + + fun nextPageParams(): SplitListParams { + 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(): SplitListParams = params + + /** The response that this page was parsed from. */ + fun response(): SplitListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [SplitListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SplitListPageAsync]. */ + class Builder internal constructor() { + + private var service: SplitServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: SplitListParams? = null + private var response: SplitListPageResponse? = null + + @JvmSynthetic + internal fun from(splitListPageAsync: SplitListPageAsync) = apply { + service = splitListPageAsync.service + streamHandlerExecutor = splitListPageAsync.streamHandlerExecutor + params = splitListPageAsync.params + response = splitListPageAsync.response + } + + fun service(service: SplitServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: SplitListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: SplitListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [SplitListPageAsync]. + * + * 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(): SplitListPageAsync = + SplitListPageAsync( + 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 SplitListPageAsync && + 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() = + "SplitListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitListPageResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitListPageResponse.kt new file mode 100644 index 0000000..84a99b3 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitListPageResponse.kt @@ -0,0 +1,303 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +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 split jobs. */ +class SplitListPageResponse +@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 [SplitListPageResponse]. + * + * The following fields are required: + * ```java + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SplitListPageResponse]. */ + 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(splitListPageResponse: SplitListPageResponse) = apply { + items = splitListPageResponse.items.map { it.toMutableList() } + nextPageToken = splitListPageResponse.nextPageToken + totalSize = splitListPageResponse.totalSize + additionalProperties = splitListPageResponse.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 [SplitListResponse] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: SplitListResponse) = 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 [SplitListPageResponse]. + * + * 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(): SplitListPageResponse = + SplitListPageResponse( + 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(): SplitListPageResponse = 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 SplitListPageResponse && + 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() = + "SplitListPageResponse{items=$items, nextPageToken=$nextPageToken, totalSize=$totalSize, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitListParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitListParams.kt new file mode 100644 index 0000000..2d63d9d --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitListParams.kt @@ -0,0 +1,500 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +import ai.llamaindex.llamacloud.core.Enum +import ai.llamaindex.llamacloud.core.JsonField +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 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 + +/** List document split jobs. */ +class SplitListParams +private constructor( + private val createdAtOnOrAfter: OffsetDateTime?, + private val createdAtOnOrBefore: OffsetDateTime?, + private val jobIds: List?, + private val organizationId: String?, + private val pageSize: Long?, + private val pageToken: String?, + private val projectId: String?, + private val status: Status?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** 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) + + /** Filter by specific job IDs */ + fun jobIds(): Optional> = Optional.ofNullable(jobIds) + + fun organizationId(): Optional = Optional.ofNullable(organizationId) + + fun pageSize(): Optional = Optional.ofNullable(pageSize) + + fun pageToken(): Optional = Optional.ofNullable(pageToken) + + fun projectId(): Optional = Optional.ofNullable(projectId) + + /** Filter by job status (pending, processing, completed, failed, cancelled) */ + 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 { + + @JvmStatic fun none(): SplitListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [SplitListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SplitListParams]. */ + class Builder internal constructor() { + + private var createdAtOnOrAfter: OffsetDateTime? = null + private var createdAtOnOrBefore: OffsetDateTime? = null + private var jobIds: MutableList? = null + private var organizationId: String? = null + private var pageSize: Long? = null + private var pageToken: String? = null + private var projectId: String? = null + private var status: Status? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(splitListParams: SplitListParams) = apply { + createdAtOnOrAfter = splitListParams.createdAtOnOrAfter + createdAtOnOrBefore = splitListParams.createdAtOnOrBefore + jobIds = splitListParams.jobIds?.toMutableList() + organizationId = splitListParams.organizationId + pageSize = splitListParams.pageSize + pageToken = splitListParams.pageToken + projectId = splitListParams.projectId + status = splitListParams.status + additionalHeaders = splitListParams.additionalHeaders.toBuilder() + additionalQueryParams = splitListParams.additionalQueryParams.toBuilder() + } + + /** 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()) + + /** Filter by specific job IDs */ + fun jobIds(jobIds: List?) = apply { this.jobIds = jobIds?.toMutableList() } + + /** Alias for calling [Builder.jobIds] with `jobIds.orElse(null)`. */ + fun jobIds(jobIds: Optional>) = jobIds(jobIds.getOrNull()) + + /** + * Adds a single [String] to [jobIds]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addJobId(jobId: String) = apply { + jobIds = (jobIds ?: mutableListOf()).apply { add(jobId) } + } + + 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()) + + /** Filter by job status (pending, processing, completed, failed, cancelled) */ + fun status(status: Status?) = apply { this.status = status } + + /** Alias for calling [Builder.status] with `status.orElse(null)`. */ + fun status(status: Optional) = status(status.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 [SplitListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SplitListParams = + SplitListParams( + createdAtOnOrAfter, + createdAtOnOrBefore, + jobIds?.toImmutable(), + organizationId, + pageSize, + pageToken, + projectId, + status, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + 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), + ) + } + jobIds?.forEach { put("job_ids", it) } + 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?.let { put("status", it.toString()) } + putAll(additionalQueryParams) + } + .build() + + /** Filter by job status (pending, processing, completed, failed, cancelled) */ + class Status @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CANCELLED = of("cancelled") + + @JvmField val COMPLETED = of("completed") + + @JvmField val FAILED = of("failed") + + @JvmField val PENDING = of("pending") + + @JvmField val PROCESSING = of("processing") + + @JvmStatic fun of(value: String) = Status(JsonField.of(value)) + } + + /** An enum containing [Status]'s known values. */ + enum class Known { + CANCELLED, + COMPLETED, + FAILED, + PENDING, + PROCESSING, + } + + /** + * An enum containing [Status]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Status] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CANCELLED, + COMPLETED, + FAILED, + PENDING, + PROCESSING, + /** An enum member indicating that [Status] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CANCELLED -> Value.CANCELLED + COMPLETED -> Value.COMPLETED + FAILED -> Value.FAILED + PENDING -> Value.PENDING + PROCESSING -> Value.PROCESSING + 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) { + CANCELLED -> Known.CANCELLED + COMPLETED -> Known.COMPLETED + FAILED -> Known.FAILED + PENDING -> Known.PENDING + PROCESSING -> Known.PROCESSING + else -> throw LlamaCloudInvalidDataException("Unknown Status: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws 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(): Status = 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 Status && 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 SplitListParams && + createdAtOnOrAfter == other.createdAtOnOrAfter && + createdAtOnOrBefore == other.createdAtOnOrBefore && + jobIds == other.jobIds && + 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( + createdAtOnOrAfter, + createdAtOnOrBefore, + jobIds, + organizationId, + pageSize, + pageToken, + projectId, + status, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "SplitListParams{createdAtOnOrAfter=$createdAtOnOrAfter, createdAtOnOrBefore=$createdAtOnOrBefore, jobIds=$jobIds, 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/split/SplitListResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitListResponse.kt new file mode 100644 index 0000000..b4078c5 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/split/SplitListResponse.kt @@ -0,0 +1,1253 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +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.checkKnown +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.core.toImmutable +import ai.llamaindex.llamacloud.errors.LlamaCloudInvalidDataException +import ai.llamaindex.llamacloud.models.beta.split.SplitCategory +import ai.llamaindex.llamacloud.models.beta.split.SplitResultResponse +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 split job. */ +class SplitListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val categories: JsonField>, + private val documentInputType: JsonField, + private val fileInput: JsonField, + private val projectId: JsonField, + private val status: JsonField, + private val userId: JsonField, + private val configurationId: JsonField, + private val createdAt: JsonField, + private val errorMessage: JsonField, + private val result: JsonField, + private val splittingStrategy: JsonField, + private val transactionId: JsonField, + private val updatedAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("categories") + @ExcludeMissing + categories: JsonField> = JsonMissing.of(), + @JsonProperty("document_input_type") + @ExcludeMissing + documentInputType: JsonField = JsonMissing.of(), + @JsonProperty("file_input") @ExcludeMissing fileInput: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), + @JsonProperty("status") @ExcludeMissing status: JsonField = JsonMissing.of(), + @JsonProperty("user_id") @ExcludeMissing userId: JsonField = JsonMissing.of(), + @JsonProperty("configuration_id") + @ExcludeMissing + configurationId: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("error_message") + @ExcludeMissing + errorMessage: JsonField = JsonMissing.of(), + @JsonProperty("result") + @ExcludeMissing + result: JsonField = JsonMissing.of(), + @JsonProperty("splitting_strategy") + @ExcludeMissing + splittingStrategy: JsonField = JsonMissing.of(), + @JsonProperty("transaction_id") + @ExcludeMissing + transactionId: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this( + id, + categories, + documentInputType, + fileInput, + projectId, + status, + userId, + configurationId, + createdAt, + errorMessage, + result, + splittingStrategy, + transactionId, + updatedAt, + mutableMapOf(), + ) + + /** + * Unique identifier for the split 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") + + /** + * Categories used for splitting. + * + * @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 categories(): List = categories.getRequired("categories") + + /** + * Whether the input was a file or parse 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 documentInputType(): DocumentInputType = + documentInputType.getRequired("document_input_type") + + /** + * File ID or parse 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 fileInput(): String = fileInput.getRequired("file_input") + + /** + * Project this job 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") + + /** + * Current job status. Valid values are: pending, processing, completed, failed, cancelled. + * + * @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") + + /** + * User who created this 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 userId(): String = userId.getRequired("user_id") + + /** + * Split configuration ID used for this job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun configurationId(): Optional = configurationId.getOptional("configuration_id") + + /** + * Creation datetime + * + * @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") + + /** + * Error message if the job failed. + * + * @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") + + /** + * Result of a completed split job. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun result(): Optional = result.getOptional("result") + + /** + * Strategy used for splitting. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun splittingStrategy(): Optional = + splittingStrategy.getOptional("splitting_strategy") + + /** + * Idempotency key scoped to the project, if one was provided. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transactionId(): Optional = transactionId.getOptional("transaction_id") + + /** + * Update datetime + * + * @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 [categories]. + * + * Unlike [categories], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("categories") + @ExcludeMissing + fun _categories(): JsonField> = categories + + /** + * Returns the raw JSON value of [documentInputType]. + * + * Unlike [documentInputType], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("document_input_type") + @ExcludeMissing + fun _documentInputType(): JsonField = documentInputType + + /** + * Returns the raw JSON value of [fileInput]. + * + * Unlike [fileInput], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("file_input") @ExcludeMissing fun _fileInput(): JsonField = fileInput + + /** + * 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 [userId]. + * + * Unlike [userId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("user_id") @ExcludeMissing fun _userId(): JsonField = userId + + /** + * Returns the raw JSON value of [configurationId]. + * + * Unlike [configurationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("configuration_id") + @ExcludeMissing + fun _configurationId(): JsonField = configurationId + + /** + * 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 [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 [result]. + * + * Unlike [result], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("result") @ExcludeMissing fun _result(): JsonField = result + + /** + * Returns the raw JSON value of [splittingStrategy]. + * + * Unlike [splittingStrategy], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("splitting_strategy") + @ExcludeMissing + fun _splittingStrategy(): JsonField = splittingStrategy + + /** + * Returns the raw JSON value of [transactionId]. + * + * Unlike [transactionId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("transaction_id") + @ExcludeMissing + fun _transactionId(): JsonField = transactionId + + /** + * 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 [SplitListResponse]. + * + * The following fields are required: + * ```java + * .id() + * .categories() + * .documentInputType() + * .fileInput() + * .projectId() + * .status() + * .userId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SplitListResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var categories: JsonField>? = null + private var documentInputType: JsonField? = null + private var fileInput: JsonField? = null + private var projectId: JsonField? = null + private var status: JsonField? = null + private var userId: JsonField? = null + private var configurationId: JsonField = JsonMissing.of() + private var createdAt: JsonField = JsonMissing.of() + private var errorMessage: JsonField = JsonMissing.of() + private var result: JsonField = JsonMissing.of() + private var splittingStrategy: JsonField = JsonMissing.of() + private var transactionId: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(splitListResponse: SplitListResponse) = apply { + id = splitListResponse.id + categories = splitListResponse.categories.map { it.toMutableList() } + documentInputType = splitListResponse.documentInputType + fileInput = splitListResponse.fileInput + projectId = splitListResponse.projectId + status = splitListResponse.status + userId = splitListResponse.userId + configurationId = splitListResponse.configurationId + createdAt = splitListResponse.createdAt + errorMessage = splitListResponse.errorMessage + result = splitListResponse.result + splittingStrategy = splitListResponse.splittingStrategy + transactionId = splitListResponse.transactionId + updatedAt = splitListResponse.updatedAt + additionalProperties = splitListResponse.additionalProperties.toMutableMap() + } + + /** Unique identifier for the split 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 } + + /** Categories used for splitting. */ + fun categories(categories: List) = categories(JsonField.of(categories)) + + /** + * Sets [Builder.categories] to an arbitrary JSON value. + * + * You should usually call [Builder.categories] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun categories(categories: JsonField>) = apply { + this.categories = categories.map { it.toMutableList() } + } + + /** + * Adds a single [SplitCategory] to [categories]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCategory(category: SplitCategory) = apply { + categories = + (categories ?: JsonField.of(mutableListOf())).also { + checkKnown("categories", it).add(category) + } + } + + /** Whether the input was a file or parse job */ + fun documentInputType(documentInputType: DocumentInputType) = + documentInputType(JsonField.of(documentInputType)) + + /** + * Sets [Builder.documentInputType] to an arbitrary JSON value. + * + * You should usually call [Builder.documentInputType] with a well-typed [DocumentInputType] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun documentInputType(documentInputType: JsonField) = apply { + this.documentInputType = documentInputType + } + + /** File ID or parse job ID */ + fun fileInput(fileInput: String) = fileInput(JsonField.of(fileInput)) + + /** + * Sets [Builder.fileInput] to an arbitrary JSON value. + * + * You should usually call [Builder.fileInput] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun fileInput(fileInput: JsonField) = apply { this.fileInput = fileInput } + + /** Project this job 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 } + + /** + * Current job status. Valid values are: pending, processing, completed, failed, cancelled. + */ + 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 } + + /** User who created this job. */ + fun userId(userId: String) = userId(JsonField.of(userId)) + + /** + * Sets [Builder.userId] to an arbitrary JSON value. + * + * You should usually call [Builder.userId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun userId(userId: JsonField) = apply { this.userId = userId } + + /** Split configuration ID used for this job. */ + fun configurationId(configurationId: String?) = + configurationId(JsonField.ofNullable(configurationId)) + + /** Alias for calling [Builder.configurationId] with `configurationId.orElse(null)`. */ + fun configurationId(configurationId: Optional) = + configurationId(configurationId.getOrNull()) + + /** + * Sets [Builder.configurationId] to an arbitrary JSON value. + * + * You should usually call [Builder.configurationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun configurationId(configurationId: JsonField) = apply { + this.configurationId = configurationId + } + + /** Creation datetime */ + 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 } + + /** Error message if the job failed. */ + 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 + } + + /** Result of a completed split job. */ + fun result(result: SplitResultResponse?) = result(JsonField.ofNullable(result)) + + /** Alias for calling [Builder.result] with `result.orElse(null)`. */ + fun result(result: Optional) = result(result.getOrNull()) + + /** + * Sets [Builder.result] to an arbitrary JSON value. + * + * You should usually call [Builder.result] with a well-typed [SplitResultResponse] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun result(result: JsonField) = apply { this.result = result } + + /** Strategy used for splitting. */ + fun splittingStrategy(splittingStrategy: SplittingStrategy) = + splittingStrategy(JsonField.of(splittingStrategy)) + + /** + * Sets [Builder.splittingStrategy] to an arbitrary JSON value. + * + * You should usually call [Builder.splittingStrategy] with a well-typed [SplittingStrategy] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun splittingStrategy(splittingStrategy: JsonField) = apply { + this.splittingStrategy = splittingStrategy + } + + /** Idempotency key scoped to the project, if one was provided. */ + fun transactionId(transactionId: String?) = + transactionId(JsonField.ofNullable(transactionId)) + + /** Alias for calling [Builder.transactionId] with `transactionId.orElse(null)`. */ + fun transactionId(transactionId: Optional) = + transactionId(transactionId.getOrNull()) + + /** + * Sets [Builder.transactionId] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun transactionId(transactionId: JsonField) = apply { + this.transactionId = transactionId + } + + /** Update datetime */ + 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 [SplitListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .categories() + * .documentInputType() + * .fileInput() + * .projectId() + * .status() + * .userId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): SplitListResponse = + SplitListResponse( + checkRequired("id", id), + checkRequired("categories", categories).map { it.toImmutable() }, + checkRequired("documentInputType", documentInputType), + checkRequired("fileInput", fileInput), + checkRequired("projectId", projectId), + checkRequired("status", status), + checkRequired("userId", userId), + configurationId, + createdAt, + errorMessage, + result, + splittingStrategy, + transactionId, + 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(): SplitListResponse = apply { + if (validated) { + return@apply + } + + id() + categories().forEach { it.validate() } + documentInputType().validate() + fileInput() + projectId() + status() + userId() + configurationId() + createdAt() + errorMessage() + result().ifPresent { it.validate() } + splittingStrategy().ifPresent { it.validate() } + transactionId() + 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) + + (categories.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (documentInputType.asKnown().getOrNull()?.validity() ?: 0) + + (if (fileInput.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (status.asKnown().isPresent) 1 else 0) + + (if (userId.asKnown().isPresent) 1 else 0) + + (if (configurationId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (errorMessage.asKnown().isPresent) 1 else 0) + + (result.asKnown().getOrNull()?.validity() ?: 0) + + (splittingStrategy.asKnown().getOrNull()?.validity() ?: 0) + + (if (transactionId.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + /** Whether the input was a file or parse job */ + class DocumentInputType @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 FILE_ID = of("file_id") + + @JvmField val PARSE_JOB_ID = of("parse_job_id") + + @JvmField val URL = of("url") + + @JvmStatic fun of(value: String) = DocumentInputType(JsonField.of(value)) + } + + /** An enum containing [DocumentInputType]'s known values. */ + enum class Known { + FILE_ID, + PARSE_JOB_ID, + URL, + } + + /** + * An enum containing [DocumentInputType]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DocumentInputType] 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 { + FILE_ID, + PARSE_JOB_ID, + URL, + /** + * An enum member indicating that [DocumentInputType] 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) { + FILE_ID -> Value.FILE_ID + PARSE_JOB_ID -> Value.PARSE_JOB_ID + URL -> Value.URL + 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) { + FILE_ID -> Known.FILE_ID + PARSE_JOB_ID -> Known.PARSE_JOB_ID + URL -> Known.URL + else -> throw LlamaCloudInvalidDataException("Unknown DocumentInputType: $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(): DocumentInputType = 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 DocumentInputType && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Strategy used for splitting. */ + class SplittingStrategy + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val allowUncategorized: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("allow_uncategorized") + @ExcludeMissing + allowUncategorized: JsonField = JsonMissing.of() + ) : this(allowUncategorized, mutableMapOf()) + + /** + * Controls handling of pages that don't match any category. 'include': pages can be grouped + * as 'uncategorized' and included in results. 'forbid': all pages must be assigned to a + * defined category. 'omit': pages can be classified as 'uncategorized' but are excluded + * from results. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun allowUncategorized(): Optional = + allowUncategorized.getOptional("allow_uncategorized") + + /** + * Returns the raw JSON value of [allowUncategorized]. + * + * Unlike [allowUncategorized], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("allow_uncategorized") + @ExcludeMissing + fun _allowUncategorized(): JsonField = allowUncategorized + + @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 [SplittingStrategy]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [SplittingStrategy]. */ + class Builder internal constructor() { + + private var allowUncategorized: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(splittingStrategy: SplittingStrategy) = apply { + allowUncategorized = splittingStrategy.allowUncategorized + additionalProperties = splittingStrategy.additionalProperties.toMutableMap() + } + + /** + * Controls handling of pages that don't match any category. 'include': pages can be + * grouped as 'uncategorized' and included in results. 'forbid': all pages must be + * assigned to a defined category. 'omit': pages can be classified as 'uncategorized' + * but are excluded from results. + */ + fun allowUncategorized(allowUncategorized: AllowUncategorized) = + allowUncategorized(JsonField.of(allowUncategorized)) + + /** + * Sets [Builder.allowUncategorized] to an arbitrary JSON value. + * + * You should usually call [Builder.allowUncategorized] with a well-typed + * [AllowUncategorized] value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun allowUncategorized(allowUncategorized: JsonField) = apply { + this.allowUncategorized = allowUncategorized + } + + 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 [SplittingStrategy]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): SplittingStrategy = + SplittingStrategy(allowUncategorized, 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(): SplittingStrategy = apply { + if (validated) { + return@apply + } + + allowUncategorized().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 = (allowUncategorized.asKnown().getOrNull()?.validity() ?: 0) + + /** + * Controls handling of pages that don't match any category. 'include': pages can be grouped + * as 'uncategorized' and included in results. 'forbid': all pages must be assigned to a + * defined category. 'omit': pages can be classified as 'uncategorized' but are excluded + * from results. + */ + class AllowUncategorized + @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 FORBID = of("forbid") + + @JvmField val INCLUDE = of("include") + + @JvmField val OMIT = of("omit") + + @JvmStatic fun of(value: String) = AllowUncategorized(JsonField.of(value)) + } + + /** An enum containing [AllowUncategorized]'s known values. */ + enum class Known { + FORBID, + INCLUDE, + OMIT, + } + + /** + * An enum containing [AllowUncategorized]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [AllowUncategorized] 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 { + FORBID, + INCLUDE, + OMIT, + /** + * An enum member indicating that [AllowUncategorized] 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) { + FORBID -> Value.FORBID + INCLUDE -> Value.INCLUDE + OMIT -> Value.OMIT + 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) { + FORBID -> Known.FORBID + INCLUDE -> Known.INCLUDE + OMIT -> Known.OMIT + else -> + throw LlamaCloudInvalidDataException("Unknown AllowUncategorized: $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(): AllowUncategorized = 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 AllowUncategorized && 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 SplittingStrategy && + allowUncategorized == other.allowUncategorized && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(allowUncategorized, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SplittingStrategy{allowUncategorized=$allowUncategorized, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is SplitListResponse && + id == other.id && + categories == other.categories && + documentInputType == other.documentInputType && + fileInput == other.fileInput && + projectId == other.projectId && + status == other.status && + userId == other.userId && + configurationId == other.configurationId && + createdAt == other.createdAt && + errorMessage == other.errorMessage && + result == other.result && + splittingStrategy == other.splittingStrategy && + transactionId == other.transactionId && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + categories, + documentInputType, + fileInput, + projectId, + status, + userId, + configurationId, + createdAt, + errorMessage, + result, + splittingStrategy, + transactionId, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "SplitListResponse{id=$id, categories=$categories, documentInputType=$documentInputType, fileInput=$fileInput, projectId=$projectId, status=$status, userId=$userId, configurationId=$configurationId, createdAt=$createdAt, errorMessage=$errorMessage, result=$result, splittingStrategy=$splittingStrategy, transactionId=$transactionId, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigCreate.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigCreate.kt new file mode 100644 index 0000000..a72aa5c --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigCreate.kt @@ -0,0 +1,997 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.webhookconfigs + +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.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 + +/** + * Request to create a stored webhook configuration. + * + * The owning tenant is taken from the request context (e.g. the project in the path), not the body. + */ +class WebhookConfigCreate +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val webhookUrl: JsonField, + private val webhookEvents: JsonField>, + private val webhookHeaders: JsonField, + private val webhookOutputFormat: JsonField, + private val webhookSigningSecret: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("webhook_url") + @ExcludeMissing + webhookUrl: JsonField = JsonMissing.of(), + @JsonProperty("webhook_events") + @ExcludeMissing + webhookEvents: JsonField> = JsonMissing.of(), + @JsonProperty("webhook_headers") + @ExcludeMissing + webhookHeaders: JsonField = JsonMissing.of(), + @JsonProperty("webhook_output_format") + @ExcludeMissing + webhookOutputFormat: JsonField = JsonMissing.of(), + @JsonProperty("webhook_signing_secret") + @ExcludeMissing + webhookSigningSecret: JsonField = JsonMissing.of(), + ) : this( + webhookUrl, + webhookEvents, + webhookHeaders, + webhookOutputFormat, + webhookSigningSecret, + mutableMapOf(), + ) + + /** + * URL to receive webhook POST notifications. + * + * @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 webhookUrl(): String = webhookUrl.getRequired("webhook_url") + + /** + * Events to subscribe to. If null, all events are delivered. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookEvents(): Optional> = webhookEvents.getOptional("webhook_events") + + /** + * Custom HTTP headers sent with each webhook request. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookHeaders(): Optional = webhookHeaders.getOptional("webhook_headers") + + /** + * Response format sent to the webhook: 'string' (default) or 'json'. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookOutputFormat(): Optional = + webhookOutputFormat.getOptional("webhook_output_format") + + /** + * Shared secret used to sign deliveries to this endpoint. Write-only: it is never returned in + * responses. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookSigningSecret(): Optional = + webhookSigningSecret.getOptional("webhook_signing_secret") + + /** + * Returns the raw JSON value of [webhookUrl]. + * + * Unlike [webhookUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("webhook_url") @ExcludeMissing fun _webhookUrl(): JsonField = webhookUrl + + /** + * Returns the raw JSON value of [webhookEvents]. + * + * Unlike [webhookEvents], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("webhook_events") + @ExcludeMissing + fun _webhookEvents(): JsonField> = webhookEvents + + /** + * Returns the raw JSON value of [webhookHeaders]. + * + * Unlike [webhookHeaders], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("webhook_headers") + @ExcludeMissing + fun _webhookHeaders(): JsonField = webhookHeaders + + /** + * Returns the raw JSON value of [webhookOutputFormat]. + * + * Unlike [webhookOutputFormat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("webhook_output_format") + @ExcludeMissing + fun _webhookOutputFormat(): JsonField = webhookOutputFormat + + /** + * Returns the raw JSON value of [webhookSigningSecret]. + * + * Unlike [webhookSigningSecret], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("webhook_signing_secret") + @ExcludeMissing + fun _webhookSigningSecret(): JsonField = webhookSigningSecret + + @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 [WebhookConfigCreate]. + * + * The following fields are required: + * ```java + * .webhookUrl() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebhookConfigCreate]. */ + class Builder internal constructor() { + + private var webhookUrl: JsonField? = null + private var webhookEvents: JsonField>? = null + private var webhookHeaders: JsonField = JsonMissing.of() + private var webhookOutputFormat: JsonField = JsonMissing.of() + private var webhookSigningSecret: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webhookConfigCreate: WebhookConfigCreate) = apply { + webhookUrl = webhookConfigCreate.webhookUrl + webhookEvents = webhookConfigCreate.webhookEvents.map { it.toMutableList() } + webhookHeaders = webhookConfigCreate.webhookHeaders + webhookOutputFormat = webhookConfigCreate.webhookOutputFormat + webhookSigningSecret = webhookConfigCreate.webhookSigningSecret + additionalProperties = webhookConfigCreate.additionalProperties.toMutableMap() + } + + /** URL to receive webhook POST notifications. */ + fun webhookUrl(webhookUrl: String) = webhookUrl(JsonField.of(webhookUrl)) + + /** + * Sets [Builder.webhookUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun webhookUrl(webhookUrl: JsonField) = apply { this.webhookUrl = webhookUrl } + + /** Events to subscribe to. If null, all events are delivered. */ + fun webhookEvents(webhookEvents: List?) = + webhookEvents(JsonField.ofNullable(webhookEvents)) + + /** Alias for calling [Builder.webhookEvents] with `webhookEvents.orElse(null)`. */ + fun webhookEvents(webhookEvents: Optional>) = + webhookEvents(webhookEvents.getOrNull()) + + /** + * Sets [Builder.webhookEvents] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookEvents] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun webhookEvents(webhookEvents: JsonField>) = apply { + this.webhookEvents = webhookEvents.map { it.toMutableList() } + } + + /** + * Adds a single [WebhookEvent] to [webhookEvents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookEvent(webhookEvent: WebhookEvent) = apply { + webhookEvents = + (webhookEvents ?: JsonField.of(mutableListOf())).also { + checkKnown("webhookEvents", it).add(webhookEvent) + } + } + + /** Custom HTTP headers sent with each webhook request. */ + fun webhookHeaders(webhookHeaders: WebhookHeaders?) = + webhookHeaders(JsonField.ofNullable(webhookHeaders)) + + /** Alias for calling [Builder.webhookHeaders] with `webhookHeaders.orElse(null)`. */ + fun webhookHeaders(webhookHeaders: Optional) = + webhookHeaders(webhookHeaders.getOrNull()) + + /** + * Sets [Builder.webhookHeaders] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookHeaders] with a well-typed [WebhookHeaders] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun webhookHeaders(webhookHeaders: JsonField) = apply { + this.webhookHeaders = webhookHeaders + } + + /** Response format sent to the webhook: 'string' (default) or 'json'. */ + fun webhookOutputFormat(webhookOutputFormat: WebhookOutputFormat?) = + webhookOutputFormat(JsonField.ofNullable(webhookOutputFormat)) + + /** + * Alias for calling [Builder.webhookOutputFormat] with `webhookOutputFormat.orElse(null)`. + */ + fun webhookOutputFormat(webhookOutputFormat: Optional) = + webhookOutputFormat(webhookOutputFormat.getOrNull()) + + /** + * Sets [Builder.webhookOutputFormat] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookOutputFormat] with a well-typed + * [WebhookOutputFormat] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun webhookOutputFormat(webhookOutputFormat: JsonField) = apply { + this.webhookOutputFormat = webhookOutputFormat + } + + /** + * Shared secret used to sign deliveries to this endpoint. Write-only: it is never returned + * in responses. + */ + fun webhookSigningSecret(webhookSigningSecret: String?) = + webhookSigningSecret(JsonField.ofNullable(webhookSigningSecret)) + + /** + * Alias for calling [Builder.webhookSigningSecret] with + * `webhookSigningSecret.orElse(null)`. + */ + fun webhookSigningSecret(webhookSigningSecret: Optional) = + webhookSigningSecret(webhookSigningSecret.getOrNull()) + + /** + * Sets [Builder.webhookSigningSecret] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookSigningSecret] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun webhookSigningSecret(webhookSigningSecret: JsonField) = apply { + this.webhookSigningSecret = webhookSigningSecret + } + + 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 [WebhookConfigCreate]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .webhookUrl() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WebhookConfigCreate = + WebhookConfigCreate( + checkRequired("webhookUrl", webhookUrl), + (webhookEvents ?: JsonMissing.of()).map { it.toImmutable() }, + webhookHeaders, + webhookOutputFormat, + webhookSigningSecret, + 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(): WebhookConfigCreate = apply { + if (validated) { + return@apply + } + + webhookUrl() + webhookEvents().ifPresent { it.forEach { it.validate() } } + webhookHeaders().ifPresent { it.validate() } + webhookOutputFormat().ifPresent { it.validate() } + webhookSigningSecret() + 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 (webhookUrl.asKnown().isPresent) 1 else 0) + + (webhookEvents.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (webhookHeaders.asKnown().getOrNull()?.validity() ?: 0) + + (webhookOutputFormat.asKnown().getOrNull()?.validity() ?: 0) + + (if (webhookSigningSecret.asKnown().isPresent) 1 else 0) + + class WebhookEvent @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 BATCH_CANCELLED = of("batch.cancelled") + + @JvmField val BATCH_ERROR = of("batch.error") + + @JvmField val BATCH_PENDING = of("batch.pending") + + @JvmField val BATCH_RUNNING = of("batch.running") + + @JvmField val BATCH_SUCCESS = of("batch.success") + + @JvmField val CLASSIFY_CANCELLED = of("classify.cancelled") + + @JvmField val CLASSIFY_ERROR = of("classify.error") + + @JvmField val CLASSIFY_PARTIAL_SUCCESS = of("classify.partial_success") + + @JvmField val CLASSIFY_PENDING = of("classify.pending") + + @JvmField val CLASSIFY_RUNNING = of("classify.running") + + @JvmField val CLASSIFY_SUCCESS = of("classify.success") + + @JvmField val EXTRACT_CANCELLED = of("extract.cancelled") + + @JvmField val EXTRACT_ERROR = of("extract.error") + + @JvmField val EXTRACT_PARTIAL_SUCCESS = of("extract.partial_success") + + @JvmField val EXTRACT_PENDING = of("extract.pending") + + @JvmField val EXTRACT_SUCCESS = of("extract.success") + + @JvmField val PARSE_CANCELLED = of("parse.cancelled") + + @JvmField val PARSE_ERROR = of("parse.error") + + @JvmField val PARSE_PARTIAL_SUCCESS = of("parse.partial_success") + + @JvmField val PARSE_PENDING = of("parse.pending") + + @JvmField val PARSE_RUNNING = of("parse.running") + + @JvmField val PARSE_SUCCESS = of("parse.success") + + @JvmField val SHEETS_CANCELLED = of("sheets.cancelled") + + @JvmField val SHEETS_ERROR = of("sheets.error") + + @JvmField val SHEETS_PARTIAL_SUCCESS = of("sheets.partial_success") + + @JvmField val SHEETS_PENDING = of("sheets.pending") + + @JvmField val SHEETS_SUCCESS = of("sheets.success") + + @JvmField val SPLIT_CANCELLED = of("split.cancelled") + + @JvmField val SPLIT_ERROR = of("split.error") + + @JvmField val SPLIT_PENDING = of("split.pending") + + @JvmField val SPLIT_PROCESSING = of("split.processing") + + @JvmField val SPLIT_SUCCESS = of("split.success") + + @JvmField val UNMAPPED_EVENT = of("unmapped_event") + + @JvmStatic fun of(value: String) = WebhookEvent(JsonField.of(value)) + } + + /** An enum containing [WebhookEvent]'s known values. */ + enum class Known { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, + CLASSIFY_CANCELLED, + CLASSIFY_ERROR, + CLASSIFY_PARTIAL_SUCCESS, + CLASSIFY_PENDING, + CLASSIFY_RUNNING, + CLASSIFY_SUCCESS, + EXTRACT_CANCELLED, + EXTRACT_ERROR, + EXTRACT_PARTIAL_SUCCESS, + EXTRACT_PENDING, + EXTRACT_SUCCESS, + PARSE_CANCELLED, + PARSE_ERROR, + PARSE_PARTIAL_SUCCESS, + PARSE_PENDING, + PARSE_RUNNING, + PARSE_SUCCESS, + SHEETS_CANCELLED, + SHEETS_ERROR, + SHEETS_PARTIAL_SUCCESS, + SHEETS_PENDING, + SHEETS_SUCCESS, + SPLIT_CANCELLED, + SPLIT_ERROR, + SPLIT_PENDING, + SPLIT_PROCESSING, + SPLIT_SUCCESS, + UNMAPPED_EVENT, + } + + /** + * An enum containing [WebhookEvent]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [WebhookEvent] 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 { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, + CLASSIFY_CANCELLED, + CLASSIFY_ERROR, + CLASSIFY_PARTIAL_SUCCESS, + CLASSIFY_PENDING, + CLASSIFY_RUNNING, + CLASSIFY_SUCCESS, + EXTRACT_CANCELLED, + EXTRACT_ERROR, + EXTRACT_PARTIAL_SUCCESS, + EXTRACT_PENDING, + EXTRACT_SUCCESS, + PARSE_CANCELLED, + PARSE_ERROR, + PARSE_PARTIAL_SUCCESS, + PARSE_PENDING, + PARSE_RUNNING, + PARSE_SUCCESS, + SHEETS_CANCELLED, + SHEETS_ERROR, + SHEETS_PARTIAL_SUCCESS, + SHEETS_PENDING, + SHEETS_SUCCESS, + SPLIT_CANCELLED, + SPLIT_ERROR, + SPLIT_PENDING, + SPLIT_PROCESSING, + SPLIT_SUCCESS, + UNMAPPED_EVENT, + /** + * An enum member indicating that [WebhookEvent] 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) { + BATCH_CANCELLED -> Value.BATCH_CANCELLED + BATCH_ERROR -> Value.BATCH_ERROR + BATCH_PENDING -> Value.BATCH_PENDING + BATCH_RUNNING -> Value.BATCH_RUNNING + BATCH_SUCCESS -> Value.BATCH_SUCCESS + CLASSIFY_CANCELLED -> Value.CLASSIFY_CANCELLED + CLASSIFY_ERROR -> Value.CLASSIFY_ERROR + CLASSIFY_PARTIAL_SUCCESS -> Value.CLASSIFY_PARTIAL_SUCCESS + CLASSIFY_PENDING -> Value.CLASSIFY_PENDING + CLASSIFY_RUNNING -> Value.CLASSIFY_RUNNING + CLASSIFY_SUCCESS -> Value.CLASSIFY_SUCCESS + EXTRACT_CANCELLED -> Value.EXTRACT_CANCELLED + EXTRACT_ERROR -> Value.EXTRACT_ERROR + EXTRACT_PARTIAL_SUCCESS -> Value.EXTRACT_PARTIAL_SUCCESS + EXTRACT_PENDING -> Value.EXTRACT_PENDING + EXTRACT_SUCCESS -> Value.EXTRACT_SUCCESS + PARSE_CANCELLED -> Value.PARSE_CANCELLED + PARSE_ERROR -> Value.PARSE_ERROR + PARSE_PARTIAL_SUCCESS -> Value.PARSE_PARTIAL_SUCCESS + PARSE_PENDING -> Value.PARSE_PENDING + PARSE_RUNNING -> Value.PARSE_RUNNING + PARSE_SUCCESS -> Value.PARSE_SUCCESS + SHEETS_CANCELLED -> Value.SHEETS_CANCELLED + SHEETS_ERROR -> Value.SHEETS_ERROR + SHEETS_PARTIAL_SUCCESS -> Value.SHEETS_PARTIAL_SUCCESS + SHEETS_PENDING -> Value.SHEETS_PENDING + SHEETS_SUCCESS -> Value.SHEETS_SUCCESS + SPLIT_CANCELLED -> Value.SPLIT_CANCELLED + SPLIT_ERROR -> Value.SPLIT_ERROR + SPLIT_PENDING -> Value.SPLIT_PENDING + SPLIT_PROCESSING -> Value.SPLIT_PROCESSING + SPLIT_SUCCESS -> Value.SPLIT_SUCCESS + UNMAPPED_EVENT -> Value.UNMAPPED_EVENT + 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) { + BATCH_CANCELLED -> Known.BATCH_CANCELLED + BATCH_ERROR -> Known.BATCH_ERROR + BATCH_PENDING -> Known.BATCH_PENDING + BATCH_RUNNING -> Known.BATCH_RUNNING + BATCH_SUCCESS -> Known.BATCH_SUCCESS + CLASSIFY_CANCELLED -> Known.CLASSIFY_CANCELLED + CLASSIFY_ERROR -> Known.CLASSIFY_ERROR + CLASSIFY_PARTIAL_SUCCESS -> Known.CLASSIFY_PARTIAL_SUCCESS + CLASSIFY_PENDING -> Known.CLASSIFY_PENDING + CLASSIFY_RUNNING -> Known.CLASSIFY_RUNNING + CLASSIFY_SUCCESS -> Known.CLASSIFY_SUCCESS + EXTRACT_CANCELLED -> Known.EXTRACT_CANCELLED + EXTRACT_ERROR -> Known.EXTRACT_ERROR + EXTRACT_PARTIAL_SUCCESS -> Known.EXTRACT_PARTIAL_SUCCESS + EXTRACT_PENDING -> Known.EXTRACT_PENDING + EXTRACT_SUCCESS -> Known.EXTRACT_SUCCESS + PARSE_CANCELLED -> Known.PARSE_CANCELLED + PARSE_ERROR -> Known.PARSE_ERROR + PARSE_PARTIAL_SUCCESS -> Known.PARSE_PARTIAL_SUCCESS + PARSE_PENDING -> Known.PARSE_PENDING + PARSE_RUNNING -> Known.PARSE_RUNNING + PARSE_SUCCESS -> Known.PARSE_SUCCESS + SHEETS_CANCELLED -> Known.SHEETS_CANCELLED + SHEETS_ERROR -> Known.SHEETS_ERROR + SHEETS_PARTIAL_SUCCESS -> Known.SHEETS_PARTIAL_SUCCESS + SHEETS_PENDING -> Known.SHEETS_PENDING + SHEETS_SUCCESS -> Known.SHEETS_SUCCESS + SPLIT_CANCELLED -> Known.SPLIT_CANCELLED + SPLIT_ERROR -> Known.SPLIT_ERROR + SPLIT_PENDING -> Known.SPLIT_PENDING + SPLIT_PROCESSING -> Known.SPLIT_PROCESSING + SPLIT_SUCCESS -> Known.SPLIT_SUCCESS + UNMAPPED_EVENT -> Known.UNMAPPED_EVENT + else -> throw LlamaCloudInvalidDataException("Unknown WebhookEvent: $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(): WebhookEvent = 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 WebhookEvent && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Custom HTTP headers sent with each webhook request. */ + class WebhookHeaders + @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 [WebhookHeaders]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebhookHeaders]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webhookHeaders: WebhookHeaders) = apply { + additionalProperties = webhookHeaders.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 [WebhookHeaders]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WebhookHeaders = WebhookHeaders(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(): WebhookHeaders = 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 WebhookHeaders && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "WebhookHeaders{additionalProperties=$additionalProperties}" + } + + /** Response format sent to the webhook: 'string' (default) or 'json'. */ + class WebhookOutputFormat + @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 JSON = of("json") + + @JvmField val STRING = of("string") + + @JvmStatic fun of(value: String) = WebhookOutputFormat(JsonField.of(value)) + } + + /** An enum containing [WebhookOutputFormat]'s known values. */ + enum class Known { + JSON, + STRING, + } + + /** + * An enum containing [WebhookOutputFormat]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [WebhookOutputFormat] 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 { + JSON, + STRING, + /** + * An enum member indicating that [WebhookOutputFormat] 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) { + JSON -> Value.JSON + STRING -> Value.STRING + 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) { + JSON -> Known.JSON + STRING -> Known.STRING + else -> throw LlamaCloudInvalidDataException("Unknown WebhookOutputFormat: $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(): WebhookOutputFormat = 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 WebhookOutputFormat && 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 WebhookConfigCreate && + webhookUrl == other.webhookUrl && + webhookEvents == other.webhookEvents && + webhookHeaders == other.webhookHeaders && + webhookOutputFormat == other.webhookOutputFormat && + webhookSigningSecret == other.webhookSigningSecret && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + webhookUrl, + webhookEvents, + webhookHeaders, + webhookOutputFormat, + webhookSigningSecret, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "WebhookConfigCreate{webhookUrl=$webhookUrl, webhookEvents=$webhookEvents, webhookHeaders=$webhookHeaders, webhookOutputFormat=$webhookOutputFormat, webhookSigningSecret=$webhookSigningSecret, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigCreateParams.kt new file mode 100644 index 0000000..ded2b33 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigCreateParams.kt @@ -0,0 +1,256 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.webhookconfigs + +import ai.llamaindex.llamacloud.core.JsonValue +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 + +/** Create a reusable webhook configuration for the current project. */ +class WebhookConfigCreateParams +private constructor( + private val organizationId: String?, + private val projectId: String?, + private val webhookConfigCreate: WebhookConfigCreate, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun organizationId(): Optional = Optional.ofNullable(organizationId) + + fun projectId(): Optional = Optional.ofNullable(projectId) + + /** + * Request to create a stored webhook configuration. + * + * The owning tenant is taken from the request context (e.g. the project in the path), not the + * body. + */ + fun webhookConfigCreate(): WebhookConfigCreate = webhookConfigCreate + + fun _additionalBodyProperties(): Map = + webhookConfigCreate._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [WebhookConfigCreateParams]. + * + * The following fields are required: + * ```java + * .webhookConfigCreate() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebhookConfigCreateParams]. */ + class Builder internal constructor() { + + private var organizationId: String? = null + private var projectId: String? = null + private var webhookConfigCreate: WebhookConfigCreate? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(webhookConfigCreateParams: WebhookConfigCreateParams) = apply { + organizationId = webhookConfigCreateParams.organizationId + projectId = webhookConfigCreateParams.projectId + webhookConfigCreate = webhookConfigCreateParams.webhookConfigCreate + additionalHeaders = webhookConfigCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = webhookConfigCreateParams.additionalQueryParams.toBuilder() + } + + 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()) + + /** + * Request to create a stored webhook configuration. + * + * The owning tenant is taken from the request context (e.g. the project in the path), not + * the body. + */ + fun webhookConfigCreate(webhookConfigCreate: WebhookConfigCreate) = apply { + this.webhookConfigCreate = webhookConfigCreate + } + + 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 [WebhookConfigCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .webhookConfigCreate() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WebhookConfigCreateParams = + WebhookConfigCreateParams( + organizationId, + projectId, + checkRequired("webhookConfigCreate", webhookConfigCreate), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): WebhookConfigCreate = webhookConfigCreate + + 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 WebhookConfigCreateParams && + organizationId == other.organizationId && + projectId == other.projectId && + webhookConfigCreate == other.webhookConfigCreate && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + organizationId, + projectId, + webhookConfigCreate, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "WebhookConfigCreateParams{organizationId=$organizationId, projectId=$projectId, webhookConfigCreate=$webhookConfigCreate, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigDeleteParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigDeleteParams.kt new file mode 100644 index 0000000..1965f54 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigDeleteParams.kt @@ -0,0 +1,271 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.webhookconfigs + +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 webhook configuration. */ +class WebhookConfigDeleteParams +private constructor( + private val configId: String?, + private val organizationId: String?, + private val projectId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + fun configId(): Optional = Optional.ofNullable(configId) + + 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(): WebhookConfigDeleteParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [WebhookConfigDeleteParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebhookConfigDeleteParams]. */ + class Builder internal constructor() { + + private var configId: 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(webhookConfigDeleteParams: WebhookConfigDeleteParams) = apply { + configId = webhookConfigDeleteParams.configId + organizationId = webhookConfigDeleteParams.organizationId + projectId = webhookConfigDeleteParams.projectId + additionalHeaders = webhookConfigDeleteParams.additionalHeaders.toBuilder() + additionalQueryParams = webhookConfigDeleteParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + webhookConfigDeleteParams.additionalBodyProperties.toMutableMap() + } + + fun configId(configId: String?) = apply { this.configId = configId } + + /** Alias for calling [Builder.configId] with `configId.orElse(null)`. */ + fun configId(configId: Optional) = configId(configId.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 [WebhookConfigDeleteParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WebhookConfigDeleteParams = + WebhookConfigDeleteParams( + configId, + organizationId, + projectId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> configId ?: "" + 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 WebhookConfigDeleteParams && + configId == other.configId && + organizationId == other.organizationId && + projectId == other.projectId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + configId, + organizationId, + projectId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "WebhookConfigDeleteParams{configId=$configId, organizationId=$organizationId, projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigListParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigListParams.kt new file mode 100644 index 0000000..9cc9e14 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigListParams.kt @@ -0,0 +1,208 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.webhookconfigs + +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 webhook configurations for the current project, newest first. */ +class WebhookConfigListParams +private constructor( + private val organizationId: String?, + private val projectId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + 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 { + + @JvmStatic fun none(): WebhookConfigListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [WebhookConfigListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebhookConfigListParams]. */ + class Builder internal constructor() { + + 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(webhookConfigListParams: WebhookConfigListParams) = apply { + organizationId = webhookConfigListParams.organizationId + projectId = webhookConfigListParams.projectId + additionalHeaders = webhookConfigListParams.additionalHeaders.toBuilder() + additionalQueryParams = webhookConfigListParams.additionalQueryParams.toBuilder() + } + + 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 [WebhookConfigListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WebhookConfigListParams = + WebhookConfigListParams( + organizationId, + projectId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + 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 WebhookConfigListParams && + organizationId == other.organizationId && + projectId == other.projectId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(organizationId, projectId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "WebhookConfigListParams{organizationId=$organizationId, projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigResponse.kt new file mode 100644 index 0000000..3201b1a --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigResponse.kt @@ -0,0 +1,1183 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.webhookconfigs + +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.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.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** A stored webhook configuration. The signing secret is never included. */ +class WebhookConfigResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val hasSecret: JsonField, + private val tenantId: JsonField, + private val tenantType: JsonValue, + private val webhookUrl: JsonField, + private val createdAt: JsonField, + private val updatedAt: JsonField, + private val webhookEvents: JsonField>, + private val webhookHeaders: JsonField, + private val webhookOutputFormat: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("has_secret") + @ExcludeMissing + hasSecret: JsonField = JsonMissing.of(), + @JsonProperty("tenant_id") @ExcludeMissing tenantId: JsonField = JsonMissing.of(), + @JsonProperty("tenant_type") @ExcludeMissing tenantType: JsonValue = JsonMissing.of(), + @JsonProperty("webhook_url") + @ExcludeMissing + webhookUrl: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + @JsonProperty("webhook_events") + @ExcludeMissing + webhookEvents: JsonField> = JsonMissing.of(), + @JsonProperty("webhook_headers") + @ExcludeMissing + webhookHeaders: JsonField = JsonMissing.of(), + @JsonProperty("webhook_output_format") + @ExcludeMissing + webhookOutputFormat: JsonField = JsonMissing.of(), + ) : this( + id, + hasSecret, + tenantId, + tenantType, + webhookUrl, + createdAt, + updatedAt, + webhookEvents, + webhookHeaders, + webhookOutputFormat, + mutableMapOf(), + ) + + /** + * Unique identifier for the webhook configuration. + * + * @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") + + /** + * Whether a signing secret is configured for this endpoint. + * + * @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 hasSecret(): Boolean = hasSecret.getRequired("has_secret") + + /** + * Owner tenant 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 tenantId(): String = tenantId.getRequired("tenant_id") + + /** + * Owner tenant type. + * + * Expected to always return the following: + * ```java + * JsonValue.from("project") + * ``` + * + * However, this method can be useful for debugging and logging (e.g. if the server responded + * with an unexpected value). + */ + @JsonProperty("tenant_type") @ExcludeMissing fun _tenantType(): JsonValue = tenantType + + /** + * URL that receives webhook POST notifications. + * + * @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 webhookUrl(): String = webhookUrl.getRequired("webhook_url") + + /** + * Creation datetime + * + * @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") + + /** + * Update datetime + * + * @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") + + /** + * Subscribed events (null = all events). + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookEvents(): Optional> = webhookEvents.getOptional("webhook_events") + + /** + * Custom HTTP headers sent with each request. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookHeaders(): Optional = webhookHeaders.getOptional("webhook_headers") + + /** + * Response format sent to the webhook. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookOutputFormat(): Optional = + webhookOutputFormat.getOptional("webhook_output_format") + + /** + * 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 [hasSecret]. + * + * Unlike [hasSecret], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("has_secret") @ExcludeMissing fun _hasSecret(): JsonField = hasSecret + + /** + * Returns the raw JSON value of [tenantId]. + * + * Unlike [tenantId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("tenant_id") @ExcludeMissing fun _tenantId(): JsonField = tenantId + + /** + * Returns the raw JSON value of [webhookUrl]. + * + * Unlike [webhookUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("webhook_url") @ExcludeMissing fun _webhookUrl(): JsonField = webhookUrl + + /** + * 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 [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 [webhookEvents]. + * + * Unlike [webhookEvents], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("webhook_events") + @ExcludeMissing + fun _webhookEvents(): JsonField> = webhookEvents + + /** + * Returns the raw JSON value of [webhookHeaders]. + * + * Unlike [webhookHeaders], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("webhook_headers") + @ExcludeMissing + fun _webhookHeaders(): JsonField = webhookHeaders + + /** + * Returns the raw JSON value of [webhookOutputFormat]. + * + * Unlike [webhookOutputFormat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("webhook_output_format") + @ExcludeMissing + fun _webhookOutputFormat(): JsonField = webhookOutputFormat + + @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 [WebhookConfigResponse]. + * + * The following fields are required: + * ```java + * .id() + * .hasSecret() + * .tenantId() + * .webhookUrl() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebhookConfigResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var hasSecret: JsonField? = null + private var tenantId: JsonField? = null + private var tenantType: JsonValue = JsonValue.from("project") + private var webhookUrl: JsonField? = null + private var createdAt: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var webhookEvents: JsonField>? = null + private var webhookHeaders: JsonField = JsonMissing.of() + private var webhookOutputFormat: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webhookConfigResponse: WebhookConfigResponse) = apply { + id = webhookConfigResponse.id + hasSecret = webhookConfigResponse.hasSecret + tenantId = webhookConfigResponse.tenantId + tenantType = webhookConfigResponse.tenantType + webhookUrl = webhookConfigResponse.webhookUrl + createdAt = webhookConfigResponse.createdAt + updatedAt = webhookConfigResponse.updatedAt + webhookEvents = webhookConfigResponse.webhookEvents.map { it.toMutableList() } + webhookHeaders = webhookConfigResponse.webhookHeaders + webhookOutputFormat = webhookConfigResponse.webhookOutputFormat + additionalProperties = webhookConfigResponse.additionalProperties.toMutableMap() + } + + /** Unique identifier for the webhook configuration. */ + 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 } + + /** Whether a signing secret is configured for this endpoint. */ + fun hasSecret(hasSecret: Boolean) = hasSecret(JsonField.of(hasSecret)) + + /** + * Sets [Builder.hasSecret] to an arbitrary JSON value. + * + * You should usually call [Builder.hasSecret] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun hasSecret(hasSecret: JsonField) = apply { this.hasSecret = hasSecret } + + /** Owner tenant ID. */ + fun tenantId(tenantId: String) = tenantId(JsonField.of(tenantId)) + + /** + * Sets [Builder.tenantId] to an arbitrary JSON value. + * + * You should usually call [Builder.tenantId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun tenantId(tenantId: JsonField) = apply { this.tenantId = tenantId } + + /** + * Sets the field to an arbitrary JSON value. + * + * It is usually unnecessary to call this method because the field defaults to the + * following: + * ```java + * JsonValue.from("project") + * ``` + * + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun tenantType(tenantType: JsonValue) = apply { this.tenantType = tenantType } + + /** URL that receives webhook POST notifications. */ + fun webhookUrl(webhookUrl: String) = webhookUrl(JsonField.of(webhookUrl)) + + /** + * Sets [Builder.webhookUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun webhookUrl(webhookUrl: JsonField) = apply { this.webhookUrl = webhookUrl } + + /** Creation datetime */ + 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 } + + /** Update datetime */ + 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 } + + /** Subscribed events (null = all events). */ + fun webhookEvents(webhookEvents: List?) = + webhookEvents(JsonField.ofNullable(webhookEvents)) + + /** Alias for calling [Builder.webhookEvents] with `webhookEvents.orElse(null)`. */ + fun webhookEvents(webhookEvents: Optional>) = + webhookEvents(webhookEvents.getOrNull()) + + /** + * Sets [Builder.webhookEvents] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookEvents] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun webhookEvents(webhookEvents: JsonField>) = apply { + this.webhookEvents = webhookEvents.map { it.toMutableList() } + } + + /** + * Adds a single [WebhookEvent] to [webhookEvents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookEvent(webhookEvent: WebhookEvent) = apply { + webhookEvents = + (webhookEvents ?: JsonField.of(mutableListOf())).also { + checkKnown("webhookEvents", it).add(webhookEvent) + } + } + + /** Custom HTTP headers sent with each request. */ + fun webhookHeaders(webhookHeaders: WebhookHeaders?) = + webhookHeaders(JsonField.ofNullable(webhookHeaders)) + + /** Alias for calling [Builder.webhookHeaders] with `webhookHeaders.orElse(null)`. */ + fun webhookHeaders(webhookHeaders: Optional) = + webhookHeaders(webhookHeaders.getOrNull()) + + /** + * Sets [Builder.webhookHeaders] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookHeaders] with a well-typed [WebhookHeaders] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun webhookHeaders(webhookHeaders: JsonField) = apply { + this.webhookHeaders = webhookHeaders + } + + /** Response format sent to the webhook. */ + fun webhookOutputFormat(webhookOutputFormat: WebhookOutputFormat?) = + webhookOutputFormat(JsonField.ofNullable(webhookOutputFormat)) + + /** + * Alias for calling [Builder.webhookOutputFormat] with `webhookOutputFormat.orElse(null)`. + */ + fun webhookOutputFormat(webhookOutputFormat: Optional) = + webhookOutputFormat(webhookOutputFormat.getOrNull()) + + /** + * Sets [Builder.webhookOutputFormat] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookOutputFormat] with a well-typed + * [WebhookOutputFormat] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun webhookOutputFormat(webhookOutputFormat: JsonField) = apply { + this.webhookOutputFormat = webhookOutputFormat + } + + 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 [WebhookConfigResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .hasSecret() + * .tenantId() + * .webhookUrl() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): WebhookConfigResponse = + WebhookConfigResponse( + checkRequired("id", id), + checkRequired("hasSecret", hasSecret), + checkRequired("tenantId", tenantId), + tenantType, + checkRequired("webhookUrl", webhookUrl), + createdAt, + updatedAt, + (webhookEvents ?: JsonMissing.of()).map { it.toImmutable() }, + webhookHeaders, + webhookOutputFormat, + 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(): WebhookConfigResponse = apply { + if (validated) { + return@apply + } + + id() + hasSecret() + tenantId() + _tenantType().let { + if (it != JsonValue.from("project")) { + throw LlamaCloudInvalidDataException("'tenantType' is invalid, received $it") + } + } + webhookUrl() + createdAt() + updatedAt() + webhookEvents().ifPresent { it.forEach { it.validate() } } + webhookHeaders().ifPresent { it.validate() } + webhookOutputFormat().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 (hasSecret.asKnown().isPresent) 1 else 0) + + (if (tenantId.asKnown().isPresent) 1 else 0) + + tenantType.let { if (it == JsonValue.from("project")) 1 else 0 } + + (if (webhookUrl.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + (webhookEvents.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (webhookHeaders.asKnown().getOrNull()?.validity() ?: 0) + + (webhookOutputFormat.asKnown().getOrNull()?.validity() ?: 0) + + class WebhookEvent @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 BATCH_CANCELLED = of("batch.cancelled") + + @JvmField val BATCH_ERROR = of("batch.error") + + @JvmField val BATCH_PENDING = of("batch.pending") + + @JvmField val BATCH_RUNNING = of("batch.running") + + @JvmField val BATCH_SUCCESS = of("batch.success") + + @JvmField val CLASSIFY_CANCELLED = of("classify.cancelled") + + @JvmField val CLASSIFY_ERROR = of("classify.error") + + @JvmField val CLASSIFY_PARTIAL_SUCCESS = of("classify.partial_success") + + @JvmField val CLASSIFY_PENDING = of("classify.pending") + + @JvmField val CLASSIFY_RUNNING = of("classify.running") + + @JvmField val CLASSIFY_SUCCESS = of("classify.success") + + @JvmField val EXTRACT_CANCELLED = of("extract.cancelled") + + @JvmField val EXTRACT_ERROR = of("extract.error") + + @JvmField val EXTRACT_PARTIAL_SUCCESS = of("extract.partial_success") + + @JvmField val EXTRACT_PENDING = of("extract.pending") + + @JvmField val EXTRACT_SUCCESS = of("extract.success") + + @JvmField val PARSE_CANCELLED = of("parse.cancelled") + + @JvmField val PARSE_ERROR = of("parse.error") + + @JvmField val PARSE_PARTIAL_SUCCESS = of("parse.partial_success") + + @JvmField val PARSE_PENDING = of("parse.pending") + + @JvmField val PARSE_RUNNING = of("parse.running") + + @JvmField val PARSE_SUCCESS = of("parse.success") + + @JvmField val SHEETS_CANCELLED = of("sheets.cancelled") + + @JvmField val SHEETS_ERROR = of("sheets.error") + + @JvmField val SHEETS_PARTIAL_SUCCESS = of("sheets.partial_success") + + @JvmField val SHEETS_PENDING = of("sheets.pending") + + @JvmField val SHEETS_SUCCESS = of("sheets.success") + + @JvmField val SPLIT_CANCELLED = of("split.cancelled") + + @JvmField val SPLIT_ERROR = of("split.error") + + @JvmField val SPLIT_PENDING = of("split.pending") + + @JvmField val SPLIT_PROCESSING = of("split.processing") + + @JvmField val SPLIT_SUCCESS = of("split.success") + + @JvmField val UNMAPPED_EVENT = of("unmapped_event") + + @JvmStatic fun of(value: String) = WebhookEvent(JsonField.of(value)) + } + + /** An enum containing [WebhookEvent]'s known values. */ + enum class Known { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, + CLASSIFY_CANCELLED, + CLASSIFY_ERROR, + CLASSIFY_PARTIAL_SUCCESS, + CLASSIFY_PENDING, + CLASSIFY_RUNNING, + CLASSIFY_SUCCESS, + EXTRACT_CANCELLED, + EXTRACT_ERROR, + EXTRACT_PARTIAL_SUCCESS, + EXTRACT_PENDING, + EXTRACT_SUCCESS, + PARSE_CANCELLED, + PARSE_ERROR, + PARSE_PARTIAL_SUCCESS, + PARSE_PENDING, + PARSE_RUNNING, + PARSE_SUCCESS, + SHEETS_CANCELLED, + SHEETS_ERROR, + SHEETS_PARTIAL_SUCCESS, + SHEETS_PENDING, + SHEETS_SUCCESS, + SPLIT_CANCELLED, + SPLIT_ERROR, + SPLIT_PENDING, + SPLIT_PROCESSING, + SPLIT_SUCCESS, + UNMAPPED_EVENT, + } + + /** + * An enum containing [WebhookEvent]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [WebhookEvent] 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 { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, + CLASSIFY_CANCELLED, + CLASSIFY_ERROR, + CLASSIFY_PARTIAL_SUCCESS, + CLASSIFY_PENDING, + CLASSIFY_RUNNING, + CLASSIFY_SUCCESS, + EXTRACT_CANCELLED, + EXTRACT_ERROR, + EXTRACT_PARTIAL_SUCCESS, + EXTRACT_PENDING, + EXTRACT_SUCCESS, + PARSE_CANCELLED, + PARSE_ERROR, + PARSE_PARTIAL_SUCCESS, + PARSE_PENDING, + PARSE_RUNNING, + PARSE_SUCCESS, + SHEETS_CANCELLED, + SHEETS_ERROR, + SHEETS_PARTIAL_SUCCESS, + SHEETS_PENDING, + SHEETS_SUCCESS, + SPLIT_CANCELLED, + SPLIT_ERROR, + SPLIT_PENDING, + SPLIT_PROCESSING, + SPLIT_SUCCESS, + UNMAPPED_EVENT, + /** + * An enum member indicating that [WebhookEvent] 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) { + BATCH_CANCELLED -> Value.BATCH_CANCELLED + BATCH_ERROR -> Value.BATCH_ERROR + BATCH_PENDING -> Value.BATCH_PENDING + BATCH_RUNNING -> Value.BATCH_RUNNING + BATCH_SUCCESS -> Value.BATCH_SUCCESS + CLASSIFY_CANCELLED -> Value.CLASSIFY_CANCELLED + CLASSIFY_ERROR -> Value.CLASSIFY_ERROR + CLASSIFY_PARTIAL_SUCCESS -> Value.CLASSIFY_PARTIAL_SUCCESS + CLASSIFY_PENDING -> Value.CLASSIFY_PENDING + CLASSIFY_RUNNING -> Value.CLASSIFY_RUNNING + CLASSIFY_SUCCESS -> Value.CLASSIFY_SUCCESS + EXTRACT_CANCELLED -> Value.EXTRACT_CANCELLED + EXTRACT_ERROR -> Value.EXTRACT_ERROR + EXTRACT_PARTIAL_SUCCESS -> Value.EXTRACT_PARTIAL_SUCCESS + EXTRACT_PENDING -> Value.EXTRACT_PENDING + EXTRACT_SUCCESS -> Value.EXTRACT_SUCCESS + PARSE_CANCELLED -> Value.PARSE_CANCELLED + PARSE_ERROR -> Value.PARSE_ERROR + PARSE_PARTIAL_SUCCESS -> Value.PARSE_PARTIAL_SUCCESS + PARSE_PENDING -> Value.PARSE_PENDING + PARSE_RUNNING -> Value.PARSE_RUNNING + PARSE_SUCCESS -> Value.PARSE_SUCCESS + SHEETS_CANCELLED -> Value.SHEETS_CANCELLED + SHEETS_ERROR -> Value.SHEETS_ERROR + SHEETS_PARTIAL_SUCCESS -> Value.SHEETS_PARTIAL_SUCCESS + SHEETS_PENDING -> Value.SHEETS_PENDING + SHEETS_SUCCESS -> Value.SHEETS_SUCCESS + SPLIT_CANCELLED -> Value.SPLIT_CANCELLED + SPLIT_ERROR -> Value.SPLIT_ERROR + SPLIT_PENDING -> Value.SPLIT_PENDING + SPLIT_PROCESSING -> Value.SPLIT_PROCESSING + SPLIT_SUCCESS -> Value.SPLIT_SUCCESS + UNMAPPED_EVENT -> Value.UNMAPPED_EVENT + 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) { + BATCH_CANCELLED -> Known.BATCH_CANCELLED + BATCH_ERROR -> Known.BATCH_ERROR + BATCH_PENDING -> Known.BATCH_PENDING + BATCH_RUNNING -> Known.BATCH_RUNNING + BATCH_SUCCESS -> Known.BATCH_SUCCESS + CLASSIFY_CANCELLED -> Known.CLASSIFY_CANCELLED + CLASSIFY_ERROR -> Known.CLASSIFY_ERROR + CLASSIFY_PARTIAL_SUCCESS -> Known.CLASSIFY_PARTIAL_SUCCESS + CLASSIFY_PENDING -> Known.CLASSIFY_PENDING + CLASSIFY_RUNNING -> Known.CLASSIFY_RUNNING + CLASSIFY_SUCCESS -> Known.CLASSIFY_SUCCESS + EXTRACT_CANCELLED -> Known.EXTRACT_CANCELLED + EXTRACT_ERROR -> Known.EXTRACT_ERROR + EXTRACT_PARTIAL_SUCCESS -> Known.EXTRACT_PARTIAL_SUCCESS + EXTRACT_PENDING -> Known.EXTRACT_PENDING + EXTRACT_SUCCESS -> Known.EXTRACT_SUCCESS + PARSE_CANCELLED -> Known.PARSE_CANCELLED + PARSE_ERROR -> Known.PARSE_ERROR + PARSE_PARTIAL_SUCCESS -> Known.PARSE_PARTIAL_SUCCESS + PARSE_PENDING -> Known.PARSE_PENDING + PARSE_RUNNING -> Known.PARSE_RUNNING + PARSE_SUCCESS -> Known.PARSE_SUCCESS + SHEETS_CANCELLED -> Known.SHEETS_CANCELLED + SHEETS_ERROR -> Known.SHEETS_ERROR + SHEETS_PARTIAL_SUCCESS -> Known.SHEETS_PARTIAL_SUCCESS + SHEETS_PENDING -> Known.SHEETS_PENDING + SHEETS_SUCCESS -> Known.SHEETS_SUCCESS + SPLIT_CANCELLED -> Known.SPLIT_CANCELLED + SPLIT_ERROR -> Known.SPLIT_ERROR + SPLIT_PENDING -> Known.SPLIT_PENDING + SPLIT_PROCESSING -> Known.SPLIT_PROCESSING + SPLIT_SUCCESS -> Known.SPLIT_SUCCESS + UNMAPPED_EVENT -> Known.UNMAPPED_EVENT + else -> throw LlamaCloudInvalidDataException("Unknown WebhookEvent: $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(): WebhookEvent = 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 WebhookEvent && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Custom HTTP headers sent with each request. */ + class WebhookHeaders + @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 [WebhookHeaders]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebhookHeaders]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webhookHeaders: WebhookHeaders) = apply { + additionalProperties = webhookHeaders.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 [WebhookHeaders]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WebhookHeaders = WebhookHeaders(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(): WebhookHeaders = 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 WebhookHeaders && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "WebhookHeaders{additionalProperties=$additionalProperties}" + } + + /** Response format sent to the webhook. */ + class WebhookOutputFormat + @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 JSON = of("json") + + @JvmField val STRING = of("string") + + @JvmStatic fun of(value: String) = WebhookOutputFormat(JsonField.of(value)) + } + + /** An enum containing [WebhookOutputFormat]'s known values. */ + enum class Known { + JSON, + STRING, + } + + /** + * An enum containing [WebhookOutputFormat]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [WebhookOutputFormat] 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 { + JSON, + STRING, + /** + * An enum member indicating that [WebhookOutputFormat] 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) { + JSON -> Value.JSON + STRING -> Value.STRING + 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) { + JSON -> Known.JSON + STRING -> Known.STRING + else -> throw LlamaCloudInvalidDataException("Unknown WebhookOutputFormat: $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(): WebhookOutputFormat = 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 WebhookOutputFormat && 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 WebhookConfigResponse && + id == other.id && + hasSecret == other.hasSecret && + tenantId == other.tenantId && + tenantType == other.tenantType && + webhookUrl == other.webhookUrl && + createdAt == other.createdAt && + updatedAt == other.updatedAt && + webhookEvents == other.webhookEvents && + webhookHeaders == other.webhookHeaders && + webhookOutputFormat == other.webhookOutputFormat && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + hasSecret, + tenantId, + tenantType, + webhookUrl, + createdAt, + updatedAt, + webhookEvents, + webhookHeaders, + webhookOutputFormat, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "WebhookConfigResponse{id=$id, hasSecret=$hasSecret, tenantId=$tenantId, tenantType=$tenantType, webhookUrl=$webhookUrl, createdAt=$createdAt, updatedAt=$updatedAt, webhookEvents=$webhookEvents, webhookHeaders=$webhookHeaders, webhookOutputFormat=$webhookOutputFormat, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigRetrieveParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigRetrieveParams.kt new file mode 100644 index 0000000..9ef36f0 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigRetrieveParams.kt @@ -0,0 +1,228 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.webhookconfigs + +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 + +/** Get a single webhook configuration by ID. */ +class WebhookConfigRetrieveParams +private constructor( + private val configId: String?, + private val organizationId: String?, + private val projectId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun configId(): Optional = Optional.ofNullable(configId) + + 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 { + + @JvmStatic fun none(): WebhookConfigRetrieveParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [WebhookConfigRetrieveParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebhookConfigRetrieveParams]. */ + class Builder internal constructor() { + + private var configId: 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(webhookConfigRetrieveParams: WebhookConfigRetrieveParams) = apply { + configId = webhookConfigRetrieveParams.configId + organizationId = webhookConfigRetrieveParams.organizationId + projectId = webhookConfigRetrieveParams.projectId + additionalHeaders = webhookConfigRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = webhookConfigRetrieveParams.additionalQueryParams.toBuilder() + } + + fun configId(configId: String?) = apply { this.configId = configId } + + /** Alias for calling [Builder.configId] with `configId.orElse(null)`. */ + fun configId(configId: Optional) = configId(configId.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) + } + + /** + * Returns an immutable instance of [WebhookConfigRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WebhookConfigRetrieveParams = + WebhookConfigRetrieveParams( + configId, + organizationId, + projectId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> configId ?: "" + 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 WebhookConfigRetrieveParams && + configId == other.configId && + organizationId == other.organizationId && + projectId == other.projectId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(configId, organizationId, projectId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "WebhookConfigRetrieveParams{configId=$configId, organizationId=$organizationId, projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigUpdateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigUpdateParams.kt new file mode 100644 index 0000000..6c05081 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigUpdateParams.kt @@ -0,0 +1,1442 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.webhookconfigs + +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.Params +import ai.llamaindex.llamacloud.core.checkKnown +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.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 + +/** Update a webhook configuration. Only fields present in the request change. */ +class WebhookConfigUpdateParams +private constructor( + private val configId: String?, + private val organizationId: String?, + private val projectId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun configId(): Optional = Optional.ofNullable(configId) + + fun organizationId(): Optional = Optional.ofNullable(organizationId) + + fun projectId(): Optional = Optional.ofNullable(projectId) + + /** + * Updated event subscriptions. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookEvents(): Optional> = body.webhookEvents() + + /** + * Updated headers. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookHeaders(): Optional = body.webhookHeaders() + + /** + * Updated output format. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookOutputFormat(): Optional = body.webhookOutputFormat() + + /** + * Updated signing secret (write-only). Send to rotate the secret. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookSigningSecret(): Optional = body.webhookSigningSecret() + + /** + * Updated webhook URL. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun webhookUrl(): Optional = body.webhookUrl() + + /** + * Returns the raw JSON value of [webhookEvents]. + * + * Unlike [webhookEvents], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _webhookEvents(): JsonField> = body._webhookEvents() + + /** + * Returns the raw JSON value of [webhookHeaders]. + * + * Unlike [webhookHeaders], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _webhookHeaders(): JsonField = body._webhookHeaders() + + /** + * Returns the raw JSON value of [webhookOutputFormat]. + * + * Unlike [webhookOutputFormat], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _webhookOutputFormat(): JsonField = body._webhookOutputFormat() + + /** + * Returns the raw JSON value of [webhookSigningSecret]. + * + * Unlike [webhookSigningSecret], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _webhookSigningSecret(): JsonField = body._webhookSigningSecret() + + /** + * Returns the raw JSON value of [webhookUrl]. + * + * Unlike [webhookUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _webhookUrl(): JsonField = body._webhookUrl() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): WebhookConfigUpdateParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of [WebhookConfigUpdateParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebhookConfigUpdateParams]. */ + class Builder internal constructor() { + + private var configId: String? = null + private var organizationId: String? = null + private var projectId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(webhookConfigUpdateParams: WebhookConfigUpdateParams) = apply { + configId = webhookConfigUpdateParams.configId + organizationId = webhookConfigUpdateParams.organizationId + projectId = webhookConfigUpdateParams.projectId + body = webhookConfigUpdateParams.body.toBuilder() + additionalHeaders = webhookConfigUpdateParams.additionalHeaders.toBuilder() + additionalQueryParams = webhookConfigUpdateParams.additionalQueryParams.toBuilder() + } + + fun configId(configId: String?) = apply { this.configId = configId } + + /** Alias for calling [Builder.configId] with `configId.orElse(null)`. */ + fun configId(configId: Optional) = configId(configId.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()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [webhookEvents] + * - [webhookHeaders] + * - [webhookOutputFormat] + * - [webhookSigningSecret] + * - [webhookUrl] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** Updated event subscriptions. */ + fun webhookEvents(webhookEvents: List?) = apply { + body.webhookEvents(webhookEvents) + } + + /** Alias for calling [Builder.webhookEvents] with `webhookEvents.orElse(null)`. */ + fun webhookEvents(webhookEvents: Optional>) = + webhookEvents(webhookEvents.getOrNull()) + + /** + * Sets [Builder.webhookEvents] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookEvents] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun webhookEvents(webhookEvents: JsonField>) = apply { + body.webhookEvents(webhookEvents) + } + + /** + * Adds a single [WebhookEvent] to [webhookEvents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookEvent(webhookEvent: WebhookEvent) = apply { + body.addWebhookEvent(webhookEvent) + } + + /** Updated headers. */ + fun webhookHeaders(webhookHeaders: WebhookHeaders?) = apply { + body.webhookHeaders(webhookHeaders) + } + + /** Alias for calling [Builder.webhookHeaders] with `webhookHeaders.orElse(null)`. */ + fun webhookHeaders(webhookHeaders: Optional) = + webhookHeaders(webhookHeaders.getOrNull()) + + /** + * Sets [Builder.webhookHeaders] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookHeaders] with a well-typed [WebhookHeaders] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun webhookHeaders(webhookHeaders: JsonField) = apply { + body.webhookHeaders(webhookHeaders) + } + + /** Updated output format. */ + fun webhookOutputFormat(webhookOutputFormat: WebhookOutputFormat?) = apply { + body.webhookOutputFormat(webhookOutputFormat) + } + + /** + * Alias for calling [Builder.webhookOutputFormat] with `webhookOutputFormat.orElse(null)`. + */ + fun webhookOutputFormat(webhookOutputFormat: Optional) = + webhookOutputFormat(webhookOutputFormat.getOrNull()) + + /** + * Sets [Builder.webhookOutputFormat] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookOutputFormat] with a well-typed + * [WebhookOutputFormat] value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun webhookOutputFormat(webhookOutputFormat: JsonField) = apply { + body.webhookOutputFormat(webhookOutputFormat) + } + + /** Updated signing secret (write-only). Send to rotate the secret. */ + fun webhookSigningSecret(webhookSigningSecret: String?) = apply { + body.webhookSigningSecret(webhookSigningSecret) + } + + /** + * Alias for calling [Builder.webhookSigningSecret] with + * `webhookSigningSecret.orElse(null)`. + */ + fun webhookSigningSecret(webhookSigningSecret: Optional) = + webhookSigningSecret(webhookSigningSecret.getOrNull()) + + /** + * Sets [Builder.webhookSigningSecret] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookSigningSecret] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun webhookSigningSecret(webhookSigningSecret: JsonField) = apply { + body.webhookSigningSecret(webhookSigningSecret) + } + + /** Updated webhook URL. */ + fun webhookUrl(webhookUrl: String?) = apply { body.webhookUrl(webhookUrl) } + + /** Alias for calling [Builder.webhookUrl] with `webhookUrl.orElse(null)`. */ + fun webhookUrl(webhookUrl: Optional) = webhookUrl(webhookUrl.getOrNull()) + + /** + * Sets [Builder.webhookUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookUrl] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun webhookUrl(webhookUrl: JsonField) = apply { body.webhookUrl(webhookUrl) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [WebhookConfigUpdateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WebhookConfigUpdateParams = + WebhookConfigUpdateParams( + configId, + organizationId, + projectId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> configId ?: "" + 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() + + /** Request to update a stored webhook configuration. Only set fields change. */ + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val webhookEvents: JsonField>, + private val webhookHeaders: JsonField, + private val webhookOutputFormat: JsonField, + private val webhookSigningSecret: JsonField, + private val webhookUrl: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("webhook_events") + @ExcludeMissing + webhookEvents: JsonField> = JsonMissing.of(), + @JsonProperty("webhook_headers") + @ExcludeMissing + webhookHeaders: JsonField = JsonMissing.of(), + @JsonProperty("webhook_output_format") + @ExcludeMissing + webhookOutputFormat: JsonField = JsonMissing.of(), + @JsonProperty("webhook_signing_secret") + @ExcludeMissing + webhookSigningSecret: JsonField = JsonMissing.of(), + @JsonProperty("webhook_url") + @ExcludeMissing + webhookUrl: JsonField = JsonMissing.of(), + ) : this( + webhookEvents, + webhookHeaders, + webhookOutputFormat, + webhookSigningSecret, + webhookUrl, + mutableMapOf(), + ) + + /** + * Updated event subscriptions. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookEvents(): Optional> = + webhookEvents.getOptional("webhook_events") + + /** + * Updated headers. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookHeaders(): Optional = + webhookHeaders.getOptional("webhook_headers") + + /** + * Updated output format. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookOutputFormat(): Optional = + webhookOutputFormat.getOptional("webhook_output_format") + + /** + * Updated signing secret (write-only). Send to rotate the secret. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookSigningSecret(): Optional = + webhookSigningSecret.getOptional("webhook_signing_secret") + + /** + * Updated webhook URL. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun webhookUrl(): Optional = webhookUrl.getOptional("webhook_url") + + /** + * Returns the raw JSON value of [webhookEvents]. + * + * Unlike [webhookEvents], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("webhook_events") + @ExcludeMissing + fun _webhookEvents(): JsonField> = webhookEvents + + /** + * Returns the raw JSON value of [webhookHeaders]. + * + * Unlike [webhookHeaders], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("webhook_headers") + @ExcludeMissing + fun _webhookHeaders(): JsonField = webhookHeaders + + /** + * Returns the raw JSON value of [webhookOutputFormat]. + * + * Unlike [webhookOutputFormat], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("webhook_output_format") + @ExcludeMissing + fun _webhookOutputFormat(): JsonField = webhookOutputFormat + + /** + * Returns the raw JSON value of [webhookSigningSecret]. + * + * Unlike [webhookSigningSecret], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("webhook_signing_secret") + @ExcludeMissing + fun _webhookSigningSecret(): JsonField = webhookSigningSecret + + /** + * Returns the raw JSON value of [webhookUrl]. + * + * Unlike [webhookUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("webhook_url") + @ExcludeMissing + fun _webhookUrl(): JsonField = webhookUrl + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Body]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var webhookEvents: JsonField>? = null + private var webhookHeaders: JsonField = JsonMissing.of() + private var webhookOutputFormat: JsonField = JsonMissing.of() + private var webhookSigningSecret: JsonField = JsonMissing.of() + private var webhookUrl: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + webhookEvents = body.webhookEvents.map { it.toMutableList() } + webhookHeaders = body.webhookHeaders + webhookOutputFormat = body.webhookOutputFormat + webhookSigningSecret = body.webhookSigningSecret + webhookUrl = body.webhookUrl + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** Updated event subscriptions. */ + fun webhookEvents(webhookEvents: List?) = + webhookEvents(JsonField.ofNullable(webhookEvents)) + + /** Alias for calling [Builder.webhookEvents] with `webhookEvents.orElse(null)`. */ + fun webhookEvents(webhookEvents: Optional>) = + webhookEvents(webhookEvents.getOrNull()) + + /** + * Sets [Builder.webhookEvents] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookEvents] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun webhookEvents(webhookEvents: JsonField>) = apply { + this.webhookEvents = webhookEvents.map { it.toMutableList() } + } + + /** + * Adds a single [WebhookEvent] to [webhookEvents]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addWebhookEvent(webhookEvent: WebhookEvent) = apply { + webhookEvents = + (webhookEvents ?: JsonField.of(mutableListOf())).also { + checkKnown("webhookEvents", it).add(webhookEvent) + } + } + + /** Updated headers. */ + fun webhookHeaders(webhookHeaders: WebhookHeaders?) = + webhookHeaders(JsonField.ofNullable(webhookHeaders)) + + /** Alias for calling [Builder.webhookHeaders] with `webhookHeaders.orElse(null)`. */ + fun webhookHeaders(webhookHeaders: Optional) = + webhookHeaders(webhookHeaders.getOrNull()) + + /** + * Sets [Builder.webhookHeaders] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookHeaders] with a well-typed [WebhookHeaders] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun webhookHeaders(webhookHeaders: JsonField) = apply { + this.webhookHeaders = webhookHeaders + } + + /** Updated output format. */ + fun webhookOutputFormat(webhookOutputFormat: WebhookOutputFormat?) = + webhookOutputFormat(JsonField.ofNullable(webhookOutputFormat)) + + /** + * Alias for calling [Builder.webhookOutputFormat] with + * `webhookOutputFormat.orElse(null)`. + */ + fun webhookOutputFormat(webhookOutputFormat: Optional) = + webhookOutputFormat(webhookOutputFormat.getOrNull()) + + /** + * Sets [Builder.webhookOutputFormat] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookOutputFormat] with a well-typed + * [WebhookOutputFormat] value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun webhookOutputFormat(webhookOutputFormat: JsonField) = apply { + this.webhookOutputFormat = webhookOutputFormat + } + + /** Updated signing secret (write-only). Send to rotate the secret. */ + fun webhookSigningSecret(webhookSigningSecret: String?) = + webhookSigningSecret(JsonField.ofNullable(webhookSigningSecret)) + + /** + * Alias for calling [Builder.webhookSigningSecret] with + * `webhookSigningSecret.orElse(null)`. + */ + fun webhookSigningSecret(webhookSigningSecret: Optional) = + webhookSigningSecret(webhookSigningSecret.getOrNull()) + + /** + * Sets [Builder.webhookSigningSecret] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookSigningSecret] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun webhookSigningSecret(webhookSigningSecret: JsonField) = apply { + this.webhookSigningSecret = webhookSigningSecret + } + + /** Updated webhook URL. */ + fun webhookUrl(webhookUrl: String?) = webhookUrl(JsonField.ofNullable(webhookUrl)) + + /** Alias for calling [Builder.webhookUrl] with `webhookUrl.orElse(null)`. */ + fun webhookUrl(webhookUrl: Optional) = webhookUrl(webhookUrl.getOrNull()) + + /** + * Sets [Builder.webhookUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.webhookUrl] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun webhookUrl(webhookUrl: JsonField) = apply { this.webhookUrl = webhookUrl } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Body = + Body( + (webhookEvents ?: JsonMissing.of()).map { it.toImmutable() }, + webhookHeaders, + webhookOutputFormat, + webhookSigningSecret, + webhookUrl, + 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(): Body = apply { + if (validated) { + return@apply + } + + webhookEvents().ifPresent { it.forEach { it.validate() } } + webhookHeaders().ifPresent { it.validate() } + webhookOutputFormat().ifPresent { it.validate() } + webhookSigningSecret() + webhookUrl() + 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 = + (webhookEvents.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (webhookHeaders.asKnown().getOrNull()?.validity() ?: 0) + + (webhookOutputFormat.asKnown().getOrNull()?.validity() ?: 0) + + (if (webhookSigningSecret.asKnown().isPresent) 1 else 0) + + (if (webhookUrl.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + webhookEvents == other.webhookEvents && + webhookHeaders == other.webhookHeaders && + webhookOutputFormat == other.webhookOutputFormat && + webhookSigningSecret == other.webhookSigningSecret && + webhookUrl == other.webhookUrl && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + webhookEvents, + webhookHeaders, + webhookOutputFormat, + webhookSigningSecret, + webhookUrl, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{webhookEvents=$webhookEvents, webhookHeaders=$webhookHeaders, webhookOutputFormat=$webhookOutputFormat, webhookSigningSecret=$webhookSigningSecret, webhookUrl=$webhookUrl, additionalProperties=$additionalProperties}" + } + + class WebhookEvent @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 BATCH_CANCELLED = of("batch.cancelled") + + @JvmField val BATCH_ERROR = of("batch.error") + + @JvmField val BATCH_PENDING = of("batch.pending") + + @JvmField val BATCH_RUNNING = of("batch.running") + + @JvmField val BATCH_SUCCESS = of("batch.success") + + @JvmField val CLASSIFY_CANCELLED = of("classify.cancelled") + + @JvmField val CLASSIFY_ERROR = of("classify.error") + + @JvmField val CLASSIFY_PARTIAL_SUCCESS = of("classify.partial_success") + + @JvmField val CLASSIFY_PENDING = of("classify.pending") + + @JvmField val CLASSIFY_RUNNING = of("classify.running") + + @JvmField val CLASSIFY_SUCCESS = of("classify.success") + + @JvmField val EXTRACT_CANCELLED = of("extract.cancelled") + + @JvmField val EXTRACT_ERROR = of("extract.error") + + @JvmField val EXTRACT_PARTIAL_SUCCESS = of("extract.partial_success") + + @JvmField val EXTRACT_PENDING = of("extract.pending") + + @JvmField val EXTRACT_SUCCESS = of("extract.success") + + @JvmField val PARSE_CANCELLED = of("parse.cancelled") + + @JvmField val PARSE_ERROR = of("parse.error") + + @JvmField val PARSE_PARTIAL_SUCCESS = of("parse.partial_success") + + @JvmField val PARSE_PENDING = of("parse.pending") + + @JvmField val PARSE_RUNNING = of("parse.running") + + @JvmField val PARSE_SUCCESS = of("parse.success") + + @JvmField val SHEETS_CANCELLED = of("sheets.cancelled") + + @JvmField val SHEETS_ERROR = of("sheets.error") + + @JvmField val SHEETS_PARTIAL_SUCCESS = of("sheets.partial_success") + + @JvmField val SHEETS_PENDING = of("sheets.pending") + + @JvmField val SHEETS_SUCCESS = of("sheets.success") + + @JvmField val SPLIT_CANCELLED = of("split.cancelled") + + @JvmField val SPLIT_ERROR = of("split.error") + + @JvmField val SPLIT_PENDING = of("split.pending") + + @JvmField val SPLIT_PROCESSING = of("split.processing") + + @JvmField val SPLIT_SUCCESS = of("split.success") + + @JvmField val UNMAPPED_EVENT = of("unmapped_event") + + @JvmStatic fun of(value: String) = WebhookEvent(JsonField.of(value)) + } + + /** An enum containing [WebhookEvent]'s known values. */ + enum class Known { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, + CLASSIFY_CANCELLED, + CLASSIFY_ERROR, + CLASSIFY_PARTIAL_SUCCESS, + CLASSIFY_PENDING, + CLASSIFY_RUNNING, + CLASSIFY_SUCCESS, + EXTRACT_CANCELLED, + EXTRACT_ERROR, + EXTRACT_PARTIAL_SUCCESS, + EXTRACT_PENDING, + EXTRACT_SUCCESS, + PARSE_CANCELLED, + PARSE_ERROR, + PARSE_PARTIAL_SUCCESS, + PARSE_PENDING, + PARSE_RUNNING, + PARSE_SUCCESS, + SHEETS_CANCELLED, + SHEETS_ERROR, + SHEETS_PARTIAL_SUCCESS, + SHEETS_PENDING, + SHEETS_SUCCESS, + SPLIT_CANCELLED, + SPLIT_ERROR, + SPLIT_PENDING, + SPLIT_PROCESSING, + SPLIT_SUCCESS, + UNMAPPED_EVENT, + } + + /** + * An enum containing [WebhookEvent]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [WebhookEvent] 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 { + BATCH_CANCELLED, + BATCH_ERROR, + BATCH_PENDING, + BATCH_RUNNING, + BATCH_SUCCESS, + CLASSIFY_CANCELLED, + CLASSIFY_ERROR, + CLASSIFY_PARTIAL_SUCCESS, + CLASSIFY_PENDING, + CLASSIFY_RUNNING, + CLASSIFY_SUCCESS, + EXTRACT_CANCELLED, + EXTRACT_ERROR, + EXTRACT_PARTIAL_SUCCESS, + EXTRACT_PENDING, + EXTRACT_SUCCESS, + PARSE_CANCELLED, + PARSE_ERROR, + PARSE_PARTIAL_SUCCESS, + PARSE_PENDING, + PARSE_RUNNING, + PARSE_SUCCESS, + SHEETS_CANCELLED, + SHEETS_ERROR, + SHEETS_PARTIAL_SUCCESS, + SHEETS_PENDING, + SHEETS_SUCCESS, + SPLIT_CANCELLED, + SPLIT_ERROR, + SPLIT_PENDING, + SPLIT_PROCESSING, + SPLIT_SUCCESS, + UNMAPPED_EVENT, + /** + * An enum member indicating that [WebhookEvent] 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) { + BATCH_CANCELLED -> Value.BATCH_CANCELLED + BATCH_ERROR -> Value.BATCH_ERROR + BATCH_PENDING -> Value.BATCH_PENDING + BATCH_RUNNING -> Value.BATCH_RUNNING + BATCH_SUCCESS -> Value.BATCH_SUCCESS + CLASSIFY_CANCELLED -> Value.CLASSIFY_CANCELLED + CLASSIFY_ERROR -> Value.CLASSIFY_ERROR + CLASSIFY_PARTIAL_SUCCESS -> Value.CLASSIFY_PARTIAL_SUCCESS + CLASSIFY_PENDING -> Value.CLASSIFY_PENDING + CLASSIFY_RUNNING -> Value.CLASSIFY_RUNNING + CLASSIFY_SUCCESS -> Value.CLASSIFY_SUCCESS + EXTRACT_CANCELLED -> Value.EXTRACT_CANCELLED + EXTRACT_ERROR -> Value.EXTRACT_ERROR + EXTRACT_PARTIAL_SUCCESS -> Value.EXTRACT_PARTIAL_SUCCESS + EXTRACT_PENDING -> Value.EXTRACT_PENDING + EXTRACT_SUCCESS -> Value.EXTRACT_SUCCESS + PARSE_CANCELLED -> Value.PARSE_CANCELLED + PARSE_ERROR -> Value.PARSE_ERROR + PARSE_PARTIAL_SUCCESS -> Value.PARSE_PARTIAL_SUCCESS + PARSE_PENDING -> Value.PARSE_PENDING + PARSE_RUNNING -> Value.PARSE_RUNNING + PARSE_SUCCESS -> Value.PARSE_SUCCESS + SHEETS_CANCELLED -> Value.SHEETS_CANCELLED + SHEETS_ERROR -> Value.SHEETS_ERROR + SHEETS_PARTIAL_SUCCESS -> Value.SHEETS_PARTIAL_SUCCESS + SHEETS_PENDING -> Value.SHEETS_PENDING + SHEETS_SUCCESS -> Value.SHEETS_SUCCESS + SPLIT_CANCELLED -> Value.SPLIT_CANCELLED + SPLIT_ERROR -> Value.SPLIT_ERROR + SPLIT_PENDING -> Value.SPLIT_PENDING + SPLIT_PROCESSING -> Value.SPLIT_PROCESSING + SPLIT_SUCCESS -> Value.SPLIT_SUCCESS + UNMAPPED_EVENT -> Value.UNMAPPED_EVENT + 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) { + BATCH_CANCELLED -> Known.BATCH_CANCELLED + BATCH_ERROR -> Known.BATCH_ERROR + BATCH_PENDING -> Known.BATCH_PENDING + BATCH_RUNNING -> Known.BATCH_RUNNING + BATCH_SUCCESS -> Known.BATCH_SUCCESS + CLASSIFY_CANCELLED -> Known.CLASSIFY_CANCELLED + CLASSIFY_ERROR -> Known.CLASSIFY_ERROR + CLASSIFY_PARTIAL_SUCCESS -> Known.CLASSIFY_PARTIAL_SUCCESS + CLASSIFY_PENDING -> Known.CLASSIFY_PENDING + CLASSIFY_RUNNING -> Known.CLASSIFY_RUNNING + CLASSIFY_SUCCESS -> Known.CLASSIFY_SUCCESS + EXTRACT_CANCELLED -> Known.EXTRACT_CANCELLED + EXTRACT_ERROR -> Known.EXTRACT_ERROR + EXTRACT_PARTIAL_SUCCESS -> Known.EXTRACT_PARTIAL_SUCCESS + EXTRACT_PENDING -> Known.EXTRACT_PENDING + EXTRACT_SUCCESS -> Known.EXTRACT_SUCCESS + PARSE_CANCELLED -> Known.PARSE_CANCELLED + PARSE_ERROR -> Known.PARSE_ERROR + PARSE_PARTIAL_SUCCESS -> Known.PARSE_PARTIAL_SUCCESS + PARSE_PENDING -> Known.PARSE_PENDING + PARSE_RUNNING -> Known.PARSE_RUNNING + PARSE_SUCCESS -> Known.PARSE_SUCCESS + SHEETS_CANCELLED -> Known.SHEETS_CANCELLED + SHEETS_ERROR -> Known.SHEETS_ERROR + SHEETS_PARTIAL_SUCCESS -> Known.SHEETS_PARTIAL_SUCCESS + SHEETS_PENDING -> Known.SHEETS_PENDING + SHEETS_SUCCESS -> Known.SHEETS_SUCCESS + SPLIT_CANCELLED -> Known.SPLIT_CANCELLED + SPLIT_ERROR -> Known.SPLIT_ERROR + SPLIT_PENDING -> Known.SPLIT_PENDING + SPLIT_PROCESSING -> Known.SPLIT_PROCESSING + SPLIT_SUCCESS -> Known.SPLIT_SUCCESS + UNMAPPED_EVENT -> Known.UNMAPPED_EVENT + else -> throw LlamaCloudInvalidDataException("Unknown WebhookEvent: $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(): WebhookEvent = 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 WebhookEvent && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Updated headers. */ + class WebhookHeaders + @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 [WebhookHeaders]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [WebhookHeaders]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(webhookHeaders: WebhookHeaders) = apply { + additionalProperties = webhookHeaders.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 [WebhookHeaders]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): WebhookHeaders = WebhookHeaders(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(): WebhookHeaders = 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 WebhookHeaders && additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = "WebhookHeaders{additionalProperties=$additionalProperties}" + } + + /** Updated output format. */ + class WebhookOutputFormat + @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 JSON = of("json") + + @JvmField val STRING = of("string") + + @JvmStatic fun of(value: String) = WebhookOutputFormat(JsonField.of(value)) + } + + /** An enum containing [WebhookOutputFormat]'s known values. */ + enum class Known { + JSON, + STRING, + } + + /** + * An enum containing [WebhookOutputFormat]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [WebhookOutputFormat] 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 { + JSON, + STRING, + /** + * An enum member indicating that [WebhookOutputFormat] 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) { + JSON -> Value.JSON + STRING -> Value.STRING + 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) { + JSON -> Known.JSON + STRING -> Known.STRING + else -> throw LlamaCloudInvalidDataException("Unknown WebhookOutputFormat: $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(): WebhookOutputFormat = 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 WebhookOutputFormat && 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 WebhookConfigUpdateParams && + configId == other.configId && + organizationId == other.organizationId && + projectId == other.projectId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + configId, + organizationId, + projectId, + body, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "WebhookConfigUpdateParams{configId=$configId, organizationId=$organizationId, projectId=$projectId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsync.kt index d26f2fe..d83e2be 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsync.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsync.kt @@ -5,6 +5,8 @@ package ai.llamaindex.llamacloud.services.async import ai.llamaindex.llamacloud.core.ClientOptions import ai.llamaindex.llamacloud.core.RequestOptions import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.models.batches.BatchCancelParams +import ai.llamaindex.llamacloud.models.batches.BatchCancelResponse import ai.llamaindex.llamacloud.models.batches.BatchCreateParams import ai.llamaindex.llamacloud.models.batches.BatchCreateResponse import ai.llamaindex.llamacloud.models.batches.BatchGetParams @@ -69,6 +71,46 @@ interface BatchServiceAsync { fun list(requestOptions: RequestOptions): CompletableFuture = list(BatchListParams.none(), requestOptions) + /** + * Cancel a running batch. + * + * Returns immediately; the batch reaches `CANCELLED` once processing stops. Files that already + * finished keep their results. A batch in a terminal status cannot be cancelled. + */ + fun cancel(batchId: String): CompletableFuture = + cancel(batchId, BatchCancelParams.none()) + + /** @see cancel */ + fun cancel( + batchId: String, + params: BatchCancelParams = BatchCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + cancel(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + batchId: String, + params: BatchCancelParams = BatchCancelParams.none(), + ): CompletableFuture = cancel(batchId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: BatchCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see cancel */ + fun cancel(params: BatchCancelParams): CompletableFuture = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + batchId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + cancel(batchId, BatchCancelParams.none(), requestOptions) + /** Get a batch by ID. */ fun get(batchId: String): CompletableFuture = get(batchId, BatchGetParams.none()) @@ -153,6 +195,47 @@ interface BatchServiceAsync { ): CompletableFuture> = list(BatchListParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /api/v2/batches/{batch_id}/cancel`, but is + * otherwise the same as [BatchServiceAsync.cancel]. + */ + fun cancel(batchId: String): CompletableFuture> = + cancel(batchId, BatchCancelParams.none()) + + /** @see cancel */ + fun cancel( + batchId: String, + params: BatchCancelParams = BatchCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + cancel(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + batchId: String, + params: BatchCancelParams = BatchCancelParams.none(), + ): CompletableFuture> = + cancel(batchId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: BatchCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see cancel */ + fun cancel( + params: BatchCancelParams + ): CompletableFuture> = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + batchId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + cancel(batchId, BatchCancelParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /api/v2/batches/{batch_id}`, but is otherwise the * same as [BatchServiceAsync.get]. diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncImpl.kt index 6eace8b..b15d33e 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncImpl.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncImpl.kt @@ -16,6 +16,8 @@ import ai.llamaindex.llamacloud.core.http.HttpResponseFor import ai.llamaindex.llamacloud.core.http.json import ai.llamaindex.llamacloud.core.http.parseable import ai.llamaindex.llamacloud.core.prepareAsync +import ai.llamaindex.llamacloud.models.batches.BatchCancelParams +import ai.llamaindex.llamacloud.models.batches.BatchCancelResponse import ai.llamaindex.llamacloud.models.batches.BatchCreateParams import ai.llamaindex.llamacloud.models.batches.BatchCreateResponse import ai.llamaindex.llamacloud.models.batches.BatchGetParams @@ -53,6 +55,13 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie // get /api/v2/batches withRawResponse().list(params, requestOptions).thenApply { it.parse() } + override fun cancel( + params: BatchCancelParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /api/v2/batches/{batch_id}/cancel + withRawResponse().cancel(params, requestOptions).thenApply { it.parse() } + override fun get( params: BatchGetParams, requestOptions: RequestOptions, @@ -142,6 +151,40 @@ class BatchServiceAsyncImpl internal constructor(private val clientOptions: Clie } } + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun cancel( + params: BatchCancelParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("batchId", params.batchId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v2", "batches", params._pathParam(0), "cancel") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { cancelHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ClassifyServiceAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ClassifyServiceAsync.kt index 5244fec..1e0b9c2 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ClassifyServiceAsync.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ClassifyServiceAsync.kt @@ -5,6 +5,8 @@ package ai.llamaindex.llamacloud.services.async import ai.llamaindex.llamacloud.core.ClientOptions import ai.llamaindex.llamacloud.core.RequestOptions import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.models.classify.ClassifyCancelParams +import ai.llamaindex.llamacloud.models.classify.ClassifyCancelResponse import ai.llamaindex.llamacloud.models.classify.ClassifyCreateParams import ai.llamaindex.llamacloud.models.classify.ClassifyCreateRequest import ai.llamaindex.llamacloud.models.classify.ClassifyCreateResponse @@ -89,6 +91,46 @@ interface ClassifyServiceAsync { fun list(requestOptions: RequestOptions): CompletableFuture = list(ClassifyListParams.none(), requestOptions) + /** + * Cancel a running classify job. + * + * Stops processing and marks the job as CANCELLED. Returns the updated job. Jobs already in a + * terminal state (COMPLETED, FAILED, CANCELLED) cannot be cancelled. + */ + fun cancel(jobId: String): CompletableFuture = + cancel(jobId, ClassifyCancelParams.none()) + + /** @see cancel */ + fun cancel( + jobId: String, + params: ClassifyCancelParams = ClassifyCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + cancel(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + jobId: String, + params: ClassifyCancelParams = ClassifyCancelParams.none(), + ): CompletableFuture = cancel(jobId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: ClassifyCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see cancel */ + fun cancel(params: ClassifyCancelParams): CompletableFuture = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + jobId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + cancel(jobId, ClassifyCancelParams.none(), requestOptions) + /** * Get a classify job by ID. * @@ -196,6 +238,47 @@ interface ClassifyServiceAsync { ): CompletableFuture> = list(ClassifyListParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /api/v2/classify/{job_id}/cancel`, but is otherwise + * the same as [ClassifyServiceAsync.cancel]. + */ + fun cancel(jobId: String): CompletableFuture> = + cancel(jobId, ClassifyCancelParams.none()) + + /** @see cancel */ + fun cancel( + jobId: String, + params: ClassifyCancelParams = ClassifyCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + cancel(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + jobId: String, + params: ClassifyCancelParams = ClassifyCancelParams.none(), + ): CompletableFuture> = + cancel(jobId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: ClassifyCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see cancel */ + fun cancel( + params: ClassifyCancelParams + ): CompletableFuture> = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + jobId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + cancel(jobId, ClassifyCancelParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /api/v2/classify/{job_id}`, but is otherwise the * same as [ClassifyServiceAsync.get]. diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ClassifyServiceAsyncImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ClassifyServiceAsyncImpl.kt index 9707881..7090478 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ClassifyServiceAsyncImpl.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ClassifyServiceAsyncImpl.kt @@ -16,6 +16,8 @@ import ai.llamaindex.llamacloud.core.http.HttpResponseFor import ai.llamaindex.llamacloud.core.http.json import ai.llamaindex.llamacloud.core.http.parseable import ai.llamaindex.llamacloud.core.prepareAsync +import ai.llamaindex.llamacloud.models.classify.ClassifyCancelParams +import ai.llamaindex.llamacloud.models.classify.ClassifyCancelResponse import ai.llamaindex.llamacloud.models.classify.ClassifyCreateParams import ai.llamaindex.llamacloud.models.classify.ClassifyCreateResponse import ai.llamaindex.llamacloud.models.classify.ClassifyGetParams @@ -53,6 +55,13 @@ class ClassifyServiceAsyncImpl internal constructor(private val clientOptions: C // get /api/v2/classify withRawResponse().list(params, requestOptions).thenApply { it.parse() } + override fun cancel( + params: ClassifyCancelParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /api/v2/classify/{job_id}/cancel + withRawResponse().cancel(params, requestOptions).thenApply { it.parse() } + override fun get( params: ClassifyGetParams, requestOptions: RequestOptions, @@ -142,6 +151,40 @@ class ClassifyServiceAsyncImpl internal constructor(private val clientOptions: C } } + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun cancel( + params: ClassifyCancelParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v2", "classify", params._pathParam(0), "cancel") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { cancelHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsync.kt index f24996d..003d8f8 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsync.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsync.kt @@ -6,6 +6,7 @@ import ai.llamaindex.llamacloud.core.ClientOptions import ai.llamaindex.llamacloud.core.RequestOptions import ai.llamaindex.llamacloud.core.http.HttpResponseFor import ai.llamaindex.llamacloud.models.configurations.ConfigurationCreate +import ai.llamaindex.llamacloud.models.extract.ExtractCancelParams import ai.llamaindex.llamacloud.models.extract.ExtractCreateParams import ai.llamaindex.llamacloud.models.extract.ExtractDeleteParams import ai.llamaindex.llamacloud.models.extract.ExtractDeleteResponse @@ -137,6 +138,43 @@ interface ExtractServiceAsync { ): CompletableFuture = delete(jobId, ExtractDeleteParams.none(), requestOptions) + /** + * Cancel a running extraction job. + * + * Stops processing and marks the job as CANCELLED. Returns the updated job. Jobs already in a + * terminal state (COMPLETED, FAILED, CANCELLED) cannot be cancelled. + */ + fun cancel(jobId: String): CompletableFuture = + cancel(jobId, ExtractCancelParams.none()) + + /** @see cancel */ + fun cancel( + jobId: String, + params: ExtractCancelParams = ExtractCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + cancel(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + jobId: String, + params: ExtractCancelParams = ExtractCancelParams.none(), + ): CompletableFuture = cancel(jobId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: ExtractCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see cancel */ + fun cancel(params: ExtractCancelParams): CompletableFuture = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel(jobId: String, requestOptions: RequestOptions): CompletableFuture = + cancel(jobId, ExtractCancelParams.none(), requestOptions) + /** Generate a JSON schema and return a product configuration request. */ fun generateSchema( params: ExtractGenerateSchemaParams @@ -342,6 +380,45 @@ interface ExtractServiceAsync { ): CompletableFuture> = delete(jobId, ExtractDeleteParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /api/v2/extract/{job_id}/cancel`, but is otherwise + * the same as [ExtractServiceAsync.cancel]. + */ + fun cancel(jobId: String): CompletableFuture> = + cancel(jobId, ExtractCancelParams.none()) + + /** @see cancel */ + fun cancel( + jobId: String, + params: ExtractCancelParams = ExtractCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + cancel(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + jobId: String, + params: ExtractCancelParams = ExtractCancelParams.none(), + ): CompletableFuture> = + cancel(jobId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: ExtractCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see cancel */ + fun cancel(params: ExtractCancelParams): CompletableFuture> = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + jobId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + cancel(jobId, ExtractCancelParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /api/v2/extract/schema/generate`, but is otherwise * the same as [ExtractServiceAsync.generateSchema]. diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsyncImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsyncImpl.kt index e05aa22..cf63839 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsyncImpl.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsyncImpl.kt @@ -17,6 +17,7 @@ import ai.llamaindex.llamacloud.core.http.json import ai.llamaindex.llamacloud.core.http.parseable import ai.llamaindex.llamacloud.core.prepareAsync import ai.llamaindex.llamacloud.models.configurations.ConfigurationCreate +import ai.llamaindex.llamacloud.models.extract.ExtractCancelParams import ai.llamaindex.llamacloud.models.extract.ExtractCreateParams import ai.llamaindex.llamacloud.models.extract.ExtractDeleteParams import ai.llamaindex.llamacloud.models.extract.ExtractDeleteResponse @@ -65,6 +66,13 @@ class ExtractServiceAsyncImpl internal constructor(private val clientOptions: Cl // delete /api/v2/extract/{job_id} withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + override fun cancel( + params: ExtractCancelParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /api/v2/extract/{job_id}/cancel + withRawResponse().cancel(params, requestOptions).thenApply { it.parse() } + override fun generateSchema( params: ExtractGenerateSchemaParams, requestOptions: RequestOptions, @@ -202,6 +210,40 @@ class ExtractServiceAsyncImpl internal constructor(private val clientOptions: Cl } } + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun cancel( + params: ExtractCancelParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v2", "extract", params._pathParam(0), "cancel") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { cancelHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val generateSchemaHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsync.kt index 780b507..12e11de 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsync.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsync.kt @@ -13,6 +13,8 @@ import ai.llamaindex.llamacloud.models.parsing.ParsingGetParams import ai.llamaindex.llamacloud.models.parsing.ParsingGetResponse import ai.llamaindex.llamacloud.models.parsing.ParsingListPageAsync import ai.llamaindex.llamacloud.models.parsing.ParsingListParams +import ai.llamaindex.llamacloud.models.parsing.ParsingListVersionsParams +import ai.llamaindex.llamacloud.models.parsing.ParsingListVersionsResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -161,6 +163,27 @@ interface ParsingServiceAsync { fun get(jobId: String, requestOptions: RequestOptions): CompletableFuture = get(jobId, ParsingGetParams.none(), requestOptions) + /** List the parse versions accepted by each tier. */ + fun listVersions(): CompletableFuture = + listVersions(ParsingListVersionsParams.none()) + + /** @see listVersions */ + fun listVersions( + params: ParsingListVersionsParams = ParsingListVersionsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see listVersions */ + fun listVersions( + params: ParsingListVersionsParams = ParsingListVersionsParams.none() + ): CompletableFuture = listVersions(params, RequestOptions.none()) + + /** @see listVersions */ + fun listVersions( + requestOptions: RequestOptions + ): CompletableFuture = + listVersions(ParsingListVersionsParams.none(), requestOptions) + /** * A view of [ParsingServiceAsync] that provides access to raw HTTP responses for each method. */ @@ -294,5 +317,30 @@ interface ParsingServiceAsync { requestOptions: RequestOptions, ): CompletableFuture> = get(jobId, ParsingGetParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v2/parse/versions`, but is otherwise the same + * as [ParsingServiceAsync.listVersions]. + */ + fun listVersions(): CompletableFuture> = + listVersions(ParsingListVersionsParams.none()) + + /** @see listVersions */ + fun listVersions( + params: ParsingListVersionsParams = ParsingListVersionsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see listVersions */ + fun listVersions( + params: ParsingListVersionsParams = ParsingListVersionsParams.none() + ): CompletableFuture> = + listVersions(params, RequestOptions.none()) + + /** @see listVersions */ + fun listVersions( + requestOptions: RequestOptions + ): CompletableFuture> = + listVersions(ParsingListVersionsParams.none(), requestOptions) } } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncImpl.kt index 61986d374..4734dbd 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncImpl.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncImpl.kt @@ -25,6 +25,8 @@ import ai.llamaindex.llamacloud.models.parsing.ParsingGetResponse import ai.llamaindex.llamacloud.models.parsing.ParsingListPageAsync import ai.llamaindex.llamacloud.models.parsing.ParsingListPageResponse import ai.llamaindex.llamacloud.models.parsing.ParsingListParams +import ai.llamaindex.llamacloud.models.parsing.ParsingListVersionsParams +import ai.llamaindex.llamacloud.models.parsing.ParsingListVersionsResponse import java.util.concurrent.CompletableFuture import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -69,6 +71,13 @@ class ParsingServiceAsyncImpl internal constructor(private val clientOptions: Cl // get /api/v2/parse/{job_id} withRawResponse().get(params, requestOptions).thenApply { it.parse() } + override fun listVersions( + params: ParsingListVersionsParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/v2/parse/versions + withRawResponse().listVersions(params, requestOptions).thenApply { it.parse() } + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ParsingServiceAsync.WithRawResponse { @@ -217,5 +226,35 @@ class ParsingServiceAsyncImpl internal constructor(private val clientOptions: Cl } } } + + private val listVersionsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun listVersions( + params: ParsingListVersionsParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v2", "parse", "versions") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listVersionsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } } } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/SplitServiceAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/SplitServiceAsync.kt new file mode 100644 index 0000000..e0715f2 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/SplitServiceAsync.kt @@ -0,0 +1,346 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.async + +import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.core.RequestOptions +import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.models.split.SplitCancelParams +import ai.llamaindex.llamacloud.models.split.SplitCancelResponse +import ai.llamaindex.llamacloud.models.split.SplitCreateParams +import ai.llamaindex.llamacloud.models.split.SplitCreateResponse +import ai.llamaindex.llamacloud.models.split.SplitDeleteParams +import ai.llamaindex.llamacloud.models.split.SplitDeleteResponse +import ai.llamaindex.llamacloud.models.split.SplitGetParams +import ai.llamaindex.llamacloud.models.split.SplitGetResponse +import ai.llamaindex.llamacloud.models.split.SplitListPageAsync +import ai.llamaindex.llamacloud.models.split.SplitListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface SplitServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SplitServiceAsync + + /** Create a document split job. */ + fun create(params: SplitCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SplitCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** List document split jobs. */ + fun list(): CompletableFuture = list(SplitListParams.none()) + + /** @see list */ + fun list( + params: SplitListParams = SplitListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: SplitListParams = SplitListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(SplitListParams.none(), requestOptions) + + /** Delete a split job and its results. */ + fun delete(splitJobId: String): CompletableFuture = + delete(splitJobId, SplitDeleteParams.none()) + + /** @see delete */ + fun delete( + splitJobId: String, + params: SplitDeleteParams = SplitDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().splitJobId(splitJobId).build(), requestOptions) + + /** @see delete */ + fun delete( + splitJobId: String, + params: SplitDeleteParams = SplitDeleteParams.none(), + ): CompletableFuture = delete(splitJobId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: SplitDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: SplitDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + splitJobId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(splitJobId, SplitDeleteParams.none(), requestOptions) + + /** + * Cancel a running split job. + * + * Requests cancellation; the job transitions to CANCELLED asynchronously once processing stops. + * Returns the job, which may still be in its current non-terminal state. Jobs already in a + * terminal state (COMPLETED, FAILED, CANCELLED) cannot be cancelled. + */ + fun cancel(splitJobId: String): CompletableFuture = + cancel(splitJobId, SplitCancelParams.none()) + + /** @see cancel */ + fun cancel( + splitJobId: String, + params: SplitCancelParams = SplitCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + cancel(params.toBuilder().splitJobId(splitJobId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + splitJobId: String, + params: SplitCancelParams = SplitCancelParams.none(), + ): CompletableFuture = cancel(splitJobId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: SplitCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see cancel */ + fun cancel(params: SplitCancelParams): CompletableFuture = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + splitJobId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + cancel(splitJobId, SplitCancelParams.none(), requestOptions) + + /** Get a document split job. */ + fun get(splitJobId: String): CompletableFuture = + get(splitJobId, SplitGetParams.none()) + + /** @see get */ + fun get( + splitJobId: String, + params: SplitGetParams = SplitGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + get(params.toBuilder().splitJobId(splitJobId).build(), requestOptions) + + /** @see get */ + fun get( + splitJobId: String, + params: SplitGetParams = SplitGetParams.none(), + ): CompletableFuture = get(splitJobId, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: SplitGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see get */ + fun get(params: SplitGetParams): CompletableFuture = + get(params, RequestOptions.none()) + + /** @see get */ + fun get( + splitJobId: String, + requestOptions: RequestOptions, + ): CompletableFuture = get(splitJobId, SplitGetParams.none(), requestOptions) + + /** A view of [SplitServiceAsync] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SplitServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/split/jobs`, but is otherwise the same as + * [SplitServiceAsync.create]. + */ + fun create( + params: SplitCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SplitCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `get /api/v1/split/jobs`, but is otherwise the same as + * [SplitServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(SplitListParams.none()) + + /** @see list */ + fun list( + params: SplitListParams = SplitListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: SplitListParams = SplitListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(SplitListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/split/jobs/{split_job_id}`, but is + * otherwise the same as [SplitServiceAsync.delete]. + */ + fun delete(splitJobId: String): CompletableFuture> = + delete(splitJobId, SplitDeleteParams.none()) + + /** @see delete */ + fun delete( + splitJobId: String, + params: SplitDeleteParams = SplitDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + delete(params.toBuilder().splitJobId(splitJobId).build(), requestOptions) + + /** @see delete */ + fun delete( + splitJobId: String, + params: SplitDeleteParams = SplitDeleteParams.none(), + ): CompletableFuture> = + delete(splitJobId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: SplitDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see delete */ + fun delete( + params: SplitDeleteParams + ): CompletableFuture> = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + splitJobId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + delete(splitJobId, SplitDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/split/jobs/{split_job_id}/cancel`, but is + * otherwise the same as [SplitServiceAsync.cancel]. + */ + fun cancel(splitJobId: String): CompletableFuture> = + cancel(splitJobId, SplitCancelParams.none()) + + /** @see cancel */ + fun cancel( + splitJobId: String, + params: SplitCancelParams = SplitCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + cancel(params.toBuilder().splitJobId(splitJobId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + splitJobId: String, + params: SplitCancelParams = SplitCancelParams.none(), + ): CompletableFuture> = + cancel(splitJobId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: SplitCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see cancel */ + fun cancel( + params: SplitCancelParams + ): CompletableFuture> = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + splitJobId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + cancel(splitJobId, SplitCancelParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/split/jobs/{split_job_id}`, but is otherwise + * the same as [SplitServiceAsync.get]. + */ + fun get(splitJobId: String): CompletableFuture> = + get(splitJobId, SplitGetParams.none()) + + /** @see get */ + fun get( + splitJobId: String, + params: SplitGetParams = SplitGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + get(params.toBuilder().splitJobId(splitJobId).build(), requestOptions) + + /** @see get */ + fun get( + splitJobId: String, + params: SplitGetParams = SplitGetParams.none(), + ): CompletableFuture> = + get(splitJobId, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: SplitGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see get */ + fun get(params: SplitGetParams): CompletableFuture> = + get(params, RequestOptions.none()) + + /** @see get */ + fun get( + splitJobId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + get(splitJobId, SplitGetParams.none(), requestOptions) + } +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/SplitServiceAsyncImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/SplitServiceAsyncImpl.kt new file mode 100644 index 0000000..45de677 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/SplitServiceAsyncImpl.kt @@ -0,0 +1,264 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.async + +import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.core.RequestOptions +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.core.handlers.errorBodyHandler +import ai.llamaindex.llamacloud.core.handlers.errorHandler +import ai.llamaindex.llamacloud.core.handlers.jsonHandler +import ai.llamaindex.llamacloud.core.http.HttpMethod +import ai.llamaindex.llamacloud.core.http.HttpRequest +import ai.llamaindex.llamacloud.core.http.HttpResponse +import ai.llamaindex.llamacloud.core.http.HttpResponse.Handler +import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.core.http.json +import ai.llamaindex.llamacloud.core.http.parseable +import ai.llamaindex.llamacloud.core.prepareAsync +import ai.llamaindex.llamacloud.models.split.SplitCancelParams +import ai.llamaindex.llamacloud.models.split.SplitCancelResponse +import ai.llamaindex.llamacloud.models.split.SplitCreateParams +import ai.llamaindex.llamacloud.models.split.SplitCreateResponse +import ai.llamaindex.llamacloud.models.split.SplitDeleteParams +import ai.llamaindex.llamacloud.models.split.SplitDeleteResponse +import ai.llamaindex.llamacloud.models.split.SplitGetParams +import ai.llamaindex.llamacloud.models.split.SplitGetResponse +import ai.llamaindex.llamacloud.models.split.SplitListPageAsync +import ai.llamaindex.llamacloud.models.split.SplitListPageResponse +import ai.llamaindex.llamacloud.models.split.SplitListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SplitServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + SplitServiceAsync { + + private val withRawResponse: SplitServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SplitServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): SplitServiceAsync = + SplitServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: SplitCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /api/v1/split/jobs + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: SplitListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/v1/split/jobs + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: SplitDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /api/v1/split/jobs/{split_job_id} + withRawResponse().delete(params, requestOptions).thenApply { it.parse() } + + override fun cancel( + params: SplitCancelParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /api/v1/split/jobs/{split_job_id}/cancel + withRawResponse().cancel(params, requestOptions).thenApply { it.parse() } + + override fun get( + params: SplitGetParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/v1/split/jobs/{split_job_id} + withRawResponse().get(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SplitServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): SplitServiceAsync.WithRawResponse = + SplitServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: SplitCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "split", "jobs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: SplitListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "split", "jobs") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + SplitListPageAsync.builder() + .service(SplitServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun delete( + params: SplitDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("splitJobId", params.splitJobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "split", "jobs", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun cancel( + params: SplitCancelParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("splitJobId", params.splitJobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "split", "jobs", params._pathParam(0), "cancel") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { cancelHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: SplitGetParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("splitJobId", params.splitJobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "split", "jobs", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { getHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/WebhookConfigServiceAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/WebhookConfigServiceAsync.kt new file mode 100644 index 0000000..c524157 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/WebhookConfigServiceAsync.kt @@ -0,0 +1,371 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.async + +import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.core.RequestOptions +import ai.llamaindex.llamacloud.core.http.HttpResponse +import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigCreate +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigCreateParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigDeleteParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigListParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigResponse +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigRetrieveParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface WebhookConfigServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): WebhookConfigServiceAsync + + /** Create a reusable webhook configuration for the current project. */ + fun create(params: WebhookConfigCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: WebhookConfigCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see create */ + fun create( + webhookConfigCreate: WebhookConfigCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + create( + WebhookConfigCreateParams.builder().webhookConfigCreate(webhookConfigCreate).build(), + requestOptions, + ) + + /** @see create */ + fun create(webhookConfigCreate: WebhookConfigCreate): CompletableFuture = + create(webhookConfigCreate, RequestOptions.none()) + + /** Get a single webhook configuration by ID. */ + fun retrieve(configId: String): CompletableFuture = + retrieve(configId, WebhookConfigRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + configId: String, + params: WebhookConfigRetrieveParams = WebhookConfigRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().configId(configId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + configId: String, + params: WebhookConfigRetrieveParams = WebhookConfigRetrieveParams.none(), + ): CompletableFuture = retrieve(configId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: WebhookConfigRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: WebhookConfigRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + configId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(configId, WebhookConfigRetrieveParams.none(), requestOptions) + + /** Update a webhook configuration. Only fields present in the request change. */ + fun update(configId: String): CompletableFuture = + update(configId, WebhookConfigUpdateParams.none()) + + /** @see update */ + fun update( + configId: String, + params: WebhookConfigUpdateParams = WebhookConfigUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + update(params.toBuilder().configId(configId).build(), requestOptions) + + /** @see update */ + fun update( + configId: String, + params: WebhookConfigUpdateParams = WebhookConfigUpdateParams.none(), + ): CompletableFuture = update(configId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: WebhookConfigUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see update */ + fun update(params: WebhookConfigUpdateParams): CompletableFuture = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + configId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + update(configId, WebhookConfigUpdateParams.none(), requestOptions) + + /** List the webhook configurations for the current project, newest first. */ + fun list(): CompletableFuture> = + list(WebhookConfigListParams.none()) + + /** @see list */ + fun list( + params: WebhookConfigListParams = WebhookConfigListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: WebhookConfigListParams = WebhookConfigListParams.none() + ): CompletableFuture> = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture> = + list(WebhookConfigListParams.none(), requestOptions) + + /** Delete a webhook configuration. */ + fun delete(configId: String): CompletableFuture = + delete(configId, WebhookConfigDeleteParams.none()) + + /** @see delete */ + fun delete( + configId: String, + params: WebhookConfigDeleteParams = WebhookConfigDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().configId(configId).build(), requestOptions) + + /** @see delete */ + fun delete( + configId: String, + params: WebhookConfigDeleteParams = WebhookConfigDeleteParams.none(), + ): CompletableFuture = delete(configId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: WebhookConfigDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: WebhookConfigDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(configId: String, requestOptions: RequestOptions): CompletableFuture = + delete(configId, WebhookConfigDeleteParams.none(), requestOptions) + + /** + * A view of [WebhookConfigServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): WebhookConfigServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/beta/webhook-configs`, but is otherwise the + * same as [WebhookConfigServiceAsync.create]. + */ + fun create( + params: WebhookConfigCreateParams + ): CompletableFuture> = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: WebhookConfigCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see create */ + fun create( + webhookConfigCreate: WebhookConfigCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + create( + WebhookConfigCreateParams.builder() + .webhookConfigCreate(webhookConfigCreate) + .build(), + requestOptions, + ) + + /** @see create */ + fun create( + webhookConfigCreate: WebhookConfigCreate + ): CompletableFuture> = + create(webhookConfigCreate, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `get /api/v1/beta/webhook-configs/{config_id}`, but is + * otherwise the same as [WebhookConfigServiceAsync.retrieve]. + */ + fun retrieve(configId: String): CompletableFuture> = + retrieve(configId, WebhookConfigRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + configId: String, + params: WebhookConfigRetrieveParams = WebhookConfigRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().configId(configId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + configId: String, + params: WebhookConfigRetrieveParams = WebhookConfigRetrieveParams.none(), + ): CompletableFuture> = + retrieve(configId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: WebhookConfigRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: WebhookConfigRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + configId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(configId, WebhookConfigRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /api/v1/beta/webhook-configs/{config_id}`, but is + * otherwise the same as [WebhookConfigServiceAsync.update]. + */ + fun update(configId: String): CompletableFuture> = + update(configId, WebhookConfigUpdateParams.none()) + + /** @see update */ + fun update( + configId: String, + params: WebhookConfigUpdateParams = WebhookConfigUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + update(params.toBuilder().configId(configId).build(), requestOptions) + + /** @see update */ + fun update( + configId: String, + params: WebhookConfigUpdateParams = WebhookConfigUpdateParams.none(), + ): CompletableFuture> = + update(configId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: WebhookConfigUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see update */ + fun update( + params: WebhookConfigUpdateParams + ): CompletableFuture> = + update(params, RequestOptions.none()) + + /** @see update */ + fun update( + configId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + update(configId, WebhookConfigUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/beta/webhook-configs`, but is otherwise the + * same as [WebhookConfigServiceAsync.list]. + */ + fun list(): CompletableFuture>> = + list(WebhookConfigListParams.none()) + + /** @see list */ + fun list( + params: WebhookConfigListParams = WebhookConfigListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture>> + + /** @see list */ + fun list( + params: WebhookConfigListParams = WebhookConfigListParams.none() + ): CompletableFuture>> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture>> = + list(WebhookConfigListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/beta/webhook-configs/{config_id}`, but is + * otherwise the same as [WebhookConfigServiceAsync.delete]. + */ + fun delete(configId: String): CompletableFuture = + delete(configId, WebhookConfigDeleteParams.none()) + + /** @see delete */ + fun delete( + configId: String, + params: WebhookConfigDeleteParams = WebhookConfigDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + delete(params.toBuilder().configId(configId).build(), requestOptions) + + /** @see delete */ + fun delete( + configId: String, + params: WebhookConfigDeleteParams = WebhookConfigDeleteParams.none(), + ): CompletableFuture = delete(configId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: WebhookConfigDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see delete */ + fun delete(params: WebhookConfigDeleteParams): CompletableFuture = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete( + configId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + delete(configId, WebhookConfigDeleteParams.none(), requestOptions) + } +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/WebhookConfigServiceAsyncImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/WebhookConfigServiceAsyncImpl.kt new file mode 100644 index 0000000..6676101 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/WebhookConfigServiceAsyncImpl.kt @@ -0,0 +1,245 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.async + +import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.core.RequestOptions +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.core.handlers.emptyHandler +import ai.llamaindex.llamacloud.core.handlers.errorBodyHandler +import ai.llamaindex.llamacloud.core.handlers.errorHandler +import ai.llamaindex.llamacloud.core.handlers.jsonHandler +import ai.llamaindex.llamacloud.core.http.HttpMethod +import ai.llamaindex.llamacloud.core.http.HttpRequest +import ai.llamaindex.llamacloud.core.http.HttpResponse +import ai.llamaindex.llamacloud.core.http.HttpResponse.Handler +import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.core.http.json +import ai.llamaindex.llamacloud.core.http.parseable +import ai.llamaindex.llamacloud.core.prepareAsync +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigCreateParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigDeleteParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigListParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigResponse +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigRetrieveParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigUpdateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class WebhookConfigServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + WebhookConfigServiceAsync { + + private val withRawResponse: WebhookConfigServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): WebhookConfigServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): WebhookConfigServiceAsync = + WebhookConfigServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: WebhookConfigCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /api/v1/beta/webhook-configs + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun retrieve( + params: WebhookConfigRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/v1/beta/webhook-configs/{config_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + + override fun update( + params: WebhookConfigUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // put /api/v1/beta/webhook-configs/{config_id} + withRawResponse().update(params, requestOptions).thenApply { it.parse() } + + override fun list( + params: WebhookConfigListParams, + requestOptions: RequestOptions, + ): CompletableFuture> = + // get /api/v1/beta/webhook-configs + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun delete( + params: WebhookConfigDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // delete /api/v1/beta/webhook-configs/{config_id} + withRawResponse().delete(params, requestOptions).thenAccept {} + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + WebhookConfigServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): WebhookConfigServiceAsync.WithRawResponse = + WebhookConfigServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: WebhookConfigCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "beta", "webhook-configs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: WebhookConfigRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("configId", params.configId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "beta", "webhook-configs", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: WebhookConfigUpdateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("configId", params.configId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "beta", "webhook-configs", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) + + override fun list( + params: WebhookConfigListParams, + requestOptions: RequestOptions, + ): CompletableFuture>> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "beta", "webhook-configs") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: WebhookConfigDeleteParams, + requestOptions: RequestOptions, + ): CompletableFuture { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("configId", params.configId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "beta", "webhook-configs", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + } + } +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/pipelines/DocumentServiceAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/pipelines/DocumentServiceAsync.kt index de7132a..22faa3d 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/pipelines/DocumentServiceAsync.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/pipelines/DocumentServiceAsync.kt @@ -12,6 +12,8 @@ import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentCreateParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentDeleteParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetChunksParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetParams +import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetStatusCountsParams +import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetStatusCountsResponse import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetStatusParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentListPageAsync import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentListParams @@ -215,6 +217,57 @@ interface DocumentServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** + * Count the documents in a pipeline, grouped by ingestion status. + * + * Counts reflect each document's last recorded status rather than a freshly computed one, so a + * document that changed status in the last few moments may still be counted under its previous + * one. Use `GET /pipelines/{pipeline_id}/documents/{document_id}/status` when a single + * document's status has to be up to the moment. + */ + @Deprecated("deprecated") + fun getStatusCounts(pipelineId: String): CompletableFuture = + getStatusCounts(pipelineId, DocumentGetStatusCountsParams.none()) + + /** @see getStatusCounts */ + @Deprecated("deprecated") + fun getStatusCounts( + pipelineId: String, + params: DocumentGetStatusCountsParams = DocumentGetStatusCountsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + getStatusCounts(params.toBuilder().pipelineId(pipelineId).build(), requestOptions) + + /** @see getStatusCounts */ + @Deprecated("deprecated") + fun getStatusCounts( + pipelineId: String, + params: DocumentGetStatusCountsParams = DocumentGetStatusCountsParams.none(), + ): CompletableFuture = + getStatusCounts(pipelineId, params, RequestOptions.none()) + + /** @see getStatusCounts */ + @Deprecated("deprecated") + fun getStatusCounts( + params: DocumentGetStatusCountsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see getStatusCounts */ + @Deprecated("deprecated") + fun getStatusCounts( + params: DocumentGetStatusCountsParams + ): CompletableFuture = + getStatusCounts(params, RequestOptions.none()) + + /** @see getStatusCounts */ + @Deprecated("deprecated") + fun getStatusCounts( + pipelineId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + getStatusCounts(pipelineId, DocumentGetStatusCountsParams.none(), requestOptions) + /** Sync a specific document for a pipeline. */ @Deprecated("deprecated") fun sync( @@ -502,6 +555,56 @@ interface DocumentServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** + * Returns a raw HTTP response for `get + * /api/v1/pipelines/{pipeline_id}/documents/status-counts`, but is otherwise the same as + * [DocumentServiceAsync.getStatusCounts]. + */ + @Deprecated("deprecated") + fun getStatusCounts( + pipelineId: String + ): CompletableFuture> = + getStatusCounts(pipelineId, DocumentGetStatusCountsParams.none()) + + /** @see getStatusCounts */ + @Deprecated("deprecated") + fun getStatusCounts( + pipelineId: String, + params: DocumentGetStatusCountsParams = DocumentGetStatusCountsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + getStatusCounts(params.toBuilder().pipelineId(pipelineId).build(), requestOptions) + + /** @see getStatusCounts */ + @Deprecated("deprecated") + fun getStatusCounts( + pipelineId: String, + params: DocumentGetStatusCountsParams = DocumentGetStatusCountsParams.none(), + ): CompletableFuture> = + getStatusCounts(pipelineId, params, RequestOptions.none()) + + /** @see getStatusCounts */ + @Deprecated("deprecated") + fun getStatusCounts( + params: DocumentGetStatusCountsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see getStatusCounts */ + @Deprecated("deprecated") + fun getStatusCounts( + params: DocumentGetStatusCountsParams + ): CompletableFuture> = + getStatusCounts(params, RequestOptions.none()) + + /** @see getStatusCounts */ + @Deprecated("deprecated") + fun getStatusCounts( + pipelineId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + getStatusCounts(pipelineId, DocumentGetStatusCountsParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post * /api/v1/pipelines/{pipeline_id}/documents/{document_id}/sync`, but is otherwise the same diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/pipelines/DocumentServiceAsyncImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/pipelines/DocumentServiceAsyncImpl.kt index de36174..437861f 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/pipelines/DocumentServiceAsyncImpl.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/pipelines/DocumentServiceAsyncImpl.kt @@ -23,6 +23,8 @@ import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentCreateParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentDeleteParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetChunksParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetParams +import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetStatusCountsParams +import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetStatusCountsResponse import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetStatusParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentListPageAsync import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentListPageResponse @@ -95,6 +97,14 @@ class DocumentServiceAsyncImpl internal constructor(private val clientOptions: C // get /api/v1/pipelines/{pipeline_id}/documents/{document_id}/status withRawResponse().getStatus(params, requestOptions).thenApply { it.parse() } + @Deprecated("deprecated") + override fun getStatusCounts( + params: DocumentGetStatusCountsParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/v1/pipelines/{pipeline_id}/documents/status-counts + withRawResponse().getStatusCounts(params, requestOptions).thenApply { it.parse() } + @Deprecated("deprecated") override fun sync( params: DocumentSyncParams, @@ -368,6 +378,47 @@ class DocumentServiceAsyncImpl internal constructor(private val clientOptions: C } } + private val getStatusCountsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + @Deprecated("deprecated") + override fun getStatusCounts( + params: DocumentGetStatusCountsParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("pipelineId", params.pipelineId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "pipelines", + params._pathParam(0), + "documents", + "status-counts", + ) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { getStatusCountsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val syncHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchService.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchService.kt index 24634ab..9926ef0 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchService.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchService.kt @@ -5,6 +5,8 @@ package ai.llamaindex.llamacloud.services.blocking import ai.llamaindex.llamacloud.core.ClientOptions import ai.llamaindex.llamacloud.core.RequestOptions import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.models.batches.BatchCancelParams +import ai.llamaindex.llamacloud.models.batches.BatchCancelResponse import ai.llamaindex.llamacloud.models.batches.BatchCreateParams import ai.llamaindex.llamacloud.models.batches.BatchCreateResponse import ai.llamaindex.llamacloud.models.batches.BatchGetParams @@ -68,6 +70,41 @@ interface BatchService { fun list(requestOptions: RequestOptions): BatchListPage = list(BatchListParams.none(), requestOptions) + /** + * Cancel a running batch. + * + * Returns immediately; the batch reaches `CANCELLED` once processing stops. Files that already + * finished keep their results. A batch in a terminal status cannot be cancelled. + */ + fun cancel(batchId: String): BatchCancelResponse = cancel(batchId, BatchCancelParams.none()) + + /** @see cancel */ + fun cancel( + batchId: String, + params: BatchCancelParams = BatchCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): BatchCancelResponse = cancel(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + batchId: String, + params: BatchCancelParams = BatchCancelParams.none(), + ): BatchCancelResponse = cancel(batchId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: BatchCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): BatchCancelResponse + + /** @see cancel */ + fun cancel(params: BatchCancelParams): BatchCancelResponse = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel(batchId: String, requestOptions: RequestOptions): BatchCancelResponse = + cancel(batchId, BatchCancelParams.none(), requestOptions) + /** Get a batch by ID. */ fun get(batchId: String): BatchGetResponse = get(batchId, BatchGetParams.none()) @@ -143,6 +180,50 @@ interface BatchService { fun list(requestOptions: RequestOptions): HttpResponseFor = list(BatchListParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /api/v2/batches/{batch_id}/cancel`, but is + * otherwise the same as [BatchService.cancel]. + */ + @MustBeClosed + fun cancel(batchId: String): HttpResponseFor = + cancel(batchId, BatchCancelParams.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + batchId: String, + params: BatchCancelParams = BatchCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + cancel(params.toBuilder().batchId(batchId).build(), requestOptions) + + /** @see cancel */ + @MustBeClosed + fun cancel( + batchId: String, + params: BatchCancelParams = BatchCancelParams.none(), + ): HttpResponseFor = cancel(batchId, params, RequestOptions.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + params: BatchCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see cancel */ + @MustBeClosed + fun cancel(params: BatchCancelParams): HttpResponseFor = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + batchId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + cancel(batchId, BatchCancelParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /api/v2/batches/{batch_id}`, but is otherwise the * same as [BatchService.get]. diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceImpl.kt index 4329ec4..6856f77 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceImpl.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceImpl.kt @@ -16,6 +16,8 @@ import ai.llamaindex.llamacloud.core.http.HttpResponseFor import ai.llamaindex.llamacloud.core.http.json import ai.llamaindex.llamacloud.core.http.parseable import ai.llamaindex.llamacloud.core.prepare +import ai.llamaindex.llamacloud.models.batches.BatchCancelParams +import ai.llamaindex.llamacloud.models.batches.BatchCancelResponse import ai.llamaindex.llamacloud.models.batches.BatchCreateParams import ai.llamaindex.llamacloud.models.batches.BatchCreateResponse import ai.llamaindex.llamacloud.models.batches.BatchGetParams @@ -49,6 +51,13 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt // get /api/v2/batches withRawResponse().list(params, requestOptions).parse() + override fun cancel( + params: BatchCancelParams, + requestOptions: RequestOptions, + ): BatchCancelResponse = + // post /api/v2/batches/{batch_id}/cancel + withRawResponse().cancel(params, requestOptions).parse() + override fun get(params: BatchGetParams, requestOptions: RequestOptions): BatchGetResponse = // get /api/v2/batches/{batch_id} withRawResponse().get(params, requestOptions).parse() @@ -128,6 +137,37 @@ class BatchServiceImpl internal constructor(private val clientOptions: ClientOpt } } + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun cancel( + params: BatchCancelParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("batchId", params.batchId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v2", "batches", params._pathParam(0), "cancel") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { cancelHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ClassifyService.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ClassifyService.kt index 960de09..d399462 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ClassifyService.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ClassifyService.kt @@ -5,6 +5,8 @@ package ai.llamaindex.llamacloud.services.blocking import ai.llamaindex.llamacloud.core.ClientOptions import ai.llamaindex.llamacloud.core.RequestOptions import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.models.classify.ClassifyCancelParams +import ai.llamaindex.llamacloud.models.classify.ClassifyCancelResponse import ai.llamaindex.llamacloud.models.classify.ClassifyCreateParams import ai.llamaindex.llamacloud.models.classify.ClassifyCreateRequest import ai.llamaindex.llamacloud.models.classify.ClassifyCreateResponse @@ -86,6 +88,41 @@ interface ClassifyService { fun list(requestOptions: RequestOptions): ClassifyListPage = list(ClassifyListParams.none(), requestOptions) + /** + * Cancel a running classify job. + * + * Stops processing and marks the job as CANCELLED. Returns the updated job. Jobs already in a + * terminal state (COMPLETED, FAILED, CANCELLED) cannot be cancelled. + */ + fun cancel(jobId: String): ClassifyCancelResponse = cancel(jobId, ClassifyCancelParams.none()) + + /** @see cancel */ + fun cancel( + jobId: String, + params: ClassifyCancelParams = ClassifyCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ClassifyCancelResponse = cancel(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + jobId: String, + params: ClassifyCancelParams = ClassifyCancelParams.none(), + ): ClassifyCancelResponse = cancel(jobId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: ClassifyCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ClassifyCancelResponse + + /** @see cancel */ + fun cancel(params: ClassifyCancelParams): ClassifyCancelResponse = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel(jobId: String, requestOptions: RequestOptions): ClassifyCancelResponse = + cancel(jobId, ClassifyCancelParams.none(), requestOptions) + /** * Get a classify job by ID. * @@ -188,6 +225,50 @@ interface ClassifyService { fun list(requestOptions: RequestOptions): HttpResponseFor = list(ClassifyListParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /api/v2/classify/{job_id}/cancel`, but is otherwise + * the same as [ClassifyService.cancel]. + */ + @MustBeClosed + fun cancel(jobId: String): HttpResponseFor = + cancel(jobId, ClassifyCancelParams.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + jobId: String, + params: ClassifyCancelParams = ClassifyCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + cancel(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see cancel */ + @MustBeClosed + fun cancel( + jobId: String, + params: ClassifyCancelParams = ClassifyCancelParams.none(), + ): HttpResponseFor = cancel(jobId, params, RequestOptions.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + params: ClassifyCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see cancel */ + @MustBeClosed + fun cancel(params: ClassifyCancelParams): HttpResponseFor = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + jobId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + cancel(jobId, ClassifyCancelParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /api/v2/classify/{job_id}`, but is otherwise the * same as [ClassifyService.get]. diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ClassifyServiceImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ClassifyServiceImpl.kt index 5bbb747..eb5336c 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ClassifyServiceImpl.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ClassifyServiceImpl.kt @@ -16,6 +16,8 @@ import ai.llamaindex.llamacloud.core.http.HttpResponseFor import ai.llamaindex.llamacloud.core.http.json import ai.llamaindex.llamacloud.core.http.parseable import ai.llamaindex.llamacloud.core.prepare +import ai.llamaindex.llamacloud.models.classify.ClassifyCancelParams +import ai.llamaindex.llamacloud.models.classify.ClassifyCancelResponse import ai.llamaindex.llamacloud.models.classify.ClassifyCreateParams import ai.llamaindex.llamacloud.models.classify.ClassifyCreateResponse import ai.llamaindex.llamacloud.models.classify.ClassifyGetParams @@ -52,6 +54,13 @@ class ClassifyServiceImpl internal constructor(private val clientOptions: Client // get /api/v2/classify withRawResponse().list(params, requestOptions).parse() + override fun cancel( + params: ClassifyCancelParams, + requestOptions: RequestOptions, + ): ClassifyCancelResponse = + // post /api/v2/classify/{job_id}/cancel + withRawResponse().cancel(params, requestOptions).parse() + override fun get( params: ClassifyGetParams, requestOptions: RequestOptions, @@ -134,6 +143,37 @@ class ClassifyServiceImpl internal constructor(private val clientOptions: Client } } + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun cancel( + params: ClassifyCancelParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v2", "classify", params._pathParam(0), "cancel") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { cancelHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val getHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractService.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractService.kt index 9a903ec..17f4159 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractService.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractService.kt @@ -6,6 +6,7 @@ import ai.llamaindex.llamacloud.core.ClientOptions import ai.llamaindex.llamacloud.core.RequestOptions import ai.llamaindex.llamacloud.core.http.HttpResponseFor import ai.llamaindex.llamacloud.models.configurations.ConfigurationCreate +import ai.llamaindex.llamacloud.models.extract.ExtractCancelParams import ai.llamaindex.llamacloud.models.extract.ExtractCreateParams import ai.llamaindex.llamacloud.models.extract.ExtractDeleteParams import ai.llamaindex.llamacloud.models.extract.ExtractDeleteResponse @@ -130,6 +131,40 @@ interface ExtractService { fun delete(jobId: String, requestOptions: RequestOptions): ExtractDeleteResponse = delete(jobId, ExtractDeleteParams.none(), requestOptions) + /** + * Cancel a running extraction job. + * + * Stops processing and marks the job as CANCELLED. Returns the updated job. Jobs already in a + * terminal state (COMPLETED, FAILED, CANCELLED) cannot be cancelled. + */ + fun cancel(jobId: String): ExtractV2Job = cancel(jobId, ExtractCancelParams.none()) + + /** @see cancel */ + fun cancel( + jobId: String, + params: ExtractCancelParams = ExtractCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ExtractV2Job = cancel(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + jobId: String, + params: ExtractCancelParams = ExtractCancelParams.none(), + ): ExtractV2Job = cancel(jobId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: ExtractCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): ExtractV2Job + + /** @see cancel */ + fun cancel(params: ExtractCancelParams): ExtractV2Job = cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel(jobId: String, requestOptions: RequestOptions): ExtractV2Job = + cancel(jobId, ExtractCancelParams.none(), requestOptions) + /** Generate a JSON schema and return a product configuration request. */ fun generateSchema(params: ExtractGenerateSchemaParams): ConfigurationCreate = generateSchema(params, RequestOptions.none()) @@ -327,6 +362,47 @@ interface ExtractService { ): HttpResponseFor = delete(jobId, ExtractDeleteParams.none(), requestOptions) + /** + * Returns a raw HTTP response for `post /api/v2/extract/{job_id}/cancel`, but is otherwise + * the same as [ExtractService.cancel]. + */ + @MustBeClosed + fun cancel(jobId: String): HttpResponseFor = + cancel(jobId, ExtractCancelParams.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + jobId: String, + params: ExtractCancelParams = ExtractCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + cancel(params.toBuilder().jobId(jobId).build(), requestOptions) + + /** @see cancel */ + @MustBeClosed + fun cancel( + jobId: String, + params: ExtractCancelParams = ExtractCancelParams.none(), + ): HttpResponseFor = cancel(jobId, params, RequestOptions.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + params: ExtractCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see cancel */ + @MustBeClosed + fun cancel(params: ExtractCancelParams): HttpResponseFor = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel(jobId: String, requestOptions: RequestOptions): HttpResponseFor = + cancel(jobId, ExtractCancelParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post /api/v2/extract/schema/generate`, but is otherwise * the same as [ExtractService.generateSchema]. diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractServiceImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractServiceImpl.kt index 90fba4b..0783582 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractServiceImpl.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractServiceImpl.kt @@ -17,6 +17,7 @@ import ai.llamaindex.llamacloud.core.http.json import ai.llamaindex.llamacloud.core.http.parseable import ai.llamaindex.llamacloud.core.prepare import ai.llamaindex.llamacloud.models.configurations.ConfigurationCreate +import ai.llamaindex.llamacloud.models.extract.ExtractCancelParams import ai.llamaindex.llamacloud.models.extract.ExtractCreateParams import ai.llamaindex.llamacloud.models.extract.ExtractDeleteParams import ai.llamaindex.llamacloud.models.extract.ExtractDeleteResponse @@ -58,6 +59,10 @@ class ExtractServiceImpl internal constructor(private val clientOptions: ClientO // delete /api/v2/extract/{job_id} withRawResponse().delete(params, requestOptions).parse() + override fun cancel(params: ExtractCancelParams, requestOptions: RequestOptions): ExtractV2Job = + // post /api/v2/extract/{job_id}/cancel + withRawResponse().cancel(params, requestOptions).parse() + override fun generateSchema( params: ExtractGenerateSchemaParams, requestOptions: RequestOptions, @@ -182,6 +187,37 @@ class ExtractServiceImpl internal constructor(private val clientOptions: ClientO } } + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun cancel( + params: ExtractCancelParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("jobId", params.jobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v2", "extract", params._pathParam(0), "cancel") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { cancelHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val generateSchemaHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingService.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingService.kt index b121260..007a5ca 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingService.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingService.kt @@ -13,6 +13,8 @@ import ai.llamaindex.llamacloud.models.parsing.ParsingGetParams import ai.llamaindex.llamacloud.models.parsing.ParsingGetResponse import ai.llamaindex.llamacloud.models.parsing.ParsingListPage import ai.llamaindex.llamacloud.models.parsing.ParsingListParams +import ai.llamaindex.llamacloud.models.parsing.ParsingListVersionsParams +import ai.llamaindex.llamacloud.models.parsing.ParsingListVersionsResponse import com.google.errorprone.annotations.MustBeClosed import java.util.function.Consumer @@ -150,6 +152,24 @@ interface ParsingService { fun get(jobId: String, requestOptions: RequestOptions): ParsingGetResponse = get(jobId, ParsingGetParams.none(), requestOptions) + /** List the parse versions accepted by each tier. */ + fun listVersions(): ParsingListVersionsResponse = listVersions(ParsingListVersionsParams.none()) + + /** @see listVersions */ + fun listVersions( + params: ParsingListVersionsParams = ParsingListVersionsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): ParsingListVersionsResponse + + /** @see listVersions */ + fun listVersions( + params: ParsingListVersionsParams = ParsingListVersionsParams.none() + ): ParsingListVersionsResponse = listVersions(params, RequestOptions.none()) + + /** @see listVersions */ + fun listVersions(requestOptions: RequestOptions): ParsingListVersionsResponse = + listVersions(ParsingListVersionsParams.none(), requestOptions) + /** A view of [ParsingService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -285,5 +305,34 @@ interface ParsingService { jobId: String, requestOptions: RequestOptions, ): HttpResponseFor = get(jobId, ParsingGetParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v2/parse/versions`, but is otherwise the same + * as [ParsingService.listVersions]. + */ + @MustBeClosed + fun listVersions(): HttpResponseFor = + listVersions(ParsingListVersionsParams.none()) + + /** @see listVersions */ + @MustBeClosed + fun listVersions( + params: ParsingListVersionsParams = ParsingListVersionsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see listVersions */ + @MustBeClosed + fun listVersions( + params: ParsingListVersionsParams = ParsingListVersionsParams.none() + ): HttpResponseFor = + listVersions(params, RequestOptions.none()) + + /** @see listVersions */ + @MustBeClosed + fun listVersions( + requestOptions: RequestOptions + ): HttpResponseFor = + listVersions(ParsingListVersionsParams.none(), requestOptions) } } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceImpl.kt index 9ca75ac..fce95eb 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceImpl.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceImpl.kt @@ -25,6 +25,8 @@ import ai.llamaindex.llamacloud.models.parsing.ParsingGetResponse import ai.llamaindex.llamacloud.models.parsing.ParsingListPage import ai.llamaindex.llamacloud.models.parsing.ParsingListPageResponse import ai.llamaindex.llamacloud.models.parsing.ParsingListParams +import ai.llamaindex.llamacloud.models.parsing.ParsingListVersionsParams +import ai.llamaindex.llamacloud.models.parsing.ParsingListVersionsResponse import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -62,6 +64,13 @@ class ParsingServiceImpl internal constructor(private val clientOptions: ClientO // get /api/v2/parse/{job_id} withRawResponse().get(params, requestOptions).parse() + override fun listVersions( + params: ParsingListVersionsParams, + requestOptions: RequestOptions, + ): ParsingListVersionsResponse = + // get /api/v2/parse/versions + withRawResponse().listVersions(params, requestOptions).parse() + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : ParsingService.WithRawResponse { @@ -197,5 +206,32 @@ class ParsingServiceImpl internal constructor(private val clientOptions: ClientO } } } + + private val listVersionsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun listVersions( + params: ParsingListVersionsParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v2", "parse", "versions") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listVersionsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } } } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/SplitService.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/SplitService.kt new file mode 100644 index 0000000..9a605f1 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/SplitService.kt @@ -0,0 +1,339 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.blocking + +import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.core.RequestOptions +import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.models.split.SplitCancelParams +import ai.llamaindex.llamacloud.models.split.SplitCancelResponse +import ai.llamaindex.llamacloud.models.split.SplitCreateParams +import ai.llamaindex.llamacloud.models.split.SplitCreateResponse +import ai.llamaindex.llamacloud.models.split.SplitDeleteParams +import ai.llamaindex.llamacloud.models.split.SplitDeleteResponse +import ai.llamaindex.llamacloud.models.split.SplitGetParams +import ai.llamaindex.llamacloud.models.split.SplitGetResponse +import ai.llamaindex.llamacloud.models.split.SplitListPage +import ai.llamaindex.llamacloud.models.split.SplitListParams +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface SplitService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SplitService + + /** Create a document split job. */ + fun create(params: SplitCreateParams): SplitCreateResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: SplitCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SplitCreateResponse + + /** List document split jobs. */ + fun list(): SplitListPage = list(SplitListParams.none()) + + /** @see list */ + fun list( + params: SplitListParams = SplitListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SplitListPage + + /** @see list */ + fun list(params: SplitListParams = SplitListParams.none()): SplitListPage = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): SplitListPage = + list(SplitListParams.none(), requestOptions) + + /** Delete a split job and its results. */ + fun delete(splitJobId: String): SplitDeleteResponse = + delete(splitJobId, SplitDeleteParams.none()) + + /** @see delete */ + fun delete( + splitJobId: String, + params: SplitDeleteParams = SplitDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SplitDeleteResponse = + delete(params.toBuilder().splitJobId(splitJobId).build(), requestOptions) + + /** @see delete */ + fun delete( + splitJobId: String, + params: SplitDeleteParams = SplitDeleteParams.none(), + ): SplitDeleteResponse = delete(splitJobId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: SplitDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SplitDeleteResponse + + /** @see delete */ + fun delete(params: SplitDeleteParams): SplitDeleteResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(splitJobId: String, requestOptions: RequestOptions): SplitDeleteResponse = + delete(splitJobId, SplitDeleteParams.none(), requestOptions) + + /** + * Cancel a running split job. + * + * Requests cancellation; the job transitions to CANCELLED asynchronously once processing stops. + * Returns the job, which may still be in its current non-terminal state. Jobs already in a + * terminal state (COMPLETED, FAILED, CANCELLED) cannot be cancelled. + */ + fun cancel(splitJobId: String): SplitCancelResponse = + cancel(splitJobId, SplitCancelParams.none()) + + /** @see cancel */ + fun cancel( + splitJobId: String, + params: SplitCancelParams = SplitCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SplitCancelResponse = + cancel(params.toBuilder().splitJobId(splitJobId).build(), requestOptions) + + /** @see cancel */ + fun cancel( + splitJobId: String, + params: SplitCancelParams = SplitCancelParams.none(), + ): SplitCancelResponse = cancel(splitJobId, params, RequestOptions.none()) + + /** @see cancel */ + fun cancel( + params: SplitCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SplitCancelResponse + + /** @see cancel */ + fun cancel(params: SplitCancelParams): SplitCancelResponse = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + fun cancel(splitJobId: String, requestOptions: RequestOptions): SplitCancelResponse = + cancel(splitJobId, SplitCancelParams.none(), requestOptions) + + /** Get a document split job. */ + fun get(splitJobId: String): SplitGetResponse = get(splitJobId, SplitGetParams.none()) + + /** @see get */ + fun get( + splitJobId: String, + params: SplitGetParams = SplitGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): SplitGetResponse = get(params.toBuilder().splitJobId(splitJobId).build(), requestOptions) + + /** @see get */ + fun get(splitJobId: String, params: SplitGetParams = SplitGetParams.none()): SplitGetResponse = + get(splitJobId, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: SplitGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): SplitGetResponse + + /** @see get */ + fun get(params: SplitGetParams): SplitGetResponse = get(params, RequestOptions.none()) + + /** @see get */ + fun get(splitJobId: String, requestOptions: RequestOptions): SplitGetResponse = + get(splitJobId, SplitGetParams.none(), requestOptions) + + /** A view of [SplitService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SplitService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/split/jobs`, but is otherwise the same as + * [SplitService.create]. + */ + @MustBeClosed + fun create(params: SplitCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: SplitCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `get /api/v1/split/jobs`, but is otherwise the same as + * [SplitService.list]. + */ + @MustBeClosed fun list(): HttpResponseFor = list(SplitListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: SplitListParams = SplitListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list(params: SplitListParams = SplitListParams.none()): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(SplitListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/split/jobs/{split_job_id}`, but is + * otherwise the same as [SplitService.delete]. + */ + @MustBeClosed + fun delete(splitJobId: String): HttpResponseFor = + delete(splitJobId, SplitDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + splitJobId: String, + params: SplitDeleteParams = SplitDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + delete(params.toBuilder().splitJobId(splitJobId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + splitJobId: String, + params: SplitDeleteParams = SplitDeleteParams.none(), + ): HttpResponseFor = delete(splitJobId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: SplitDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see delete */ + @MustBeClosed + fun delete(params: SplitDeleteParams): HttpResponseFor = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + splitJobId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + delete(splitJobId, SplitDeleteParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `post /api/v1/split/jobs/{split_job_id}/cancel`, but is + * otherwise the same as [SplitService.cancel]. + */ + @MustBeClosed + fun cancel(splitJobId: String): HttpResponseFor = + cancel(splitJobId, SplitCancelParams.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + splitJobId: String, + params: SplitCancelParams = SplitCancelParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + cancel(params.toBuilder().splitJobId(splitJobId).build(), requestOptions) + + /** @see cancel */ + @MustBeClosed + fun cancel( + splitJobId: String, + params: SplitCancelParams = SplitCancelParams.none(), + ): HttpResponseFor = cancel(splitJobId, params, RequestOptions.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + params: SplitCancelParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see cancel */ + @MustBeClosed + fun cancel(params: SplitCancelParams): HttpResponseFor = + cancel(params, RequestOptions.none()) + + /** @see cancel */ + @MustBeClosed + fun cancel( + splitJobId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + cancel(splitJobId, SplitCancelParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/split/jobs/{split_job_id}`, but is otherwise + * the same as [SplitService.get]. + */ + @MustBeClosed + fun get(splitJobId: String): HttpResponseFor = + get(splitJobId, SplitGetParams.none()) + + /** @see get */ + @MustBeClosed + fun get( + splitJobId: String, + params: SplitGetParams = SplitGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + get(params.toBuilder().splitJobId(splitJobId).build(), requestOptions) + + /** @see get */ + @MustBeClosed + fun get( + splitJobId: String, + params: SplitGetParams = SplitGetParams.none(), + ): HttpResponseFor = get(splitJobId, params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get( + params: SplitGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see get */ + @MustBeClosed + fun get(params: SplitGetParams): HttpResponseFor = + get(params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get( + splitJobId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + get(splitJobId, SplitGetParams.none(), requestOptions) + } +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/SplitServiceImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/SplitServiceImpl.kt new file mode 100644 index 0000000..972d671 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/SplitServiceImpl.kt @@ -0,0 +1,241 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.blocking + +import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.core.RequestOptions +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.core.handlers.errorBodyHandler +import ai.llamaindex.llamacloud.core.handlers.errorHandler +import ai.llamaindex.llamacloud.core.handlers.jsonHandler +import ai.llamaindex.llamacloud.core.http.HttpMethod +import ai.llamaindex.llamacloud.core.http.HttpRequest +import ai.llamaindex.llamacloud.core.http.HttpResponse +import ai.llamaindex.llamacloud.core.http.HttpResponse.Handler +import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.core.http.json +import ai.llamaindex.llamacloud.core.http.parseable +import ai.llamaindex.llamacloud.core.prepare +import ai.llamaindex.llamacloud.models.split.SplitCancelParams +import ai.llamaindex.llamacloud.models.split.SplitCancelResponse +import ai.llamaindex.llamacloud.models.split.SplitCreateParams +import ai.llamaindex.llamacloud.models.split.SplitCreateResponse +import ai.llamaindex.llamacloud.models.split.SplitDeleteParams +import ai.llamaindex.llamacloud.models.split.SplitDeleteResponse +import ai.llamaindex.llamacloud.models.split.SplitGetParams +import ai.llamaindex.llamacloud.models.split.SplitGetResponse +import ai.llamaindex.llamacloud.models.split.SplitListPage +import ai.llamaindex.llamacloud.models.split.SplitListPageResponse +import ai.llamaindex.llamacloud.models.split.SplitListParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class SplitServiceImpl internal constructor(private val clientOptions: ClientOptions) : + SplitService { + + private val withRawResponse: SplitService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): SplitService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): SplitService = + SplitServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: SplitCreateParams, + requestOptions: RequestOptions, + ): SplitCreateResponse = + // post /api/v1/split/jobs + withRawResponse().create(params, requestOptions).parse() + + override fun list(params: SplitListParams, requestOptions: RequestOptions): SplitListPage = + // get /api/v1/split/jobs + withRawResponse().list(params, requestOptions).parse() + + override fun delete( + params: SplitDeleteParams, + requestOptions: RequestOptions, + ): SplitDeleteResponse = + // delete /api/v1/split/jobs/{split_job_id} + withRawResponse().delete(params, requestOptions).parse() + + override fun cancel( + params: SplitCancelParams, + requestOptions: RequestOptions, + ): SplitCancelResponse = + // post /api/v1/split/jobs/{split_job_id}/cancel + withRawResponse().cancel(params, requestOptions).parse() + + override fun get(params: SplitGetParams, requestOptions: RequestOptions): SplitGetResponse = + // get /api/v1/split/jobs/{split_job_id} + withRawResponse().get(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + SplitService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): SplitService.WithRawResponse = + SplitServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: SplitCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "split", "jobs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: SplitListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "split", "jobs") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + SplitListPage.builder() + .service(SplitServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + + private val deleteHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun delete( + params: SplitDeleteParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("splitJobId", params.splitJobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "split", "jobs", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { deleteHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val cancelHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun cancel( + params: SplitCancelParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("splitJobId", params.splitJobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "split", "jobs", params._pathParam(0), "cancel") + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { cancelHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: SplitGetParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("splitJobId", params.splitJobId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "split", "jobs", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { getHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/WebhookConfigService.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/WebhookConfigService.kt new file mode 100644 index 0000000..413fad2 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/WebhookConfigService.kt @@ -0,0 +1,371 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.blocking + +import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.core.RequestOptions +import ai.llamaindex.llamacloud.core.http.HttpResponse +import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigCreate +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigCreateParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigDeleteParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigListParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigResponse +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigRetrieveParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigUpdateParams +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface WebhookConfigService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): WebhookConfigService + + /** Create a reusable webhook configuration for the current project. */ + fun create(params: WebhookConfigCreateParams): WebhookConfigResponse = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: WebhookConfigCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): WebhookConfigResponse + + /** @see create */ + fun create( + webhookConfigCreate: WebhookConfigCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): WebhookConfigResponse = + create( + WebhookConfigCreateParams.builder().webhookConfigCreate(webhookConfigCreate).build(), + requestOptions, + ) + + /** @see create */ + fun create(webhookConfigCreate: WebhookConfigCreate): WebhookConfigResponse = + create(webhookConfigCreate, RequestOptions.none()) + + /** Get a single webhook configuration by ID. */ + fun retrieve(configId: String): WebhookConfigResponse = + retrieve(configId, WebhookConfigRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + configId: String, + params: WebhookConfigRetrieveParams = WebhookConfigRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): WebhookConfigResponse = + retrieve(params.toBuilder().configId(configId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + configId: String, + params: WebhookConfigRetrieveParams = WebhookConfigRetrieveParams.none(), + ): WebhookConfigResponse = retrieve(configId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: WebhookConfigRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): WebhookConfigResponse + + /** @see retrieve */ + fun retrieve(params: WebhookConfigRetrieveParams): WebhookConfigResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(configId: String, requestOptions: RequestOptions): WebhookConfigResponse = + retrieve(configId, WebhookConfigRetrieveParams.none(), requestOptions) + + /** Update a webhook configuration. Only fields present in the request change. */ + fun update(configId: String): WebhookConfigResponse = + update(configId, WebhookConfigUpdateParams.none()) + + /** @see update */ + fun update( + configId: String, + params: WebhookConfigUpdateParams = WebhookConfigUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): WebhookConfigResponse = update(params.toBuilder().configId(configId).build(), requestOptions) + + /** @see update */ + fun update( + configId: String, + params: WebhookConfigUpdateParams = WebhookConfigUpdateParams.none(), + ): WebhookConfigResponse = update(configId, params, RequestOptions.none()) + + /** @see update */ + fun update( + params: WebhookConfigUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): WebhookConfigResponse + + /** @see update */ + fun update(params: WebhookConfigUpdateParams): WebhookConfigResponse = + update(params, RequestOptions.none()) + + /** @see update */ + fun update(configId: String, requestOptions: RequestOptions): WebhookConfigResponse = + update(configId, WebhookConfigUpdateParams.none(), requestOptions) + + /** List the webhook configurations for the current project, newest first. */ + fun list(): List = list(WebhookConfigListParams.none()) + + /** @see list */ + fun list( + params: WebhookConfigListParams = WebhookConfigListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): List + + /** @see list */ + fun list( + params: WebhookConfigListParams = WebhookConfigListParams.none() + ): List = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): List = + list(WebhookConfigListParams.none(), requestOptions) + + /** Delete a webhook configuration. */ + fun delete(configId: String) = delete(configId, WebhookConfigDeleteParams.none()) + + /** @see delete */ + fun delete( + configId: String, + params: WebhookConfigDeleteParams = WebhookConfigDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ) = delete(params.toBuilder().configId(configId).build(), requestOptions) + + /** @see delete */ + fun delete( + configId: String, + params: WebhookConfigDeleteParams = WebhookConfigDeleteParams.none(), + ) = delete(configId, params, RequestOptions.none()) + + /** @see delete */ + fun delete( + params: WebhookConfigDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ) + + /** @see delete */ + fun delete(params: WebhookConfigDeleteParams) = delete(params, RequestOptions.none()) + + /** @see delete */ + fun delete(configId: String, requestOptions: RequestOptions) = + delete(configId, WebhookConfigDeleteParams.none(), requestOptions) + + /** + * A view of [WebhookConfigService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): WebhookConfigService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /api/v1/beta/webhook-configs`, but is otherwise the + * same as [WebhookConfigService.create]. + */ + @MustBeClosed + fun create(params: WebhookConfigCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: WebhookConfigCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see create */ + @MustBeClosed + fun create( + webhookConfigCreate: WebhookConfigCreate, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + create( + WebhookConfigCreateParams.builder() + .webhookConfigCreate(webhookConfigCreate) + .build(), + requestOptions, + ) + + /** @see create */ + @MustBeClosed + fun create( + webhookConfigCreate: WebhookConfigCreate + ): HttpResponseFor = + create(webhookConfigCreate, RequestOptions.none()) + + /** + * Returns a raw HTTP response for `get /api/v1/beta/webhook-configs/{config_id}`, but is + * otherwise the same as [WebhookConfigService.retrieve]. + */ + @MustBeClosed + fun retrieve(configId: String): HttpResponseFor = + retrieve(configId, WebhookConfigRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + configId: String, + params: WebhookConfigRetrieveParams = WebhookConfigRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().configId(configId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + configId: String, + params: WebhookConfigRetrieveParams = WebhookConfigRetrieveParams.none(), + ): HttpResponseFor = + retrieve(configId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: WebhookConfigRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: WebhookConfigRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + configId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(configId, WebhookConfigRetrieveParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `put /api/v1/beta/webhook-configs/{config_id}`, but is + * otherwise the same as [WebhookConfigService.update]. + */ + @MustBeClosed + fun update(configId: String): HttpResponseFor = + update(configId, WebhookConfigUpdateParams.none()) + + /** @see update */ + @MustBeClosed + fun update( + configId: String, + params: WebhookConfigUpdateParams = WebhookConfigUpdateParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + update(params.toBuilder().configId(configId).build(), requestOptions) + + /** @see update */ + @MustBeClosed + fun update( + configId: String, + params: WebhookConfigUpdateParams = WebhookConfigUpdateParams.none(), + ): HttpResponseFor = update(configId, params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + params: WebhookConfigUpdateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see update */ + @MustBeClosed + fun update(params: WebhookConfigUpdateParams): HttpResponseFor = + update(params, RequestOptions.none()) + + /** @see update */ + @MustBeClosed + fun update( + configId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + update(configId, WebhookConfigUpdateParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v1/beta/webhook-configs`, but is otherwise the + * same as [WebhookConfigService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor> = + list(WebhookConfigListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: WebhookConfigListParams = WebhookConfigListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor> + + /** @see list */ + @MustBeClosed + fun list( + params: WebhookConfigListParams = WebhookConfigListParams.none() + ): HttpResponseFor> = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor> = + list(WebhookConfigListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `delete /api/v1/beta/webhook-configs/{config_id}`, but is + * otherwise the same as [WebhookConfigService.delete]. + */ + @MustBeClosed + fun delete(configId: String): HttpResponse = + delete(configId, WebhookConfigDeleteParams.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + configId: String, + params: WebhookConfigDeleteParams = WebhookConfigDeleteParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse = delete(params.toBuilder().configId(configId).build(), requestOptions) + + /** @see delete */ + @MustBeClosed + fun delete( + configId: String, + params: WebhookConfigDeleteParams = WebhookConfigDeleteParams.none(), + ): HttpResponse = delete(configId, params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete( + params: WebhookConfigDeleteParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponse + + /** @see delete */ + @MustBeClosed + fun delete(params: WebhookConfigDeleteParams): HttpResponse = + delete(params, RequestOptions.none()) + + /** @see delete */ + @MustBeClosed + fun delete(configId: String, requestOptions: RequestOptions): HttpResponse = + delete(configId, WebhookConfigDeleteParams.none(), requestOptions) + } +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/WebhookConfigServiceImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/WebhookConfigServiceImpl.kt new file mode 100644 index 0000000..3ec1961 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/WebhookConfigServiceImpl.kt @@ -0,0 +1,227 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.blocking + +import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.core.RequestOptions +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.core.handlers.emptyHandler +import ai.llamaindex.llamacloud.core.handlers.errorBodyHandler +import ai.llamaindex.llamacloud.core.handlers.errorHandler +import ai.llamaindex.llamacloud.core.handlers.jsonHandler +import ai.llamaindex.llamacloud.core.http.HttpMethod +import ai.llamaindex.llamacloud.core.http.HttpRequest +import ai.llamaindex.llamacloud.core.http.HttpResponse +import ai.llamaindex.llamacloud.core.http.HttpResponse.Handler +import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.core.http.json +import ai.llamaindex.llamacloud.core.http.parseable +import ai.llamaindex.llamacloud.core.prepare +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigCreateParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigDeleteParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigListParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigResponse +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigRetrieveParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigUpdateParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class WebhookConfigServiceImpl internal constructor(private val clientOptions: ClientOptions) : + WebhookConfigService { + + private val withRawResponse: WebhookConfigService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): WebhookConfigService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): WebhookConfigService = + WebhookConfigServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: WebhookConfigCreateParams, + requestOptions: RequestOptions, + ): WebhookConfigResponse = + // post /api/v1/beta/webhook-configs + withRawResponse().create(params, requestOptions).parse() + + override fun retrieve( + params: WebhookConfigRetrieveParams, + requestOptions: RequestOptions, + ): WebhookConfigResponse = + // get /api/v1/beta/webhook-configs/{config_id} + withRawResponse().retrieve(params, requestOptions).parse() + + override fun update( + params: WebhookConfigUpdateParams, + requestOptions: RequestOptions, + ): WebhookConfigResponse = + // put /api/v1/beta/webhook-configs/{config_id} + withRawResponse().update(params, requestOptions).parse() + + override fun list( + params: WebhookConfigListParams, + requestOptions: RequestOptions, + ): List = + // get /api/v1/beta/webhook-configs + withRawResponse().list(params, requestOptions).parse() + + override fun delete(params: WebhookConfigDeleteParams, requestOptions: RequestOptions) { + // delete /api/v1/beta/webhook-configs/{config_id} + withRawResponse().delete(params, requestOptions) + } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + WebhookConfigService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): WebhookConfigService.WithRawResponse = + WebhookConfigServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: WebhookConfigCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "beta", "webhook-configs") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: WebhookConfigRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("configId", params.configId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "beta", "webhook-configs", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val updateHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun update( + params: WebhookConfigUpdateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("configId", params.configId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "beta", "webhook-configs", params._pathParam(0)) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { updateHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val listHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) + + override fun list( + params: WebhookConfigListParams, + requestOptions: RequestOptions, + ): HttpResponseFor> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "beta", "webhook-configs") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.forEach { it.validate() } + } + } + } + } + + private val deleteHandler: Handler = emptyHandler() + + override fun delete( + params: WebhookConfigDeleteParams, + requestOptions: RequestOptions, + ): HttpResponse { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("configId", params.configId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "beta", "webhook-configs", params._pathParam(0)) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response.use { deleteHandler.handle(it) } + } + } + } +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/pipelines/DocumentService.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/pipelines/DocumentService.kt index 9e7e136..085a65f 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/pipelines/DocumentService.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/pipelines/DocumentService.kt @@ -12,6 +12,8 @@ import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentCreateParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentDeleteParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetChunksParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetParams +import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetStatusCountsParams +import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetStatusCountsResponse import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetStatusParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentListPage import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentListParams @@ -195,6 +197,54 @@ interface DocumentService { requestOptions: RequestOptions = RequestOptions.none(), ): ManagedIngestionStatusResponse + /** + * Count the documents in a pipeline, grouped by ingestion status. + * + * Counts reflect each document's last recorded status rather than a freshly computed one, so a + * document that changed status in the last few moments may still be counted under its previous + * one. Use `GET /pipelines/{pipeline_id}/documents/{document_id}/status` when a single + * document's status has to be up to the moment. + */ + @Deprecated("deprecated") + fun getStatusCounts(pipelineId: String): DocumentGetStatusCountsResponse = + getStatusCounts(pipelineId, DocumentGetStatusCountsParams.none()) + + /** @see getStatusCounts */ + @Deprecated("deprecated") + fun getStatusCounts( + pipelineId: String, + params: DocumentGetStatusCountsParams = DocumentGetStatusCountsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): DocumentGetStatusCountsResponse = + getStatusCounts(params.toBuilder().pipelineId(pipelineId).build(), requestOptions) + + /** @see getStatusCounts */ + @Deprecated("deprecated") + fun getStatusCounts( + pipelineId: String, + params: DocumentGetStatusCountsParams = DocumentGetStatusCountsParams.none(), + ): DocumentGetStatusCountsResponse = getStatusCounts(pipelineId, params, RequestOptions.none()) + + /** @see getStatusCounts */ + @Deprecated("deprecated") + fun getStatusCounts( + params: DocumentGetStatusCountsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): DocumentGetStatusCountsResponse + + /** @see getStatusCounts */ + @Deprecated("deprecated") + fun getStatusCounts(params: DocumentGetStatusCountsParams): DocumentGetStatusCountsResponse = + getStatusCounts(params, RequestOptions.none()) + + /** @see getStatusCounts */ + @Deprecated("deprecated") + fun getStatusCounts( + pipelineId: String, + requestOptions: RequestOptions, + ): DocumentGetStatusCountsResponse = + getStatusCounts(pipelineId, DocumentGetStatusCountsParams.none(), requestOptions) + /** Sync a specific document for a pipeline. */ @Deprecated("deprecated") fun sync(documentId: String, params: DocumentSyncParams): DocumentSyncResponse = @@ -484,6 +534,60 @@ interface DocumentService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** + * Returns a raw HTTP response for `get + * /api/v1/pipelines/{pipeline_id}/documents/status-counts`, but is otherwise the same as + * [DocumentService.getStatusCounts]. + */ + @Deprecated("deprecated") + @MustBeClosed + fun getStatusCounts(pipelineId: String): HttpResponseFor = + getStatusCounts(pipelineId, DocumentGetStatusCountsParams.none()) + + /** @see getStatusCounts */ + @Deprecated("deprecated") + @MustBeClosed + fun getStatusCounts( + pipelineId: String, + params: DocumentGetStatusCountsParams = DocumentGetStatusCountsParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + getStatusCounts(params.toBuilder().pipelineId(pipelineId).build(), requestOptions) + + /** @see getStatusCounts */ + @Deprecated("deprecated") + @MustBeClosed + fun getStatusCounts( + pipelineId: String, + params: DocumentGetStatusCountsParams = DocumentGetStatusCountsParams.none(), + ): HttpResponseFor = + getStatusCounts(pipelineId, params, RequestOptions.none()) + + /** @see getStatusCounts */ + @Deprecated("deprecated") + @MustBeClosed + fun getStatusCounts( + params: DocumentGetStatusCountsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see getStatusCounts */ + @Deprecated("deprecated") + @MustBeClosed + fun getStatusCounts( + params: DocumentGetStatusCountsParams + ): HttpResponseFor = + getStatusCounts(params, RequestOptions.none()) + + /** @see getStatusCounts */ + @Deprecated("deprecated") + @MustBeClosed + fun getStatusCounts( + pipelineId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + getStatusCounts(pipelineId, DocumentGetStatusCountsParams.none(), requestOptions) + /** * Returns a raw HTTP response for `post * /api/v1/pipelines/{pipeline_id}/documents/{document_id}/sync`, but is otherwise the same diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/pipelines/DocumentServiceImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/pipelines/DocumentServiceImpl.kt index 18e9fa2..618a8d2 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/pipelines/DocumentServiceImpl.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/pipelines/DocumentServiceImpl.kt @@ -23,6 +23,8 @@ import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentCreateParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentDeleteParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetChunksParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetParams +import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetStatusCountsParams +import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetStatusCountsResponse import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetStatusParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentListPage import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentListPageResponse @@ -89,6 +91,14 @@ class DocumentServiceImpl internal constructor(private val clientOptions: Client // get /api/v1/pipelines/{pipeline_id}/documents/{document_id}/status withRawResponse().getStatus(params, requestOptions).parse() + @Deprecated("deprecated") + override fun getStatusCounts( + params: DocumentGetStatusCountsParams, + requestOptions: RequestOptions, + ): DocumentGetStatusCountsResponse = + // get /api/v1/pipelines/{pipeline_id}/documents/status-counts + withRawResponse().getStatusCounts(params, requestOptions).parse() + @Deprecated("deprecated") override fun sync( params: DocumentSyncParams, @@ -343,6 +353,44 @@ class DocumentServiceImpl internal constructor(private val clientOptions: Client } } + private val getStatusCountsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + @Deprecated("deprecated") + override fun getStatusCounts( + params: DocumentGetStatusCountsParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("pipelineId", params.pipelineId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "api", + "v1", + "pipelines", + params._pathParam(0), + "documents", + "status-counts", + ) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { getStatusCountsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val syncHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCancelParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCancelParamsTest.kt new file mode 100644 index 0000000..8ebb0bf --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCancelParamsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.batches + +import ai.llamaindex.llamacloud.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BatchCancelParamsTest { + + @Test + fun create() { + BatchCancelParams.builder() + .batchId("batch_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = BatchCancelParams.builder().batchId("batch_id").build() + + assertThat(params._pathParam(0)).isEqualTo("batch_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + BatchCancelParams.builder() + .batchId("batch_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = BatchCancelParams.builder().batchId("batch_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCancelResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCancelResponseTest.kt new file mode 100644 index 0000000..ec478c5 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/batches/BatchCancelResponseTest.kt @@ -0,0 +1,125 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.batches + +import ai.llamaindex.llamacloud.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class BatchCancelResponseTest { + + @Test + fun create() { + val batchCancelResponse = + BatchCancelResponse.builder() + .id("id") + .config( + BatchCancelResponse.Config.builder() + .job( + BatchCancelResponse.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchCancelResponse.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + .projectId("project_id") + .sourceDirectoryId("source_directory_id") + .status(BatchCancelResponse.Status.CANCELLED) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addResult( + BatchCancelResponse.Result.builder() + .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .errorMessage("error_message") + .jobReference( + BatchCancelResponse.Result.JobReference.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .type(BatchCancelResponse.Result.JobReference.Type.PARSE_V2) + .build() + ) + .build() + ) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(batchCancelResponse.id()).isEqualTo("id") + assertThat(batchCancelResponse.config()) + .isEqualTo( + BatchCancelResponse.Config.builder() + .job( + BatchCancelResponse.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchCancelResponse.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + assertThat(batchCancelResponse.projectId()).isEqualTo("project_id") + assertThat(batchCancelResponse.sourceDirectoryId()).isEqualTo("source_directory_id") + assertThat(batchCancelResponse.status()).isEqualTo(BatchCancelResponse.Status.CANCELLED) + assertThat(batchCancelResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(batchCancelResponse.results().getOrNull()) + .containsExactly( + BatchCancelResponse.Result.builder() + .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .errorMessage("error_message") + .jobReference( + BatchCancelResponse.Result.JobReference.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .type(BatchCancelResponse.Result.JobReference.Type.PARSE_V2) + .build() + ) + .build() + ) + assertThat(batchCancelResponse.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val batchCancelResponse = + BatchCancelResponse.builder() + .id("id") + .config( + BatchCancelResponse.Config.builder() + .job( + BatchCancelResponse.Config.Job.builder() + .configurationId("cfg-PARSE_AGENTIC") + .type(BatchCancelResponse.Config.Job.Type.PARSE_V2) + .build() + ) + .build() + ) + .projectId("project_id") + .sourceDirectoryId("source_directory_id") + .status(BatchCancelResponse.Status.CANCELLED) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addResult( + BatchCancelResponse.Result.builder() + .sourceDirectoryFileId("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .errorMessage("error_message") + .jobReference( + BatchCancelResponse.Result.JobReference.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .type(BatchCancelResponse.Result.JobReference.Type.PARSE_V2) + .build() + ) + .build() + ) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedBatchCancelResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(batchCancelResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedBatchCancelResponse).isEqualTo(batchCancelResponse) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCancelParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCancelParamsTest.kt new file mode 100644 index 0000000..4b19efe --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCancelParamsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.classify + +import ai.llamaindex.llamacloud.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ClassifyCancelParamsTest { + + @Test + fun create() { + ClassifyCancelParams.builder() + .jobId("job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = ClassifyCancelParams.builder().jobId("job_id").build() + + assertThat(params._pathParam(0)).isEqualTo("job_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + ClassifyCancelParams.builder() + .jobId("job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = ClassifyCancelParams.builder().jobId("job_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCancelResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCancelResponseTest.kt new file mode 100644 index 0000000..05a48f4 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/classify/ClassifyCancelResponseTest.kt @@ -0,0 +1,153 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.classify + +import ai.llamaindex.llamacloud.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ClassifyCancelResponseTest { + + @Test + fun create() { + val classifyCancelResponse = + ClassifyCancelResponse.builder() + .id("id") + .configuration( + ClassifyConfiguration.builder() + .addRule( + ClassifyConfiguration.Rule.builder() + .description( + "contains invoice number, line items, and total amount" + ) + .type("invoice") + .build() + ) + .mode(ClassifyConfiguration.Mode.FAST) + .parsingConfiguration( + ClassifyConfiguration.ParsingConfiguration.builder() + .lang("en") + .maxPages(10L) + .targetPages("1,3,5-7") + .build() + ) + .build() + ) + .documentInputType(ClassifyCancelResponse.DocumentInputType.FILE_ID) + .fileInput("file_input") + .projectId("project_id") + .status(ClassifyCancelResponse.Status.COMPLETED) + .userId("user_id") + .configurationId("configuration_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errorMessage("error_message") + .parseJobId("parse_job_id") + .result( + ClassifyResult.builder() + .confidence(0.0) + .reasoning("reasoning") + .type("type") + .build() + ) + .transactionId("transaction_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(classifyCancelResponse.id()).isEqualTo("id") + assertThat(classifyCancelResponse.configuration()) + .isEqualTo( + ClassifyConfiguration.builder() + .addRule( + ClassifyConfiguration.Rule.builder() + .description("contains invoice number, line items, and total amount") + .type("invoice") + .build() + ) + .mode(ClassifyConfiguration.Mode.FAST) + .parsingConfiguration( + ClassifyConfiguration.ParsingConfiguration.builder() + .lang("en") + .maxPages(10L) + .targetPages("1,3,5-7") + .build() + ) + .build() + ) + assertThat(classifyCancelResponse.documentInputType()) + .isEqualTo(ClassifyCancelResponse.DocumentInputType.FILE_ID) + assertThat(classifyCancelResponse.fileInput()).isEqualTo("file_input") + assertThat(classifyCancelResponse.projectId()).isEqualTo("project_id") + assertThat(classifyCancelResponse.status()) + .isEqualTo(ClassifyCancelResponse.Status.COMPLETED) + assertThat(classifyCancelResponse.userId()).isEqualTo("user_id") + assertThat(classifyCancelResponse.configurationId()).contains("configuration_id") + assertThat(classifyCancelResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(classifyCancelResponse.errorMessage()).contains("error_message") + assertThat(classifyCancelResponse.parseJobId()).contains("parse_job_id") + assertThat(classifyCancelResponse.result()) + .contains( + ClassifyResult.builder().confidence(0.0).reasoning("reasoning").type("type").build() + ) + assertThat(classifyCancelResponse.transactionId()).contains("transaction_id") + assertThat(classifyCancelResponse.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val classifyCancelResponse = + ClassifyCancelResponse.builder() + .id("id") + .configuration( + ClassifyConfiguration.builder() + .addRule( + ClassifyConfiguration.Rule.builder() + .description( + "contains invoice number, line items, and total amount" + ) + .type("invoice") + .build() + ) + .mode(ClassifyConfiguration.Mode.FAST) + .parsingConfiguration( + ClassifyConfiguration.ParsingConfiguration.builder() + .lang("en") + .maxPages(10L) + .targetPages("1,3,5-7") + .build() + ) + .build() + ) + .documentInputType(ClassifyCancelResponse.DocumentInputType.FILE_ID) + .fileInput("file_input") + .projectId("project_id") + .status(ClassifyCancelResponse.Status.COMPLETED) + .userId("user_id") + .configurationId("configuration_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errorMessage("error_message") + .parseJobId("parse_job_id") + .result( + ClassifyResult.builder() + .confidence(0.0) + .reasoning("reasoning") + .type("type") + .build() + ) + .transactionId("transaction_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedClassifyCancelResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(classifyCancelResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedClassifyCancelResponse).isEqualTo(classifyCancelResponse) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractCancelParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractCancelParamsTest.kt new file mode 100644 index 0000000..31fd4c7 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractCancelParamsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.extract + +import ai.llamaindex.llamacloud.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ExtractCancelParamsTest { + + @Test + fun create() { + ExtractCancelParams.builder() + .jobId("job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = ExtractCancelParams.builder().jobId("job_id").build() + + assertThat(params._pathParam(0)).isEqualTo("job_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + ExtractCancelParams.builder() + .jobId("job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = ExtractCancelParams.builder().jobId("job_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsParamsTest.kt new file mode 100644 index 0000000..2911244 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsParamsTest.kt @@ -0,0 +1,13 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.parsing + +import org.junit.jupiter.api.Test + +internal class ParsingListVersionsParamsTest { + + @Test + fun create() { + ParsingListVersionsParams.builder().build() + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsResponseTest.kt new file mode 100644 index 0000000..54147f4 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsResponseTest.kt @@ -0,0 +1,51 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.parsing + +import ai.llamaindex.llamacloud.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ParsingListVersionsResponseTest { + + @Test + fun create() { + val parsingListVersionsResponse = + ParsingListVersionsResponse.builder() + .addAgentic(ParsingListVersionsResponse.Agentic._2026_07_24) + .addAgenticPlus(ParsingListVersionsResponse.AgenticPlus._2026_07_08) + .addCostEffective(ParsingListVersionsResponse.CostEffective._2026_07_23) + .addFast(ParsingListVersionsResponse.Fast._2026_06_15) + .build() + + assertThat(parsingListVersionsResponse.agentic()) + .containsExactly(ParsingListVersionsResponse.Agentic._2026_07_24) + assertThat(parsingListVersionsResponse.agenticPlus()) + .containsExactly(ParsingListVersionsResponse.AgenticPlus._2026_07_08) + assertThat(parsingListVersionsResponse.costEffective()) + .containsExactly(ParsingListVersionsResponse.CostEffective._2026_07_23) + assertThat(parsingListVersionsResponse.fast()) + .containsExactly(ParsingListVersionsResponse.Fast._2026_06_15) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val parsingListVersionsResponse = + ParsingListVersionsResponse.builder() + .addAgentic(ParsingListVersionsResponse.Agentic._2026_07_24) + .addAgenticPlus(ParsingListVersionsResponse.AgenticPlus._2026_07_08) + .addCostEffective(ParsingListVersionsResponse.CostEffective._2026_07_23) + .addFast(ParsingListVersionsResponse.Fast._2026_06_15) + .build() + + val roundtrippedParsingListVersionsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(parsingListVersionsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedParsingListVersionsResponse).isEqualTo(parsingListVersionsResponse) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/documents/DocumentGetStatusCountsParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/documents/DocumentGetStatusCountsParamsTest.kt new file mode 100644 index 0000000..054d4de --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/documents/DocumentGetStatusCountsParamsTest.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.pipelines.documents + +import ai.llamaindex.llamacloud.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DocumentGetStatusCountsParamsTest { + + @Test + fun create() { + DocumentGetStatusCountsParams.builder() + .pipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fileId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .onlyDirectUpload(true) + .build() + } + + @Test + fun pathParams() { + val params = + DocumentGetStatusCountsParams.builder() + .pipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + DocumentGetStatusCountsParams.builder() + .pipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fileId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .onlyDirectUpload(true) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("data_source_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("file_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("only_direct_upload", "true") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + DocumentGetStatusCountsParams.builder() + .pipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/documents/DocumentGetStatusCountsResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/documents/DocumentGetStatusCountsResponseTest.kt new file mode 100644 index 0000000..2c0218d --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/pipelines/documents/DocumentGetStatusCountsResponseTest.kt @@ -0,0 +1,71 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.pipelines.documents + +import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class DocumentGetStatusCountsResponseTest { + + @Test + fun create() { + val documentGetStatusCountsResponse = + DocumentGetStatusCountsResponse.builder() + .counts( + DocumentGetStatusCountsResponse.Counts.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .pipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .totalCount(0L) + .dataSourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fileId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .onlyDirectUpload(true) + .build() + + assertThat(documentGetStatusCountsResponse.counts()) + .isEqualTo( + DocumentGetStatusCountsResponse.Counts.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + assertThat(documentGetStatusCountsResponse.pipelineId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(documentGetStatusCountsResponse.totalCount()).isEqualTo(0L) + assertThat(documentGetStatusCountsResponse.dataSourceId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(documentGetStatusCountsResponse.fileId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(documentGetStatusCountsResponse.onlyDirectUpload()).contains(true) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val documentGetStatusCountsResponse = + DocumentGetStatusCountsResponse.builder() + .counts( + DocumentGetStatusCountsResponse.Counts.builder() + .putAdditionalProperty("foo", JsonValue.from(0)) + .build() + ) + .pipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .totalCount(0L) + .dataSourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fileId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .onlyDirectUpload(true) + .build() + + val roundtrippedDocumentGetStatusCountsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(documentGetStatusCountsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedDocumentGetStatusCountsResponse) + .isEqualTo(documentGetStatusCountsResponse) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitCancelParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitCancelParamsTest.kt new file mode 100644 index 0000000..0073664 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitCancelParamsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +import ai.llamaindex.llamacloud.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SplitCancelParamsTest { + + @Test + fun create() { + SplitCancelParams.builder() + .splitJobId("split_job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = SplitCancelParams.builder().splitJobId("split_job_id").build() + + assertThat(params._pathParam(0)).isEqualTo("split_job_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + SplitCancelParams.builder() + .splitJobId("split_job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = SplitCancelParams.builder().splitJobId("split_job_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitCancelResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitCancelResponseTest.kt new file mode 100644 index 0000000..e42de09 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitCancelResponseTest.kt @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +import ai.llamaindex.llamacloud.core.jsonMapper +import ai.llamaindex.llamacloud.models.beta.split.SplitCategory +import ai.llamaindex.llamacloud.models.beta.split.SplitResultResponse +import ai.llamaindex.llamacloud.models.beta.split.SplitSegmentResponse +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SplitCancelResponseTest { + + @Test + fun create() { + val splitCancelResponse = + SplitCancelResponse.builder() + .id("id") + .addCategory(SplitCategory.builder().name("x").description("x").build()) + .documentInputType(SplitCancelResponse.DocumentInputType.FILE_ID) + .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .projectId("project_id") + .status("status") + .userId("user_id") + .configurationId("configuration_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errorMessage("error_message") + .result( + SplitResultResponse.builder() + .addSegment( + SplitSegmentResponse.builder() + .category("category") + .confidenceCategory("confidence_category") + .addPage(0L) + .build() + ) + .build() + ) + .splittingStrategy( + SplitCancelResponse.SplittingStrategy.builder() + .allowUncategorized( + SplitCancelResponse.SplittingStrategy.AllowUncategorized.FORBID + ) + .build() + ) + .transactionId("transaction_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(splitCancelResponse.id()).isEqualTo("id") + assertThat(splitCancelResponse.categories()) + .containsExactly(SplitCategory.builder().name("x").description("x").build()) + assertThat(splitCancelResponse.documentInputType()) + .isEqualTo(SplitCancelResponse.DocumentInputType.FILE_ID) + assertThat(splitCancelResponse.fileInput()) + .isEqualTo("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + assertThat(splitCancelResponse.projectId()).isEqualTo("project_id") + assertThat(splitCancelResponse.status()).isEqualTo("status") + assertThat(splitCancelResponse.userId()).isEqualTo("user_id") + assertThat(splitCancelResponse.configurationId()).contains("configuration_id") + assertThat(splitCancelResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(splitCancelResponse.errorMessage()).contains("error_message") + assertThat(splitCancelResponse.result()) + .contains( + SplitResultResponse.builder() + .addSegment( + SplitSegmentResponse.builder() + .category("category") + .confidenceCategory("confidence_category") + .addPage(0L) + .build() + ) + .build() + ) + assertThat(splitCancelResponse.splittingStrategy()) + .contains( + SplitCancelResponse.SplittingStrategy.builder() + .allowUncategorized( + SplitCancelResponse.SplittingStrategy.AllowUncategorized.FORBID + ) + .build() + ) + assertThat(splitCancelResponse.transactionId()).contains("transaction_id") + assertThat(splitCancelResponse.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val splitCancelResponse = + SplitCancelResponse.builder() + .id("id") + .addCategory(SplitCategory.builder().name("x").description("x").build()) + .documentInputType(SplitCancelResponse.DocumentInputType.FILE_ID) + .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .projectId("project_id") + .status("status") + .userId("user_id") + .configurationId("configuration_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errorMessage("error_message") + .result( + SplitResultResponse.builder() + .addSegment( + SplitSegmentResponse.builder() + .category("category") + .confidenceCategory("confidence_category") + .addPage(0L) + .build() + ) + .build() + ) + .splittingStrategy( + SplitCancelResponse.SplittingStrategy.builder() + .allowUncategorized( + SplitCancelResponse.SplittingStrategy.AllowUncategorized.FORBID + ) + .build() + ) + .transactionId("transaction_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedSplitCancelResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(splitCancelResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSplitCancelResponse).isEqualTo(splitCancelResponse) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitCreateParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitCreateParamsTest.kt new file mode 100644 index 0000000..2786b53 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitCreateParamsTest.kt @@ -0,0 +1,229 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.core.http.QueryParams +import ai.llamaindex.llamacloud.models.beta.split.SplitCategory +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SplitCreateParamsTest { + + @Test + fun create() { + SplitCreateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .configuration( + SplitCreateParams.Configuration.builder() + .addCategory(SplitCategory.builder().name("x").description("x").build()) + .splittingStrategy( + SplitCreateParams.Configuration.SplittingStrategy.builder() + .allowUncategorized( + SplitCreateParams.Configuration.SplittingStrategy.AllowUncategorized + .FORBID + ) + .build() + ) + .build() + ) + .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .transactionId("tx-unique-idempotency-key") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") + .addWebhookConfiguration( + SplitCreateParams.WebhookConfiguration.builder() + .addWebhookEvent( + SplitCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS + ) + .addWebhookEvent( + SplitCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR + ) + .webhookHeaders( + SplitCreateParams.WebhookConfiguration.WebhookHeaders.builder() + .putAdditionalProperty("Authorization", JsonValue.from("Bearer sk-...")) + .build() + ) + .webhookOutputFormat("json") + .webhookSigningSecret("whsec_...") + .webhookUrl("https://example.com/webhooks/llamacloud") + .build() + ) + .build() + } + + @Test + fun queryParams() { + val params = + SplitCreateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .configuration( + SplitCreateParams.Configuration.builder() + .addCategory(SplitCategory.builder().name("x").description("x").build()) + .splittingStrategy( + SplitCreateParams.Configuration.SplittingStrategy.builder() + .allowUncategorized( + SplitCreateParams.Configuration.SplittingStrategy + .AllowUncategorized + .FORBID + ) + .build() + ) + .build() + ) + .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .transactionId("tx-unique-idempotency-key") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") + .addWebhookConfiguration( + SplitCreateParams.WebhookConfiguration.builder() + .addWebhookEvent( + SplitCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS + ) + .addWebhookEvent( + SplitCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR + ) + .webhookHeaders( + SplitCreateParams.WebhookConfiguration.WebhookHeaders.builder() + .putAdditionalProperty( + "Authorization", + JsonValue.from("Bearer sk-..."), + ) + .build() + ) + .webhookOutputFormat("json") + .webhookSigningSecret("whsec_...") + .webhookUrl("https://example.com/webhooks/llamacloud") + .build() + ) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + SplitCreateParams.builder() + .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } + + @Test + fun body() { + val params = + SplitCreateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .configuration( + SplitCreateParams.Configuration.builder() + .addCategory(SplitCategory.builder().name("x").description("x").build()) + .splittingStrategy( + SplitCreateParams.Configuration.SplittingStrategy.builder() + .allowUncategorized( + SplitCreateParams.Configuration.SplittingStrategy + .AllowUncategorized + .FORBID + ) + .build() + ) + .build() + ) + .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .transactionId("tx-unique-idempotency-key") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") + .addWebhookConfiguration( + SplitCreateParams.WebhookConfiguration.builder() + .addWebhookEvent( + SplitCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS + ) + .addWebhookEvent( + SplitCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR + ) + .webhookHeaders( + SplitCreateParams.WebhookConfiguration.WebhookHeaders.builder() + .putAdditionalProperty( + "Authorization", + JsonValue.from("Bearer sk-..."), + ) + .build() + ) + .webhookOutputFormat("json") + .webhookSigningSecret("whsec_...") + .webhookUrl("https://example.com/webhooks/llamacloud") + .build() + ) + .build() + + val body = params._body() + + assertThat(body.fileInput()).isEqualTo("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + assertThat(body.configuration()) + .contains( + SplitCreateParams.Configuration.builder() + .addCategory(SplitCategory.builder().name("x").description("x").build()) + .splittingStrategy( + SplitCreateParams.Configuration.SplittingStrategy.builder() + .allowUncategorized( + SplitCreateParams.Configuration.SplittingStrategy.AllowUncategorized + .FORBID + ) + .build() + ) + .build() + ) + assertThat(body.configurationId()).contains("cfg-11111111-2222-3333-4444-555555555555") + assertThat(body.transactionId()).contains("tx-unique-idempotency-key") + assertThat(body.webhookConfigurationIds().getOrNull()).containsExactly("whc-...", "whc-...") + assertThat(body.webhookConfigurations().getOrNull()) + .containsExactly( + SplitCreateParams.WebhookConfiguration.builder() + .addWebhookEvent( + SplitCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS + ) + .addWebhookEvent( + SplitCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR + ) + .webhookHeaders( + SplitCreateParams.WebhookConfiguration.WebhookHeaders.builder() + .putAdditionalProperty("Authorization", JsonValue.from("Bearer sk-...")) + .build() + ) + .webhookOutputFormat("json") + .webhookSigningSecret("whsec_...") + .webhookUrl("https://example.com/webhooks/llamacloud") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + SplitCreateParams.builder() + .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .build() + + val body = params._body() + + assertThat(body.fileInput()).isEqualTo("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitCreateResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitCreateResponseTest.kt new file mode 100644 index 0000000..1ccc4a0 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitCreateResponseTest.kt @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +import ai.llamaindex.llamacloud.core.jsonMapper +import ai.llamaindex.llamacloud.models.beta.split.SplitCategory +import ai.llamaindex.llamacloud.models.beta.split.SplitResultResponse +import ai.llamaindex.llamacloud.models.beta.split.SplitSegmentResponse +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SplitCreateResponseTest { + + @Test + fun create() { + val splitCreateResponse = + SplitCreateResponse.builder() + .id("id") + .addCategory(SplitCategory.builder().name("x").description("x").build()) + .documentInputType(SplitCreateResponse.DocumentInputType.FILE_ID) + .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .projectId("project_id") + .status("status") + .userId("user_id") + .configurationId("configuration_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errorMessage("error_message") + .result( + SplitResultResponse.builder() + .addSegment( + SplitSegmentResponse.builder() + .category("category") + .confidenceCategory("confidence_category") + .addPage(0L) + .build() + ) + .build() + ) + .splittingStrategy( + SplitCreateResponse.SplittingStrategy.builder() + .allowUncategorized( + SplitCreateResponse.SplittingStrategy.AllowUncategorized.FORBID + ) + .build() + ) + .transactionId("transaction_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(splitCreateResponse.id()).isEqualTo("id") + assertThat(splitCreateResponse.categories()) + .containsExactly(SplitCategory.builder().name("x").description("x").build()) + assertThat(splitCreateResponse.documentInputType()) + .isEqualTo(SplitCreateResponse.DocumentInputType.FILE_ID) + assertThat(splitCreateResponse.fileInput()) + .isEqualTo("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + assertThat(splitCreateResponse.projectId()).isEqualTo("project_id") + assertThat(splitCreateResponse.status()).isEqualTo("status") + assertThat(splitCreateResponse.userId()).isEqualTo("user_id") + assertThat(splitCreateResponse.configurationId()).contains("configuration_id") + assertThat(splitCreateResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(splitCreateResponse.errorMessage()).contains("error_message") + assertThat(splitCreateResponse.result()) + .contains( + SplitResultResponse.builder() + .addSegment( + SplitSegmentResponse.builder() + .category("category") + .confidenceCategory("confidence_category") + .addPage(0L) + .build() + ) + .build() + ) + assertThat(splitCreateResponse.splittingStrategy()) + .contains( + SplitCreateResponse.SplittingStrategy.builder() + .allowUncategorized( + SplitCreateResponse.SplittingStrategy.AllowUncategorized.FORBID + ) + .build() + ) + assertThat(splitCreateResponse.transactionId()).contains("transaction_id") + assertThat(splitCreateResponse.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val splitCreateResponse = + SplitCreateResponse.builder() + .id("id") + .addCategory(SplitCategory.builder().name("x").description("x").build()) + .documentInputType(SplitCreateResponse.DocumentInputType.FILE_ID) + .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .projectId("project_id") + .status("status") + .userId("user_id") + .configurationId("configuration_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errorMessage("error_message") + .result( + SplitResultResponse.builder() + .addSegment( + SplitSegmentResponse.builder() + .category("category") + .confidenceCategory("confidence_category") + .addPage(0L) + .build() + ) + .build() + ) + .splittingStrategy( + SplitCreateResponse.SplittingStrategy.builder() + .allowUncategorized( + SplitCreateResponse.SplittingStrategy.AllowUncategorized.FORBID + ) + .build() + ) + .transactionId("transaction_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedSplitCreateResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(splitCreateResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSplitCreateResponse).isEqualTo(splitCreateResponse) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitDeleteParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitDeleteParamsTest.kt new file mode 100644 index 0000000..e2f4b5c --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitDeleteParamsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +import ai.llamaindex.llamacloud.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SplitDeleteParamsTest { + + @Test + fun create() { + SplitDeleteParams.builder() + .splitJobId("split_job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = SplitDeleteParams.builder().splitJobId("split_job_id").build() + + assertThat(params._pathParam(0)).isEqualTo("split_job_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + SplitDeleteParams.builder() + .splitJobId("split_job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = SplitDeleteParams.builder().splitJobId("split_job_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitDeleteResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitDeleteResponseTest.kt new file mode 100644 index 0000000..41ca756 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitDeleteResponseTest.kt @@ -0,0 +1,30 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +import ai.llamaindex.llamacloud.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SplitDeleteResponseTest { + + @Test + fun create() { + val splitDeleteResponse = SplitDeleteResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val splitDeleteResponse = SplitDeleteResponse.builder().build() + + val roundtrippedSplitDeleteResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(splitDeleteResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSplitDeleteResponse).isEqualTo(splitDeleteResponse) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitGetParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitGetParamsTest.kt new file mode 100644 index 0000000..0a85865 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitGetParamsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +import ai.llamaindex.llamacloud.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SplitGetParamsTest { + + @Test + fun create() { + SplitGetParams.builder() + .splitJobId("split_job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = SplitGetParams.builder().splitJobId("split_job_id").build() + + assertThat(params._pathParam(0)).isEqualTo("split_job_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + SplitGetParams.builder() + .splitJobId("split_job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = SplitGetParams.builder().splitJobId("split_job_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitGetResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitGetResponseTest.kt new file mode 100644 index 0000000..b8af88b --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitGetResponseTest.kt @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +import ai.llamaindex.llamacloud.core.jsonMapper +import ai.llamaindex.llamacloud.models.beta.split.SplitCategory +import ai.llamaindex.llamacloud.models.beta.split.SplitResultResponse +import ai.llamaindex.llamacloud.models.beta.split.SplitSegmentResponse +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SplitGetResponseTest { + + @Test + fun create() { + val splitGetResponse = + SplitGetResponse.builder() + .id("id") + .addCategory(SplitCategory.builder().name("x").description("x").build()) + .documentInputType(SplitGetResponse.DocumentInputType.FILE_ID) + .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .projectId("project_id") + .status("status") + .userId("user_id") + .configurationId("configuration_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errorMessage("error_message") + .result( + SplitResultResponse.builder() + .addSegment( + SplitSegmentResponse.builder() + .category("category") + .confidenceCategory("confidence_category") + .addPage(0L) + .build() + ) + .build() + ) + .splittingStrategy( + SplitGetResponse.SplittingStrategy.builder() + .allowUncategorized( + SplitGetResponse.SplittingStrategy.AllowUncategorized.FORBID + ) + .build() + ) + .transactionId("transaction_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(splitGetResponse.id()).isEqualTo("id") + assertThat(splitGetResponse.categories()) + .containsExactly(SplitCategory.builder().name("x").description("x").build()) + assertThat(splitGetResponse.documentInputType()) + .isEqualTo(SplitGetResponse.DocumentInputType.FILE_ID) + assertThat(splitGetResponse.fileInput()) + .isEqualTo("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + assertThat(splitGetResponse.projectId()).isEqualTo("project_id") + assertThat(splitGetResponse.status()).isEqualTo("status") + assertThat(splitGetResponse.userId()).isEqualTo("user_id") + assertThat(splitGetResponse.configurationId()).contains("configuration_id") + assertThat(splitGetResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(splitGetResponse.errorMessage()).contains("error_message") + assertThat(splitGetResponse.result()) + .contains( + SplitResultResponse.builder() + .addSegment( + SplitSegmentResponse.builder() + .category("category") + .confidenceCategory("confidence_category") + .addPage(0L) + .build() + ) + .build() + ) + assertThat(splitGetResponse.splittingStrategy()) + .contains( + SplitGetResponse.SplittingStrategy.builder() + .allowUncategorized( + SplitGetResponse.SplittingStrategy.AllowUncategorized.FORBID + ) + .build() + ) + assertThat(splitGetResponse.transactionId()).contains("transaction_id") + assertThat(splitGetResponse.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val splitGetResponse = + SplitGetResponse.builder() + .id("id") + .addCategory(SplitCategory.builder().name("x").description("x").build()) + .documentInputType(SplitGetResponse.DocumentInputType.FILE_ID) + .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .projectId("project_id") + .status("status") + .userId("user_id") + .configurationId("configuration_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errorMessage("error_message") + .result( + SplitResultResponse.builder() + .addSegment( + SplitSegmentResponse.builder() + .category("category") + .confidenceCategory("confidence_category") + .addPage(0L) + .build() + ) + .build() + ) + .splittingStrategy( + SplitGetResponse.SplittingStrategy.builder() + .allowUncategorized( + SplitGetResponse.SplittingStrategy.AllowUncategorized.FORBID + ) + .build() + ) + .transactionId("transaction_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedSplitGetResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(splitGetResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSplitGetResponse).isEqualTo(splitGetResponse) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitListPageResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitListPageResponseTest.kt new file mode 100644 index 0000000..018b23d --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitListPageResponseTest.kt @@ -0,0 +1,148 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +import ai.llamaindex.llamacloud.core.jsonMapper +import ai.llamaindex.llamacloud.models.beta.split.SplitCategory +import ai.llamaindex.llamacloud.models.beta.split.SplitResultResponse +import ai.llamaindex.llamacloud.models.beta.split.SplitSegmentResponse +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SplitListPageResponseTest { + + @Test + fun create() { + val splitListPageResponse = + SplitListPageResponse.builder() + .addItem( + SplitListResponse.builder() + .id("id") + .addCategory(SplitCategory.builder().name("x").description("x").build()) + .documentInputType(SplitListResponse.DocumentInputType.FILE_ID) + .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .projectId("project_id") + .status("status") + .userId("user_id") + .configurationId("configuration_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errorMessage("error_message") + .result( + SplitResultResponse.builder() + .addSegment( + SplitSegmentResponse.builder() + .category("category") + .confidenceCategory("confidence_category") + .addPage(0L) + .build() + ) + .build() + ) + .splittingStrategy( + SplitListResponse.SplittingStrategy.builder() + .allowUncategorized( + SplitListResponse.SplittingStrategy.AllowUncategorized.FORBID + ) + .build() + ) + .transactionId("transaction_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .nextPageToken("next_page_token") + .totalSize(0L) + .build() + + assertThat(splitListPageResponse.items()) + .containsExactly( + SplitListResponse.builder() + .id("id") + .addCategory(SplitCategory.builder().name("x").description("x").build()) + .documentInputType(SplitListResponse.DocumentInputType.FILE_ID) + .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .projectId("project_id") + .status("status") + .userId("user_id") + .configurationId("configuration_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errorMessage("error_message") + .result( + SplitResultResponse.builder() + .addSegment( + SplitSegmentResponse.builder() + .category("category") + .confidenceCategory("confidence_category") + .addPage(0L) + .build() + ) + .build() + ) + .splittingStrategy( + SplitListResponse.SplittingStrategy.builder() + .allowUncategorized( + SplitListResponse.SplittingStrategy.AllowUncategorized.FORBID + ) + .build() + ) + .transactionId("transaction_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(splitListPageResponse.nextPageToken()).contains("next_page_token") + assertThat(splitListPageResponse.totalSize()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val splitListPageResponse = + SplitListPageResponse.builder() + .addItem( + SplitListResponse.builder() + .id("id") + .addCategory(SplitCategory.builder().name("x").description("x").build()) + .documentInputType(SplitListResponse.DocumentInputType.FILE_ID) + .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .projectId("project_id") + .status("status") + .userId("user_id") + .configurationId("configuration_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errorMessage("error_message") + .result( + SplitResultResponse.builder() + .addSegment( + SplitSegmentResponse.builder() + .category("category") + .confidenceCategory("confidence_category") + .addPage(0L) + .build() + ) + .build() + ) + .splittingStrategy( + SplitListResponse.SplittingStrategy.builder() + .allowUncategorized( + SplitListResponse.SplittingStrategy.AllowUncategorized.FORBID + ) + .build() + ) + .transactionId("transaction_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .nextPageToken("next_page_token") + .totalSize(0L) + .build() + + val roundtrippedSplitListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(splitListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSplitListPageResponse).isEqualTo(splitListPageResponse) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitListParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitListParamsTest.kt new file mode 100644 index 0000000..b3c6069 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitListParamsTest.kt @@ -0,0 +1,68 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +import ai.llamaindex.llamacloud.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SplitListParamsTest { + + @Test + fun create() { + SplitListParams.builder() + .createdAtOnOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAtOnOrBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addJobId("string") + .addJobId("string") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pageSize(0L) + .pageToken("page_token") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status(SplitListParams.Status.CANCELLED) + .build() + } + + @Test + fun queryParams() { + val params = + SplitListParams.builder() + .createdAtOnOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAtOnOrBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addJobId("string") + .addJobId("string") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pageSize(0L) + .pageToken("page_token") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .status(SplitListParams.Status.CANCELLED) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("created_at_on_or_after", "2019-12-27T18:11:19.117Z") + .put("created_at_on_or_before", "2019-12-27T18:11:19.117Z") + .put("job_ids", "string") + .put("job_ids", "string") + .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("page_size", "0") + .put("page_token", "page_token") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("status", "cancelled") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = SplitListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitListResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitListResponseTest.kt new file mode 100644 index 0000000..976955e --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/split/SplitListResponseTest.kt @@ -0,0 +1,136 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.split + +import ai.llamaindex.llamacloud.core.jsonMapper +import ai.llamaindex.llamacloud.models.beta.split.SplitCategory +import ai.llamaindex.llamacloud.models.beta.split.SplitResultResponse +import ai.llamaindex.llamacloud.models.beta.split.SplitSegmentResponse +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class SplitListResponseTest { + + @Test + fun create() { + val splitListResponse = + SplitListResponse.builder() + .id("id") + .addCategory(SplitCategory.builder().name("x").description("x").build()) + .documentInputType(SplitListResponse.DocumentInputType.FILE_ID) + .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .projectId("project_id") + .status("status") + .userId("user_id") + .configurationId("configuration_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errorMessage("error_message") + .result( + SplitResultResponse.builder() + .addSegment( + SplitSegmentResponse.builder() + .category("category") + .confidenceCategory("confidence_category") + .addPage(0L) + .build() + ) + .build() + ) + .splittingStrategy( + SplitListResponse.SplittingStrategy.builder() + .allowUncategorized( + SplitListResponse.SplittingStrategy.AllowUncategorized.FORBID + ) + .build() + ) + .transactionId("transaction_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(splitListResponse.id()).isEqualTo("id") + assertThat(splitListResponse.categories()) + .containsExactly(SplitCategory.builder().name("x").description("x").build()) + assertThat(splitListResponse.documentInputType()) + .isEqualTo(SplitListResponse.DocumentInputType.FILE_ID) + assertThat(splitListResponse.fileInput()) + .isEqualTo("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + assertThat(splitListResponse.projectId()).isEqualTo("project_id") + assertThat(splitListResponse.status()).isEqualTo("status") + assertThat(splitListResponse.userId()).isEqualTo("user_id") + assertThat(splitListResponse.configurationId()).contains("configuration_id") + assertThat(splitListResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(splitListResponse.errorMessage()).contains("error_message") + assertThat(splitListResponse.result()) + .contains( + SplitResultResponse.builder() + .addSegment( + SplitSegmentResponse.builder() + .category("category") + .confidenceCategory("confidence_category") + .addPage(0L) + .build() + ) + .build() + ) + assertThat(splitListResponse.splittingStrategy()) + .contains( + SplitListResponse.SplittingStrategy.builder() + .allowUncategorized( + SplitListResponse.SplittingStrategy.AllowUncategorized.FORBID + ) + .build() + ) + assertThat(splitListResponse.transactionId()).contains("transaction_id") + assertThat(splitListResponse.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val splitListResponse = + SplitListResponse.builder() + .id("id") + .addCategory(SplitCategory.builder().name("x").description("x").build()) + .documentInputType(SplitListResponse.DocumentInputType.FILE_ID) + .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .projectId("project_id") + .status("status") + .userId("user_id") + .configurationId("configuration_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .errorMessage("error_message") + .result( + SplitResultResponse.builder() + .addSegment( + SplitSegmentResponse.builder() + .category("category") + .confidenceCategory("confidence_category") + .addPage(0L) + .build() + ) + .build() + ) + .splittingStrategy( + SplitListResponse.SplittingStrategy.builder() + .allowUncategorized( + SplitListResponse.SplittingStrategy.AllowUncategorized.FORBID + ) + .build() + ) + .transactionId("transaction_id") + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedSplitListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(splitListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedSplitListResponse).isEqualTo(splitListResponse) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigCreateParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigCreateParamsTest.kt new file mode 100644 index 0000000..b598e43 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigCreateParamsTest.kt @@ -0,0 +1,150 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.webhookconfigs + +import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WebhookConfigCreateParamsTest { + + @Test + fun create() { + WebhookConfigCreateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .webhookConfigCreate( + WebhookConfigCreate.builder() + .webhookUrl("https://example.com/webhooks/llamacloud") + .addWebhookEvent(WebhookConfigCreate.WebhookEvent.PARSE_SUCCESS) + .addWebhookEvent(WebhookConfigCreate.WebhookEvent.PARSE_ERROR) + .webhookHeaders( + WebhookConfigCreate.WebhookHeaders.builder() + .putAdditionalProperty("Authorization", JsonValue.from("Bearer sk-...")) + .build() + ) + .webhookOutputFormat(WebhookConfigCreate.WebhookOutputFormat.JSON) + .webhookSigningSecret("whsec_...") + .build() + ) + .build() + } + + @Test + fun queryParams() { + val params = + WebhookConfigCreateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .webhookConfigCreate( + WebhookConfigCreate.builder() + .webhookUrl("https://example.com/webhooks/llamacloud") + .addWebhookEvent(WebhookConfigCreate.WebhookEvent.PARSE_SUCCESS) + .addWebhookEvent(WebhookConfigCreate.WebhookEvent.PARSE_ERROR) + .webhookHeaders( + WebhookConfigCreate.WebhookHeaders.builder() + .putAdditionalProperty( + "Authorization", + JsonValue.from("Bearer sk-..."), + ) + .build() + ) + .webhookOutputFormat(WebhookConfigCreate.WebhookOutputFormat.JSON) + .webhookSigningSecret("whsec_...") + .build() + ) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + WebhookConfigCreateParams.builder() + .webhookConfigCreate( + WebhookConfigCreate.builder() + .webhookUrl("https://example.com/webhooks/llamacloud") + .build() + ) + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } + + @Test + fun body() { + val params = + WebhookConfigCreateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .webhookConfigCreate( + WebhookConfigCreate.builder() + .webhookUrl("https://example.com/webhooks/llamacloud") + .addWebhookEvent(WebhookConfigCreate.WebhookEvent.PARSE_SUCCESS) + .addWebhookEvent(WebhookConfigCreate.WebhookEvent.PARSE_ERROR) + .webhookHeaders( + WebhookConfigCreate.WebhookHeaders.builder() + .putAdditionalProperty( + "Authorization", + JsonValue.from("Bearer sk-..."), + ) + .build() + ) + .webhookOutputFormat(WebhookConfigCreate.WebhookOutputFormat.JSON) + .webhookSigningSecret("whsec_...") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + WebhookConfigCreate.builder() + .webhookUrl("https://example.com/webhooks/llamacloud") + .addWebhookEvent(WebhookConfigCreate.WebhookEvent.PARSE_SUCCESS) + .addWebhookEvent(WebhookConfigCreate.WebhookEvent.PARSE_ERROR) + .webhookHeaders( + WebhookConfigCreate.WebhookHeaders.builder() + .putAdditionalProperty("Authorization", JsonValue.from("Bearer sk-...")) + .build() + ) + .webhookOutputFormat(WebhookConfigCreate.WebhookOutputFormat.JSON) + .webhookSigningSecret("whsec_...") + .build() + ) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + WebhookConfigCreateParams.builder() + .webhookConfigCreate( + WebhookConfigCreate.builder() + .webhookUrl("https://example.com/webhooks/llamacloud") + .build() + ) + .build() + + val body = params._body() + + assertThat(body) + .isEqualTo( + WebhookConfigCreate.builder() + .webhookUrl("https://example.com/webhooks/llamacloud") + .build() + ) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigCreateTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigCreateTest.kt new file mode 100644 index 0000000..88f867e --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigCreateTest.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.webhookconfigs + +import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WebhookConfigCreateTest { + + @Test + fun create() { + val webhookConfigCreate = + WebhookConfigCreate.builder() + .webhookUrl("https://example.com/webhooks/llamacloud") + .addWebhookEvent(WebhookConfigCreate.WebhookEvent.PARSE_SUCCESS) + .addWebhookEvent(WebhookConfigCreate.WebhookEvent.PARSE_ERROR) + .webhookHeaders( + WebhookConfigCreate.WebhookHeaders.builder() + .putAdditionalProperty("Authorization", JsonValue.from("Bearer sk-...")) + .build() + ) + .webhookOutputFormat(WebhookConfigCreate.WebhookOutputFormat.JSON) + .webhookSigningSecret("whsec_...") + .build() + + assertThat(webhookConfigCreate.webhookUrl()) + .isEqualTo("https://example.com/webhooks/llamacloud") + assertThat(webhookConfigCreate.webhookEvents().getOrNull()) + .containsExactly( + WebhookConfigCreate.WebhookEvent.PARSE_SUCCESS, + WebhookConfigCreate.WebhookEvent.PARSE_ERROR, + ) + assertThat(webhookConfigCreate.webhookHeaders()) + .contains( + WebhookConfigCreate.WebhookHeaders.builder() + .putAdditionalProperty("Authorization", JsonValue.from("Bearer sk-...")) + .build() + ) + assertThat(webhookConfigCreate.webhookOutputFormat()) + .contains(WebhookConfigCreate.WebhookOutputFormat.JSON) + assertThat(webhookConfigCreate.webhookSigningSecret()).contains("whsec_...") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val webhookConfigCreate = + WebhookConfigCreate.builder() + .webhookUrl("https://example.com/webhooks/llamacloud") + .addWebhookEvent(WebhookConfigCreate.WebhookEvent.PARSE_SUCCESS) + .addWebhookEvent(WebhookConfigCreate.WebhookEvent.PARSE_ERROR) + .webhookHeaders( + WebhookConfigCreate.WebhookHeaders.builder() + .putAdditionalProperty("Authorization", JsonValue.from("Bearer sk-...")) + .build() + ) + .webhookOutputFormat(WebhookConfigCreate.WebhookOutputFormat.JSON) + .webhookSigningSecret("whsec_...") + .build() + + val roundtrippedWebhookConfigCreate = + jsonMapper.readValue( + jsonMapper.writeValueAsString(webhookConfigCreate), + jacksonTypeRef(), + ) + + assertThat(roundtrippedWebhookConfigCreate).isEqualTo(webhookConfigCreate) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigDeleteParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigDeleteParamsTest.kt new file mode 100644 index 0000000..4da46f5 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigDeleteParamsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.webhookconfigs + +import ai.llamaindex.llamacloud.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WebhookConfigDeleteParamsTest { + + @Test + fun create() { + WebhookConfigDeleteParams.builder() + .configId("config_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = WebhookConfigDeleteParams.builder().configId("config_id").build() + + assertThat(params._pathParam(0)).isEqualTo("config_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + WebhookConfigDeleteParams.builder() + .configId("config_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = WebhookConfigDeleteParams.builder().configId("config_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigListParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigListParamsTest.kt new file mode 100644 index 0000000..f31bb0c --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigListParamsTest.kt @@ -0,0 +1,46 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.webhookconfigs + +import ai.llamaindex.llamacloud.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WebhookConfigListParamsTest { + + @Test + fun create() { + WebhookConfigListParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun queryParams() { + val params = + WebhookConfigListParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = WebhookConfigListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigResponseTest.kt new file mode 100644 index 0000000..6bb611a --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigResponseTest.kt @@ -0,0 +1,82 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.webhookconfigs + +import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WebhookConfigResponseTest { + + @Test + fun create() { + val webhookConfigResponse = + WebhookConfigResponse.builder() + .id("id") + .hasSecret(true) + .tenantId("tenant_id") + .webhookUrl("webhook_url") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addWebhookEvent(WebhookConfigResponse.WebhookEvent.BATCH_CANCELLED) + .webhookHeaders( + WebhookConfigResponse.WebhookHeaders.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .webhookOutputFormat(WebhookConfigResponse.WebhookOutputFormat.JSON) + .build() + + assertThat(webhookConfigResponse.id()).isEqualTo("id") + assertThat(webhookConfigResponse.hasSecret()).isEqualTo(true) + assertThat(webhookConfigResponse.tenantId()).isEqualTo("tenant_id") + assertThat(webhookConfigResponse.webhookUrl()).isEqualTo("webhook_url") + assertThat(webhookConfigResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(webhookConfigResponse.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(webhookConfigResponse.webhookEvents().getOrNull()) + .containsExactly(WebhookConfigResponse.WebhookEvent.BATCH_CANCELLED) + assertThat(webhookConfigResponse.webhookHeaders()) + .contains( + WebhookConfigResponse.WebhookHeaders.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(webhookConfigResponse.webhookOutputFormat()) + .contains(WebhookConfigResponse.WebhookOutputFormat.JSON) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val webhookConfigResponse = + WebhookConfigResponse.builder() + .id("id") + .hasSecret(true) + .tenantId("tenant_id") + .webhookUrl("webhook_url") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .addWebhookEvent(WebhookConfigResponse.WebhookEvent.BATCH_CANCELLED) + .webhookHeaders( + WebhookConfigResponse.WebhookHeaders.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .webhookOutputFormat(WebhookConfigResponse.WebhookOutputFormat.JSON) + .build() + + val roundtrippedWebhookConfigResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(webhookConfigResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedWebhookConfigResponse).isEqualTo(webhookConfigResponse) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigRetrieveParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigRetrieveParamsTest.kt new file mode 100644 index 0000000..d9632ca --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigRetrieveParamsTest.kt @@ -0,0 +1,57 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.webhookconfigs + +import ai.llamaindex.llamacloud.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WebhookConfigRetrieveParamsTest { + + @Test + fun create() { + WebhookConfigRetrieveParams.builder() + .configId("config_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = WebhookConfigRetrieveParams.builder().configId("config_id").build() + + assertThat(params._pathParam(0)).isEqualTo("config_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + WebhookConfigRetrieveParams.builder() + .configId("config_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = WebhookConfigRetrieveParams.builder().configId("config_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigUpdateParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigUpdateParamsTest.kt new file mode 100644 index 0000000..6626f40 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/webhookconfigs/WebhookConfigUpdateParamsTest.kt @@ -0,0 +1,118 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.webhookconfigs + +import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.core.http.QueryParams +import kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class WebhookConfigUpdateParamsTest { + + @Test + fun create() { + WebhookConfigUpdateParams.builder() + .configId("config_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWebhookEvent(WebhookConfigUpdateParams.WebhookEvent.BATCH_CANCELLED) + .webhookHeaders( + WebhookConfigUpdateParams.WebhookHeaders.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .webhookOutputFormat(WebhookConfigUpdateParams.WebhookOutputFormat.JSON) + .webhookSigningSecret("webhook_signing_secret") + .webhookUrl("webhook_url") + .build() + } + + @Test + fun pathParams() { + val params = WebhookConfigUpdateParams.builder().configId("config_id").build() + + assertThat(params._pathParam(0)).isEqualTo("config_id") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + WebhookConfigUpdateParams.builder() + .configId("config_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWebhookEvent(WebhookConfigUpdateParams.WebhookEvent.BATCH_CANCELLED) + .webhookHeaders( + WebhookConfigUpdateParams.WebhookHeaders.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .webhookOutputFormat(WebhookConfigUpdateParams.WebhookOutputFormat.JSON) + .webhookSigningSecret("webhook_signing_secret") + .webhookUrl("webhook_url") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = WebhookConfigUpdateParams.builder().configId("config_id").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } + + @Test + fun body() { + val params = + WebhookConfigUpdateParams.builder() + .configId("config_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWebhookEvent(WebhookConfigUpdateParams.WebhookEvent.BATCH_CANCELLED) + .webhookHeaders( + WebhookConfigUpdateParams.WebhookHeaders.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .webhookOutputFormat(WebhookConfigUpdateParams.WebhookOutputFormat.JSON) + .webhookSigningSecret("webhook_signing_secret") + .webhookUrl("webhook_url") + .build() + + val body = params._body() + + assertThat(body.webhookEvents().getOrNull()) + .containsExactly(WebhookConfigUpdateParams.WebhookEvent.BATCH_CANCELLED) + assertThat(body.webhookHeaders()) + .contains( + WebhookConfigUpdateParams.WebhookHeaders.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + assertThat(body.webhookOutputFormat()) + .contains(WebhookConfigUpdateParams.WebhookOutputFormat.JSON) + assertThat(body.webhookSigningSecret()).contains("webhook_signing_secret") + assertThat(body.webhookUrl()).contains("webhook_url") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = WebhookConfigUpdateParams.builder().configId("config_id").build() + + val body = params._body() + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncTest.kt index 4bcdfe2..54ed018 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/BatchServiceAsyncTest.kt @@ -4,6 +4,7 @@ package ai.llamaindex.llamacloud.services.async import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClientAsync import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.models.batches.BatchCancelParams import ai.llamaindex.llamacloud.models.batches.BatchCreateParams import ai.llamaindex.llamacloud.models.batches.BatchGetParams import org.junit.jupiter.api.Disabled @@ -75,6 +76,25 @@ internal class BatchServiceAsyncTest { page.response().validate() } + @Disabled("Mock server tests are disabled") + @Test + fun cancel() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val batchServiceAsync = client.batches() + + val responseFuture = + batchServiceAsync.cancel( + BatchCancelParams.builder() + .batchId("batch_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + @Disabled("Mock server tests are disabled") @Test fun get() { diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ClassifyServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ClassifyServiceAsyncTest.kt index cf5490c..83e3267 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ClassifyServiceAsyncTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ClassifyServiceAsyncTest.kt @@ -4,6 +4,7 @@ package ai.llamaindex.llamacloud.services.async import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClientAsync import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.models.classify.ClassifyCancelParams import ai.llamaindex.llamacloud.models.classify.ClassifyConfiguration import ai.llamaindex.llamacloud.models.classify.ClassifyCreateParams import ai.llamaindex.llamacloud.models.classify.ClassifyCreateRequest @@ -98,6 +99,25 @@ internal class ClassifyServiceAsyncTest { page.response().validate() } + @Disabled("Mock server tests are disabled") + @Test + fun cancel() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val classifyServiceAsync = client.classify() + + val responseFuture = + classifyServiceAsync.cancel( + ClassifyCancelParams.builder() + .jobId("job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + @Disabled("Mock server tests are disabled") @Test fun get() { diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsyncTest.kt index 96c1014..c1c0c9e 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsyncTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsyncTest.kt @@ -4,6 +4,7 @@ package ai.llamaindex.llamacloud.services.async import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClientAsync import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.models.extract.ExtractCancelParams import ai.llamaindex.llamacloud.models.extract.ExtractConfiguration import ai.llamaindex.llamacloud.models.extract.ExtractCreateParams import ai.llamaindex.llamacloud.models.extract.ExtractDeleteParams @@ -137,6 +138,25 @@ internal class ExtractServiceAsyncTest { extract.validate() } + @Disabled("Mock server tests are disabled") + @Test + fun cancel() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val extractServiceAsync = client.extract() + + val extractV2JobFuture = + extractServiceAsync.cancel( + ExtractCancelParams.builder() + .jobId("job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val extractV2Job = extractV2JobFuture.get() + extractV2Job.validate() + } + @Disabled("Mock server tests are disabled") @Test fun generateSchema() { diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncTest.kt index be5b91a..d1eb789 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ParsingServiceAsyncTest.kt @@ -380,4 +380,16 @@ internal class ParsingServiceAsyncTest { val parsing = parsingFuture.get() parsing.validate() } + + @Disabled("Mock server tests are disabled") + @Test + fun listVersions() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val parsingServiceAsync = client.parsing() + + val responseFuture = parsingServiceAsync.listVersions() + + val response = responseFuture.get() + response.validate() + } } diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/SplitServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/SplitServiceAsyncTest.kt new file mode 100644 index 0000000..2bbbf36 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/SplitServiceAsyncTest.kt @@ -0,0 +1,143 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.async + +import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClientAsync +import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.models.beta.split.SplitCategory +import ai.llamaindex.llamacloud.models.split.SplitCancelParams +import ai.llamaindex.llamacloud.models.split.SplitCreateParams +import ai.llamaindex.llamacloud.models.split.SplitDeleteParams +import ai.llamaindex.llamacloud.models.split.SplitGetParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class SplitServiceAsyncTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val splitServiceAsync = client.split() + + val splitFuture = + splitServiceAsync.create( + SplitCreateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .configuration( + SplitCreateParams.Configuration.builder() + .addCategory(SplitCategory.builder().name("x").description("x").build()) + .splittingStrategy( + SplitCreateParams.Configuration.SplittingStrategy.builder() + .allowUncategorized( + SplitCreateParams.Configuration.SplittingStrategy + .AllowUncategorized + .FORBID + ) + .build() + ) + .build() + ) + .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .transactionId("tx-unique-idempotency-key") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") + .addWebhookConfiguration( + SplitCreateParams.WebhookConfiguration.builder() + .addWebhookEvent( + SplitCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS + ) + .addWebhookEvent( + SplitCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR + ) + .webhookHeaders( + SplitCreateParams.WebhookConfiguration.WebhookHeaders.builder() + .putAdditionalProperty( + "Authorization", + JsonValue.from("Bearer sk-..."), + ) + .build() + ) + .webhookOutputFormat("json") + .webhookSigningSecret("whsec_...") + .webhookUrl("https://example.com/webhooks/llamacloud") + .build() + ) + .build() + ) + + val split = splitFuture.get() + split.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val splitServiceAsync = client.split() + + val pageFuture = splitServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun delete() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val splitServiceAsync = client.split() + + val splitFuture = + splitServiceAsync.delete( + SplitDeleteParams.builder() + .splitJobId("split_job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val split = splitFuture.get() + split.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun cancel() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val splitServiceAsync = client.split() + + val responseFuture = + splitServiceAsync.cancel( + SplitCancelParams.builder() + .splitJobId("split_job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun get() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val splitServiceAsync = client.split() + + val splitFuture = + splitServiceAsync.get( + SplitGetParams.builder() + .splitJobId("split_job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val split = splitFuture.get() + split.validate() + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/WebhookConfigServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/WebhookConfigServiceAsyncTest.kt new file mode 100644 index 0000000..37effe3 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/WebhookConfigServiceAsyncTest.kt @@ -0,0 +1,135 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.async + +import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClientAsync +import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigCreate +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigCreateParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigDeleteParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigListParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigRetrieveParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class WebhookConfigServiceAsyncTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val webhookConfigServiceAsync = client.webhookConfigs() + + val webhookConfigResponseFuture = + webhookConfigServiceAsync.create( + WebhookConfigCreateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .webhookConfigCreate( + WebhookConfigCreate.builder() + .webhookUrl("https://example.com/webhooks/llamacloud") + .addWebhookEvent(WebhookConfigCreate.WebhookEvent.PARSE_SUCCESS) + .addWebhookEvent(WebhookConfigCreate.WebhookEvent.PARSE_ERROR) + .webhookHeaders( + WebhookConfigCreate.WebhookHeaders.builder() + .putAdditionalProperty( + "Authorization", + JsonValue.from("Bearer sk-..."), + ) + .build() + ) + .webhookOutputFormat(WebhookConfigCreate.WebhookOutputFormat.JSON) + .webhookSigningSecret("whsec_...") + .build() + ) + .build() + ) + + val webhookConfigResponse = webhookConfigResponseFuture.get() + webhookConfigResponse.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun retrieve() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val webhookConfigServiceAsync = client.webhookConfigs() + + val webhookConfigResponseFuture = + webhookConfigServiceAsync.retrieve( + WebhookConfigRetrieveParams.builder() + .configId("config_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val webhookConfigResponse = webhookConfigResponseFuture.get() + webhookConfigResponse.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun update() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val webhookConfigServiceAsync = client.webhookConfigs() + + val webhookConfigResponseFuture = + webhookConfigServiceAsync.update( + WebhookConfigUpdateParams.builder() + .configId("config_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWebhookEvent(WebhookConfigUpdateParams.WebhookEvent.BATCH_CANCELLED) + .webhookHeaders( + WebhookConfigUpdateParams.WebhookHeaders.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .webhookOutputFormat(WebhookConfigUpdateParams.WebhookOutputFormat.JSON) + .webhookSigningSecret("webhook_signing_secret") + .webhookUrl("webhook_url") + .build() + ) + + val webhookConfigResponse = webhookConfigResponseFuture.get() + webhookConfigResponse.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val webhookConfigServiceAsync = client.webhookConfigs() + + val webhookConfigResponsesFuture = + webhookConfigServiceAsync.list( + WebhookConfigListParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val webhookConfigResponses = webhookConfigResponsesFuture.get() + webhookConfigResponses.forEach { it.validate() } + } + + @Disabled("Mock server tests are disabled") + @Test + fun delete() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val webhookConfigServiceAsync = client.webhookConfigs() + + val future = + webhookConfigServiceAsync.delete( + WebhookConfigDeleteParams.builder() + .configId("config_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val response = future.get() + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/pipelines/DocumentServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/pipelines/DocumentServiceAsyncTest.kt index f4ea055..f596d03 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/pipelines/DocumentServiceAsyncTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/pipelines/DocumentServiceAsyncTest.kt @@ -9,6 +9,7 @@ import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentCreateParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentDeleteParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetChunksParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetParams +import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetStatusCountsParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetStatusParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentSyncParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentUpsertParams @@ -131,6 +132,26 @@ internal class DocumentServiceAsyncTest { managedIngestionStatusResponse.validate() } + @Disabled("Mock server tests are disabled") + @Test + fun getStatusCounts() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val documentServiceAsync = client.pipelines().documents() + + val responseFuture = + documentServiceAsync.getStatusCounts( + DocumentGetStatusCountsParams.builder() + .pipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fileId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .onlyDirectUpload(true) + .build() + ) + + val response = responseFuture.get() + response.validate() + } + @Disabled("Mock server tests are disabled") @Test fun sync() { diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceTest.kt index a0da2cb..c122cca 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/BatchServiceTest.kt @@ -4,6 +4,7 @@ package ai.llamaindex.llamacloud.services.blocking import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClient import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.models.batches.BatchCancelParams import ai.llamaindex.llamacloud.models.batches.BatchCreateParams import ai.llamaindex.llamacloud.models.batches.BatchGetParams import org.junit.jupiter.api.Disabled @@ -73,6 +74,24 @@ internal class BatchServiceTest { page.response().validate() } + @Disabled("Mock server tests are disabled") + @Test + fun cancel() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val batchService = client.batches() + + val response = + batchService.cancel( + BatchCancelParams.builder() + .batchId("batch_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + response.validate() + } + @Disabled("Mock server tests are disabled") @Test fun get() { diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ClassifyServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ClassifyServiceTest.kt index 53d2676..d61d8ea 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ClassifyServiceTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ClassifyServiceTest.kt @@ -4,6 +4,7 @@ package ai.llamaindex.llamacloud.services.blocking import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClient import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.models.classify.ClassifyCancelParams import ai.llamaindex.llamacloud.models.classify.ClassifyConfiguration import ai.llamaindex.llamacloud.models.classify.ClassifyCreateParams import ai.llamaindex.llamacloud.models.classify.ClassifyCreateRequest @@ -96,6 +97,24 @@ internal class ClassifyServiceTest { page.response().validate() } + @Disabled("Mock server tests are disabled") + @Test + fun cancel() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val classifyService = client.classify() + + val response = + classifyService.cancel( + ClassifyCancelParams.builder() + .jobId("job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + response.validate() + } + @Disabled("Mock server tests are disabled") @Test fun get() { diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractServiceTest.kt index 5061d11..7a54bb6 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractServiceTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractServiceTest.kt @@ -4,6 +4,7 @@ package ai.llamaindex.llamacloud.services.blocking import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClient import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.models.extract.ExtractCancelParams import ai.llamaindex.llamacloud.models.extract.ExtractConfiguration import ai.llamaindex.llamacloud.models.extract.ExtractCreateParams import ai.llamaindex.llamacloud.models.extract.ExtractDeleteParams @@ -134,6 +135,24 @@ internal class ExtractServiceTest { extract.validate() } + @Disabled("Mock server tests are disabled") + @Test + fun cancel() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val extractService = client.extract() + + val extractV2Job = + extractService.cancel( + ExtractCancelParams.builder() + .jobId("job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + extractV2Job.validate() + } + @Disabled("Mock server tests are disabled") @Test fun generateSchema() { diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceTest.kt index 094fd4f..e72f74c 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ParsingServiceTest.kt @@ -376,4 +376,15 @@ internal class ParsingServiceTest { parsing.validate() } + + @Disabled("Mock server tests are disabled") + @Test + fun listVersions() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val parsingService = client.parsing() + + val response = parsingService.listVersions() + + response.validate() + } } diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/SplitServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/SplitServiceTest.kt new file mode 100644 index 0000000..75572be --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/SplitServiceTest.kt @@ -0,0 +1,138 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.blocking + +import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClient +import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.models.beta.split.SplitCategory +import ai.llamaindex.llamacloud.models.split.SplitCancelParams +import ai.llamaindex.llamacloud.models.split.SplitCreateParams +import ai.llamaindex.llamacloud.models.split.SplitDeleteParams +import ai.llamaindex.llamacloud.models.split.SplitGetParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class SplitServiceTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val splitService = client.split() + + val split = + splitService.create( + SplitCreateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fileInput("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .configuration( + SplitCreateParams.Configuration.builder() + .addCategory(SplitCategory.builder().name("x").description("x").build()) + .splittingStrategy( + SplitCreateParams.Configuration.SplittingStrategy.builder() + .allowUncategorized( + SplitCreateParams.Configuration.SplittingStrategy + .AllowUncategorized + .FORBID + ) + .build() + ) + .build() + ) + .configurationId("cfg-11111111-2222-3333-4444-555555555555") + .transactionId("tx-unique-idempotency-key") + .addWebhookConfigurationId("whc-...") + .addWebhookConfigurationId("whc-...") + .addWebhookConfiguration( + SplitCreateParams.WebhookConfiguration.builder() + .addWebhookEvent( + SplitCreateParams.WebhookConfiguration.WebhookEvent.PARSE_SUCCESS + ) + .addWebhookEvent( + SplitCreateParams.WebhookConfiguration.WebhookEvent.PARSE_ERROR + ) + .webhookHeaders( + SplitCreateParams.WebhookConfiguration.WebhookHeaders.builder() + .putAdditionalProperty( + "Authorization", + JsonValue.from("Bearer sk-..."), + ) + .build() + ) + .webhookOutputFormat("json") + .webhookSigningSecret("whsec_...") + .webhookUrl("https://example.com/webhooks/llamacloud") + .build() + ) + .build() + ) + + split.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val splitService = client.split() + + val page = splitService.list() + + page.response().validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun delete() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val splitService = client.split() + + val split = + splitService.delete( + SplitDeleteParams.builder() + .splitJobId("split_job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + split.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun cancel() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val splitService = client.split() + + val response = + splitService.cancel( + SplitCancelParams.builder() + .splitJobId("split_job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + response.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun get() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val splitService = client.split() + + val split = + splitService.get( + SplitGetParams.builder() + .splitJobId("split_job_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + split.validate() + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/WebhookConfigServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/WebhookConfigServiceTest.kt new file mode 100644 index 0000000..968cc09 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/WebhookConfigServiceTest.kt @@ -0,0 +1,128 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.blocking + +import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClient +import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigCreate +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigCreateParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigDeleteParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigListParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigRetrieveParams +import ai.llamaindex.llamacloud.models.webhookconfigs.WebhookConfigUpdateParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class WebhookConfigServiceTest { + + @Disabled("Mock server tests are disabled") + @Test + fun create() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val webhookConfigService = client.webhookConfigs() + + val webhookConfigResponse = + webhookConfigService.create( + WebhookConfigCreateParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .webhookConfigCreate( + WebhookConfigCreate.builder() + .webhookUrl("https://example.com/webhooks/llamacloud") + .addWebhookEvent(WebhookConfigCreate.WebhookEvent.PARSE_SUCCESS) + .addWebhookEvent(WebhookConfigCreate.WebhookEvent.PARSE_ERROR) + .webhookHeaders( + WebhookConfigCreate.WebhookHeaders.builder() + .putAdditionalProperty( + "Authorization", + JsonValue.from("Bearer sk-..."), + ) + .build() + ) + .webhookOutputFormat(WebhookConfigCreate.WebhookOutputFormat.JSON) + .webhookSigningSecret("whsec_...") + .build() + ) + .build() + ) + + webhookConfigResponse.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun retrieve() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val webhookConfigService = client.webhookConfigs() + + val webhookConfigResponse = + webhookConfigService.retrieve( + WebhookConfigRetrieveParams.builder() + .configId("config_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + webhookConfigResponse.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun update() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val webhookConfigService = client.webhookConfigs() + + val webhookConfigResponse = + webhookConfigService.update( + WebhookConfigUpdateParams.builder() + .configId("config_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addWebhookEvent(WebhookConfigUpdateParams.WebhookEvent.BATCH_CANCELLED) + .webhookHeaders( + WebhookConfigUpdateParams.WebhookHeaders.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .webhookOutputFormat(WebhookConfigUpdateParams.WebhookOutputFormat.JSON) + .webhookSigningSecret("webhook_signing_secret") + .webhookUrl("webhook_url") + .build() + ) + + webhookConfigResponse.validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val webhookConfigService = client.webhookConfigs() + + val webhookConfigResponses = + webhookConfigService.list( + WebhookConfigListParams.builder() + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + webhookConfigResponses.forEach { it.validate() } + } + + @Disabled("Mock server tests are disabled") + @Test + fun delete() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val webhookConfigService = client.webhookConfigs() + + webhookConfigService.delete( + WebhookConfigDeleteParams.builder() + .configId("config_id") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/pipelines/DocumentServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/pipelines/DocumentServiceTest.kt index bb62ad9..cc5aa64 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/pipelines/DocumentServiceTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/pipelines/DocumentServiceTest.kt @@ -9,6 +9,7 @@ import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentCreateParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentDeleteParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetChunksParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetParams +import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetStatusCountsParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentGetStatusParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentSyncParams import ai.llamaindex.llamacloud.models.pipelines.documents.DocumentUpsertParams @@ -123,6 +124,25 @@ internal class DocumentServiceTest { managedIngestionStatusResponse.validate() } + @Disabled("Mock server tests are disabled") + @Test + fun getStatusCounts() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val documentService = client.pipelines().documents() + + val response = + documentService.getStatusCounts( + DocumentGetStatusCountsParams.builder() + .pipelineId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dataSourceId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .fileId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .onlyDirectUpload(true) + .build() + ) + + response.validate() + } + @Disabled("Mock server tests are disabled") @Test fun sync() { diff --git a/llama-cloud-proguard-test/src/test/kotlin/ai/llamaindex/llamacloud/proguard/ProGuardCompatibilityTest.kt b/llama-cloud-proguard-test/src/test/kotlin/ai/llamaindex/llamacloud/proguard/ProGuardCompatibilityTest.kt index 73c1885..10217c0 100644 --- a/llama-cloud-proguard-test/src/test/kotlin/ai/llamaindex/llamacloud/proguard/ProGuardCompatibilityTest.kt +++ b/llama-cloud-proguard-test/src/test/kotlin/ai/llamaindex/llamacloud/proguard/ProGuardCompatibilityTest.kt @@ -52,12 +52,14 @@ internal class ProGuardCompatibilityTest { assertThat(client).isNotNull() assertThat(client.files()).isNotNull() assertThat(client.sheets()).isNotNull() + assertThat(client.split()).isNotNull() assertThat(client.parsing()).isNotNull() assertThat(client.extract()).isNotNull() assertThat(client.classifier()).isNotNull() assertThat(client.batches()).isNotNull() assertThat(client.classify()).isNotNull() assertThat(client.configurations()).isNotNull() + assertThat(client.webhookConfigs()).isNotNull() assertThat(client.projects()).isNotNull() assertThat(client.dataSinks()).isNotNull() assertThat(client.dataSources()).isNotNull() From 94cd22b20d999c5013eb8ff772691e125b95c706 Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Sat, 8 Aug 2026 02:24:59 +0000 Subject: [PATCH 23/28] fix(llamaparse): retry qwen context-overflow 400s with a shrinking OCR anchor (#23817) Stainless-Generated-From: 88b854a7e89d0954f03921855c19e66d00eff16a --- .../configurations/ParseV2Parameters.kt | 36 ++++++++--------- .../models/parsing/ParsingCreateParams.kt | 40 +++++++++---------- .../parsing/ParsingListVersionsResponse.kt | 6 +++ .../ParsingListVersionsResponseTest.kt | 6 +-- 4 files changed, 47 insertions(+), 41 deletions(-) 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 134d4f2..90c3b80 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,7 +142,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-07-23` + * - `cost_effective`: `2026-08-08` * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * @@ -480,7 +480,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-07-23` + * - `cost_effective`: `2026-08-08` * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * @@ -1011,7 +1011,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-07-23` + * - `cost_effective`: `2026-08-08` * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * @@ -1033,9 +1033,9 @@ private constructor( @JvmField val LATEST = of("latest") - @JvmField val _2026_07_24 = of("2026-07-24") + @JvmField val _2026_08_08 = of("2026-08-08") - @JvmField val _2026_07_23 = of("2026-07-23") + @JvmField val _2026_07_24 = of("2026-07-24") @JvmField val _2026_07_08 = of("2026-07-08") @@ -1047,8 +1047,8 @@ private constructor( /** An enum containing [Version]'s known values. */ enum class Known { LATEST, + _2026_08_08, _2026_07_24, - _2026_07_23, _2026_07_08, _2026_06_15, } @@ -1064,8 +1064,8 @@ private constructor( */ enum class Value { LATEST, + _2026_08_08, _2026_07_24, - _2026_07_23, _2026_07_08, _2026_06_15, /** An enum member indicating that [Version] was instantiated with an unknown value. */ @@ -1082,8 +1082,8 @@ private constructor( fun value(): Value = when (this) { LATEST -> Value.LATEST + _2026_08_08 -> Value._2026_08_08 _2026_07_24 -> Value._2026_07_24 - _2026_07_23 -> Value._2026_07_23 _2026_07_08 -> Value._2026_07_08 _2026_06_15 -> Value._2026_06_15 else -> Value._UNKNOWN @@ -1101,8 +1101,8 @@ private constructor( fun known(): Known = when (this) { LATEST -> Known.LATEST + _2026_08_08 -> Known._2026_08_08 _2026_07_24 -> Known._2026_07_24 - _2026_07_23 -> Known._2026_07_23 _2026_07_08 -> Known._2026_07_08 _2026_06_15 -> Known._2026_06_15 else -> throw LlamaCloudInvalidDataException("Unknown Version: $value") @@ -9688,7 +9688,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-07-23` + * - `cost_effective`: `2026-08-08` * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * @@ -10192,7 +10192,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-07-23` + * - `cost_effective`: `2026-08-08` * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * @@ -11806,7 +11806,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-07-23` + * - `cost_effective`: `2026-08-08` * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * @@ -11831,9 +11831,9 @@ private constructor( @JvmField val LATEST = of("latest") - @JvmField val _2026_07_24 = of("2026-07-24") + @JvmField val _2026_08_08 = of("2026-08-08") - @JvmField val _2026_07_23 = of("2026-07-23") + @JvmField val _2026_07_24 = of("2026-07-24") @JvmField val _2026_07_08 = of("2026-07-08") @@ -11845,8 +11845,8 @@ private constructor( /** An enum containing [Version]'s known values. */ enum class Known { LATEST, + _2026_08_08, _2026_07_24, - _2026_07_23, _2026_07_08, _2026_06_15, } @@ -11862,8 +11862,8 @@ private constructor( */ enum class Value { LATEST, + _2026_08_08, _2026_07_24, - _2026_07_23, _2026_07_08, _2026_06_15, /** @@ -11883,8 +11883,8 @@ private constructor( fun value(): Value = when (this) { LATEST -> Value.LATEST + _2026_08_08 -> Value._2026_08_08 _2026_07_24 -> Value._2026_07_24 - _2026_07_23 -> Value._2026_07_23 _2026_07_08 -> Value._2026_07_08 _2026_06_15 -> Value._2026_06_15 else -> Value._UNKNOWN @@ -11902,8 +11902,8 @@ private constructor( fun known(): Known = when (this) { LATEST -> Known.LATEST + _2026_08_08 -> Known._2026_08_08 _2026_07_24 -> Known._2026_07_24 - _2026_07_23 -> Known._2026_07_23 _2026_07_08 -> Known._2026_07_08 _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/parsing/ParsingCreateParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt index 1268e80..001ae71 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingCreateParams.kt @@ -76,7 +76,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-07-23` + * - `cost_effective`: `2026-08-08` * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * @@ -464,7 +464,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-07-23` + * - `cost_effective`: `2026-08-08` * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * @@ -1081,7 +1081,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-07-23` + * - `cost_effective`: `2026-08-08` * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * @@ -1515,7 +1515,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-07-23` + * - `cost_effective`: `2026-08-08` * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * @@ -2216,7 +2216,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-07-23` + * - `cost_effective`: `2026-08-08` * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * @@ -2238,9 +2238,9 @@ private constructor( @JvmField val LATEST = of("latest") - @JvmField val _2026_07_24 = of("2026-07-24") + @JvmField val _2026_08_08 = of("2026-08-08") - @JvmField val _2026_07_23 = of("2026-07-23") + @JvmField val _2026_07_24 = of("2026-07-24") @JvmField val _2026_07_08 = of("2026-07-08") @@ -2252,8 +2252,8 @@ private constructor( /** An enum containing [Version]'s known values. */ enum class Known { LATEST, + _2026_08_08, _2026_07_24, - _2026_07_23, _2026_07_08, _2026_06_15, } @@ -2269,8 +2269,8 @@ private constructor( */ enum class Value { LATEST, + _2026_08_08, _2026_07_24, - _2026_07_23, _2026_07_08, _2026_06_15, /** An enum member indicating that [Version] was instantiated with an unknown value. */ @@ -2287,8 +2287,8 @@ private constructor( fun value(): Value = when (this) { LATEST -> Value.LATEST + _2026_08_08 -> Value._2026_08_08 _2026_07_24 -> Value._2026_07_24 - _2026_07_23 -> Value._2026_07_23 _2026_07_08 -> Value._2026_07_08 _2026_06_15 -> Value._2026_06_15 else -> Value._UNKNOWN @@ -2306,8 +2306,8 @@ private constructor( fun known(): Known = when (this) { LATEST -> Known.LATEST + _2026_08_08 -> Known._2026_08_08 _2026_07_24 -> Known._2026_07_24 - _2026_07_23 -> Known._2026_07_23 _2026_07_08 -> Known._2026_07_08 _2026_06_15 -> Known._2026_06_15 else -> throw LlamaCloudInvalidDataException("Unknown Version: $value") @@ -10893,7 +10893,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-07-23` + * - `cost_effective`: `2026-08-08` * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * @@ -11397,7 +11397,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-07-23` + * - `cost_effective`: `2026-08-08` * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * @@ -13011,7 +13011,7 @@ private constructor( * * Current `latest` by tier: * - `fast`: `2026-06-15` - * - `cost_effective`: `2026-07-23` + * - `cost_effective`: `2026-08-08` * - `agentic`: `2026-07-24` * - `agentic_plus`: `2026-07-08` * @@ -13036,9 +13036,9 @@ private constructor( @JvmField val LATEST = of("latest") - @JvmField val _2026_07_24 = of("2026-07-24") + @JvmField val _2026_08_08 = of("2026-08-08") - @JvmField val _2026_07_23 = of("2026-07-23") + @JvmField val _2026_07_24 = of("2026-07-24") @JvmField val _2026_07_08 = of("2026-07-08") @@ -13050,8 +13050,8 @@ private constructor( /** An enum containing [Version]'s known values. */ enum class Known { LATEST, + _2026_08_08, _2026_07_24, - _2026_07_23, _2026_07_08, _2026_06_15, } @@ -13067,8 +13067,8 @@ private constructor( */ enum class Value { LATEST, + _2026_08_08, _2026_07_24, - _2026_07_23, _2026_07_08, _2026_06_15, /** @@ -13088,8 +13088,8 @@ private constructor( fun value(): Value = when (this) { LATEST -> Value.LATEST + _2026_08_08 -> Value._2026_08_08 _2026_07_24 -> Value._2026_07_24 - _2026_07_23 -> Value._2026_07_23 _2026_07_08 -> Value._2026_07_08 _2026_06_15 -> Value._2026_06_15 else -> Value._UNKNOWN @@ -13107,8 +13107,8 @@ private constructor( fun known(): Known = when (this) { LATEST -> Known.LATEST + _2026_08_08 -> Known._2026_08_08 _2026_07_24 -> Known._2026_07_24 - _2026_07_23 -> Known._2026_07_23 _2026_07_08 -> Known._2026_07_08 _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/parsing/ParsingListVersionsResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsResponse.kt index 8be9a9c..3438f2f 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsResponse.kt @@ -1096,6 +1096,8 @@ private constructor( companion object { + @JvmField val _2026_08_08 = of("2026-08-08") + @JvmField val _2026_07_23 = of("2026-07-23") @JvmField val _2026_06_26 = of("2026-06-26") @@ -1125,6 +1127,7 @@ private constructor( /** An enum containing [CostEffective]'s known values. */ enum class Known { + _2026_08_08, _2026_07_23, _2026_06_26, _2026_06_18, @@ -1149,6 +1152,7 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { + _2026_08_08, _2026_07_23, _2026_06_26, _2026_06_18, @@ -1177,6 +1181,7 @@ private constructor( */ fun value(): Value = when (this) { + _2026_08_08 -> Value._2026_08_08 _2026_07_23 -> Value._2026_07_23 _2026_06_26 -> Value._2026_06_26 _2026_06_18 -> Value._2026_06_18 @@ -1203,6 +1208,7 @@ private constructor( */ fun known(): Known = when (this) { + _2026_08_08 -> Known._2026_08_08 _2026_07_23 -> Known._2026_07_23 _2026_06_26 -> Known._2026_06_26 _2026_06_18 -> Known._2026_06_18 diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsResponseTest.kt index 54147f4..104c37d 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsResponseTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingListVersionsResponseTest.kt @@ -15,7 +15,7 @@ internal class ParsingListVersionsResponseTest { ParsingListVersionsResponse.builder() .addAgentic(ParsingListVersionsResponse.Agentic._2026_07_24) .addAgenticPlus(ParsingListVersionsResponse.AgenticPlus._2026_07_08) - .addCostEffective(ParsingListVersionsResponse.CostEffective._2026_07_23) + .addCostEffective(ParsingListVersionsResponse.CostEffective._2026_08_08) .addFast(ParsingListVersionsResponse.Fast._2026_06_15) .build() @@ -24,7 +24,7 @@ internal class ParsingListVersionsResponseTest { assertThat(parsingListVersionsResponse.agenticPlus()) .containsExactly(ParsingListVersionsResponse.AgenticPlus._2026_07_08) assertThat(parsingListVersionsResponse.costEffective()) - .containsExactly(ParsingListVersionsResponse.CostEffective._2026_07_23) + .containsExactly(ParsingListVersionsResponse.CostEffective._2026_08_08) assertThat(parsingListVersionsResponse.fast()) .containsExactly(ParsingListVersionsResponse.Fast._2026_06_15) } @@ -36,7 +36,7 @@ internal class ParsingListVersionsResponseTest { ParsingListVersionsResponse.builder() .addAgentic(ParsingListVersionsResponse.Agentic._2026_07_24) .addAgenticPlus(ParsingListVersionsResponse.AgenticPlus._2026_07_08) - .addCostEffective(ParsingListVersionsResponse.CostEffective._2026_07_23) + .addCostEffective(ParsingListVersionsResponse.CostEffective._2026_08_08) .addFast(ParsingListVersionsResponse.Fast._2026_06_15) .build() From c82b3ed20961018b01592faa7761c60dfd33bfe8 Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Mon, 10 Aug 2026 22:51:17 +0000 Subject: [PATCH 24/28] feat(forms): emit bboxes in v2 forms output (#23974) Stainless-Generated-From: d4af75a0d8962a31ba5c87280aef4a00b16b9018 --- .../directories/DirectoryCreateResponse.kt | 59 ++++++++- .../beta/directories/DirectoryGetResponse.kt | 59 ++++++++- .../beta/directories/DirectoryListResponse.kt | 59 ++++++++- .../directories/DirectoryUpdateResponse.kt | 59 ++++++++- .../llamacloud/models/parsing/FormField.kt | 57 ++++++++- .../llamacloud/models/parsing/FormTable.kt | 57 ++++++++- .../models/parsing/ParsingGetResponse.kt | 121 +++++++++++++++++- .../DirectoryCreateResponseTest.kt | 3 + .../directories/DirectoryGetResponseTest.kt | 3 + .../DirectoryListPageResponseTest.kt | 3 + .../directories/DirectoryListResponseTest.kt | 3 + .../DirectoryUpdateResponseTest.kt | 3 + .../models/parsing/FormFieldTest.kt | 79 ++++++++++++ .../models/parsing/FormSectionTest.kt | 78 +++++++++++ .../models/parsing/FormTableCellItemsTest.kt | 78 +++++++++++ .../models/parsing/FormTableTest.kt | 40 ++++++ .../llamacloud/models/parsing/FormTest.kt | 78 +++++++++++ .../models/parsing/ParsingGetResponseTest.kt | 84 ++++++++++++ 18 files changed, 909 insertions(+), 14 deletions(-) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryCreateResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryCreateResponse.kt index 90759b7..ee332dc 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryCreateResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryCreateResponse.kt @@ -27,6 +27,7 @@ private constructor( private val id: JsonField, private val name: JsonField, private val projectId: JsonField, + private val connectorSubscriptionId: JsonField, private val createdAt: JsonField, private val deletedAt: JsonField, private val description: JsonField, @@ -42,6 +43,9 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), + @JsonProperty("connector_subscription_id") + @ExcludeMissing + connectorSubscriptionId: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @@ -65,6 +69,7 @@ private constructor( id, name, projectId, + connectorSubscriptionId, createdAt, deletedAt, description, @@ -99,6 +104,16 @@ private constructor( */ fun projectId(): String = projectId.getRequired("project_id") + /** + * Connector Subscription whose files sync into this directory. Null for a directory populated + * by manual uploads. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun connectorSubscriptionId(): Optional = + connectorSubscriptionId.getOptional("connector_subscription_id") + /** * Creation datetime * @@ -176,6 +191,16 @@ private constructor( */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + /** + * Returns the raw JSON value of [connectorSubscriptionId]. + * + * Unlike [connectorSubscriptionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("connector_subscription_id") + @ExcludeMissing + fun _connectorSubscriptionId(): JsonField = connectorSubscriptionId + /** * Returns the raw JSON value of [createdAt]. * @@ -268,6 +293,7 @@ private constructor( private var id: JsonField? = null private var name: JsonField? = null private var projectId: JsonField? = null + private var connectorSubscriptionId: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() private var deletedAt: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() @@ -282,6 +308,7 @@ private constructor( id = directoryCreateResponse.id name = directoryCreateResponse.name projectId = directoryCreateResponse.projectId + connectorSubscriptionId = directoryCreateResponse.connectorSubscriptionId createdAt = directoryCreateResponse.createdAt deletedAt = directoryCreateResponse.deletedAt description = directoryCreateResponse.description @@ -326,6 +353,31 @@ private constructor( */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + /** + * Connector Subscription whose files sync into this directory. Null for a directory + * populated by manual uploads. + */ + fun connectorSubscriptionId(connectorSubscriptionId: String?) = + connectorSubscriptionId(JsonField.ofNullable(connectorSubscriptionId)) + + /** + * Alias for calling [Builder.connectorSubscriptionId] with + * `connectorSubscriptionId.orElse(null)`. + */ + fun connectorSubscriptionId(connectorSubscriptionId: Optional) = + connectorSubscriptionId(connectorSubscriptionId.getOrNull()) + + /** + * Sets [Builder.connectorSubscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.connectorSubscriptionId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun connectorSubscriptionId(connectorSubscriptionId: JsonField) = apply { + this.connectorSubscriptionId = connectorSubscriptionId + } + /** Creation datetime */ fun createdAt(createdAt: OffsetDateTime?) = createdAt(JsonField.ofNullable(createdAt)) @@ -472,6 +524,7 @@ private constructor( checkRequired("id", id), checkRequired("name", name), checkRequired("projectId", projectId), + connectorSubscriptionId, createdAt, deletedAt, description, @@ -501,6 +554,7 @@ private constructor( id() name() projectId() + connectorSubscriptionId() createdAt() deletedAt() description() @@ -529,6 +583,7 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (connectorSubscriptionId.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (if (deletedAt.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + @@ -798,6 +853,7 @@ private constructor( id == other.id && name == other.name && projectId == other.projectId && + connectorSubscriptionId == other.connectorSubscriptionId && createdAt == other.createdAt && deletedAt == other.deletedAt && description == other.description && @@ -813,6 +869,7 @@ private constructor( id, name, projectId, + connectorSubscriptionId, createdAt, deletedAt, description, @@ -827,5 +884,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DirectoryCreateResponse{id=$id, name=$name, projectId=$projectId, createdAt=$createdAt, deletedAt=$deletedAt, description=$description, expiresAt=$expiresAt, systemMetadata=$systemMetadata, type=$type, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" + "DirectoryCreateResponse{id=$id, name=$name, projectId=$projectId, connectorSubscriptionId=$connectorSubscriptionId, createdAt=$createdAt, deletedAt=$deletedAt, description=$description, expiresAt=$expiresAt, systemMetadata=$systemMetadata, type=$type, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryGetResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryGetResponse.kt index 250d16c..e6cf928 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryGetResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryGetResponse.kt @@ -27,6 +27,7 @@ private constructor( private val id: JsonField, private val name: JsonField, private val projectId: JsonField, + private val connectorSubscriptionId: JsonField, private val createdAt: JsonField, private val deletedAt: JsonField, private val description: JsonField, @@ -42,6 +43,9 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), + @JsonProperty("connector_subscription_id") + @ExcludeMissing + connectorSubscriptionId: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @@ -65,6 +69,7 @@ private constructor( id, name, projectId, + connectorSubscriptionId, createdAt, deletedAt, description, @@ -99,6 +104,16 @@ private constructor( */ fun projectId(): String = projectId.getRequired("project_id") + /** + * Connector Subscription whose files sync into this directory. Null for a directory populated + * by manual uploads. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun connectorSubscriptionId(): Optional = + connectorSubscriptionId.getOptional("connector_subscription_id") + /** * Creation datetime * @@ -176,6 +191,16 @@ private constructor( */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + /** + * Returns the raw JSON value of [connectorSubscriptionId]. + * + * Unlike [connectorSubscriptionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("connector_subscription_id") + @ExcludeMissing + fun _connectorSubscriptionId(): JsonField = connectorSubscriptionId + /** * Returns the raw JSON value of [createdAt]. * @@ -268,6 +293,7 @@ private constructor( private var id: JsonField? = null private var name: JsonField? = null private var projectId: JsonField? = null + private var connectorSubscriptionId: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() private var deletedAt: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() @@ -282,6 +308,7 @@ private constructor( id = directoryGetResponse.id name = directoryGetResponse.name projectId = directoryGetResponse.projectId + connectorSubscriptionId = directoryGetResponse.connectorSubscriptionId createdAt = directoryGetResponse.createdAt deletedAt = directoryGetResponse.deletedAt description = directoryGetResponse.description @@ -326,6 +353,31 @@ private constructor( */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + /** + * Connector Subscription whose files sync into this directory. Null for a directory + * populated by manual uploads. + */ + fun connectorSubscriptionId(connectorSubscriptionId: String?) = + connectorSubscriptionId(JsonField.ofNullable(connectorSubscriptionId)) + + /** + * Alias for calling [Builder.connectorSubscriptionId] with + * `connectorSubscriptionId.orElse(null)`. + */ + fun connectorSubscriptionId(connectorSubscriptionId: Optional) = + connectorSubscriptionId(connectorSubscriptionId.getOrNull()) + + /** + * Sets [Builder.connectorSubscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.connectorSubscriptionId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun connectorSubscriptionId(connectorSubscriptionId: JsonField) = apply { + this.connectorSubscriptionId = connectorSubscriptionId + } + /** Creation datetime */ fun createdAt(createdAt: OffsetDateTime?) = createdAt(JsonField.ofNullable(createdAt)) @@ -472,6 +524,7 @@ private constructor( checkRequired("id", id), checkRequired("name", name), checkRequired("projectId", projectId), + connectorSubscriptionId, createdAt, deletedAt, description, @@ -501,6 +554,7 @@ private constructor( id() name() projectId() + connectorSubscriptionId() createdAt() deletedAt() description() @@ -529,6 +583,7 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (connectorSubscriptionId.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (if (deletedAt.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + @@ -798,6 +853,7 @@ private constructor( id == other.id && name == other.name && projectId == other.projectId && + connectorSubscriptionId == other.connectorSubscriptionId && createdAt == other.createdAt && deletedAt == other.deletedAt && description == other.description && @@ -813,6 +869,7 @@ private constructor( id, name, projectId, + connectorSubscriptionId, createdAt, deletedAt, description, @@ -827,5 +884,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DirectoryGetResponse{id=$id, name=$name, projectId=$projectId, createdAt=$createdAt, deletedAt=$deletedAt, description=$description, expiresAt=$expiresAt, systemMetadata=$systemMetadata, type=$type, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" + "DirectoryGetResponse{id=$id, name=$name, projectId=$projectId, connectorSubscriptionId=$connectorSubscriptionId, createdAt=$createdAt, deletedAt=$deletedAt, description=$description, expiresAt=$expiresAt, systemMetadata=$systemMetadata, type=$type, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryListResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryListResponse.kt index 8cbbdf4..be1884a 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryListResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryListResponse.kt @@ -27,6 +27,7 @@ private constructor( private val id: JsonField, private val name: JsonField, private val projectId: JsonField, + private val connectorSubscriptionId: JsonField, private val createdAt: JsonField, private val deletedAt: JsonField, private val description: JsonField, @@ -42,6 +43,9 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), + @JsonProperty("connector_subscription_id") + @ExcludeMissing + connectorSubscriptionId: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @@ -65,6 +69,7 @@ private constructor( id, name, projectId, + connectorSubscriptionId, createdAt, deletedAt, description, @@ -99,6 +104,16 @@ private constructor( */ fun projectId(): String = projectId.getRequired("project_id") + /** + * Connector Subscription whose files sync into this directory. Null for a directory populated + * by manual uploads. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun connectorSubscriptionId(): Optional = + connectorSubscriptionId.getOptional("connector_subscription_id") + /** * Creation datetime * @@ -176,6 +191,16 @@ private constructor( */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + /** + * Returns the raw JSON value of [connectorSubscriptionId]. + * + * Unlike [connectorSubscriptionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("connector_subscription_id") + @ExcludeMissing + fun _connectorSubscriptionId(): JsonField = connectorSubscriptionId + /** * Returns the raw JSON value of [createdAt]. * @@ -268,6 +293,7 @@ private constructor( private var id: JsonField? = null private var name: JsonField? = null private var projectId: JsonField? = null + private var connectorSubscriptionId: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() private var deletedAt: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() @@ -282,6 +308,7 @@ private constructor( id = directoryListResponse.id name = directoryListResponse.name projectId = directoryListResponse.projectId + connectorSubscriptionId = directoryListResponse.connectorSubscriptionId createdAt = directoryListResponse.createdAt deletedAt = directoryListResponse.deletedAt description = directoryListResponse.description @@ -326,6 +353,31 @@ private constructor( */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + /** + * Connector Subscription whose files sync into this directory. Null for a directory + * populated by manual uploads. + */ + fun connectorSubscriptionId(connectorSubscriptionId: String?) = + connectorSubscriptionId(JsonField.ofNullable(connectorSubscriptionId)) + + /** + * Alias for calling [Builder.connectorSubscriptionId] with + * `connectorSubscriptionId.orElse(null)`. + */ + fun connectorSubscriptionId(connectorSubscriptionId: Optional) = + connectorSubscriptionId(connectorSubscriptionId.getOrNull()) + + /** + * Sets [Builder.connectorSubscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.connectorSubscriptionId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun connectorSubscriptionId(connectorSubscriptionId: JsonField) = apply { + this.connectorSubscriptionId = connectorSubscriptionId + } + /** Creation datetime */ fun createdAt(createdAt: OffsetDateTime?) = createdAt(JsonField.ofNullable(createdAt)) @@ -472,6 +524,7 @@ private constructor( checkRequired("id", id), checkRequired("name", name), checkRequired("projectId", projectId), + connectorSubscriptionId, createdAt, deletedAt, description, @@ -501,6 +554,7 @@ private constructor( id() name() projectId() + connectorSubscriptionId() createdAt() deletedAt() description() @@ -529,6 +583,7 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (connectorSubscriptionId.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (if (deletedAt.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + @@ -798,6 +853,7 @@ private constructor( id == other.id && name == other.name && projectId == other.projectId && + connectorSubscriptionId == other.connectorSubscriptionId && createdAt == other.createdAt && deletedAt == other.deletedAt && description == other.description && @@ -813,6 +869,7 @@ private constructor( id, name, projectId, + connectorSubscriptionId, createdAt, deletedAt, description, @@ -827,5 +884,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DirectoryListResponse{id=$id, name=$name, projectId=$projectId, createdAt=$createdAt, deletedAt=$deletedAt, description=$description, expiresAt=$expiresAt, systemMetadata=$systemMetadata, type=$type, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" + "DirectoryListResponse{id=$id, name=$name, projectId=$projectId, connectorSubscriptionId=$connectorSubscriptionId, createdAt=$createdAt, deletedAt=$deletedAt, description=$description, expiresAt=$expiresAt, systemMetadata=$systemMetadata, type=$type, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryUpdateResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryUpdateResponse.kt index 5b5ffa1..31d0315 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryUpdateResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryUpdateResponse.kt @@ -27,6 +27,7 @@ private constructor( private val id: JsonField, private val name: JsonField, private val projectId: JsonField, + private val connectorSubscriptionId: JsonField, private val createdAt: JsonField, private val deletedAt: JsonField, private val description: JsonField, @@ -42,6 +43,9 @@ private constructor( @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), + @JsonProperty("connector_subscription_id") + @ExcludeMissing + connectorSubscriptionId: JsonField = JsonMissing.of(), @JsonProperty("created_at") @ExcludeMissing createdAt: JsonField = JsonMissing.of(), @@ -65,6 +69,7 @@ private constructor( id, name, projectId, + connectorSubscriptionId, createdAt, deletedAt, description, @@ -99,6 +104,16 @@ private constructor( */ fun projectId(): String = projectId.getRequired("project_id") + /** + * Connector Subscription whose files sync into this directory. Null for a directory populated + * by manual uploads. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun connectorSubscriptionId(): Optional = + connectorSubscriptionId.getOptional("connector_subscription_id") + /** * Creation datetime * @@ -176,6 +191,16 @@ private constructor( */ @JsonProperty("project_id") @ExcludeMissing fun _projectId(): JsonField = projectId + /** + * Returns the raw JSON value of [connectorSubscriptionId]. + * + * Unlike [connectorSubscriptionId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("connector_subscription_id") + @ExcludeMissing + fun _connectorSubscriptionId(): JsonField = connectorSubscriptionId + /** * Returns the raw JSON value of [createdAt]. * @@ -268,6 +293,7 @@ private constructor( private var id: JsonField? = null private var name: JsonField? = null private var projectId: JsonField? = null + private var connectorSubscriptionId: JsonField = JsonMissing.of() private var createdAt: JsonField = JsonMissing.of() private var deletedAt: JsonField = JsonMissing.of() private var description: JsonField = JsonMissing.of() @@ -282,6 +308,7 @@ private constructor( id = directoryUpdateResponse.id name = directoryUpdateResponse.name projectId = directoryUpdateResponse.projectId + connectorSubscriptionId = directoryUpdateResponse.connectorSubscriptionId createdAt = directoryUpdateResponse.createdAt deletedAt = directoryUpdateResponse.deletedAt description = directoryUpdateResponse.description @@ -326,6 +353,31 @@ private constructor( */ fun projectId(projectId: JsonField) = apply { this.projectId = projectId } + /** + * Connector Subscription whose files sync into this directory. Null for a directory + * populated by manual uploads. + */ + fun connectorSubscriptionId(connectorSubscriptionId: String?) = + connectorSubscriptionId(JsonField.ofNullable(connectorSubscriptionId)) + + /** + * Alias for calling [Builder.connectorSubscriptionId] with + * `connectorSubscriptionId.orElse(null)`. + */ + fun connectorSubscriptionId(connectorSubscriptionId: Optional) = + connectorSubscriptionId(connectorSubscriptionId.getOrNull()) + + /** + * Sets [Builder.connectorSubscriptionId] to an arbitrary JSON value. + * + * You should usually call [Builder.connectorSubscriptionId] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun connectorSubscriptionId(connectorSubscriptionId: JsonField) = apply { + this.connectorSubscriptionId = connectorSubscriptionId + } + /** Creation datetime */ fun createdAt(createdAt: OffsetDateTime?) = createdAt(JsonField.ofNullable(createdAt)) @@ -472,6 +524,7 @@ private constructor( checkRequired("id", id), checkRequired("name", name), checkRequired("projectId", projectId), + connectorSubscriptionId, createdAt, deletedAt, description, @@ -501,6 +554,7 @@ private constructor( id() name() projectId() + connectorSubscriptionId() createdAt() deletedAt() description() @@ -529,6 +583,7 @@ private constructor( (if (id.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (projectId.asKnown().isPresent) 1 else 0) + + (if (connectorSubscriptionId.asKnown().isPresent) 1 else 0) + (if (createdAt.asKnown().isPresent) 1 else 0) + (if (deletedAt.asKnown().isPresent) 1 else 0) + (if (description.asKnown().isPresent) 1 else 0) + @@ -798,6 +853,7 @@ private constructor( id == other.id && name == other.name && projectId == other.projectId && + connectorSubscriptionId == other.connectorSubscriptionId && createdAt == other.createdAt && deletedAt == other.deletedAt && description == other.description && @@ -813,6 +869,7 @@ private constructor( id, name, projectId, + connectorSubscriptionId, createdAt, deletedAt, description, @@ -827,5 +884,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "DirectoryUpdateResponse{id=$id, name=$name, projectId=$projectId, createdAt=$createdAt, deletedAt=$deletedAt, description=$description, expiresAt=$expiresAt, systemMetadata=$systemMetadata, type=$type, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" + "DirectoryUpdateResponse{id=$id, name=$name, projectId=$projectId, connectorSubscriptionId=$connectorSubscriptionId, createdAt=$createdAt, deletedAt=$deletedAt, description=$description, expiresAt=$expiresAt, systemMetadata=$systemMetadata, type=$type, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/FormField.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/FormField.kt index 9e8c652..adf9ba1 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/FormField.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/FormField.kt @@ -37,6 +37,7 @@ class FormField private constructor( private val field: JsonField, private val id: JsonField, + private val bbox: JsonField>, private val isEmpty: JsonField, private val label: JsonField, private val type: JsonField, @@ -49,6 +50,7 @@ private constructor( private constructor( @JsonProperty("field") @ExcludeMissing field: JsonField = JsonMissing.of(), @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("bbox") @ExcludeMissing bbox: JsonField> = JsonMissing.of(), @JsonProperty("isEmpty") @ExcludeMissing isEmpty: JsonField = JsonMissing.of(), @JsonProperty("label") @ExcludeMissing label: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), @@ -56,7 +58,7 @@ private constructor( @JsonProperty("valueItems") @ExcludeMissing valueItems: JsonField> = JsonMissing.of(), - ) : this(field, id, isEmpty, label, type, value, valueItems, mutableMapOf()) + ) : this(field, id, bbox, isEmpty, label, type, value, valueItems, mutableMapOf()) /** * Kind of entry: text (any free-text input), checkbox, single_select, multi_select, or @@ -75,6 +77,14 @@ private constructor( */ fun id(): Optional = id.getOptional("id") + /** + * Bounding boxes of the field's fillable area on the page. + * + * @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") + /** * True for a printed-but-blank text field (mutually exclusive with value) * @@ -130,6 +140,13 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * 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 [isEmpty]. * @@ -197,6 +214,7 @@ private constructor( private var field: JsonField? = null private var id: JsonField = JsonMissing.of() + private var bbox: JsonField>? = null private var isEmpty: JsonField = JsonMissing.of() private var label: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -208,6 +226,7 @@ private constructor( internal fun from(formField: FormField) = apply { field = formField.field id = formField.id + bbox = formField.bbox.map { it.toMutableList() } isEmpty = formField.isEmpty label = formField.label type = formField.type @@ -244,6 +263,34 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** Bounding boxes of the field's fillable area on the page. */ + 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) + } + } + /** True for a printed-but-blank text field (mutually exclusive with value) */ fun isEmpty(isEmpty: Boolean?) = isEmpty(JsonField.ofNullable(isEmpty)) @@ -422,6 +469,7 @@ private constructor( FormField( checkRequired("field", field), id, + (bbox ?: JsonMissing.of()).map { it.toImmutable() }, isEmpty, label, type, @@ -448,6 +496,7 @@ private constructor( field().validate() id() + bbox().ifPresent { it.forEach { it.validate() } } isEmpty() label() type().ifPresent { it.validate() } @@ -473,6 +522,7 @@ private constructor( internal fun validity(): Int = (field.asKnown().getOrNull()?.validity() ?: 0) + (if (id.asKnown().isPresent) 1 else 0) + + (bbox.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (isEmpty.asKnown().isPresent) 1 else 0) + (if (label.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + @@ -1230,6 +1280,7 @@ private constructor( return other is FormField && field == other.field && id == other.id && + bbox == other.bbox && isEmpty == other.isEmpty && label == other.label && type == other.type && @@ -1239,11 +1290,11 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(field, id, isEmpty, label, type, value, valueItems, additionalProperties) + Objects.hash(field, id, bbox, isEmpty, label, type, value, valueItems, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "FormField{field=$field, id=$id, isEmpty=$isEmpty, label=$label, type=$type, value=$value, valueItems=$valueItems, additionalProperties=$additionalProperties}" + "FormField{field=$field, id=$id, bbox=$bbox, isEmpty=$isEmpty, label=$label, type=$type, value=$value, valueItems=$valueItems, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/FormTable.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/FormTable.kt index 051c181..239426b 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/FormTable.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/FormTable.kt @@ -37,6 +37,7 @@ class FormTable private constructor( private val rows: JsonField>>, private val id: JsonField, + private val bbox: JsonField>, private val columns: JsonField>, private val label: JsonField, private val type: JsonField, @@ -47,12 +48,13 @@ private constructor( private constructor( @JsonProperty("rows") @ExcludeMissing rows: JsonField>> = JsonMissing.of(), @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("bbox") @ExcludeMissing bbox: JsonField> = JsonMissing.of(), @JsonProperty("columns") @ExcludeMissing columns: JsonField> = JsonMissing.of(), @JsonProperty("label") @ExcludeMissing label: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(rows, id, columns, label, type, mutableMapOf()) + ) : this(rows, id, bbox, columns, label, type, mutableMapOf()) /** * Table cells: a verbatim string, null for a printed-but-blank cell, or an object holding the @@ -71,6 +73,14 @@ private constructor( */ fun id(): Optional = id.getOptional("id") + /** + * Bounding boxes of the table's fillable regions on the page. + * + * @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") + /** * Printed column headers in order, if any * @@ -109,6 +119,13 @@ private constructor( */ @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + /** + * 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 [columns]. * @@ -160,6 +177,7 @@ private constructor( private var rows: JsonField>>? = null private var id: JsonField = JsonMissing.of() + private var bbox: JsonField>? = null private var columns: JsonField>? = null private var label: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -169,6 +187,7 @@ private constructor( internal fun from(formTable: FormTable) = apply { rows = formTable.rows.map { it.toMutableList() } id = formTable.id + bbox = formTable.bbox.map { it.toMutableList() } columns = formTable.columns.map { it.toMutableList() } label = formTable.label type = formTable.type @@ -215,6 +234,34 @@ private constructor( */ fun id(id: JsonField) = apply { this.id = id } + /** Bounding boxes of the table's fillable regions on the page. */ + 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) + } + } + /** Printed column headers in order, if any */ fun columns(columns: List?) = columns(JsonField.ofNullable(columns)) @@ -304,6 +351,7 @@ private constructor( FormTable( checkRequired("rows", rows).map { it.toImmutable() }, id, + (bbox ?: JsonMissing.of()).map { it.toImmutable() }, (columns ?: JsonMissing.of()).map { it.toImmutable() }, label, type, @@ -328,6 +376,7 @@ private constructor( rows().forEach { it.forEach { it?.validate() } } id() + bbox().ifPresent { it.forEach { it.validate() } } columns() label() type().ifPresent { it.validate() } @@ -352,6 +401,7 @@ private constructor( (rows.asKnown().getOrNull()?.sumOf { it.sumOf { (it?.validity() ?: 0).toInt() }.toInt() } ?: 0) + (if (id.asKnown().isPresent) 1 else 0) + + (bbox.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (columns.asKnown().getOrNull()?.size ?: 0) + (if (label.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) @@ -714,6 +764,7 @@ private constructor( return other is FormTable && rows == other.rows && id == other.id && + bbox == other.bbox && columns == other.columns && label == other.label && type == other.type && @@ -721,11 +772,11 @@ private constructor( } private val hashCode: Int by lazy { - Objects.hash(rows, id, columns, label, type, additionalProperties) + Objects.hash(rows, id, bbox, columns, label, type, additionalProperties) } override fun hashCode(): Int = hashCode override fun toString() = - "FormTable{rows=$rows, id=$id, columns=$columns, label=$label, type=$type, additionalProperties=$additionalProperties}" + "FormTable{rows=$rows, id=$id, bbox=$bbox, columns=$columns, label=$label, type=$type, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponse.kt index df11bdb..50d796f 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponse.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponse.kt @@ -2062,6 +2062,8 @@ private constructor( private val forms: JsonField>, private val pageNumber: JsonField, private val success: JsonValue, + private val pageHeight: JsonField, + private val pageWidth: JsonField, private val additionalProperties: MutableMap, ) { @@ -2074,7 +2076,13 @@ private constructor( @ExcludeMissing pageNumber: JsonField = JsonMissing.of(), @JsonProperty("success") @ExcludeMissing success: JsonValue = JsonMissing.of(), - ) : this(forms, pageNumber, success, mutableMapOf()) + @JsonProperty("page_height") + @ExcludeMissing + pageHeight: JsonField = JsonMissing.of(), + @JsonProperty("page_width") + @ExcludeMissing + pageWidth: JsonField = JsonMissing.of(), + ) : this(forms, pageNumber, success, pageHeight, pageWidth, mutableMapOf()) /** * Forms detected on the page @@ -2107,6 +2115,22 @@ private constructor( */ @JsonProperty("success") @ExcludeMissing fun _success(): JsonValue = success + /** + * Height of the page in points + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun pageHeight(): Optional = pageHeight.getOptional("page_height") + + /** + * Width of the page in points + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type + * (e.g. if the server responded with an unexpected value). + */ + fun pageWidth(): Optional = pageWidth.getOptional("page_width") + /** * Returns the raw JSON value of [forms]. * @@ -2125,6 +2149,26 @@ private constructor( @ExcludeMissing fun _pageNumber(): JsonField = pageNumber + /** + * Returns the raw JSON value of [pageHeight]. + * + * Unlike [pageHeight], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("page_height") + @ExcludeMissing + fun _pageHeight(): JsonField = pageHeight + + /** + * Returns the raw JSON value of [pageWidth]. + * + * Unlike [pageWidth], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("page_width") + @ExcludeMissing + fun _pageWidth(): JsonField = pageWidth + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -2157,6 +2201,8 @@ private constructor( private var forms: JsonField>? = null private var pageNumber: JsonField? = null private var success: JsonValue = JsonValue.from(true) + private var pageHeight: JsonField = JsonMissing.of() + private var pageWidth: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2164,6 +2210,8 @@ private constructor( forms = formsResultPage.forms.map { it.toMutableList() } pageNumber = formsResultPage.pageNumber success = formsResultPage.success + pageHeight = formsResultPage.pageHeight + pageWidth = formsResultPage.pageWidth additionalProperties = formsResultPage.additionalProperties.toMutableMap() } @@ -2221,6 +2269,56 @@ private constructor( */ fun success(success: JsonValue) = apply { this.success = success } + /** Height of the page in points */ + fun pageHeight(pageHeight: Double?) = + pageHeight(JsonField.ofNullable(pageHeight)) + + /** + * Alias for [Builder.pageHeight]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun pageHeight(pageHeight: Double) = pageHeight(pageHeight as Double?) + + /** Alias for calling [Builder.pageHeight] with `pageHeight.orElse(null)`. */ + fun pageHeight(pageHeight: Optional) = + pageHeight(pageHeight.getOrNull()) + + /** + * Sets [Builder.pageHeight] to an arbitrary JSON value. + * + * You should usually call [Builder.pageHeight] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun pageHeight(pageHeight: JsonField) = apply { + this.pageHeight = pageHeight + } + + /** Width of the page in points */ + fun pageWidth(pageWidth: Double?) = pageWidth(JsonField.ofNullable(pageWidth)) + + /** + * Alias for [Builder.pageWidth]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun pageWidth(pageWidth: Double) = pageWidth(pageWidth as Double?) + + /** Alias for calling [Builder.pageWidth] with `pageWidth.orElse(null)`. */ + fun pageWidth(pageWidth: Optional) = pageWidth(pageWidth.getOrNull()) + + /** + * Sets [Builder.pageWidth] to an arbitrary JSON value. + * + * You should usually call [Builder.pageWidth] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun pageWidth(pageWidth: JsonField) = apply { + this.pageWidth = pageWidth + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2261,6 +2359,8 @@ private constructor( checkRequired("forms", forms).map { it.toImmutable() }, checkRequired("pageNumber", pageNumber), success, + pageHeight, + pageWidth, additionalProperties.toMutableMap(), ) } @@ -2291,6 +2391,8 @@ private constructor( ) } } + pageHeight() + pageWidth() validated = true } @@ -2312,7 +2414,9 @@ private constructor( internal fun validity(): Int = (forms.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (pageNumber.asKnown().isPresent) 1 else 0) + - success.let { if (it == JsonValue.from(true)) 1 else 0 } + success.let { if (it == JsonValue.from(true)) 1 else 0 } + + (if (pageHeight.asKnown().isPresent) 1 else 0) + + (if (pageWidth.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { @@ -2323,17 +2427,26 @@ private constructor( forms == other.forms && pageNumber == other.pageNumber && success == other.success && + pageHeight == other.pageHeight && + pageWidth == other.pageWidth && additionalProperties == other.additionalProperties } private val hashCode: Int by lazy { - Objects.hash(forms, pageNumber, success, additionalProperties) + Objects.hash( + forms, + pageNumber, + success, + pageHeight, + pageWidth, + additionalProperties, + ) } override fun hashCode(): Int = hashCode override fun toString() = - "FormsResultPage{forms=$forms, pageNumber=$pageNumber, success=$success, additionalProperties=$additionalProperties}" + "FormsResultPage{forms=$forms, pageNumber=$pageNumber, success=$success, pageHeight=$pageHeight, pageWidth=$pageWidth, additionalProperties=$additionalProperties}" } /** A page whose processing failed. */ diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryCreateResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryCreateResponseTest.kt index 4d6978b..5b9982f 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryCreateResponseTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryCreateResponseTest.kt @@ -18,6 +18,7 @@ internal class DirectoryCreateResponseTest { .id("id") .name("x") .projectId("project_id") + .connectorSubscriptionId("csub-abc123") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") @@ -34,6 +35,7 @@ internal class DirectoryCreateResponseTest { assertThat(directoryCreateResponse.id()).isEqualTo("id") assertThat(directoryCreateResponse.name()).isEqualTo("x") assertThat(directoryCreateResponse.projectId()).isEqualTo("project_id") + assertThat(directoryCreateResponse.connectorSubscriptionId()).contains("csub-abc123") assertThat(directoryCreateResponse.createdAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(directoryCreateResponse.deletedAt()) @@ -60,6 +62,7 @@ internal class DirectoryCreateResponseTest { .id("id") .name("x") .projectId("project_id") + .connectorSubscriptionId("csub-abc123") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryGetResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryGetResponseTest.kt index 7621471..f4fc2d2 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryGetResponseTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryGetResponseTest.kt @@ -18,6 +18,7 @@ internal class DirectoryGetResponseTest { .id("id") .name("x") .projectId("project_id") + .connectorSubscriptionId("csub-abc123") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") @@ -34,6 +35,7 @@ internal class DirectoryGetResponseTest { assertThat(directoryGetResponse.id()).isEqualTo("id") assertThat(directoryGetResponse.name()).isEqualTo("x") assertThat(directoryGetResponse.projectId()).isEqualTo("project_id") + assertThat(directoryGetResponse.connectorSubscriptionId()).contains("csub-abc123") assertThat(directoryGetResponse.createdAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(directoryGetResponse.deletedAt()) @@ -60,6 +62,7 @@ internal class DirectoryGetResponseTest { .id("id") .name("x") .projectId("project_id") + .connectorSubscriptionId("csub-abc123") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryListPageResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryListPageResponseTest.kt index bbc42e1..f94061e 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryListPageResponseTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryListPageResponseTest.kt @@ -20,6 +20,7 @@ internal class DirectoryListPageResponseTest { .id("id") .name("x") .projectId("project_id") + .connectorSubscriptionId("csub-abc123") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") @@ -43,6 +44,7 @@ internal class DirectoryListPageResponseTest { .id("id") .name("x") .projectId("project_id") + .connectorSubscriptionId("csub-abc123") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") @@ -70,6 +72,7 @@ internal class DirectoryListPageResponseTest { .id("id") .name("x") .projectId("project_id") + .connectorSubscriptionId("csub-abc123") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryListResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryListResponseTest.kt index c376380..6f7e549 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryListResponseTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryListResponseTest.kt @@ -18,6 +18,7 @@ internal class DirectoryListResponseTest { .id("id") .name("x") .projectId("project_id") + .connectorSubscriptionId("csub-abc123") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") @@ -34,6 +35,7 @@ internal class DirectoryListResponseTest { assertThat(directoryListResponse.id()).isEqualTo("id") assertThat(directoryListResponse.name()).isEqualTo("x") assertThat(directoryListResponse.projectId()).isEqualTo("project_id") + assertThat(directoryListResponse.connectorSubscriptionId()).contains("csub-abc123") assertThat(directoryListResponse.createdAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(directoryListResponse.deletedAt()) @@ -60,6 +62,7 @@ internal class DirectoryListResponseTest { .id("id") .name("x") .projectId("project_id") + .connectorSubscriptionId("csub-abc123") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryUpdateResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryUpdateResponseTest.kt index 81b8e72..20d3358 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryUpdateResponseTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/beta/directories/DirectoryUpdateResponseTest.kt @@ -18,6 +18,7 @@ internal class DirectoryUpdateResponseTest { .id("id") .name("x") .projectId("project_id") + .connectorSubscriptionId("csub-abc123") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") @@ -34,6 +35,7 @@ internal class DirectoryUpdateResponseTest { assertThat(directoryUpdateResponse.id()).isEqualTo("id") assertThat(directoryUpdateResponse.name()).isEqualTo("x") assertThat(directoryUpdateResponse.projectId()).isEqualTo("project_id") + assertThat(directoryUpdateResponse.connectorSubscriptionId()).contains("csub-abc123") assertThat(directoryUpdateResponse.createdAt()) .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) assertThat(directoryUpdateResponse.deletedAt()) @@ -60,6 +62,7 @@ internal class DirectoryUpdateResponseTest { .id("id") .name("x") .projectId("project_id") + .connectorSubscriptionId("csub-abc123") .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .deletedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) .description("description") diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/FormFieldTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/FormFieldTest.kt index 811ae74..51b546a 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/FormFieldTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/FormFieldTest.kt @@ -16,6 +16,19 @@ internal class FormFieldTest { FormField.builder() .field(FormField.Field.CHECKBOX) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .isEmpty(true) .label("label") .type(FormField.Type.FIELD) @@ -26,6 +39,19 @@ internal class FormFieldTest { FormTable.builder() .addRow(listOf(FormTable.Row.ofString("string"))) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .addColumn("string") .label("label") .type(FormTable.Type.TABLE) @@ -40,6 +66,20 @@ internal class FormFieldTest { assertThat(formField.field()).isEqualTo(FormField.Field.CHECKBOX) assertThat(formField.id()).contains("id") + assertThat(formField.bbox().getOrNull()) + .containsExactly( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) assertThat(formField.isEmpty()).contains(true) assertThat(formField.label()).contains("label") assertThat(formField.type()).contains(FormField.Type.FIELD) @@ -52,6 +92,19 @@ internal class FormFieldTest { FormTable.builder() .addRow(listOf(FormTable.Row.ofString("string"))) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .addColumn("string") .label("label") .type(FormTable.Type.TABLE) @@ -72,6 +125,19 @@ internal class FormFieldTest { FormField.builder() .field(FormField.Field.CHECKBOX) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .isEmpty(true) .label("label") .type(FormField.Type.FIELD) @@ -82,6 +148,19 @@ internal class FormFieldTest { FormTable.builder() .addRow(listOf(FormTable.Row.ofString("string"))) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .addColumn("string") .label("label") .type(FormTable.Type.TABLE) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/FormSectionTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/FormSectionTest.kt index c80284d..de6482d 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/FormSectionTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/FormSectionTest.kt @@ -17,6 +17,19 @@ internal class FormSectionTest { FormField.builder() .field(FormField.Field.CHECKBOX) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .isEmpty(true) .label("label") .type(FormField.Type.FIELD) @@ -25,6 +38,19 @@ internal class FormSectionTest { FormTable.builder() .addRow(listOf(FormTable.Row.ofString("string"))) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .addColumn("string") .label("label") .type(FormTable.Type.TABLE) @@ -43,6 +69,19 @@ internal class FormSectionTest { FormField.builder() .field(FormField.Field.CHECKBOX) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .isEmpty(true) .label("label") .type(FormField.Type.FIELD) @@ -51,6 +90,19 @@ internal class FormSectionTest { FormTable.builder() .addRow(listOf(FormTable.Row.ofString("string"))) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .addColumn("string") .label("label") .type(FormTable.Type.TABLE) @@ -73,6 +125,19 @@ internal class FormSectionTest { FormField.builder() .field(FormField.Field.CHECKBOX) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .isEmpty(true) .label("label") .type(FormField.Type.FIELD) @@ -81,6 +146,19 @@ internal class FormSectionTest { FormTable.builder() .addRow(listOf(FormTable.Row.ofString("string"))) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .addColumn("string") .label("label") .type(FormTable.Type.TABLE) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/FormTableCellItemsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/FormTableCellItemsTest.kt index 5d3662a..59e1ddd 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/FormTableCellItemsTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/FormTableCellItemsTest.kt @@ -17,6 +17,19 @@ internal class FormTableCellItemsTest { FormField.builder() .field(FormField.Field.CHECKBOX) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .isEmpty(true) .label("label") .type(FormField.Type.FIELD) @@ -27,6 +40,19 @@ internal class FormTableCellItemsTest { FormTable.builder() .addRow(listOf(FormTable.Row.ofString("string"))) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .addColumn("string") .label("label") .type(FormTable.Type.TABLE) @@ -47,6 +73,19 @@ internal class FormTableCellItemsTest { FormField.builder() .field(FormField.Field.CHECKBOX) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .isEmpty(true) .label("label") .type(FormField.Type.FIELD) @@ -57,6 +96,19 @@ internal class FormTableCellItemsTest { FormTable.builder() .addRow(listOf(FormTable.Row.ofString("string"))) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .addColumn("string") .label("label") .type(FormTable.Type.TABLE) @@ -81,6 +133,19 @@ internal class FormTableCellItemsTest { FormField.builder() .field(FormField.Field.CHECKBOX) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .isEmpty(true) .label("label") .type(FormField.Type.FIELD) @@ -91,6 +156,19 @@ internal class FormTableCellItemsTest { FormTable.builder() .addRow(listOf(FormTable.Row.ofString("string"))) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .addColumn("string") .label("label") .type(FormTable.Type.TABLE) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/FormTableTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/FormTableTest.kt index edf38db..7967d7c 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/FormTableTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/FormTableTest.kt @@ -16,6 +16,19 @@ internal class FormTableTest { FormTable.builder() .addRow(listOf(FormTable.Row.ofString("string"))) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .addColumn("string") .label("label") .type(FormTable.Type.TABLE) @@ -23,6 +36,20 @@ internal class FormTableTest { assertThat(formTable.rows()).containsExactly(listOf(FormTable.Row.ofString("string"))) assertThat(formTable.id()).contains("id") + assertThat(formTable.bbox().getOrNull()) + .containsExactly( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) assertThat(formTable.columns().getOrNull()).containsExactly("string") assertThat(formTable.label()).contains("label") assertThat(formTable.type()).contains(FormTable.Type.TABLE) @@ -35,6 +62,19 @@ internal class FormTableTest { FormTable.builder() .addRow(listOf(FormTable.Row.ofString("string"))) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .addColumn("string") .label("label") .type(FormTable.Type.TABLE) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/FormTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/FormTest.kt index 58b3f06..a4909fa 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/FormTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/FormTest.kt @@ -17,6 +17,19 @@ internal class FormTest { FormField.builder() .field(FormField.Field.CHECKBOX) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .isEmpty(true) .label("label") .type(FormField.Type.FIELD) @@ -27,6 +40,19 @@ internal class FormTest { FormTable.builder() .addRow(listOf(FormTable.Row.ofString("string"))) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .addColumn("string") .label("label") .type(FormTable.Type.TABLE) @@ -61,6 +87,19 @@ internal class FormTest { FormField.builder() .field(FormField.Field.CHECKBOX) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .isEmpty(true) .label("label") .type(FormField.Type.FIELD) @@ -71,6 +110,19 @@ internal class FormTest { FormTable.builder() .addRow(listOf(FormTable.Row.ofString("string"))) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .addColumn("string") .label("label") .type(FormTable.Type.TABLE) @@ -110,6 +162,19 @@ internal class FormTest { FormField.builder() .field(FormField.Field.CHECKBOX) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .isEmpty(true) .label("label") .type(FormField.Type.FIELD) @@ -120,6 +185,19 @@ internal class FormTest { FormTable.builder() .addRow(listOf(FormTable.Row.ofString("string"))) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .addColumn("string") .label("label") .type(FormTable.Type.TABLE) diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponseTest.kt index 8f17f38..f366394 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponseTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/parsing/ParsingGetResponseTest.kt @@ -44,6 +44,19 @@ internal class ParsingGetResponseTest { FormField.builder() .field(FormField.Field.CHECKBOX) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .isEmpty(true) .label("label") .type(FormField.Type.FIELD) @@ -60,6 +73,19 @@ internal class ParsingGetResponseTest { ) ) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .addColumn("string") .label("label") .type(FormTable.Type.TABLE) @@ -89,6 +115,8 @@ internal class ParsingGetResponseTest { .build() ) .pageNumber(0L) + .pageHeight(0.0) + .pageWidth(0.0) .build() ) .build() @@ -308,6 +336,19 @@ internal class ParsingGetResponseTest { FormField.builder() .field(FormField.Field.CHECKBOX) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .isEmpty(true) .label("label") .type(FormField.Type.FIELD) @@ -322,6 +363,19 @@ internal class ParsingGetResponseTest { ) ) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .addColumn("string") .label("label") .type(FormTable.Type.TABLE) @@ -351,6 +405,8 @@ internal class ParsingGetResponseTest { .build() ) .pageNumber(0L) + .pageHeight(0.0) + .pageWidth(0.0) .build() ) .build() @@ -573,6 +629,19 @@ internal class ParsingGetResponseTest { FormField.builder() .field(FormField.Field.CHECKBOX) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .isEmpty(true) .label("label") .type(FormField.Type.FIELD) @@ -589,6 +658,19 @@ internal class ParsingGetResponseTest { ) ) .id("id") + .addBbox( + BBox.builder() + .h(0.0) + .w(0.0) + .x(0.0) + .y(0.0) + .confidence(0.0) + .endIndex(0L) + .label("label") + .r(0.0) + .startIndex(0L) + .build() + ) .addColumn("string") .label("label") .type(FormTable.Type.TABLE) @@ -618,6 +700,8 @@ internal class ParsingGetResponseTest { .build() ) .pageNumber(0L) + .pageHeight(0.0) + .pageWidth(0.0) .build() ) .build() From 457316555a6d715ead4643063a555fafdf4abaa9 Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Tue, 11 Aug 2026 01:49:55 +0000 Subject: [PATCH 25/28] LI-8754 follow-up: surface the endpoints the console actively consumes Stainless-Generated-From: c6d811aff942f25b349388d763e50904d0e18dc3 --- .stats.yml | 2 +- .../llamacloud/client/LlamaCloudClient.kt | 10 + .../client/LlamaCloudClientAsync.kt | 10 + .../client/LlamaCloudClientAsyncImpl.kt | 28 + .../llamacloud/client/LlamaCloudClientImpl.kt | 28 + .../models/files/FileRetrieveParams.kt | 258 +++++ .../models/files/FileRetrieveResponse.kt | 539 +++++++++++ .../models/jobdatapoints/JobDataPoint.kt | 879 ++++++++++++++++++ .../jobdatapoints/JobDataPointListPage.kt | 131 +++ .../JobDataPointListPageAsync.kt | 145 +++ .../JobDataPointListPageResponse.kt | 303 ++++++ .../jobdatapoints/JobDataPointListParams.kt | 525 +++++++++++ .../models/v2projects/V2ProjectGetParams.kt | 213 +++++ .../models/v2projects/V2ProjectGetResponse.kt | 397 ++++++++ .../models/v2projects/V2ProjectListPage.kt | 131 +++ .../v2projects/V2ProjectListPageAsync.kt | 146 +++ .../v2projects/V2ProjectListPageResponse.kt | 305 ++++++ .../models/v2projects/V2ProjectListParams.kt | 248 +++++ .../v2projects/V2ProjectListResponse.kt | 397 ++++++++ .../services/async/FileServiceAsync.kt | 78 ++ .../services/async/FileServiceAsyncImpl.kt | 42 + .../async/JobDataPointServiceAsync.kt | 67 ++ .../async/JobDataPointServiceAsyncImpl.kt | 93 ++ .../services/async/V2ProjectServiceAsync.kt | 162 ++++ .../async/V2ProjectServiceAsyncImpl.kt | 137 +++ .../services/blocking/FileService.kt | 76 ++ .../services/blocking/FileServiceImpl.kt | 39 + .../services/blocking/JobDataPointService.kt | 66 ++ .../blocking/JobDataPointServiceImpl.kt | 88 ++ .../services/blocking/V2ProjectService.kt | 154 +++ .../services/blocking/V2ProjectServiceImpl.kt | 129 +++ .../models/files/FileRetrieveParamsTest.kt | 65 ++ .../models/files/FileRetrieveResponseTest.kt | 98 ++ .../JobDataPointListPageResponseTest.kt | 106 +++ .../JobDataPointListParamsTest.kt | 72 ++ .../models/jobdatapoints/JobDataPointTest.kt | 88 ++ .../v2projects/V2ProjectGetParamsTest.kt | 56 ++ .../v2projects/V2ProjectGetResponseTest.kt | 56 ++ .../V2ProjectListPageResponseTest.kt | 73 ++ .../v2projects/V2ProjectListParamsTest.kt | 52 ++ .../v2projects/V2ProjectListResponseTest.kt | 56 ++ .../services/async/FileServiceAsyncTest.kt | 22 + .../async/JobDataPointServiceAsyncTest.kt | 28 + .../async/V2ProjectServiceAsyncTest.kt | 41 + .../services/blocking/FileServiceTest.kt | 21 + .../blocking/JobDataPointServiceTest.kt | 27 + .../services/blocking/V2ProjectServiceTest.kt | 39 + .../proguard/ProGuardCompatibilityTest.kt | 2 + 48 files changed, 6727 insertions(+), 1 deletion(-) create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/files/FileRetrieveParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/files/FileRetrieveResponse.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPoint.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListPage.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListPageAsync.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListPageResponse.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectGetParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectGetResponse.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListPage.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListPageAsync.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListPageResponse.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListParams.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListResponse.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/JobDataPointServiceAsync.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/JobDataPointServiceAsyncImpl.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/V2ProjectServiceAsync.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/V2ProjectServiceAsyncImpl.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/JobDataPointService.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/JobDataPointServiceImpl.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/V2ProjectService.kt create mode 100644 llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/V2ProjectServiceImpl.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/files/FileRetrieveParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/files/FileRetrieveResponseTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListPageResponseTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectGetParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectGetResponseTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListPageResponseTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListParamsTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListResponseTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/JobDataPointServiceAsyncTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/V2ProjectServiceAsyncTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/JobDataPointServiceTest.kt create mode 100644 llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/V2ProjectServiceTest.kt diff --git a/.stats.yml b/.stats.yml index 953d452..77de729 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 146 +configured_endpoints: 150 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 304e7fd..77ad4dd 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 @@ -12,12 +12,14 @@ 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.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 import ai.llamaindex.llamacloud.services.blocking.RetrieverService import ai.llamaindex.llamacloud.services.blocking.SheetService import ai.llamaindex.llamacloud.services.blocking.SplitService +import ai.llamaindex.llamacloud.services.blocking.V2ProjectService import ai.llamaindex.llamacloud.services.blocking.WebhookConfigService import java.util.function.Consumer @@ -79,6 +81,10 @@ interface LlamaCloudClient { fun projects(): ProjectService + fun v2Projects(): V2ProjectService + + fun jobDataPoints(): JobDataPointService + fun dataSinks(): DataSinkService fun dataSources(): DataSourceService @@ -134,6 +140,10 @@ interface LlamaCloudClient { fun projects(): ProjectService.WithRawResponse + fun v2Projects(): V2ProjectService.WithRawResponse + + fun jobDataPoints(): JobDataPointService.WithRawResponse + fun dataSinks(): DataSinkService.WithRawResponse fun dataSources(): DataSourceService.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 565d45d..a8d90c0 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 @@ -12,12 +12,14 @@ 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.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 import ai.llamaindex.llamacloud.services.async.RetrieverServiceAsync import ai.llamaindex.llamacloud.services.async.SheetServiceAsync import ai.llamaindex.llamacloud.services.async.SplitServiceAsync +import ai.llamaindex.llamacloud.services.async.V2ProjectServiceAsync import ai.llamaindex.llamacloud.services.async.WebhookConfigServiceAsync import java.util.function.Consumer @@ -79,6 +81,10 @@ interface LlamaCloudClientAsync { fun projects(): ProjectServiceAsync + fun v2Projects(): V2ProjectServiceAsync + + fun jobDataPoints(): JobDataPointServiceAsync + fun dataSinks(): DataSinkServiceAsync fun dataSources(): DataSourceServiceAsync @@ -138,6 +144,10 @@ interface LlamaCloudClientAsync { fun projects(): ProjectServiceAsync.WithRawResponse + fun v2Projects(): V2ProjectServiceAsync.WithRawResponse + + fun jobDataPoints(): JobDataPointServiceAsync.WithRawResponse + fun dataSinks(): DataSinkServiceAsync.WithRawResponse fun dataSources(): DataSourceServiceAsync.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 3587fb4..2cf79cd 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 @@ -22,6 +22,8 @@ import ai.llamaindex.llamacloud.services.async.ExtractServiceAsync import ai.llamaindex.llamacloud.services.async.ExtractServiceAsyncImpl 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 @@ -34,6 +36,8 @@ import ai.llamaindex.llamacloud.services.async.SheetServiceAsync import ai.llamaindex.llamacloud.services.async.SheetServiceAsyncImpl import ai.llamaindex.llamacloud.services.async.SplitServiceAsync import ai.llamaindex.llamacloud.services.async.SplitServiceAsyncImpl +import ai.llamaindex.llamacloud.services.async.V2ProjectServiceAsync +import ai.llamaindex.llamacloud.services.async.V2ProjectServiceAsyncImpl import ai.llamaindex.llamacloud.services.async.WebhookConfigServiceAsync import ai.llamaindex.llamacloud.services.async.WebhookConfigServiceAsyncImpl import java.util.function.Consumer @@ -97,6 +101,14 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam ProjectServiceAsyncImpl(clientOptionsWithUserAgent) } + private val v2Projects: V2ProjectServiceAsync by lazy { + V2ProjectServiceAsyncImpl(clientOptionsWithUserAgent) + } + + private val jobDataPoints: JobDataPointServiceAsync by lazy { + JobDataPointServiceAsyncImpl(clientOptionsWithUserAgent) + } + private val dataSinks: DataSinkServiceAsync by lazy { DataSinkServiceAsyncImpl(clientOptionsWithUserAgent) } @@ -144,6 +156,10 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam override fun projects(): ProjectServiceAsync = projects + override fun v2Projects(): V2ProjectServiceAsync = v2Projects + + override fun jobDataPoints(): JobDataPointServiceAsync = jobDataPoints + override fun dataSinks(): DataSinkServiceAsync = dataSinks override fun dataSources(): DataSourceServiceAsync = dataSources @@ -203,6 +219,14 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam ProjectServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val v2Projects: V2ProjectServiceAsync.WithRawResponse by lazy { + V2ProjectServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + + private val jobDataPoints: JobDataPointServiceAsync.WithRawResponse by lazy { + JobDataPointServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + private val dataSinks: DataSinkServiceAsync.WithRawResponse by lazy { DataSinkServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -252,6 +276,10 @@ class LlamaCloudClientAsyncImpl(private val clientOptions: ClientOptions) : Llam override fun projects(): ProjectServiceAsync.WithRawResponse = projects + override fun v2Projects(): V2ProjectServiceAsync.WithRawResponse = v2Projects + + override fun jobDataPoints(): JobDataPointServiceAsync.WithRawResponse = jobDataPoints + override fun dataSinks(): DataSinkServiceAsync.WithRawResponse = dataSinks override fun dataSources(): DataSourceServiceAsync.WithRawResponse = dataSources 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 891f102..0a4639e 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 @@ -22,6 +22,8 @@ import ai.llamaindex.llamacloud.services.blocking.ExtractService import ai.llamaindex.llamacloud.services.blocking.ExtractServiceImpl 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 @@ -34,6 +36,8 @@ import ai.llamaindex.llamacloud.services.blocking.SheetService import ai.llamaindex.llamacloud.services.blocking.SheetServiceImpl import ai.llamaindex.llamacloud.services.blocking.SplitService import ai.llamaindex.llamacloud.services.blocking.SplitServiceImpl +import ai.llamaindex.llamacloud.services.blocking.V2ProjectService +import ai.llamaindex.llamacloud.services.blocking.V2ProjectServiceImpl import ai.llamaindex.llamacloud.services.blocking.WebhookConfigService import ai.llamaindex.llamacloud.services.blocking.WebhookConfigServiceImpl import java.util.function.Consumer @@ -85,6 +89,14 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou private val projects: ProjectService by lazy { ProjectServiceImpl(clientOptionsWithUserAgent) } + private val v2Projects: V2ProjectService by lazy { + V2ProjectServiceImpl(clientOptionsWithUserAgent) + } + + private val jobDataPoints: JobDataPointService by lazy { + JobDataPointServiceImpl(clientOptionsWithUserAgent) + } + private val dataSinks: DataSinkService by lazy { DataSinkServiceImpl(clientOptionsWithUserAgent) } @@ -132,6 +144,10 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou override fun projects(): ProjectService = projects + override fun v2Projects(): V2ProjectService = v2Projects + + override fun jobDataPoints(): JobDataPointService = jobDataPoints + override fun dataSinks(): DataSinkService = dataSinks override fun dataSources(): DataSourceService = dataSources @@ -191,6 +207,14 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou ProjectServiceImpl.WithRawResponseImpl(clientOptions) } + private val v2Projects: V2ProjectService.WithRawResponse by lazy { + V2ProjectServiceImpl.WithRawResponseImpl(clientOptions) + } + + private val jobDataPoints: JobDataPointService.WithRawResponse by lazy { + JobDataPointServiceImpl.WithRawResponseImpl(clientOptions) + } + private val dataSinks: DataSinkService.WithRawResponse by lazy { DataSinkServiceImpl.WithRawResponseImpl(clientOptions) } @@ -240,6 +264,10 @@ class LlamaCloudClientImpl(private val clientOptions: ClientOptions) : LlamaClou override fun projects(): ProjectService.WithRawResponse = projects + override fun v2Projects(): V2ProjectService.WithRawResponse = v2Projects + + override fun jobDataPoints(): JobDataPointService.WithRawResponse = jobDataPoints + override fun dataSinks(): DataSinkService.WithRawResponse = dataSinks override fun dataSources(): DataSourceService.WithRawResponse = dataSources diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/files/FileRetrieveParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/files/FileRetrieveParams.kt new file mode 100644 index 0000000..92a45e2 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/files/FileRetrieveParams.kt @@ -0,0 +1,258 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.files + +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 + +/** Get file metadata by ID. */ +class FileRetrieveParams +private constructor( + private val fileId: String?, + private val expand: List?, + private val organizationId: String?, + private val projectId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun fileId(): Optional = Optional.ofNullable(fileId) + + /** Fields to expand. */ + fun expand(): Optional> = Optional.ofNullable(expand) + + 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 { + + @JvmStatic fun none(): FileRetrieveParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [FileRetrieveParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileRetrieveParams]. */ + class Builder internal constructor() { + + private var fileId: String? = null + private var expand: MutableList? = 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(fileRetrieveParams: FileRetrieveParams) = apply { + fileId = fileRetrieveParams.fileId + expand = fileRetrieveParams.expand?.toMutableList() + organizationId = fileRetrieveParams.organizationId + projectId = fileRetrieveParams.projectId + additionalHeaders = fileRetrieveParams.additionalHeaders.toBuilder() + additionalQueryParams = fileRetrieveParams.additionalQueryParams.toBuilder() + } + + fun fileId(fileId: String?) = apply { this.fileId = fileId } + + /** Alias for calling [Builder.fileId] with `fileId.orElse(null)`. */ + fun fileId(fileId: Optional) = fileId(fileId.getOrNull()) + + /** Fields to expand. */ + fun expand(expand: List?) = apply { this.expand = expand?.toMutableList() } + + /** Alias for calling [Builder.expand] with `expand.orElse(null)`. */ + fun expand(expand: Optional>) = expand(expand.getOrNull()) + + /** + * Adds a single [String] to [Builder.expand]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addExpand(expand: String) = apply { + this.expand = (this.expand ?: mutableListOf()).apply { add(expand) } + } + + 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 [FileRetrieveParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): FileRetrieveParams = + FileRetrieveParams( + fileId, + expand?.toImmutable(), + organizationId, + projectId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> fileId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + expand?.forEach { put("expand", it) } + 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 FileRetrieveParams && + fileId == other.fileId && + expand == other.expand && + organizationId == other.organizationId && + projectId == other.projectId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + fileId, + expand, + organizationId, + projectId, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "FileRetrieveParams{fileId=$fileId, expand=$expand, organizationId=$organizationId, projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/files/FileRetrieveResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/files/FileRetrieveResponse.kt new file mode 100644 index 0000000..68ec379 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/files/FileRetrieveResponse.kt @@ -0,0 +1,539 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.files + +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 + +/** An uploaded file. */ +class FileRetrieveResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val name: JsonField, + private val projectId: JsonField, + private val downloadUrl: JsonField, + private val expiresAt: JsonField, + private val externalFileId: JsonField, + private val fileType: JsonField, + private val lastModifiedAt: JsonField, + private val purpose: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("project_id") @ExcludeMissing projectId: JsonField = JsonMissing.of(), + @JsonProperty("download_url") + @ExcludeMissing + downloadUrl: JsonField = JsonMissing.of(), + @JsonProperty("expires_at") + @ExcludeMissing + expiresAt: JsonField = JsonMissing.of(), + @JsonProperty("external_file_id") + @ExcludeMissing + externalFileId: JsonField = JsonMissing.of(), + @JsonProperty("file_type") @ExcludeMissing fileType: JsonField = JsonMissing.of(), + @JsonProperty("last_modified_at") + @ExcludeMissing + lastModifiedAt: JsonField = JsonMissing.of(), + @JsonProperty("purpose") @ExcludeMissing purpose: JsonField = JsonMissing.of(), + ) : this( + id, + name, + projectId, + downloadUrl, + expiresAt, + externalFileId, + fileType, + lastModifiedAt, + purpose, + mutableMapOf(), + ) + + /** + * Unique file identifier + * + * @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") + + /** + * File name including extension + * + * @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") + + /** + * Project this file 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") + + /** + * Schema for a presigned URL. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun downloadUrl(): Optional = downloadUrl.getOptional("download_url") + + /** + * When the file expires and may be automatically removed. Null means no expiration. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun expiresAt(): Optional = expiresAt.getOptional("expires_at") + + /** + * Optional ID for correlating with an external system + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun externalFileId(): Optional = externalFileId.getOptional("external_file_id") + + /** + * File extension (pdf, docx, png, etc.) + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun fileType(): Optional = fileType.getOptional("file_type") + + /** + * When the file was last modified (ISO 8601) + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun lastModifiedAt(): Optional = lastModifiedAt.getOptional("last_modified_at") + + /** + * How the file will be used: user_data, parse, extract, classify, split, sheet, or agent_app + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun purpose(): Optional = purpose.getOptional("purpose") + + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [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 [downloadUrl]. + * + * Unlike [downloadUrl], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("download_url") + @ExcludeMissing + fun _downloadUrl(): JsonField = downloadUrl + + /** + * Returns the raw JSON value of [expiresAt]. + * + * Unlike [expiresAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("expires_at") + @ExcludeMissing + fun _expiresAt(): JsonField = expiresAt + + /** + * Returns the raw JSON value of [externalFileId]. + * + * Unlike [externalFileId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("external_file_id") + @ExcludeMissing + fun _externalFileId(): JsonField = externalFileId + + /** + * Returns the raw JSON value of [fileType]. + * + * Unlike [fileType], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("file_type") @ExcludeMissing fun _fileType(): JsonField = fileType + + /** + * Returns the raw JSON value of [lastModifiedAt]. + * + * Unlike [lastModifiedAt], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("last_modified_at") + @ExcludeMissing + fun _lastModifiedAt(): JsonField = lastModifiedAt + + /** + * Returns the raw JSON value of [purpose]. + * + * Unlike [purpose], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("purpose") @ExcludeMissing fun _purpose(): JsonField = purpose + + @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 [FileRetrieveResponse]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .projectId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [FileRetrieveResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var name: JsonField? = null + private var projectId: JsonField? = null + private var downloadUrl: JsonField = JsonMissing.of() + private var expiresAt: JsonField = JsonMissing.of() + private var externalFileId: JsonField = JsonMissing.of() + private var fileType: JsonField = JsonMissing.of() + private var lastModifiedAt: JsonField = JsonMissing.of() + private var purpose: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(fileRetrieveResponse: FileRetrieveResponse) = apply { + id = fileRetrieveResponse.id + name = fileRetrieveResponse.name + projectId = fileRetrieveResponse.projectId + downloadUrl = fileRetrieveResponse.downloadUrl + expiresAt = fileRetrieveResponse.expiresAt + externalFileId = fileRetrieveResponse.externalFileId + fileType = fileRetrieveResponse.fileType + lastModifiedAt = fileRetrieveResponse.lastModifiedAt + purpose = fileRetrieveResponse.purpose + additionalProperties = fileRetrieveResponse.additionalProperties.toMutableMap() + } + + /** Unique file identifier */ + 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 } + + /** File name including extension */ + 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 } + + /** Project this file 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 } + + /** Schema for a presigned URL. */ + fun downloadUrl(downloadUrl: PresignedUrl?) = downloadUrl(JsonField.ofNullable(downloadUrl)) + + /** Alias for calling [Builder.downloadUrl] with `downloadUrl.orElse(null)`. */ + fun downloadUrl(downloadUrl: Optional) = downloadUrl(downloadUrl.getOrNull()) + + /** + * Sets [Builder.downloadUrl] to an arbitrary JSON value. + * + * You should usually call [Builder.downloadUrl] with a well-typed [PresignedUrl] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun downloadUrl(downloadUrl: JsonField) = apply { + this.downloadUrl = downloadUrl + } + + /** When the file expires and may be automatically removed. Null means no expiration. */ + fun expiresAt(expiresAt: OffsetDateTime?) = expiresAt(JsonField.ofNullable(expiresAt)) + + /** Alias for calling [Builder.expiresAt] with `expiresAt.orElse(null)`. */ + fun expiresAt(expiresAt: Optional) = expiresAt(expiresAt.getOrNull()) + + /** + * Sets [Builder.expiresAt] to an arbitrary JSON value. + * + * You should usually call [Builder.expiresAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun expiresAt(expiresAt: JsonField) = apply { this.expiresAt = expiresAt } + + /** Optional ID for correlating with an external system */ + fun externalFileId(externalFileId: String?) = + externalFileId(JsonField.ofNullable(externalFileId)) + + /** Alias for calling [Builder.externalFileId] with `externalFileId.orElse(null)`. */ + fun externalFileId(externalFileId: Optional) = + externalFileId(externalFileId.getOrNull()) + + /** + * Sets [Builder.externalFileId] to an arbitrary JSON value. + * + * You should usually call [Builder.externalFileId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun externalFileId(externalFileId: JsonField) = apply { + this.externalFileId = externalFileId + } + + /** File extension (pdf, docx, png, etc.) */ + fun fileType(fileType: String?) = fileType(JsonField.ofNullable(fileType)) + + /** Alias for calling [Builder.fileType] with `fileType.orElse(null)`. */ + fun fileType(fileType: Optional) = fileType(fileType.getOrNull()) + + /** + * Sets [Builder.fileType] to an arbitrary JSON value. + * + * You should usually call [Builder.fileType] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun fileType(fileType: JsonField) = apply { this.fileType = fileType } + + /** When the file was last modified (ISO 8601) */ + fun lastModifiedAt(lastModifiedAt: OffsetDateTime?) = + lastModifiedAt(JsonField.ofNullable(lastModifiedAt)) + + /** Alias for calling [Builder.lastModifiedAt] with `lastModifiedAt.orElse(null)`. */ + fun lastModifiedAt(lastModifiedAt: Optional) = + lastModifiedAt(lastModifiedAt.getOrNull()) + + /** + * Sets [Builder.lastModifiedAt] to an arbitrary JSON value. + * + * You should usually call [Builder.lastModifiedAt] with a well-typed [OffsetDateTime] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun lastModifiedAt(lastModifiedAt: JsonField) = apply { + this.lastModifiedAt = lastModifiedAt + } + + /** + * How the file will be used: user_data, parse, extract, classify, split, sheet, or + * agent_app + */ + fun purpose(purpose: String?) = purpose(JsonField.ofNullable(purpose)) + + /** Alias for calling [Builder.purpose] with `purpose.orElse(null)`. */ + fun purpose(purpose: Optional) = purpose(purpose.getOrNull()) + + /** + * Sets [Builder.purpose] to an arbitrary JSON value. + * + * You should usually call [Builder.purpose] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun purpose(purpose: JsonField) = apply { this.purpose = purpose } + + 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 [FileRetrieveResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .projectId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): FileRetrieveResponse = + FileRetrieveResponse( + checkRequired("id", id), + checkRequired("name", name), + checkRequired("projectId", projectId), + downloadUrl, + expiresAt, + externalFileId, + fileType, + lastModifiedAt, + purpose, + 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(): FileRetrieveResponse = apply { + if (validated) { + return@apply + } + + id() + name() + projectId() + downloadUrl().ifPresent { it.validate() } + expiresAt() + externalFileId() + fileType() + lastModifiedAt() + purpose() + 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 (name.asKnown().isPresent) 1 else 0) + + (if (projectId.asKnown().isPresent) 1 else 0) + + (downloadUrl.asKnown().getOrNull()?.validity() ?: 0) + + (if (expiresAt.asKnown().isPresent) 1 else 0) + + (if (externalFileId.asKnown().isPresent) 1 else 0) + + (if (fileType.asKnown().isPresent) 1 else 0) + + (if (lastModifiedAt.asKnown().isPresent) 1 else 0) + + (if (purpose.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is FileRetrieveResponse && + id == other.id && + name == other.name && + projectId == other.projectId && + downloadUrl == other.downloadUrl && + expiresAt == other.expiresAt && + externalFileId == other.externalFileId && + fileType == other.fileType && + lastModifiedAt == other.lastModifiedAt && + purpose == other.purpose && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + name, + projectId, + downloadUrl, + expiresAt, + externalFileId, + fileType, + lastModifiedAt, + purpose, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "FileRetrieveResponse{id=$id, name=$name, projectId=$projectId, downloadUrl=$downloadUrl, expiresAt=$expiresAt, externalFileId=$externalFileId, fileType=$fileType, lastModifiedAt=$lastModifiedAt, purpose=$purpose, additionalProperties=$additionalProperties}" +} 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 new file mode 100644 index 0000000..cd5a243 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPoint.kt @@ -0,0 +1,879 @@ +// 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/JobDataPointListPage.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListPage.kt new file mode 100644 index 0000000..78eb924 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListPage.kt @@ -0,0 +1,131 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.jobdatapoints + +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 java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see JobDataPointService.list */ +class JobDataPointListPage +private constructor( + private val service: JobDataPointService, + private val params: JobDataPointListParams, + private val response: JobDataPointListPageResponse, +) : Page { + + /** + * Delegates to [JobDataPointListPageResponse], but gracefully handles missing data. + * + * @see JobDataPointListPageResponse.items + */ + override fun items(): List = + response._items().getOptional("items").getOrNull() ?: emptyList() + + /** + * Delegates to [JobDataPointListPageResponse], but gracefully handles missing data. + * + * @see JobDataPointListPageResponse.nextPageToken + */ + fun nextPageToken(): Optional = response._nextPageToken().getOptional("next_page_token") + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageToken().isPresent + + fun nextPageParams(): JobDataPointListParams { + val nextCursor = + nextPageToken().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().pageToken(nextCursor).build() + } + + override fun nextPage(): JobDataPointListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): JobDataPointListParams = params + + /** The response that this page was parsed from. */ + fun response(): JobDataPointListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [JobDataPointListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [JobDataPointListPage]. */ + class Builder internal constructor() { + + private var service: JobDataPointService? = null + private var params: JobDataPointListParams? = null + private var response: JobDataPointListPageResponse? = null + + @JvmSynthetic + internal fun from(jobDataPointListPage: JobDataPointListPage) = apply { + service = jobDataPointListPage.service + params = jobDataPointListPage.params + response = jobDataPointListPage.response + } + + fun service(service: JobDataPointService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: JobDataPointListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: JobDataPointListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [JobDataPointListPage]. + * + * 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(): JobDataPointListPage = + JobDataPointListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is JobDataPointListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "JobDataPointListPage{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/jobdatapoints/JobDataPointListPageAsync.kt new file mode 100644 index 0000000..75e78d3 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListPageAsync.kt @@ -0,0 +1,145 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.jobdatapoints + +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 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 +private constructor( + private val service: JobDataPointServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: JobDataPointListParams, + private val response: JobDataPointListPageResponse, +) : PageAsync { + + /** + * Delegates to [JobDataPointListPageResponse], but gracefully handles missing data. + * + * @see JobDataPointListPageResponse.items + */ + override fun items(): List = + response._items().getOptional("items").getOrNull() ?: emptyList() + + /** + * Delegates to [JobDataPointListPageResponse], but gracefully handles missing data. + * + * @see JobDataPointListPageResponse.nextPageToken + */ + fun nextPageToken(): Optional = response._nextPageToken().getOptional("next_page_token") + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageToken().isPresent + + fun nextPageParams(): JobDataPointListParams { + 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(): JobDataPointListParams = params + + /** The response that this page was parsed from. */ + fun response(): JobDataPointListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [JobDataPointListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [JobDataPointListPageAsync]. */ + class Builder internal constructor() { + + private var service: JobDataPointServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: JobDataPointListParams? = null + private var response: JobDataPointListPageResponse? = null + + @JvmSynthetic + internal fun from(jobDataPointListPageAsync: JobDataPointListPageAsync) = apply { + service = jobDataPointListPageAsync.service + streamHandlerExecutor = jobDataPointListPageAsync.streamHandlerExecutor + params = jobDataPointListPageAsync.params + response = jobDataPointListPageAsync.response + } + + fun service(service: JobDataPointServiceAsync) = 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 } + + /** The response that this page was parsed from. */ + fun response(response: JobDataPointListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [JobDataPointListPageAsync]. + * + * 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(): JobDataPointListPageAsync = + JobDataPointListPageAsync( + 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 JobDataPointListPageAsync && + 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() = + "JobDataPointListPageAsync{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/jobdatapoints/JobDataPointListPageResponse.kt new file mode 100644 index 0000000..8267489 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListPageResponse.kt @@ -0,0 +1,303 @@ +// 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.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 job data points. */ +class JobDataPointListPageResponse +@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 [JobDataPointListPageResponse]. + * + * The following fields are required: + * ```java + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [JobDataPointListPageResponse]. */ + 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(jobDataPointListPageResponse: JobDataPointListPageResponse) = apply { + items = jobDataPointListPageResponse.items.map { it.toMutableList() } + nextPageToken = jobDataPointListPageResponse.nextPageToken + totalSize = jobDataPointListPageResponse.totalSize + additionalProperties = jobDataPointListPageResponse.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 [JobDataPoint] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: JobDataPoint) = 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 [JobDataPointListPageResponse]. + * + * 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(): JobDataPointListPageResponse = + JobDataPointListPageResponse( + 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(): JobDataPointListPageResponse = 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 JobDataPointListPageResponse && + 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() = + "JobDataPointListPageResponse{items=$items, nextPageToken=$nextPageToken, totalSize=$totalSize, 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 new file mode 100644 index 0000000..07dfb34 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListParams.kt @@ -0,0 +1,525 @@ +// 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/v2projects/V2ProjectGetParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectGetParams.kt new file mode 100644 index 0000000..82292ab --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectGetParams.kt @@ -0,0 +1,213 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.v2projects + +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 + +/** Get a project by ID. */ +class V2ProjectGetParams +private constructor( + private val projectId: String?, + private val organizationId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun projectId(): Optional = Optional.ofNullable(projectId) + + fun organizationId(): Optional = Optional.ofNullable(organizationId) + + /** 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(): V2ProjectGetParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [V2ProjectGetParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [V2ProjectGetParams]. */ + class Builder internal constructor() { + + private var projectId: String? = null + private var organizationId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(v2ProjectGetParams: V2ProjectGetParams) = apply { + projectId = v2ProjectGetParams.projectId + organizationId = v2ProjectGetParams.organizationId + additionalHeaders = v2ProjectGetParams.additionalHeaders.toBuilder() + additionalQueryParams = v2ProjectGetParams.additionalQueryParams.toBuilder() + } + + 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 organizationId(organizationId: String?) = apply { this.organizationId = organizationId } + + /** Alias for calling [Builder.organizationId] with `organizationId.orElse(null)`. */ + fun organizationId(organizationId: Optional) = + organizationId(organizationId.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 [V2ProjectGetParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): V2ProjectGetParams = + V2ProjectGetParams( + projectId, + organizationId, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _pathParam(index: Int): String = + when (index) { + 0 -> projectId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + organizationId?.let { put("organization_id", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is V2ProjectGetParams && + projectId == other.projectId && + organizationId == other.organizationId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(projectId, organizationId, additionalHeaders, additionalQueryParams) + + override fun toString() = + "V2ProjectGetParams{projectId=$projectId, organizationId=$organizationId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectGetResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectGetResponse.kt new file mode 100644 index 0000000..a8aedd1 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectGetResponse.kt @@ -0,0 +1,397 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.v2projects + +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 + +/** API response schema for a project. */ +class V2ProjectGetResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val name: JsonField, + private val organizationId: JsonField, + private val createdAt: JsonField, + private val isDefault: JsonField, + private val updatedAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("organization_id") + @ExcludeMissing + organizationId: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("is_default") + @ExcludeMissing + isDefault: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this(id, name, organizationId, createdAt, isDefault, updatedAt, mutableMapOf()) + + /** + * The project's unique identifier. + * + * @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 project's display name. + * + * @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 organization the project 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 organizationId(): String = organizationId.getRequired("organization_id") + + /** + * Creation datetime + * + * @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") + + /** + * Whether this project is the default project for its organization. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isDefault(): Optional = isDefault.getOptional("is_default") + + /** + * Update datetime + * + * @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 [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 [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("organization_id") + @ExcludeMissing + fun _organizationId(): JsonField = organizationId + + /** + * 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 [isDefault]. + * + * Unlike [isDefault], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_default") @ExcludeMissing fun _isDefault(): JsonField = isDefault + + /** + * 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 [V2ProjectGetResponse]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .organizationId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [V2ProjectGetResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var name: JsonField? = null + private var organizationId: JsonField? = null + private var createdAt: JsonField = JsonMissing.of() + private var isDefault: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(v2ProjectGetResponse: V2ProjectGetResponse) = apply { + id = v2ProjectGetResponse.id + name = v2ProjectGetResponse.name + organizationId = v2ProjectGetResponse.organizationId + createdAt = v2ProjectGetResponse.createdAt + isDefault = v2ProjectGetResponse.isDefault + updatedAt = v2ProjectGetResponse.updatedAt + additionalProperties = v2ProjectGetResponse.additionalProperties.toMutableMap() + } + + /** The project's unique identifier. */ + 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 project's display name. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** The organization the project belongs to. */ + fun organizationId(organizationId: String) = organizationId(JsonField.of(organizationId)) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField) = apply { + this.organizationId = organizationId + } + + /** Creation datetime */ + 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 } + + /** Whether this project is the default project for its organization. */ + fun isDefault(isDefault: Boolean) = isDefault(JsonField.of(isDefault)) + + /** + * Sets [Builder.isDefault] to an arbitrary JSON value. + * + * You should usually call [Builder.isDefault] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isDefault(isDefault: JsonField) = apply { this.isDefault = isDefault } + + /** Update datetime */ + 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 [V2ProjectGetResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .organizationId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): V2ProjectGetResponse = + V2ProjectGetResponse( + checkRequired("id", id), + checkRequired("name", name), + checkRequired("organizationId", organizationId), + createdAt, + isDefault, + 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(): V2ProjectGetResponse = apply { + if (validated) { + return@apply + } + + id() + name() + organizationId() + createdAt() + isDefault() + 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) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (isDefault.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is V2ProjectGetResponse && + id == other.id && + name == other.name && + organizationId == other.organizationId && + createdAt == other.createdAt && + isDefault == other.isDefault && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + name, + organizationId, + createdAt, + isDefault, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "V2ProjectGetResponse{id=$id, name=$name, organizationId=$organizationId, createdAt=$createdAt, isDefault=$isDefault, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListPage.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListPage.kt new file mode 100644 index 0000000..3430257 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListPage.kt @@ -0,0 +1,131 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.v2projects + +import ai.llamaindex.llamacloud.core.AutoPager +import ai.llamaindex.llamacloud.core.Page +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.services.blocking.V2ProjectService +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** @see V2ProjectService.list */ +class V2ProjectListPage +private constructor( + private val service: V2ProjectService, + private val params: V2ProjectListParams, + private val response: V2ProjectListPageResponse, +) : Page { + + /** + * Delegates to [V2ProjectListPageResponse], but gracefully handles missing data. + * + * @see V2ProjectListPageResponse.items + */ + override fun items(): List = + response._items().getOptional("items").getOrNull() ?: emptyList() + + /** + * Delegates to [V2ProjectListPageResponse], but gracefully handles missing data. + * + * @see V2ProjectListPageResponse.nextPageToken + */ + fun nextPageToken(): Optional = response._nextPageToken().getOptional("next_page_token") + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageToken().isPresent + + fun nextPageParams(): V2ProjectListParams { + val nextCursor = + nextPageToken().getOrNull() + ?: throw IllegalStateException("Cannot construct next page params") + return params.toBuilder().pageToken(nextCursor).build() + } + + override fun nextPage(): V2ProjectListPage = service.list(nextPageParams()) + + fun autoPager(): AutoPager = AutoPager.from(this) + + /** The parameters that were used to request this page. */ + fun params(): V2ProjectListParams = params + + /** The response that this page was parsed from. */ + fun response(): V2ProjectListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [V2ProjectListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [V2ProjectListPage]. */ + class Builder internal constructor() { + + private var service: V2ProjectService? = null + private var params: V2ProjectListParams? = null + private var response: V2ProjectListPageResponse? = null + + @JvmSynthetic + internal fun from(v2ProjectListPage: V2ProjectListPage) = apply { + service = v2ProjectListPage.service + params = v2ProjectListPage.params + response = v2ProjectListPage.response + } + + fun service(service: V2ProjectService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: V2ProjectListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: V2ProjectListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [V2ProjectListPage]. + * + * 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(): V2ProjectListPage = + V2ProjectListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is V2ProjectListPage && + service == other.service && + params == other.params && + response == other.response + } + + override fun hashCode(): Int = Objects.hash(service, params, response) + + override fun toString() = + "V2ProjectListPage{service=$service, params=$params, response=$response}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListPageAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListPageAsync.kt new file mode 100644 index 0000000..655031a --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListPageAsync.kt @@ -0,0 +1,146 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.v2projects + +import ai.llamaindex.llamacloud.core.AutoPagerAsync +import ai.llamaindex.llamacloud.core.PageAsync +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.services.async.V2ProjectServiceAsync +import java.util.Objects +import java.util.Optional +import java.util.concurrent.CompletableFuture +import java.util.concurrent.Executor +import kotlin.jvm.optionals.getOrNull + +/** @see V2ProjectServiceAsync.list */ +class V2ProjectListPageAsync +private constructor( + private val service: V2ProjectServiceAsync, + private val streamHandlerExecutor: Executor, + private val params: V2ProjectListParams, + private val response: V2ProjectListPageResponse, +) : PageAsync { + + /** + * Delegates to [V2ProjectListPageResponse], but gracefully handles missing data. + * + * @see V2ProjectListPageResponse.items + */ + override fun items(): List = + response._items().getOptional("items").getOrNull() ?: emptyList() + + /** + * Delegates to [V2ProjectListPageResponse], but gracefully handles missing data. + * + * @see V2ProjectListPageResponse.nextPageToken + */ + fun nextPageToken(): Optional = response._nextPageToken().getOptional("next_page_token") + + override fun hasNextPage(): Boolean = items().isNotEmpty() && nextPageToken().isPresent + + fun nextPageParams(): V2ProjectListParams { + 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(): V2ProjectListParams = params + + /** The response that this page was parsed from. */ + fun response(): V2ProjectListPageResponse = response + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [V2ProjectListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .streamHandlerExecutor() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [V2ProjectListPageAsync]. */ + class Builder internal constructor() { + + private var service: V2ProjectServiceAsync? = null + private var streamHandlerExecutor: Executor? = null + private var params: V2ProjectListParams? = null + private var response: V2ProjectListPageResponse? = null + + @JvmSynthetic + internal fun from(v2ProjectListPageAsync: V2ProjectListPageAsync) = apply { + service = v2ProjectListPageAsync.service + streamHandlerExecutor = v2ProjectListPageAsync.streamHandlerExecutor + params = v2ProjectListPageAsync.params + response = v2ProjectListPageAsync.response + } + + fun service(service: V2ProjectServiceAsync) = apply { this.service = service } + + fun streamHandlerExecutor(streamHandlerExecutor: Executor) = apply { + this.streamHandlerExecutor = streamHandlerExecutor + } + + /** The parameters that were used to request this page. */ + fun params(params: V2ProjectListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: V2ProjectListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [V2ProjectListPageAsync]. + * + * 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(): V2ProjectListPageAsync = + V2ProjectListPageAsync( + 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 V2ProjectListPageAsync && + 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() = + "V2ProjectListPageAsync{service=$service, streamHandlerExecutor=$streamHandlerExecutor, params=$params, response=$response}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListPageResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListPageResponse.kt new file mode 100644 index 0000000..6ddb5ca --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListPageResponse.kt @@ -0,0 +1,305 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.v2projects + +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 + +/** API query response schema for projects. */ +class V2ProjectListPageResponse +@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 [V2ProjectListPageResponse]. + * + * The following fields are required: + * ```java + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [V2ProjectListPageResponse]. */ + 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(v2ProjectListPageResponse: V2ProjectListPageResponse) = apply { + items = v2ProjectListPageResponse.items.map { it.toMutableList() } + nextPageToken = v2ProjectListPageResponse.nextPageToken + totalSize = v2ProjectListPageResponse.totalSize + additionalProperties = v2ProjectListPageResponse.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 [V2ProjectListResponse] to [items]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addItem(item: V2ProjectListResponse) = 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 [V2ProjectListPageResponse]. + * + * 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(): V2ProjectListPageResponse = + V2ProjectListPageResponse( + 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(): V2ProjectListPageResponse = 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 V2ProjectListPageResponse && + 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() = + "V2ProjectListPageResponse{items=$items, nextPageToken=$nextPageToken, totalSize=$totalSize, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListParams.kt new file mode 100644 index 0000000..2d98687 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListParams.kt @@ -0,0 +1,248 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.v2projects + +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 projects in an organization. Requires `organization_id` or a project-scoped API key. */ +class V2ProjectListParams +private constructor( + private val name: String?, + private val organizationId: String?, + private val pageSize: Long?, + private val pageToken: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + fun name(): Optional = Optional.ofNullable(name) + + fun organizationId(): Optional = Optional.ofNullable(organizationId) + + fun pageSize(): Optional = Optional.ofNullable(pageSize) + + fun pageToken(): Optional = Optional.ofNullable(pageToken) + + /** 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(): V2ProjectListParams = builder().build() + + /** Returns a mutable builder for constructing an instance of [V2ProjectListParams]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [V2ProjectListParams]. */ + class Builder internal constructor() { + + private var name: String? = null + private var organizationId: String? = null + private var pageSize: Long? = null + private var pageToken: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(v2ProjectListParams: V2ProjectListParams) = apply { + name = v2ProjectListParams.name + organizationId = v2ProjectListParams.organizationId + pageSize = v2ProjectListParams.pageSize + pageToken = v2ProjectListParams.pageToken + additionalHeaders = v2ProjectListParams.additionalHeaders.toBuilder() + additionalQueryParams = v2ProjectListParams.additionalQueryParams.toBuilder() + } + + fun name(name: String?) = apply { this.name = name } + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.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 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 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 [V2ProjectListParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): V2ProjectListParams = + V2ProjectListParams( + name, + organizationId, + pageSize, + pageToken, + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = + QueryParams.builder() + .apply { + name?.let { put("name", it) } + organizationId?.let { put("organization_id", it) } + pageSize?.let { put("page_size", it.toString()) } + pageToken?.let { put("page_token", it) } + putAll(additionalQueryParams) + } + .build() + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is V2ProjectListParams && + name == other.name && + organizationId == other.organizationId && + pageSize == other.pageSize && + pageToken == other.pageToken && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash( + name, + organizationId, + pageSize, + pageToken, + additionalHeaders, + additionalQueryParams, + ) + + override fun toString() = + "V2ProjectListParams{name=$name, organizationId=$organizationId, pageSize=$pageSize, pageToken=$pageToken, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListResponse.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListResponse.kt new file mode 100644 index 0000000..31924ce --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListResponse.kt @@ -0,0 +1,397 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.v2projects + +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 + +/** API response schema for a project. */ +class V2ProjectListResponse +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +private constructor( + private val id: JsonField, + private val name: JsonField, + private val organizationId: JsonField, + private val createdAt: JsonField, + private val isDefault: JsonField, + private val updatedAt: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("organization_id") + @ExcludeMissing + organizationId: JsonField = JsonMissing.of(), + @JsonProperty("created_at") + @ExcludeMissing + createdAt: JsonField = JsonMissing.of(), + @JsonProperty("is_default") + @ExcludeMissing + isDefault: JsonField = JsonMissing.of(), + @JsonProperty("updated_at") + @ExcludeMissing + updatedAt: JsonField = JsonMissing.of(), + ) : this(id, name, organizationId, createdAt, isDefault, updatedAt, mutableMapOf()) + + /** + * The project's unique identifier. + * + * @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 project's display name. + * + * @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 organization the project 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 organizationId(): String = organizationId.getRequired("organization_id") + + /** + * Creation datetime + * + * @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") + + /** + * Whether this project is the default project for its organization. + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun isDefault(): Optional = isDefault.getOptional("is_default") + + /** + * Update datetime + * + * @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 [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 [organizationId]. + * + * Unlike [organizationId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("organization_id") + @ExcludeMissing + fun _organizationId(): JsonField = organizationId + + /** + * 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 [isDefault]. + * + * Unlike [isDefault], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("is_default") @ExcludeMissing fun _isDefault(): JsonField = isDefault + + /** + * 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 [V2ProjectListResponse]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .organizationId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [V2ProjectListResponse]. */ + class Builder internal constructor() { + + private var id: JsonField? = null + private var name: JsonField? = null + private var organizationId: JsonField? = null + private var createdAt: JsonField = JsonMissing.of() + private var isDefault: JsonField = JsonMissing.of() + private var updatedAt: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(v2ProjectListResponse: V2ProjectListResponse) = apply { + id = v2ProjectListResponse.id + name = v2ProjectListResponse.name + organizationId = v2ProjectListResponse.organizationId + createdAt = v2ProjectListResponse.createdAt + isDefault = v2ProjectListResponse.isDefault + updatedAt = v2ProjectListResponse.updatedAt + additionalProperties = v2ProjectListResponse.additionalProperties.toMutableMap() + } + + /** The project's unique identifier. */ + 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 project's display name. */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** The organization the project belongs to. */ + fun organizationId(organizationId: String) = organizationId(JsonField.of(organizationId)) + + /** + * Sets [Builder.organizationId] to an arbitrary JSON value. + * + * You should usually call [Builder.organizationId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun organizationId(organizationId: JsonField) = apply { + this.organizationId = organizationId + } + + /** Creation datetime */ + 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 } + + /** Whether this project is the default project for its organization. */ + fun isDefault(isDefault: Boolean) = isDefault(JsonField.of(isDefault)) + + /** + * Sets [Builder.isDefault] to an arbitrary JSON value. + * + * You should usually call [Builder.isDefault] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun isDefault(isDefault: JsonField) = apply { this.isDefault = isDefault } + + /** Update datetime */ + 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 [V2ProjectListResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .organizationId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): V2ProjectListResponse = + V2ProjectListResponse( + checkRequired("id", id), + checkRequired("name", name), + checkRequired("organizationId", organizationId), + createdAt, + isDefault, + 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(): V2ProjectListResponse = apply { + if (validated) { + return@apply + } + + id() + name() + organizationId() + createdAt() + isDefault() + 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) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (organizationId.asKnown().isPresent) 1 else 0) + + (if (createdAt.asKnown().isPresent) 1 else 0) + + (if (isDefault.asKnown().isPresent) 1 else 0) + + (if (updatedAt.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is V2ProjectListResponse && + id == other.id && + name == other.name && + organizationId == other.organizationId && + createdAt == other.createdAt && + isDefault == other.isDefault && + updatedAt == other.updatedAt && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + id, + name, + organizationId, + createdAt, + isDefault, + updatedAt, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "V2ProjectListResponse{id=$id, name=$name, organizationId=$organizationId, createdAt=$createdAt, isDefault=$isDefault, updatedAt=$updatedAt, additionalProperties=$additionalProperties}" +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsync.kt index 23b150c..ebf25f4 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsync.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsync.kt @@ -14,6 +14,8 @@ import ai.llamaindex.llamacloud.models.files.FileListPageAsync import ai.llamaindex.llamacloud.models.files.FileListParams import ai.llamaindex.llamacloud.models.files.FileQueryParams import ai.llamaindex.llamacloud.models.files.FileQueryResponse +import ai.llamaindex.llamacloud.models.files.FileRetrieveParams +import ai.llamaindex.llamacloud.models.files.FileRetrieveResponse import ai.llamaindex.llamacloud.models.files.PresignedUrl import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -50,6 +52,41 @@ interface FileServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** Get file metadata by ID. */ + fun retrieve(fileId: String): CompletableFuture = + retrieve(fileId, FileRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + fileId: String, + params: FileRetrieveParams = FileRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + fileId: String, + params: FileRetrieveParams = FileRetrieveParams.none(), + ): CompletableFuture = retrieve(fileId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: FileRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see retrieve */ + fun retrieve(params: FileRetrieveParams): CompletableFuture = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + fileId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + retrieve(fileId, FileRetrieveParams.none(), requestOptions) + /** * List files with optional filtering and pagination. * @@ -180,6 +217,47 @@ interface FileServiceAsync { requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** + * Returns a raw HTTP response for `get /api/v1/beta/files/{file_id}`, but is otherwise the + * same as [FileServiceAsync.retrieve]. + */ + fun retrieve(fileId: String): CompletableFuture> = + retrieve(fileId, FileRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + fileId: String, + params: FileRetrieveParams = FileRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + fileId: String, + params: FileRetrieveParams = FileRetrieveParams.none(), + ): CompletableFuture> = + retrieve(fileId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: FileRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see retrieve */ + fun retrieve( + params: FileRetrieveParams + ): CompletableFuture> = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + fileId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + retrieve(fileId, FileRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /api/v1/beta/files`, but is otherwise the same as * [FileServiceAsync.list]. diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsyncImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsyncImpl.kt index ed90d73..c768e1f 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsyncImpl.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsyncImpl.kt @@ -27,6 +27,8 @@ import ai.llamaindex.llamacloud.models.files.FileListPageResponse import ai.llamaindex.llamacloud.models.files.FileListParams import ai.llamaindex.llamacloud.models.files.FileQueryParams import ai.llamaindex.llamacloud.models.files.FileQueryResponse +import ai.llamaindex.llamacloud.models.files.FileRetrieveParams +import ai.llamaindex.llamacloud.models.files.FileRetrieveResponse import ai.llamaindex.llamacloud.models.files.PresignedUrl import java.util.concurrent.CompletableFuture import java.util.function.Consumer @@ -51,6 +53,13 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien // post /api/v1/beta/files withRawResponse().create(params, requestOptions).thenApply { it.parse() } + override fun retrieve( + params: FileRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/v1/beta/files/{file_id} + withRawResponse().retrieve(params, requestOptions).thenApply { it.parse() } + override fun list( params: FileListParams, requestOptions: RequestOptions, @@ -124,6 +133,39 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: FileRetrieveParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "beta", "files", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/JobDataPointServiceAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/JobDataPointServiceAsync.kt new file mode 100644 index 0000000..2c1fba9 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/JobDataPointServiceAsync.kt @@ -0,0 +1,67 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.async + +import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.core.RequestOptions +import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.models.jobdatapoints.JobDataPointListPageAsync +import ai.llamaindex.llamacloud.models.jobdatapoints.JobDataPointListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface JobDataPointServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobDataPointServiceAsync + + /** Returns paginated job data points for the current project. */ + fun list(params: JobDataPointListParams): CompletableFuture = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: JobDataPointListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * A view of [JobDataPointServiceAsync] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): JobDataPointServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/job-data-points`, but is otherwise the same + * as [JobDataPointServiceAsync.list]. + */ + fun list( + params: JobDataPointListParams + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: JobDataPointListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + } +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/JobDataPointServiceAsyncImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/JobDataPointServiceAsyncImpl.kt new file mode 100644 index 0000000..1e9d699 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/JobDataPointServiceAsyncImpl.kt @@ -0,0 +1,93 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.async + +import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.core.RequestOptions +import ai.llamaindex.llamacloud.core.handlers.errorBodyHandler +import ai.llamaindex.llamacloud.core.handlers.errorHandler +import ai.llamaindex.llamacloud.core.handlers.jsonHandler +import ai.llamaindex.llamacloud.core.http.HttpMethod +import ai.llamaindex.llamacloud.core.http.HttpRequest +import ai.llamaindex.llamacloud.core.http.HttpResponse +import ai.llamaindex.llamacloud.core.http.HttpResponse.Handler +import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.core.http.parseable +import ai.llamaindex.llamacloud.core.prepareAsync +import ai.llamaindex.llamacloud.models.jobdatapoints.JobDataPointListPageAsync +import ai.llamaindex.llamacloud.models.jobdatapoints.JobDataPointListPageResponse +import ai.llamaindex.llamacloud.models.jobdatapoints.JobDataPointListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +class JobDataPointServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + JobDataPointServiceAsync { + + private val withRawResponse: JobDataPointServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): JobDataPointServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): JobDataPointServiceAsync = + JobDataPointServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: JobDataPointListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/v1/job-data-points + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + JobDataPointServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): JobDataPointServiceAsync.WithRawResponse = + JobDataPointServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: JobDataPointListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "job-data-points") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + JobDataPointListPageAsync.builder() + .service(JobDataPointServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + } +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/V2ProjectServiceAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/V2ProjectServiceAsync.kt new file mode 100644 index 0000000..ed87684 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/V2ProjectServiceAsync.kt @@ -0,0 +1,162 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.async + +import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.core.RequestOptions +import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.models.v2projects.V2ProjectGetParams +import ai.llamaindex.llamacloud.models.v2projects.V2ProjectGetResponse +import ai.llamaindex.llamacloud.models.v2projects.V2ProjectListPageAsync +import ai.llamaindex.llamacloud.models.v2projects.V2ProjectListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface V2ProjectServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): V2ProjectServiceAsync + + /** List projects in an organization. Requires `organization_id` or a project-scoped API key. */ + fun list(): CompletableFuture = list(V2ProjectListParams.none()) + + /** @see list */ + fun list( + params: V2ProjectListParams = V2ProjectListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see list */ + fun list( + params: V2ProjectListParams = V2ProjectListParams.none() + ): CompletableFuture = list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): CompletableFuture = + list(V2ProjectListParams.none(), requestOptions) + + /** Get a project by ID. */ + fun get(projectId: String): CompletableFuture = + get(projectId, V2ProjectGetParams.none()) + + /** @see get */ + fun get( + projectId: String, + params: V2ProjectGetParams = V2ProjectGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + get(params.toBuilder().projectId(projectId).build(), requestOptions) + + /** @see get */ + fun get( + projectId: String, + params: V2ProjectGetParams = V2ProjectGetParams.none(), + ): CompletableFuture = get(projectId, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: V2ProjectGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see get */ + fun get(params: V2ProjectGetParams): CompletableFuture = + get(params, RequestOptions.none()) + + /** @see get */ + fun get( + projectId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + get(projectId, V2ProjectGetParams.none(), requestOptions) + + /** + * A view of [V2ProjectServiceAsync] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): V2ProjectServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v2/projects`, but is otherwise the same as + * [V2ProjectServiceAsync.list]. + */ + fun list(): CompletableFuture> = + list(V2ProjectListParams.none()) + + /** @see list */ + fun list( + params: V2ProjectListParams = V2ProjectListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see list */ + fun list( + params: V2ProjectListParams = V2ProjectListParams.none() + ): CompletableFuture> = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + requestOptions: RequestOptions + ): CompletableFuture> = + list(V2ProjectListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v2/projects/{project_id}`, but is otherwise the + * same as [V2ProjectServiceAsync.get]. + */ + fun get(projectId: String): CompletableFuture> = + get(projectId, V2ProjectGetParams.none()) + + /** @see get */ + fun get( + projectId: String, + params: V2ProjectGetParams = V2ProjectGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + get(params.toBuilder().projectId(projectId).build(), requestOptions) + + /** @see get */ + fun get( + projectId: String, + params: V2ProjectGetParams = V2ProjectGetParams.none(), + ): CompletableFuture> = + get(projectId, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: V2ProjectGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see get */ + fun get( + params: V2ProjectGetParams + ): CompletableFuture> = + get(params, RequestOptions.none()) + + /** @see get */ + fun get( + projectId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + get(projectId, V2ProjectGetParams.none(), requestOptions) + } +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/V2ProjectServiceAsyncImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/V2ProjectServiceAsyncImpl.kt new file mode 100644 index 0000000..a8cd75e --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/V2ProjectServiceAsyncImpl.kt @@ -0,0 +1,137 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.async + +import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.core.RequestOptions +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.core.handlers.errorBodyHandler +import ai.llamaindex.llamacloud.core.handlers.errorHandler +import ai.llamaindex.llamacloud.core.handlers.jsonHandler +import ai.llamaindex.llamacloud.core.http.HttpMethod +import ai.llamaindex.llamacloud.core.http.HttpRequest +import ai.llamaindex.llamacloud.core.http.HttpResponse +import ai.llamaindex.llamacloud.core.http.HttpResponse.Handler +import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.core.http.parseable +import ai.llamaindex.llamacloud.core.prepareAsync +import ai.llamaindex.llamacloud.models.v2projects.V2ProjectGetParams +import ai.llamaindex.llamacloud.models.v2projects.V2ProjectGetResponse +import ai.llamaindex.llamacloud.models.v2projects.V2ProjectListPageAsync +import ai.llamaindex.llamacloud.models.v2projects.V2ProjectListPageResponse +import ai.llamaindex.llamacloud.models.v2projects.V2ProjectListParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class V2ProjectServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : + V2ProjectServiceAsync { + + private val withRawResponse: V2ProjectServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): V2ProjectServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): V2ProjectServiceAsync = + V2ProjectServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: V2ProjectListParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/v2/projects + withRawResponse().list(params, requestOptions).thenApply { it.parse() } + + override fun get( + params: V2ProjectGetParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // get /api/v2/projects/{project_id} + withRawResponse().get(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + V2ProjectServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): V2ProjectServiceAsync.WithRawResponse = + V2ProjectServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: V2ProjectListParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v2", "projects") + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + V2ProjectListPageAsync.builder() + .service(V2ProjectServiceAsyncImpl(clientOptions)) + .streamHandlerExecutor(clientOptions.streamHandlerExecutor) + .params(params) + .response(it) + .build() + } + } + } + } + + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: V2ProjectGetParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("projectId", params.projectId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v2", "projects", params._pathParam(0)) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { getHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/FileService.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/FileService.kt index 26a7bed..f54b892 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/FileService.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/FileService.kt @@ -14,6 +14,8 @@ import ai.llamaindex.llamacloud.models.files.FileListPage import ai.llamaindex.llamacloud.models.files.FileListParams import ai.llamaindex.llamacloud.models.files.FileQueryParams import ai.llamaindex.llamacloud.models.files.FileQueryResponse +import ai.llamaindex.llamacloud.models.files.FileRetrieveParams +import ai.llamaindex.llamacloud.models.files.FileRetrieveResponse import ai.llamaindex.llamacloud.models.files.PresignedUrl import com.google.errorprone.annotations.MustBeClosed import java.util.function.Consumer @@ -49,6 +51,36 @@ interface FileService { requestOptions: RequestOptions = RequestOptions.none(), ): FileCreateResponse + /** Get file metadata by ID. */ + fun retrieve(fileId: String): FileRetrieveResponse = retrieve(fileId, FileRetrieveParams.none()) + + /** @see retrieve */ + fun retrieve( + fileId: String, + params: FileRetrieveParams = FileRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): FileRetrieveResponse = retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see retrieve */ + fun retrieve( + fileId: String, + params: FileRetrieveParams = FileRetrieveParams.none(), + ): FileRetrieveResponse = retrieve(fileId, params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve( + params: FileRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): FileRetrieveResponse + + /** @see retrieve */ + fun retrieve(params: FileRetrieveParams): FileRetrieveResponse = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + fun retrieve(fileId: String, requestOptions: RequestOptions): FileRetrieveResponse = + retrieve(fileId, FileRetrieveParams.none(), requestOptions) + /** * List files with optional filtering and pagination. * @@ -168,6 +200,50 @@ interface FileService { requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** + * Returns a raw HTTP response for `get /api/v1/beta/files/{file_id}`, but is otherwise the + * same as [FileService.retrieve]. + */ + @MustBeClosed + fun retrieve(fileId: String): HttpResponseFor = + retrieve(fileId, FileRetrieveParams.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + fileId: String, + params: FileRetrieveParams = FileRetrieveParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + retrieve(params.toBuilder().fileId(fileId).build(), requestOptions) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + fileId: String, + params: FileRetrieveParams = FileRetrieveParams.none(), + ): HttpResponseFor = retrieve(fileId, params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + params: FileRetrieveParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see retrieve */ + @MustBeClosed + fun retrieve(params: FileRetrieveParams): HttpResponseFor = + retrieve(params, RequestOptions.none()) + + /** @see retrieve */ + @MustBeClosed + fun retrieve( + fileId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + retrieve(fileId, FileRetrieveParams.none(), requestOptions) + /** * Returns a raw HTTP response for `get /api/v1/beta/files`, but is otherwise the same as * [FileService.list]. diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/FileServiceImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/FileServiceImpl.kt index 7835586..2295961 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/FileServiceImpl.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/FileServiceImpl.kt @@ -27,6 +27,8 @@ import ai.llamaindex.llamacloud.models.files.FileListPageResponse import ai.llamaindex.llamacloud.models.files.FileListParams import ai.llamaindex.llamacloud.models.files.FileQueryParams import ai.llamaindex.llamacloud.models.files.FileQueryResponse +import ai.llamaindex.llamacloud.models.files.FileRetrieveParams +import ai.llamaindex.llamacloud.models.files.FileRetrieveResponse import ai.llamaindex.llamacloud.models.files.PresignedUrl import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull @@ -49,6 +51,13 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti // post /api/v1/beta/files withRawResponse().create(params, requestOptions).parse() + override fun retrieve( + params: FileRetrieveParams, + requestOptions: RequestOptions, + ): FileRetrieveResponse = + // get /api/v1/beta/files/{file_id} + withRawResponse().retrieve(params, requestOptions).parse() + override fun list(params: FileListParams, requestOptions: RequestOptions): FileListPage = // get /api/v1/beta/files withRawResponse().list(params, requestOptions).parse() @@ -108,6 +117,36 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti } } + private val retrieveHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun retrieve( + params: FileRetrieveParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("fileId", params.fileId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "beta", "files", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { retrieveHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/JobDataPointService.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/JobDataPointService.kt new file mode 100644 index 0000000..2ce32f7 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/JobDataPointService.kt @@ -0,0 +1,66 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.blocking + +import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.core.RequestOptions +import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.models.jobdatapoints.JobDataPointListPage +import ai.llamaindex.llamacloud.models.jobdatapoints.JobDataPointListParams +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface JobDataPointService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobDataPointService + + /** Returns paginated job data points for the current project. */ + fun list(params: JobDataPointListParams): JobDataPointListPage = + list(params, RequestOptions.none()) + + /** @see list */ + fun list( + params: JobDataPointListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): JobDataPointListPage + + /** + * A view of [JobDataPointService] that provides access to raw HTTP responses for each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): JobDataPointService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v1/job-data-points`, but is otherwise the same + * as [JobDataPointService.list]. + */ + @MustBeClosed + fun list(params: JobDataPointListParams): HttpResponseFor = + list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: JobDataPointListParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + } +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/JobDataPointServiceImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/JobDataPointServiceImpl.kt new file mode 100644 index 0000000..a733db9 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/JobDataPointServiceImpl.kt @@ -0,0 +1,88 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.blocking + +import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.core.RequestOptions +import ai.llamaindex.llamacloud.core.handlers.errorBodyHandler +import ai.llamaindex.llamacloud.core.handlers.errorHandler +import ai.llamaindex.llamacloud.core.handlers.jsonHandler +import ai.llamaindex.llamacloud.core.http.HttpMethod +import ai.llamaindex.llamacloud.core.http.HttpRequest +import ai.llamaindex.llamacloud.core.http.HttpResponse +import ai.llamaindex.llamacloud.core.http.HttpResponse.Handler +import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.core.http.parseable +import ai.llamaindex.llamacloud.core.prepare +import ai.llamaindex.llamacloud.models.jobdatapoints.JobDataPointListPage +import ai.llamaindex.llamacloud.models.jobdatapoints.JobDataPointListPageResponse +import ai.llamaindex.llamacloud.models.jobdatapoints.JobDataPointListParams +import java.util.function.Consumer + +class JobDataPointServiceImpl internal constructor(private val clientOptions: ClientOptions) : + JobDataPointService { + + private val withRawResponse: JobDataPointService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): JobDataPointService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): JobDataPointService = + JobDataPointServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: JobDataPointListParams, + requestOptions: RequestOptions, + ): JobDataPointListPage = + // get /api/v1/job-data-points + withRawResponse().list(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + JobDataPointService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): JobDataPointService.WithRawResponse = + JobDataPointServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: JobDataPointListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v1", "job-data-points") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + JobDataPointListPage.builder() + .service(JobDataPointServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + } +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/V2ProjectService.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/V2ProjectService.kt new file mode 100644 index 0000000..fe43d88 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/V2ProjectService.kt @@ -0,0 +1,154 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.blocking + +import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.core.RequestOptions +import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.models.v2projects.V2ProjectGetParams +import ai.llamaindex.llamacloud.models.v2projects.V2ProjectGetResponse +import ai.llamaindex.llamacloud.models.v2projects.V2ProjectListPage +import ai.llamaindex.llamacloud.models.v2projects.V2ProjectListParams +import com.google.errorprone.annotations.MustBeClosed +import java.util.function.Consumer + +interface V2ProjectService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): V2ProjectService + + /** List projects in an organization. Requires `organization_id` or a project-scoped API key. */ + fun list(): V2ProjectListPage = list(V2ProjectListParams.none()) + + /** @see list */ + fun list( + params: V2ProjectListParams = V2ProjectListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): V2ProjectListPage + + /** @see list */ + fun list(params: V2ProjectListParams = V2ProjectListParams.none()): V2ProjectListPage = + list(params, RequestOptions.none()) + + /** @see list */ + fun list(requestOptions: RequestOptions): V2ProjectListPage = + list(V2ProjectListParams.none(), requestOptions) + + /** Get a project by ID. */ + fun get(projectId: String): V2ProjectGetResponse = get(projectId, V2ProjectGetParams.none()) + + /** @see get */ + fun get( + projectId: String, + params: V2ProjectGetParams = V2ProjectGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): V2ProjectGetResponse = get(params.toBuilder().projectId(projectId).build(), requestOptions) + + /** @see get */ + fun get( + projectId: String, + params: V2ProjectGetParams = V2ProjectGetParams.none(), + ): V2ProjectGetResponse = get(projectId, params, RequestOptions.none()) + + /** @see get */ + fun get( + params: V2ProjectGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): V2ProjectGetResponse + + /** @see get */ + fun get(params: V2ProjectGetParams): V2ProjectGetResponse = get(params, RequestOptions.none()) + + /** @see get */ + fun get(projectId: String, requestOptions: RequestOptions): V2ProjectGetResponse = + get(projectId, V2ProjectGetParams.none(), requestOptions) + + /** A view of [V2ProjectService] that provides access to raw HTTP responses for each method. */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): V2ProjectService.WithRawResponse + + /** + * Returns a raw HTTP response for `get /api/v2/projects`, but is otherwise the same as + * [V2ProjectService.list]. + */ + @MustBeClosed + fun list(): HttpResponseFor = list(V2ProjectListParams.none()) + + /** @see list */ + @MustBeClosed + fun list( + params: V2ProjectListParams = V2ProjectListParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see list */ + @MustBeClosed + fun list( + params: V2ProjectListParams = V2ProjectListParams.none() + ): HttpResponseFor = list(params, RequestOptions.none()) + + /** @see list */ + @MustBeClosed + fun list(requestOptions: RequestOptions): HttpResponseFor = + list(V2ProjectListParams.none(), requestOptions) + + /** + * Returns a raw HTTP response for `get /api/v2/projects/{project_id}`, but is otherwise the + * same as [V2ProjectService.get]. + */ + @MustBeClosed + fun get(projectId: String): HttpResponseFor = + get(projectId, V2ProjectGetParams.none()) + + /** @see get */ + @MustBeClosed + fun get( + projectId: String, + params: V2ProjectGetParams = V2ProjectGetParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + get(params.toBuilder().projectId(projectId).build(), requestOptions) + + /** @see get */ + @MustBeClosed + fun get( + projectId: String, + params: V2ProjectGetParams = V2ProjectGetParams.none(), + ): HttpResponseFor = get(projectId, params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get( + params: V2ProjectGetParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see get */ + @MustBeClosed + fun get(params: V2ProjectGetParams): HttpResponseFor = + get(params, RequestOptions.none()) + + /** @see get */ + @MustBeClosed + fun get( + projectId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + get(projectId, V2ProjectGetParams.none(), requestOptions) + } +} diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/V2ProjectServiceImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/V2ProjectServiceImpl.kt new file mode 100644 index 0000000..7ebe838 --- /dev/null +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/V2ProjectServiceImpl.kt @@ -0,0 +1,129 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.blocking + +import ai.llamaindex.llamacloud.core.ClientOptions +import ai.llamaindex.llamacloud.core.RequestOptions +import ai.llamaindex.llamacloud.core.checkRequired +import ai.llamaindex.llamacloud.core.handlers.errorBodyHandler +import ai.llamaindex.llamacloud.core.handlers.errorHandler +import ai.llamaindex.llamacloud.core.handlers.jsonHandler +import ai.llamaindex.llamacloud.core.http.HttpMethod +import ai.llamaindex.llamacloud.core.http.HttpRequest +import ai.llamaindex.llamacloud.core.http.HttpResponse +import ai.llamaindex.llamacloud.core.http.HttpResponse.Handler +import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.core.http.parseable +import ai.llamaindex.llamacloud.core.prepare +import ai.llamaindex.llamacloud.models.v2projects.V2ProjectGetParams +import ai.llamaindex.llamacloud.models.v2projects.V2ProjectGetResponse +import ai.llamaindex.llamacloud.models.v2projects.V2ProjectListPage +import ai.llamaindex.llamacloud.models.v2projects.V2ProjectListPageResponse +import ai.llamaindex.llamacloud.models.v2projects.V2ProjectListParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class V2ProjectServiceImpl internal constructor(private val clientOptions: ClientOptions) : + V2ProjectService { + + private val withRawResponse: V2ProjectService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): V2ProjectService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): V2ProjectService = + V2ProjectServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun list( + params: V2ProjectListParams, + requestOptions: RequestOptions, + ): V2ProjectListPage = + // get /api/v2/projects + withRawResponse().list(params, requestOptions).parse() + + override fun get( + params: V2ProjectGetParams, + requestOptions: RequestOptions, + ): V2ProjectGetResponse = + // get /api/v2/projects/{project_id} + withRawResponse().get(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + V2ProjectService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): V2ProjectService.WithRawResponse = + V2ProjectServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun list( + params: V2ProjectListParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v2", "projects") + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { listHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + .let { + V2ProjectListPage.builder() + .service(V2ProjectServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() + } + } + } + + private val getHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun get( + params: V2ProjectGetParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("projectId", params.projectId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("api", "v2", "projects", params._pathParam(0)) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { getHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/files/FileRetrieveParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/files/FileRetrieveParamsTest.kt new file mode 100644 index 0000000..8cf350c --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/files/FileRetrieveParamsTest.kt @@ -0,0 +1,65 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.files + +import ai.llamaindex.llamacloud.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileRetrieveParamsTest { + + @Test + fun create() { + FileRetrieveParams.builder() + .fileId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExpand("string") + .addExpand("string") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + FileRetrieveParams.builder().fileId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + FileRetrieveParams.builder() + .fileId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExpand("string") + .addExpand("string") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("expand", "string") + .put("expand", "string") + .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + FileRetrieveParams.builder().fileId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/files/FileRetrieveResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/files/FileRetrieveResponseTest.kt new file mode 100644 index 0000000..027b822 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/files/FileRetrieveResponseTest.kt @@ -0,0 +1,98 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.files + +import ai.llamaindex.llamacloud.core.JsonValue +import ai.llamaindex.llamacloud.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class FileRetrieveResponseTest { + + @Test + fun create() { + val fileRetrieveResponse = + FileRetrieveResponse.builder() + .id("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .name("invoice.pdf") + .projectId("123e4567-e89b-12d3-a456-426614174000") + .downloadUrl( + PresignedUrl.builder() + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .formFields( + PresignedUrl.FormFields.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalFileId("ext-12345") + .fileType("pdf") + .lastModifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .purpose("parse") + .build() + + assertThat(fileRetrieveResponse.id()).isEqualTo("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + assertThat(fileRetrieveResponse.name()).isEqualTo("invoice.pdf") + assertThat(fileRetrieveResponse.projectId()) + .isEqualTo("123e4567-e89b-12d3-a456-426614174000") + assertThat(fileRetrieveResponse.downloadUrl()) + .contains( + PresignedUrl.builder() + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .formFields( + PresignedUrl.FormFields.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + assertThat(fileRetrieveResponse.expiresAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(fileRetrieveResponse.externalFileId()).contains("ext-12345") + assertThat(fileRetrieveResponse.fileType()).contains("pdf") + assertThat(fileRetrieveResponse.lastModifiedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(fileRetrieveResponse.purpose()).contains("parse") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val fileRetrieveResponse = + FileRetrieveResponse.builder() + .id("dfl-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .name("invoice.pdf") + .projectId("123e4567-e89b-12d3-a456-426614174000") + .downloadUrl( + PresignedUrl.builder() + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .url("https://example.com") + .formFields( + PresignedUrl.FormFields.builder() + .putAdditionalProperty("foo", JsonValue.from("string")) + .build() + ) + .build() + ) + .expiresAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .externalFileId("ext-12345") + .fileType("pdf") + .lastModifiedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .purpose("parse") + .build() + + val roundtrippedFileRetrieveResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(fileRetrieveResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedFileRetrieveResponse).isEqualTo(fileRetrieveResponse) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListPageResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListPageResponseTest.kt new file mode 100644 index 0000000..c9790ab --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListPageResponseTest.kt @@ -0,0 +1,106 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.jobdatapoints + +import ai.llamaindex.llamacloud.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class JobDataPointListPageResponseTest { + + @Test + fun create() { + val jobDataPointListPageResponse = + JobDataPointListPageResponse.builder() + .addItem( + JobDataPoint.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .createdAt(OffsetDateTime.parse("2026-04-29T18:00:00Z")) + .customTag("premium") + .projectId("11111111-1111-1111-1111-111111111111") + .status("completed") + .updatedAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .errorMessage("Failed to process file.") + .stateTransitions( + JobDataPoint.StateTransitions.builder() + .cancelledAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .completedAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .failedAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .pendingAt(OffsetDateTime.parse("2026-04-29T18:00:00Z")) + .runningAt(OffsetDateTime.parse("2026-04-29T18:00:05Z")) + .throttledAt(OffsetDateTime.parse("2026-04-29T18:00:02Z")) + .build() + ) + .build() + ) + .nextPageToken("next_page_token") + .totalSize(0L) + .build() + + assertThat(jobDataPointListPageResponse.items()) + .containsExactly( + JobDataPoint.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .createdAt(OffsetDateTime.parse("2026-04-29T18:00:00Z")) + .customTag("premium") + .projectId("11111111-1111-1111-1111-111111111111") + .status("completed") + .updatedAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .errorMessage("Failed to process file.") + .stateTransitions( + JobDataPoint.StateTransitions.builder() + .cancelledAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .completedAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .failedAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .pendingAt(OffsetDateTime.parse("2026-04-29T18:00:00Z")) + .runningAt(OffsetDateTime.parse("2026-04-29T18:00:05Z")) + .throttledAt(OffsetDateTime.parse("2026-04-29T18:00:02Z")) + .build() + ) + .build() + ) + assertThat(jobDataPointListPageResponse.nextPageToken()).contains("next_page_token") + assertThat(jobDataPointListPageResponse.totalSize()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val jobDataPointListPageResponse = + JobDataPointListPageResponse.builder() + .addItem( + JobDataPoint.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .createdAt(OffsetDateTime.parse("2026-04-29T18:00:00Z")) + .customTag("premium") + .projectId("11111111-1111-1111-1111-111111111111") + .status("completed") + .updatedAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .errorMessage("Failed to process file.") + .stateTransitions( + JobDataPoint.StateTransitions.builder() + .cancelledAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .completedAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .failedAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .pendingAt(OffsetDateTime.parse("2026-04-29T18:00:00Z")) + .runningAt(OffsetDateTime.parse("2026-04-29T18:00:05Z")) + .throttledAt(OffsetDateTime.parse("2026-04-29T18:00:02Z")) + .build() + ) + .build() + ) + .nextPageToken("next_page_token") + .totalSize(0L) + .build() + + val roundtrippedJobDataPointListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(jobDataPointListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedJobDataPointListPageResponse).isEqualTo(jobDataPointListPageResponse) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListParamsTest.kt new file mode 100644 index 0000000..6cff91b --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointListParamsTest.kt @@ -0,0 +1,72 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.jobdatapoints + +import ai.llamaindex.llamacloud.core.http.QueryParams +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class JobDataPointListParamsTest { + + @Test + fun create() { + JobDataPointListParams.builder() + .jobType(JobDataPointListParams.JobType.PARSE) + .createdAtOnOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAtOnOrBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hours(24L) + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pageSize(100L) + .pageToken("page_token") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addStatus("completed") + .addStatus("failed") + .build() + } + + @Test + fun queryParams() { + val params = + JobDataPointListParams.builder() + .jobType(JobDataPointListParams.JobType.PARSE) + .createdAtOnOrAfter(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .createdAtOnOrBefore(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .hours(24L) + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .pageSize(100L) + .pageToken("page_token") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addStatus("completed") + .addStatus("failed") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("job_type", "parse") + .put("created_at_on_or_after", "2019-12-27T18:11:19.117Z") + .put("created_at_on_or_before", "2019-12-27T18:11:19.117Z") + .put("hours", "24") + .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("page_size", "100") + .put("page_token", "page_token") + .put("project_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .put("status", "completed") + .put("status", "failed") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + JobDataPointListParams.builder().jobType(JobDataPointListParams.JobType.PARSE).build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().put("job_type", "parse").build()) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointTest.kt new file mode 100644 index 0000000..8e7d861 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/jobdatapoints/JobDataPointTest.kt @@ -0,0 +1,88 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.jobdatapoints + +import ai.llamaindex.llamacloud.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class JobDataPointTest { + + @Test + fun create() { + val jobDataPoint = + JobDataPoint.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .createdAt(OffsetDateTime.parse("2026-04-29T18:00:00Z")) + .customTag("premium") + .projectId("11111111-1111-1111-1111-111111111111") + .status("completed") + .updatedAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .errorMessage("Failed to process file.") + .stateTransitions( + JobDataPoint.StateTransitions.builder() + .cancelledAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .completedAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .failedAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .pendingAt(OffsetDateTime.parse("2026-04-29T18:00:00Z")) + .runningAt(OffsetDateTime.parse("2026-04-29T18:00:05Z")) + .throttledAt(OffsetDateTime.parse("2026-04-29T18:00:02Z")) + .build() + ) + .build() + + assertThat(jobDataPoint.id()).isEqualTo("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + assertThat(jobDataPoint.createdAt()).isEqualTo(OffsetDateTime.parse("2026-04-29T18:00:00Z")) + assertThat(jobDataPoint.customTag()).isEqualTo("premium") + assertThat(jobDataPoint.projectId()).isEqualTo("11111111-1111-1111-1111-111111111111") + assertThat(jobDataPoint.status()).isEqualTo("completed") + assertThat(jobDataPoint.updatedAt()).isEqualTo(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + assertThat(jobDataPoint.errorMessage()).contains("Failed to process file.") + assertThat(jobDataPoint.stateTransitions()) + .contains( + JobDataPoint.StateTransitions.builder() + .cancelledAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .completedAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .failedAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .pendingAt(OffsetDateTime.parse("2026-04-29T18:00:00Z")) + .runningAt(OffsetDateTime.parse("2026-04-29T18:00:05Z")) + .throttledAt(OffsetDateTime.parse("2026-04-29T18:00:02Z")) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val jobDataPoint = + JobDataPoint.builder() + .id("pjb-aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee") + .createdAt(OffsetDateTime.parse("2026-04-29T18:00:00Z")) + .customTag("premium") + .projectId("11111111-1111-1111-1111-111111111111") + .status("completed") + .updatedAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .errorMessage("Failed to process file.") + .stateTransitions( + JobDataPoint.StateTransitions.builder() + .cancelledAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .completedAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .failedAt(OffsetDateTime.parse("2026-04-29T18:01:00Z")) + .pendingAt(OffsetDateTime.parse("2026-04-29T18:00:00Z")) + .runningAt(OffsetDateTime.parse("2026-04-29T18:00:05Z")) + .throttledAt(OffsetDateTime.parse("2026-04-29T18:00:02Z")) + .build() + ) + .build() + + val roundtrippedJobDataPoint = + jsonMapper.readValue( + jsonMapper.writeValueAsString(jobDataPoint), + jacksonTypeRef(), + ) + + assertThat(roundtrippedJobDataPoint).isEqualTo(jobDataPoint) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectGetParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectGetParamsTest.kt new file mode 100644 index 0000000..93d031d --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectGetParamsTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.v2projects + +import ai.llamaindex.llamacloud.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class V2ProjectGetParamsTest { + + @Test + fun create() { + V2ProjectGetParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + } + + @Test + fun pathParams() { + val params = + V2ProjectGetParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun queryParams() { + val params = + V2ProjectGetParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("organization_id", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = + V2ProjectGetParams.builder().projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectGetResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectGetResponseTest.kt new file mode 100644 index 0000000..e1802d3 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectGetResponseTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.v2projects + +import ai.llamaindex.llamacloud.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class V2ProjectGetResponseTest { + + @Test + fun create() { + val v2ProjectGetResponse = + V2ProjectGetResponse.builder() + .id("id") + .name("name") + .organizationId("organization_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isDefault(true) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(v2ProjectGetResponse.id()).isEqualTo("id") + assertThat(v2ProjectGetResponse.name()).isEqualTo("name") + assertThat(v2ProjectGetResponse.organizationId()).isEqualTo("organization_id") + assertThat(v2ProjectGetResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(v2ProjectGetResponse.isDefault()).contains(true) + assertThat(v2ProjectGetResponse.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val v2ProjectGetResponse = + V2ProjectGetResponse.builder() + .id("id") + .name("name") + .organizationId("organization_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isDefault(true) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedV2ProjectGetResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(v2ProjectGetResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedV2ProjectGetResponse).isEqualTo(v2ProjectGetResponse) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListPageResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListPageResponseTest.kt new file mode 100644 index 0000000..257505b --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListPageResponseTest.kt @@ -0,0 +1,73 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.v2projects + +import ai.llamaindex.llamacloud.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class V2ProjectListPageResponseTest { + + @Test + fun create() { + val v2ProjectListPageResponse = + V2ProjectListPageResponse.builder() + .addItem( + V2ProjectListResponse.builder() + .id("id") + .name("name") + .organizationId("organization_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isDefault(true) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .nextPageToken("next_page_token") + .totalSize(0L) + .build() + + assertThat(v2ProjectListPageResponse.items()) + .containsExactly( + V2ProjectListResponse.builder() + .id("id") + .name("name") + .organizationId("organization_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isDefault(true) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + assertThat(v2ProjectListPageResponse.nextPageToken()).contains("next_page_token") + assertThat(v2ProjectListPageResponse.totalSize()).contains(0L) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val v2ProjectListPageResponse = + V2ProjectListPageResponse.builder() + .addItem( + V2ProjectListResponse.builder() + .id("id") + .name("name") + .organizationId("organization_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isDefault(true) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .nextPageToken("next_page_token") + .totalSize(0L) + .build() + + val roundtrippedV2ProjectListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(v2ProjectListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedV2ProjectListPageResponse).isEqualTo(v2ProjectListPageResponse) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListParamsTest.kt new file mode 100644 index 0000000..5c3af66 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListParamsTest.kt @@ -0,0 +1,52 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.v2projects + +import ai.llamaindex.llamacloud.core.http.QueryParams +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class V2ProjectListParamsTest { + + @Test + fun create() { + V2ProjectListParams.builder() + .name("name") + .organizationId("organization_id") + .pageSize(0L) + .pageToken("page_token") + .build() + } + + @Test + fun queryParams() { + val params = + V2ProjectListParams.builder() + .name("name") + .organizationId("organization_id") + .pageSize(0L) + .pageToken("page_token") + .build() + + val queryParams = params._queryParams() + + assertThat(queryParams) + .isEqualTo( + QueryParams.builder() + .put("name", "name") + .put("organization_id", "organization_id") + .put("page_size", "0") + .put("page_token", "page_token") + .build() + ) + } + + @Test + fun queryParamsWithoutOptionalFields() { + val params = V2ProjectListParams.builder().build() + + val queryParams = params._queryParams() + + assertThat(queryParams).isEqualTo(QueryParams.builder().build()) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListResponseTest.kt new file mode 100644 index 0000000..9c2559b --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/v2projects/V2ProjectListResponseTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.models.v2projects + +import ai.llamaindex.llamacloud.core.jsonMapper +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class V2ProjectListResponseTest { + + @Test + fun create() { + val v2ProjectListResponse = + V2ProjectListResponse.builder() + .id("id") + .name("name") + .organizationId("organization_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isDefault(true) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + assertThat(v2ProjectListResponse.id()).isEqualTo("id") + assertThat(v2ProjectListResponse.name()).isEqualTo("name") + assertThat(v2ProjectListResponse.organizationId()).isEqualTo("organization_id") + assertThat(v2ProjectListResponse.createdAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + assertThat(v2ProjectListResponse.isDefault()).contains(true) + assertThat(v2ProjectListResponse.updatedAt()) + .contains(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val v2ProjectListResponse = + V2ProjectListResponse.builder() + .id("id") + .name("name") + .organizationId("organization_id") + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .isDefault(true) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + + val roundtrippedV2ProjectListResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(v2ProjectListResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedV2ProjectListResponse).isEqualTo(v2ProjectListResponse) + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsyncTest.kt index 12c36e5..af70389 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsyncTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsyncTest.kt @@ -7,6 +7,7 @@ import ai.llamaindex.llamacloud.models.files.FileCreateParams import ai.llamaindex.llamacloud.models.files.FileDeleteParams import ai.llamaindex.llamacloud.models.files.FileGetParams import ai.llamaindex.llamacloud.models.files.FileQueryParams +import ai.llamaindex.llamacloud.models.files.FileRetrieveParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -33,6 +34,27 @@ internal class FileServiceAsyncTest { file.validate() } + @Disabled("Mock server tests are disabled") + @Test + fun retrieve() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val fileServiceAsync = client.files() + + val fileFuture = + fileServiceAsync.retrieve( + FileRetrieveParams.builder() + .fileId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExpand("string") + .addExpand("string") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val file = fileFuture.get() + file.validate() + } + @Disabled("Mock server tests are disabled") @Test fun list() { diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/JobDataPointServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/JobDataPointServiceAsyncTest.kt new file mode 100644 index 0000000..a7ed1c5 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/JobDataPointServiceAsyncTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.async + +import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClientAsync +import ai.llamaindex.llamacloud.models.jobdatapoints.JobDataPointListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class JobDataPointServiceAsyncTest { + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val jobDataPointServiceAsync = client.jobDataPoints() + + val pageFuture = + jobDataPointServiceAsync.list( + JobDataPointListParams.builder() + .jobType(JobDataPointListParams.JobType.PARSE) + .build() + ) + + val page = pageFuture.get() + page.response().validate() + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/V2ProjectServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/V2ProjectServiceAsyncTest.kt new file mode 100644 index 0000000..a7e73d9 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/V2ProjectServiceAsyncTest.kt @@ -0,0 +1,41 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.async + +import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClientAsync +import ai.llamaindex.llamacloud.models.v2projects.V2ProjectGetParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class V2ProjectServiceAsyncTest { + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val v2ProjectServiceAsync = client.v2Projects() + + val pageFuture = v2ProjectServiceAsync.list() + + val page = pageFuture.get() + page.response().validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun get() { + val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() + val v2ProjectServiceAsync = client.v2Projects() + + val v2ProjectFuture = + v2ProjectServiceAsync.get( + V2ProjectGetParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val v2Project = v2ProjectFuture.get() + v2Project.validate() + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/FileServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/FileServiceTest.kt index 9072de0..65d4709 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/FileServiceTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/FileServiceTest.kt @@ -7,6 +7,7 @@ import ai.llamaindex.llamacloud.models.files.FileCreateParams import ai.llamaindex.llamacloud.models.files.FileDeleteParams import ai.llamaindex.llamacloud.models.files.FileGetParams import ai.llamaindex.llamacloud.models.files.FileQueryParams +import ai.llamaindex.llamacloud.models.files.FileRetrieveParams import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test @@ -32,6 +33,26 @@ internal class FileServiceTest { file.validate() } + @Disabled("Mock server tests are disabled") + @Test + fun retrieve() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val fileService = client.files() + + val file = + fileService.retrieve( + FileRetrieveParams.builder() + .fileId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addExpand("string") + .addExpand("string") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + file.validate() + } + @Disabled("Mock server tests are disabled") @Test fun list() { diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/JobDataPointServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/JobDataPointServiceTest.kt new file mode 100644 index 0000000..8b02f50 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/JobDataPointServiceTest.kt @@ -0,0 +1,27 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.blocking + +import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClient +import ai.llamaindex.llamacloud.models.jobdatapoints.JobDataPointListParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class JobDataPointServiceTest { + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val jobDataPointService = client.jobDataPoints() + + val page = + jobDataPointService.list( + JobDataPointListParams.builder() + .jobType(JobDataPointListParams.JobType.PARSE) + .build() + ) + + page.response().validate() + } +} diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/V2ProjectServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/V2ProjectServiceTest.kt new file mode 100644 index 0000000..c17e171 --- /dev/null +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/V2ProjectServiceTest.kt @@ -0,0 +1,39 @@ +// File generated from our OpenAPI spec by Stainless. + +package ai.llamaindex.llamacloud.services.blocking + +import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClient +import ai.llamaindex.llamacloud.models.v2projects.V2ProjectGetParams +import org.junit.jupiter.api.Disabled +import org.junit.jupiter.api.Test + +internal class V2ProjectServiceTest { + + @Disabled("Mock server tests are disabled") + @Test + fun list() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val v2ProjectService = client.v2Projects() + + val page = v2ProjectService.list() + + page.response().validate() + } + + @Disabled("Mock server tests are disabled") + @Test + fun get() { + val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() + val v2ProjectService = client.v2Projects() + + val v2Project = + v2ProjectService.get( + V2ProjectGetParams.builder() + .projectId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + v2Project.validate() + } +} diff --git a/llama-cloud-proguard-test/src/test/kotlin/ai/llamaindex/llamacloud/proguard/ProGuardCompatibilityTest.kt b/llama-cloud-proguard-test/src/test/kotlin/ai/llamaindex/llamacloud/proguard/ProGuardCompatibilityTest.kt index 10217c0..f4a5fe0 100644 --- a/llama-cloud-proguard-test/src/test/kotlin/ai/llamaindex/llamacloud/proguard/ProGuardCompatibilityTest.kt +++ b/llama-cloud-proguard-test/src/test/kotlin/ai/llamaindex/llamacloud/proguard/ProGuardCompatibilityTest.kt @@ -61,6 +61,8 @@ internal class ProGuardCompatibilityTest { assertThat(client.configurations()).isNotNull() assertThat(client.webhookConfigs()).isNotNull() assertThat(client.projects()).isNotNull() + assertThat(client.v2Projects()).isNotNull() + assertThat(client.jobDataPoints()).isNotNull() assertThat(client.dataSinks()).isNotNull() assertThat(client.dataSources()).isNotNull() assertThat(client.pipelines()).isNotNull() From e37155179c4355cd400cecc9943de86a84e3bd74 Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Tue, 11 Aug 2026 19:11:04 +0000 Subject: [PATCH 26/28] Enable Extract v2 caching with configuration control (#23715) Stainless-Generated-From: 2fdd9cc9a4a2bd379e1f0645beba8f7b040a9dc4 --- .../configurations/ExtractV2Parameters.kt | 45 ++++++++++++++++++- .../models/extract/ExtractConfiguration.kt | 45 ++++++++++++++++++- .../configurations/ExtractV2ParametersTest.kt | 3 ++ .../extract/ExtractConfigurationTest.kt | 3 ++ .../models/extract/ExtractCreateParamsTest.kt | 4 ++ .../models/extract/ExtractV2JobCreateTest.kt | 3 ++ .../extract/ExtractV2JobQueryResponseTest.kt | 3 ++ .../models/extract/ExtractV2JobTest.kt | 3 ++ .../services/async/ExtractServiceAsyncTest.kt | 1 + .../services/blocking/ExtractServiceTest.kt | 1 + 10 files changed, 109 insertions(+), 2 deletions(-) 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 8e1c67e..b725b0c 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 @@ -28,6 +28,7 @@ private constructor( private val productType: JsonValue, private val citeSources: JsonField, private val confidenceScores: JsonField, + private val disableCache: JsonField, private val extractionTarget: JsonField, private val maxPages: JsonField, private val parseConfigId: JsonField, @@ -53,6 +54,9 @@ private constructor( @JsonProperty("confidence_scores") @ExcludeMissing confidenceScores: JsonField = JsonMissing.of(), + @JsonProperty("disable_cache") + @ExcludeMissing + disableCache: JsonField = JsonMissing.of(), @JsonProperty("extraction_target") @ExcludeMissing extractionTarget: JsonField = JsonMissing.of(), @@ -80,6 +84,7 @@ private constructor( productType, citeSources, confidenceScores, + disableCache, extractionTarget, maxPages, parseConfigId, @@ -133,6 +138,14 @@ private constructor( */ fun confidenceScores(): Optional = confidenceScores.getOptional("confidence_scores") + /** + * Disable reuse and storage of Extract results + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + 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 @@ -257,6 +270,15 @@ private constructor( @ExcludeMissing fun _confidenceScores(): JsonField = confidenceScores + /** + * Returns the raw JSON value of [disableCache]. + * + * Unlike [disableCache], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("disable_cache") + @ExcludeMissing + fun _disableCache(): JsonField = disableCache + /** * Returns the raw JSON value of [extractionTarget]. * @@ -372,6 +394,7 @@ private constructor( private var productType: JsonValue = JsonValue.from("extract_v2") private var citeSources: JsonField = JsonMissing.of() private var confidenceScores: JsonField = JsonMissing.of() + private var disableCache: JsonField = JsonMissing.of() private var extractionTarget: JsonField = JsonMissing.of() private var maxPages: JsonField = JsonMissing.of() private var parseConfigId: JsonField = JsonMissing.of() @@ -390,6 +413,7 @@ private constructor( productType = extractV2Parameters.productType citeSources = extractV2Parameters.citeSources confidenceScores = extractV2Parameters.confidenceScores + disableCache = extractV2Parameters.disableCache extractionTarget = extractV2Parameters.extractionTarget maxPages = extractV2Parameters.maxPages parseConfigId = extractV2Parameters.parseConfigId @@ -465,6 +489,20 @@ private constructor( this.confidenceScores = confidenceScores } + /** Disable reuse and storage of Extract results */ + fun disableCache(disableCache: Boolean) = disableCache(JsonField.of(disableCache)) + + /** + * Sets [Builder.disableCache] to an arbitrary JSON value. + * + * You should usually call [Builder.disableCache] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun disableCache(disableCache: JsonField) = apply { + this.disableCache = disableCache + } + /** * 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 @@ -702,6 +740,7 @@ private constructor( productType, citeSources, confidenceScores, + disableCache, extractionTarget, maxPages, parseConfigId, @@ -739,6 +778,7 @@ private constructor( } citeSources() confidenceScores() + disableCache() extractionTarget().ifPresent { it.validate() } maxPages() parseConfigId() @@ -771,6 +811,7 @@ private constructor( productType.let { if (it == JsonValue.from("extract_v2")) 1 else 0 } + (if (citeSources.asKnown().isPresent) 1 else 0) + (if (confidenceScores.asKnown().isPresent) 1 else 0) + + (if (disableCache.asKnown().isPresent) 1 else 0) + (extractionTarget.asKnown().getOrNull()?.validity() ?: 0) + (if (maxPages.asKnown().isPresent) 1 else 0) + (if (parseConfigId.asKnown().isPresent) 1 else 0) + @@ -1200,6 +1241,7 @@ private constructor( productType == other.productType && citeSources == other.citeSources && confidenceScores == other.confidenceScores && + disableCache == other.disableCache && extractionTarget == other.extractionTarget && maxPages == other.maxPages && parseConfigId == other.parseConfigId && @@ -1219,6 +1261,7 @@ private constructor( productType, citeSources, confidenceScores, + disableCache, extractionTarget, maxPages, parseConfigId, @@ -1236,5 +1279,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ExtractV2Parameters{dataSchema=$dataSchema, productType=$productType, citeSources=$citeSources, confidenceScores=$confidenceScores, extractionTarget=$extractionTarget, maxPages=$maxPages, parseConfigId=$parseConfigId, parseTier=$parseTier, sheetNames=$sheetNames, spreadsheetMode=$spreadsheetMode, systemPrompt=$systemPrompt, targetPages=$targetPages, tier=$tier, version=$version, additionalProperties=$additionalProperties}" + "ExtractV2Parameters{dataSchema=$dataSchema, productType=$productType, citeSources=$citeSources, confidenceScores=$confidenceScores, disableCache=$disableCache, extractionTarget=$extractionTarget, maxPages=$maxPages, parseConfigId=$parseConfigId, parseTier=$parseTier, sheetNames=$sheetNames, spreadsheetMode=$spreadsheetMode, systemPrompt=$systemPrompt, targetPages=$targetPages, tier=$tier, version=$version, additionalProperties=$additionalProperties}" } 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 0cf7005..0433f48 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 @@ -27,6 +27,7 @@ private constructor( private val dataSchema: JsonField, private val citeSources: JsonField, private val confidenceScores: JsonField, + private val disableCache: JsonField, private val extractionTarget: JsonField, private val maxPages: JsonField, private val parseConfigId: JsonField, @@ -51,6 +52,9 @@ private constructor( @JsonProperty("confidence_scores") @ExcludeMissing confidenceScores: JsonField = JsonMissing.of(), + @JsonProperty("disable_cache") + @ExcludeMissing + disableCache: JsonField = JsonMissing.of(), @JsonProperty("extraction_target") @ExcludeMissing extractionTarget: JsonField = JsonMissing.of(), @@ -77,6 +81,7 @@ private constructor( dataSchema, citeSources, confidenceScores, + disableCache, extractionTarget, maxPages, parseConfigId, @@ -117,6 +122,14 @@ private constructor( */ fun confidenceScores(): Optional = confidenceScores.getOptional("confidence_scores") + /** + * Disable reuse and storage of Extract results + * + * @throws LlamaCloudInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + 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 @@ -241,6 +254,15 @@ private constructor( @ExcludeMissing fun _confidenceScores(): JsonField = confidenceScores + /** + * Returns the raw JSON value of [disableCache]. + * + * Unlike [disableCache], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("disable_cache") + @ExcludeMissing + fun _disableCache(): JsonField = disableCache + /** * Returns the raw JSON value of [extractionTarget]. * @@ -355,6 +377,7 @@ private constructor( private var dataSchema: JsonField? = null private var citeSources: JsonField = JsonMissing.of() private var confidenceScores: JsonField = JsonMissing.of() + private var disableCache: JsonField = JsonMissing.of() private var extractionTarget: JsonField = JsonMissing.of() private var maxPages: JsonField = JsonMissing.of() private var parseConfigId: JsonField = JsonMissing.of() @@ -372,6 +395,7 @@ private constructor( dataSchema = extractConfiguration.dataSchema citeSources = extractConfiguration.citeSources confidenceScores = extractConfiguration.confidenceScores + disableCache = extractConfiguration.disableCache extractionTarget = extractConfiguration.extractionTarget maxPages = extractConfiguration.maxPages parseConfigId = extractConfiguration.parseConfigId @@ -433,6 +457,20 @@ private constructor( this.confidenceScores = confidenceScores } + /** Disable reuse and storage of Extract results */ + fun disableCache(disableCache: Boolean) = disableCache(JsonField.of(disableCache)) + + /** + * Sets [Builder.disableCache] to an arbitrary JSON value. + * + * You should usually call [Builder.disableCache] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun disableCache(disableCache: JsonField) = apply { + this.disableCache = disableCache + } + /** * 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 @@ -669,6 +707,7 @@ private constructor( checkRequired("dataSchema", dataSchema), citeSources, confidenceScores, + disableCache, extractionTarget, maxPages, parseConfigId, @@ -701,6 +740,7 @@ private constructor( dataSchema().validate() citeSources() confidenceScores() + disableCache() extractionTarget().ifPresent { it.validate() } maxPages() parseConfigId() @@ -732,6 +772,7 @@ private constructor( (dataSchema.asKnown().getOrNull()?.validity() ?: 0) + (if (citeSources.asKnown().isPresent) 1 else 0) + (if (confidenceScores.asKnown().isPresent) 1 else 0) + + (if (disableCache.asKnown().isPresent) 1 else 0) + (extractionTarget.asKnown().getOrNull()?.validity() ?: 0) + (if (maxPages.asKnown().isPresent) 1 else 0) + (if (parseConfigId.asKnown().isPresent) 1 else 0) + @@ -1160,6 +1201,7 @@ private constructor( dataSchema == other.dataSchema && citeSources == other.citeSources && confidenceScores == other.confidenceScores && + disableCache == other.disableCache && extractionTarget == other.extractionTarget && maxPages == other.maxPages && parseConfigId == other.parseConfigId && @@ -1178,6 +1220,7 @@ private constructor( dataSchema, citeSources, confidenceScores, + disableCache, extractionTarget, maxPages, parseConfigId, @@ -1195,5 +1238,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "ExtractConfiguration{dataSchema=$dataSchema, citeSources=$citeSources, confidenceScores=$confidenceScores, extractionTarget=$extractionTarget, maxPages=$maxPages, parseConfigId=$parseConfigId, parseTier=$parseTier, sheetNames=$sheetNames, spreadsheetMode=$spreadsheetMode, systemPrompt=$systemPrompt, targetPages=$targetPages, tier=$tier, version=$version, additionalProperties=$additionalProperties}" + "ExtractConfiguration{dataSchema=$dataSchema, citeSources=$citeSources, confidenceScores=$confidenceScores, disableCache=$disableCache, extractionTarget=$extractionTarget, maxPages=$maxPages, parseConfigId=$parseConfigId, parseTier=$parseTier, sheetNames=$sheetNames, spreadsheetMode=$spreadsheetMode, systemPrompt=$systemPrompt, targetPages=$targetPages, tier=$tier, version=$version, additionalProperties=$additionalProperties}" } diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/configurations/ExtractV2ParametersTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/configurations/ExtractV2ParametersTest.kt index 8ce176d..4cb735c 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/configurations/ExtractV2ParametersTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/configurations/ExtractV2ParametersTest.kt @@ -22,6 +22,7 @@ internal class ExtractV2ParametersTest { ) .citeSources(true) .confidenceScores(true) + .disableCache(true) .extractionTarget(ExtractV2Parameters.ExtractionTarget.PER_DOC) .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") @@ -45,6 +46,7 @@ internal class ExtractV2ParametersTest { ) assertThat(extractV2Parameters.citeSources()).contains(true) assertThat(extractV2Parameters.confidenceScores()).contains(true) + assertThat(extractV2Parameters.disableCache()).contains(true) assertThat(extractV2Parameters.extractionTarget()) .contains(ExtractV2Parameters.ExtractionTarget.PER_DOC) assertThat(extractV2Parameters.maxPages()).contains(10L) @@ -75,6 +77,7 @@ internal class ExtractV2ParametersTest { ) .citeSources(true) .confidenceScores(true) + .disableCache(true) .extractionTarget(ExtractV2Parameters.ExtractionTarget.PER_DOC) .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractConfigurationTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractConfigurationTest.kt index 4b70942..50b9087 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractConfigurationTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractConfigurationTest.kt @@ -22,6 +22,7 @@ internal class ExtractConfigurationTest { ) .citeSources(true) .confidenceScores(true) + .disableCache(true) .extractionTarget(ExtractConfiguration.ExtractionTarget.PER_DOC) .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") @@ -45,6 +46,7 @@ internal class ExtractConfigurationTest { ) assertThat(extractConfiguration.citeSources()).contains(true) assertThat(extractConfiguration.confidenceScores()).contains(true) + assertThat(extractConfiguration.disableCache()).contains(true) assertThat(extractConfiguration.extractionTarget()) .contains(ExtractConfiguration.ExtractionTarget.PER_DOC) assertThat(extractConfiguration.maxPages()).contains(10L) @@ -75,6 +77,7 @@ internal class ExtractConfigurationTest { ) .citeSources(true) .confidenceScores(true) + .disableCache(true) .extractionTarget(ExtractConfiguration.ExtractionTarget.PER_DOC) .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractCreateParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractCreateParamsTest.kt index 0d7375e..af3cd12 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractCreateParamsTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractCreateParamsTest.kt @@ -36,6 +36,7 @@ internal class ExtractCreateParamsTest { ) .citeSources(true) .confidenceScores(true) + .disableCache(true) .extractionTarget(ExtractConfiguration.ExtractionTarget.PER_DOC) .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") @@ -111,6 +112,7 @@ internal class ExtractCreateParamsTest { ) .citeSources(true) .confidenceScores(true) + .disableCache(true) .extractionTarget(ExtractConfiguration.ExtractionTarget.PER_DOC) .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") @@ -213,6 +215,7 @@ internal class ExtractCreateParamsTest { ) .citeSources(true) .confidenceScores(true) + .disableCache(true) .extractionTarget(ExtractConfiguration.ExtractionTarget.PER_DOC) .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") @@ -282,6 +285,7 @@ internal class ExtractCreateParamsTest { ) .citeSources(true) .confidenceScores(true) + .disableCache(true) .extractionTarget(ExtractConfiguration.ExtractionTarget.PER_DOC) .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobCreateTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobCreateTest.kt index 00b914b..e6d77ba 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobCreateTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobCreateTest.kt @@ -35,6 +35,7 @@ internal class ExtractV2JobCreateTest { ) .citeSources(true) .confidenceScores(true) + .disableCache(true) .extractionTarget(ExtractConfiguration.ExtractionTarget.PER_DOC) .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") @@ -98,6 +99,7 @@ internal class ExtractV2JobCreateTest { ) .citeSources(true) .confidenceScores(true) + .disableCache(true) .extractionTarget(ExtractConfiguration.ExtractionTarget.PER_DOC) .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") @@ -163,6 +165,7 @@ internal class ExtractV2JobCreateTest { ) .citeSources(true) .confidenceScores(true) + .disableCache(true) .extractionTarget(ExtractConfiguration.ExtractionTarget.PER_DOC) .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobQueryResponseTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobQueryResponseTest.kt index e2d42c8..ac77e50 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobQueryResponseTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobQueryResponseTest.kt @@ -35,6 +35,7 @@ internal class ExtractV2JobQueryResponseTest { ) .citeSources(true) .confidenceScores(true) + .disableCache(true) .extractionTarget(ExtractConfiguration.ExtractionTarget.PER_DOC) .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") @@ -184,6 +185,7 @@ internal class ExtractV2JobQueryResponseTest { ) .citeSources(true) .confidenceScores(true) + .disableCache(true) .extractionTarget(ExtractConfiguration.ExtractionTarget.PER_DOC) .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") @@ -337,6 +339,7 @@ internal class ExtractV2JobQueryResponseTest { ) .citeSources(true) .confidenceScores(true) + .disableCache(true) .extractionTarget(ExtractConfiguration.ExtractionTarget.PER_DOC) .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobTest.kt index 52fad3a..3536131 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/extract/ExtractV2JobTest.kt @@ -30,6 +30,7 @@ internal class ExtractV2JobTest { ) .citeSources(true) .confidenceScores(true) + .disableCache(true) .extractionTarget(ExtractConfiguration.ExtractionTarget.PER_DOC) .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") @@ -169,6 +170,7 @@ internal class ExtractV2JobTest { ) .citeSources(true) .confidenceScores(true) + .disableCache(true) .extractionTarget(ExtractConfiguration.ExtractionTarget.PER_DOC) .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") @@ -314,6 +316,7 @@ internal class ExtractV2JobTest { ) .citeSources(true) .confidenceScores(true) + .disableCache(true) .extractionTarget(ExtractConfiguration.ExtractionTarget.PER_DOC) .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsyncTest.kt index c1c0c9e..b9824ee 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsyncTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/ExtractServiceAsyncTest.kt @@ -56,6 +56,7 @@ internal class ExtractServiceAsyncTest { ) .citeSources(true) .confidenceScores(true) + .disableCache(true) .extractionTarget(ExtractConfiguration.ExtractionTarget.PER_DOC) .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractServiceTest.kt index 7a54bb6..7faf7d9 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractServiceTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/ExtractServiceTest.kt @@ -56,6 +56,7 @@ internal class ExtractServiceTest { ) .citeSources(true) .confidenceScores(true) + .disableCache(true) .extractionTarget(ExtractConfiguration.ExtractionTarget.PER_DOC) .maxPages(10L) .parseConfigId("cfg-11111111-2222-3333-4444-555555555555") From 46b7f51d05eba9700a594af08f9ab0141c825f2c Mon Sep 17 00:00:00 2001 From: stlc-bot Date: Wed, 12 Aug 2026 22:53:37 +0000 Subject: [PATCH 27/28] feat(files): rename files.get to files.content and restore files.retrieve Stainless-Generated-From: a260c4725ab14a809f7462d506170624350d27f1 --- ...{FileGetParams.kt => FileContentParams.kt} | 32 ++++---- .../services/async/FileServiceAsync.kt | 79 ++++++++++--------- .../services/async/FileServiceAsyncImpl.kt | 16 ++-- .../services/blocking/FileService.kt | 75 +++++++++--------- .../services/blocking/FileServiceImpl.kt | 14 ++-- ...ParamsTest.kt => FileContentParamsTest.kt} | 12 +-- .../services/async/FileServiceAsyncTest.kt | 8 +- .../services/blocking/FileServiceTest.kt | 8 +- 8 files changed, 125 insertions(+), 119 deletions(-) rename llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/files/{FileGetParams.kt => FileContentParams.kt} (89%) rename llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/files/{FileGetParamsTest.kt => FileContentParamsTest.kt} (82%) diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/files/FileGetParams.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/files/FileContentParams.kt similarity index 89% rename from llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/files/FileGetParams.kt rename to llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/files/FileContentParams.kt index 5ef05f6..7537c33 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/files/FileGetParams.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/models/files/FileContentParams.kt @@ -10,7 +10,7 @@ import java.util.Optional import kotlin.jvm.optionals.getOrNull /** Get a presigned URL to download the file content. */ -class FileGetParams +class FileContentParams private constructor( private val fileId: String?, private val expiresAtSeconds: Long?, @@ -38,13 +38,13 @@ private constructor( companion object { - @JvmStatic fun none(): FileGetParams = builder().build() + @JvmStatic fun none(): FileContentParams = builder().build() - /** Returns a mutable builder for constructing an instance of [FileGetParams]. */ + /** Returns a mutable builder for constructing an instance of [FileContentParams]. */ @JvmStatic fun builder() = Builder() } - /** A builder for [FileGetParams]. */ + /** A builder for [FileContentParams]. */ class Builder internal constructor() { private var fileId: String? = null @@ -55,13 +55,13 @@ private constructor( private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @JvmSynthetic - internal fun from(fileGetParams: FileGetParams) = apply { - fileId = fileGetParams.fileId - expiresAtSeconds = fileGetParams.expiresAtSeconds - organizationId = fileGetParams.organizationId - projectId = fileGetParams.projectId - additionalHeaders = fileGetParams.additionalHeaders.toBuilder() - additionalQueryParams = fileGetParams.additionalQueryParams.toBuilder() + internal fun from(fileContentParams: FileContentParams) = apply { + fileId = fileContentParams.fileId + expiresAtSeconds = fileContentParams.expiresAtSeconds + organizationId = fileContentParams.organizationId + projectId = fileContentParams.projectId + additionalHeaders = fileContentParams.additionalHeaders.toBuilder() + additionalQueryParams = fileContentParams.additionalQueryParams.toBuilder() } fun fileId(fileId: String?) = apply { this.fileId = fileId } @@ -194,12 +194,12 @@ private constructor( } /** - * Returns an immutable instance of [FileGetParams]. + * Returns an immutable instance of [FileContentParams]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): FileGetParams = - FileGetParams( + fun build(): FileContentParams = + FileContentParams( fileId, expiresAtSeconds, organizationId, @@ -232,7 +232,7 @@ private constructor( return true } - return other is FileGetParams && + return other is FileContentParams && fileId == other.fileId && expiresAtSeconds == other.expiresAtSeconds && organizationId == other.organizationId && @@ -252,5 +252,5 @@ private constructor( ) override fun toString() = - "FileGetParams{fileId=$fileId, expiresAtSeconds=$expiresAtSeconds, organizationId=$organizationId, projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" + "FileContentParams{fileId=$fileId, expiresAtSeconds=$expiresAtSeconds, organizationId=$organizationId, projectId=$projectId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" } diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsync.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsync.kt index ebf25f4..d61cc02 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsync.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsync.kt @@ -6,10 +6,10 @@ import ai.llamaindex.llamacloud.core.ClientOptions import ai.llamaindex.llamacloud.core.RequestOptions import ai.llamaindex.llamacloud.core.http.HttpResponse import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.models.files.FileContentParams import ai.llamaindex.llamacloud.models.files.FileCreateParams import ai.llamaindex.llamacloud.models.files.FileCreateResponse import ai.llamaindex.llamacloud.models.files.FileDeleteParams -import ai.llamaindex.llamacloud.models.files.FileGetParams import ai.llamaindex.llamacloud.models.files.FileListPageAsync import ai.llamaindex.llamacloud.models.files.FileListParams import ai.llamaindex.llamacloud.models.files.FileQueryParams @@ -140,35 +140,36 @@ interface FileServiceAsync { delete(fileId, FileDeleteParams.none(), requestOptions) /** Get a presigned URL to download the file content. */ - fun get(fileId: String): CompletableFuture = get(fileId, FileGetParams.none()) + fun content(fileId: String): CompletableFuture = + content(fileId, FileContentParams.none()) - /** @see get */ - fun get( + /** @see content */ + fun content( fileId: String, - params: FileGetParams = FileGetParams.none(), + params: FileContentParams = FileContentParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture = - get(params.toBuilder().fileId(fileId).build(), requestOptions) + content(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see get */ - fun get( + /** @see content */ + fun content( fileId: String, - params: FileGetParams = FileGetParams.none(), - ): CompletableFuture = get(fileId, params, RequestOptions.none()) + params: FileContentParams = FileContentParams.none(), + ): CompletableFuture = content(fileId, params, RequestOptions.none()) - /** @see get */ - fun get( - params: FileGetParams, + /** @see content */ + fun content( + params: FileContentParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture - /** @see get */ - fun get(params: FileGetParams): CompletableFuture = - get(params, RequestOptions.none()) + /** @see content */ + fun content(params: FileContentParams): CompletableFuture = + content(params, RequestOptions.none()) - /** @see get */ - fun get(fileId: String, requestOptions: RequestOptions): CompletableFuture = - get(fileId, FileGetParams.none(), requestOptions) + /** @see content */ + fun content(fileId: String, requestOptions: RequestOptions): CompletableFuture = + content(fileId, FileContentParams.none(), requestOptions) /** Query files with filtering and pagination. Deprecated: use `GET /files`. */ @Deprecated("Use the GET /files endpoint instead") @@ -322,42 +323,42 @@ interface FileServiceAsync { /** * Returns a raw HTTP response for `get /api/v1/beta/files/{file_id}/content`, but is - * otherwise the same as [FileServiceAsync.get]. + * otherwise the same as [FileServiceAsync.content]. */ - fun get(fileId: String): CompletableFuture> = - get(fileId, FileGetParams.none()) + fun content(fileId: String): CompletableFuture> = + content(fileId, FileContentParams.none()) - /** @see get */ - fun get( + /** @see content */ + fun content( fileId: String, - params: FileGetParams = FileGetParams.none(), + params: FileContentParams = FileContentParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> = - get(params.toBuilder().fileId(fileId).build(), requestOptions) + content(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see get */ - fun get( + /** @see content */ + fun content( fileId: String, - params: FileGetParams = FileGetParams.none(), + params: FileContentParams = FileContentParams.none(), ): CompletableFuture> = - get(fileId, params, RequestOptions.none()) + content(fileId, params, RequestOptions.none()) - /** @see get */ - fun get( - params: FileGetParams, + /** @see content */ + fun content( + params: FileContentParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> - /** @see get */ - fun get(params: FileGetParams): CompletableFuture> = - get(params, RequestOptions.none()) + /** @see content */ + fun content(params: FileContentParams): CompletableFuture> = + content(params, RequestOptions.none()) - /** @see get */ - fun get( + /** @see content */ + fun content( fileId: String, requestOptions: RequestOptions, ): CompletableFuture> = - get(fileId, FileGetParams.none(), requestOptions) + content(fileId, FileContentParams.none(), requestOptions) /** * Returns a raw HTTP response for `post /api/v1/beta/files/query`, but is otherwise the diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsyncImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsyncImpl.kt index c768e1f..ad1e3e5 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsyncImpl.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsyncImpl.kt @@ -18,10 +18,10 @@ import ai.llamaindex.llamacloud.core.http.json import ai.llamaindex.llamacloud.core.http.multipartFormData import ai.llamaindex.llamacloud.core.http.parseable import ai.llamaindex.llamacloud.core.prepareAsync +import ai.llamaindex.llamacloud.models.files.FileContentParams import ai.llamaindex.llamacloud.models.files.FileCreateParams import ai.llamaindex.llamacloud.models.files.FileCreateResponse import ai.llamaindex.llamacloud.models.files.FileDeleteParams -import ai.llamaindex.llamacloud.models.files.FileGetParams import ai.llamaindex.llamacloud.models.files.FileListPageAsync import ai.llamaindex.llamacloud.models.files.FileListPageResponse import ai.llamaindex.llamacloud.models.files.FileListParams @@ -74,12 +74,12 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien // delete /api/v1/beta/files/{file_id} withRawResponse().delete(params, requestOptions).thenAccept {} - override fun get( - params: FileGetParams, + override fun content( + params: FileContentParams, requestOptions: RequestOptions, ): CompletableFuture = // get /api/v1/beta/files/{file_id}/content - withRawResponse().get(params, requestOptions).thenApply { it.parse() } + withRawResponse().content(params, requestOptions).thenApply { it.parse() } @Deprecated("Use the GET /files endpoint instead") override fun query( @@ -231,11 +231,11 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien } } - private val getHandler: Handler = + private val contentHandler: Handler = jsonHandler(clientOptions.jsonMapper) - override fun get( - params: FileGetParams, + override fun content( + params: FileContentParams, requestOptions: RequestOptions, ): CompletableFuture> { // We check here instead of in the params builder because this can be specified @@ -254,7 +254,7 @@ class FileServiceAsyncImpl internal constructor(private val clientOptions: Clien .thenApply { response -> errorHandler.handle(response).parseable { response - .use { getHandler.handle(it) } + .use { contentHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/FileService.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/FileService.kt index f54b892..a4622ec 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/FileService.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/FileService.kt @@ -6,10 +6,10 @@ import ai.llamaindex.llamacloud.core.ClientOptions import ai.llamaindex.llamacloud.core.RequestOptions import ai.llamaindex.llamacloud.core.http.HttpResponse import ai.llamaindex.llamacloud.core.http.HttpResponseFor +import ai.llamaindex.llamacloud.models.files.FileContentParams import ai.llamaindex.llamacloud.models.files.FileCreateParams import ai.llamaindex.llamacloud.models.files.FileCreateResponse import ai.llamaindex.llamacloud.models.files.FileDeleteParams -import ai.llamaindex.llamacloud.models.files.FileGetParams import ai.llamaindex.llamacloud.models.files.FileListPage import ai.llamaindex.llamacloud.models.files.FileListParams import ai.llamaindex.llamacloud.models.files.FileQueryParams @@ -128,31 +128,33 @@ interface FileService { delete(fileId, FileDeleteParams.none(), requestOptions) /** Get a presigned URL to download the file content. */ - fun get(fileId: String): PresignedUrl = get(fileId, FileGetParams.none()) + fun content(fileId: String): PresignedUrl = content(fileId, FileContentParams.none()) - /** @see get */ - fun get( + /** @see content */ + fun content( fileId: String, - params: FileGetParams = FileGetParams.none(), + params: FileContentParams = FileContentParams.none(), requestOptions: RequestOptions = RequestOptions.none(), - ): PresignedUrl = get(params.toBuilder().fileId(fileId).build(), requestOptions) + ): PresignedUrl = content(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see get */ - fun get(fileId: String, params: FileGetParams = FileGetParams.none()): PresignedUrl = - get(fileId, params, RequestOptions.none()) + /** @see content */ + fun content( + fileId: String, + params: FileContentParams = FileContentParams.none(), + ): PresignedUrl = content(fileId, params, RequestOptions.none()) - /** @see get */ - fun get( - params: FileGetParams, + /** @see content */ + fun content( + params: FileContentParams, requestOptions: RequestOptions = RequestOptions.none(), ): PresignedUrl - /** @see get */ - fun get(params: FileGetParams): PresignedUrl = get(params, RequestOptions.none()) + /** @see content */ + fun content(params: FileContentParams): PresignedUrl = content(params, RequestOptions.none()) - /** @see get */ - fun get(fileId: String, requestOptions: RequestOptions): PresignedUrl = - get(fileId, FileGetParams.none(), requestOptions) + /** @see content */ + fun content(fileId: String, requestOptions: RequestOptions): PresignedUrl = + content(fileId, FileContentParams.none(), requestOptions) /** Query files with filtering and pagination. Deprecated: use `GET /files`. */ @Deprecated("Use the GET /files endpoint instead") @@ -307,43 +309,44 @@ interface FileService { /** * Returns a raw HTTP response for `get /api/v1/beta/files/{file_id}/content`, but is - * otherwise the same as [FileService.get]. + * otherwise the same as [FileService.content]. */ @MustBeClosed - fun get(fileId: String): HttpResponseFor = get(fileId, FileGetParams.none()) + fun content(fileId: String): HttpResponseFor = + content(fileId, FileContentParams.none()) - /** @see get */ + /** @see content */ @MustBeClosed - fun get( + fun content( fileId: String, - params: FileGetParams = FileGetParams.none(), + params: FileContentParams = FileContentParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor = - get(params.toBuilder().fileId(fileId).build(), requestOptions) + content(params.toBuilder().fileId(fileId).build(), requestOptions) - /** @see get */ + /** @see content */ @MustBeClosed - fun get( + fun content( fileId: String, - params: FileGetParams = FileGetParams.none(), - ): HttpResponseFor = get(fileId, params, RequestOptions.none()) + params: FileContentParams = FileContentParams.none(), + ): HttpResponseFor = content(fileId, params, RequestOptions.none()) - /** @see get */ + /** @see content */ @MustBeClosed - fun get( - params: FileGetParams, + fun content( + params: FileContentParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor - /** @see get */ + /** @see content */ @MustBeClosed - fun get(params: FileGetParams): HttpResponseFor = - get(params, RequestOptions.none()) + fun content(params: FileContentParams): HttpResponseFor = + content(params, RequestOptions.none()) - /** @see get */ + /** @see content */ @MustBeClosed - fun get(fileId: String, requestOptions: RequestOptions): HttpResponseFor = - get(fileId, FileGetParams.none(), requestOptions) + fun content(fileId: String, requestOptions: RequestOptions): HttpResponseFor = + content(fileId, FileContentParams.none(), requestOptions) /** * Returns a raw HTTP response for `post /api/v1/beta/files/query`, but is otherwise the diff --git a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/FileServiceImpl.kt b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/FileServiceImpl.kt index 2295961..8c03097 100644 --- a/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/FileServiceImpl.kt +++ b/llama-cloud-core/src/main/kotlin/ai/llamaindex/llamacloud/services/blocking/FileServiceImpl.kt @@ -18,10 +18,10 @@ import ai.llamaindex.llamacloud.core.http.json import ai.llamaindex.llamacloud.core.http.multipartFormData import ai.llamaindex.llamacloud.core.http.parseable import ai.llamaindex.llamacloud.core.prepare +import ai.llamaindex.llamacloud.models.files.FileContentParams import ai.llamaindex.llamacloud.models.files.FileCreateParams import ai.llamaindex.llamacloud.models.files.FileCreateResponse import ai.llamaindex.llamacloud.models.files.FileDeleteParams -import ai.llamaindex.llamacloud.models.files.FileGetParams import ai.llamaindex.llamacloud.models.files.FileListPage import ai.llamaindex.llamacloud.models.files.FileListPageResponse import ai.llamaindex.llamacloud.models.files.FileListParams @@ -67,9 +67,9 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti withRawResponse().delete(params, requestOptions) } - override fun get(params: FileGetParams, requestOptions: RequestOptions): PresignedUrl = + override fun content(params: FileContentParams, requestOptions: RequestOptions): PresignedUrl = // get /api/v1/beta/files/{file_id}/content - withRawResponse().get(params, requestOptions).parse() + withRawResponse().content(params, requestOptions).parse() @Deprecated("Use the GET /files endpoint instead") override fun query(params: FileQueryParams, requestOptions: RequestOptions): FileQueryResponse = @@ -205,11 +205,11 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti } } - private val getHandler: Handler = + private val contentHandler: Handler = jsonHandler(clientOptions.jsonMapper) - override fun get( - params: FileGetParams, + override fun content( + params: FileContentParams, requestOptions: RequestOptions, ): HttpResponseFor { // We check here instead of in the params builder because this can be specified @@ -226,7 +226,7 @@ class FileServiceImpl internal constructor(private val clientOptions: ClientOpti val response = clientOptions.httpClient.execute(request, requestOptions) return errorHandler.handle(response).parseable { response - .use { getHandler.handle(it) } + .use { contentHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { it.validate() diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/files/FileGetParamsTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/files/FileContentParamsTest.kt similarity index 82% rename from llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/files/FileGetParamsTest.kt rename to llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/files/FileContentParamsTest.kt index 040c0a7..3e61754 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/files/FileGetParamsTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/models/files/FileContentParamsTest.kt @@ -6,11 +6,11 @@ import ai.llamaindex.llamacloud.core.http.QueryParams import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class FileGetParamsTest { +internal class FileContentParamsTest { @Test fun create() { - FileGetParams.builder() + FileContentParams.builder() .fileId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .expiresAtSeconds(0L) .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -20,7 +20,8 @@ internal class FileGetParamsTest { @Test fun pathParams() { - val params = FileGetParams.builder().fileId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val params = + FileContentParams.builder().fileId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() assertThat(params._pathParam(0)).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") // out-of-bound path param @@ -30,7 +31,7 @@ internal class FileGetParamsTest { @Test fun queryParams() { val params = - FileGetParams.builder() + FileContentParams.builder() .fileId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .expiresAtSeconds(0L) .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -51,7 +52,8 @@ internal class FileGetParamsTest { @Test fun queryParamsWithoutOptionalFields() { - val params = FileGetParams.builder().fileId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() + val params = + FileContentParams.builder().fileId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e").build() val queryParams = params._queryParams() diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsyncTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsyncTest.kt index af70389..ce88a30 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsyncTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/async/FileServiceAsyncTest.kt @@ -3,9 +3,9 @@ package ai.llamaindex.llamacloud.services.async import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClientAsync +import ai.llamaindex.llamacloud.models.files.FileContentParams import ai.llamaindex.llamacloud.models.files.FileCreateParams import ai.llamaindex.llamacloud.models.files.FileDeleteParams -import ai.llamaindex.llamacloud.models.files.FileGetParams import ai.llamaindex.llamacloud.models.files.FileQueryParams import ai.llamaindex.llamacloud.models.files.FileRetrieveParams import org.junit.jupiter.api.Disabled @@ -87,13 +87,13 @@ internal class FileServiceAsyncTest { @Disabled("Mock server tests are disabled") @Test - fun get() { + fun content() { val client = LlamaCloudOkHttpClientAsync.builder().apiKey("My API Key").build() val fileServiceAsync = client.files() val presignedUrlFuture = - fileServiceAsync.get( - FileGetParams.builder() + fileServiceAsync.content( + FileContentParams.builder() .fileId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .expiresAtSeconds(0L) .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") diff --git a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/FileServiceTest.kt b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/FileServiceTest.kt index 65d4709..ef1ed50 100644 --- a/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/FileServiceTest.kt +++ b/llama-cloud-core/src/test/kotlin/ai/llamaindex/llamacloud/services/blocking/FileServiceTest.kt @@ -3,9 +3,9 @@ package ai.llamaindex.llamacloud.services.blocking import ai.llamaindex.llamacloud.client.okhttp.LlamaCloudOkHttpClient +import ai.llamaindex.llamacloud.models.files.FileContentParams import ai.llamaindex.llamacloud.models.files.FileCreateParams import ai.llamaindex.llamacloud.models.files.FileDeleteParams -import ai.llamaindex.llamacloud.models.files.FileGetParams import ai.llamaindex.llamacloud.models.files.FileQueryParams import ai.llamaindex.llamacloud.models.files.FileRetrieveParams import org.junit.jupiter.api.Disabled @@ -81,13 +81,13 @@ internal class FileServiceTest { @Disabled("Mock server tests are disabled") @Test - fun get() { + fun content() { val client = LlamaCloudOkHttpClient.builder().apiKey("My API Key").build() val fileService = client.files() val presignedUrl = - fileService.get( - FileGetParams.builder() + fileService.content( + FileContentParams.builder() .fileId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .expiresAtSeconds(0L) .organizationId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") From 0f29c291a2cbe14854cfa9bac29a8c01dd94bde1 Mon Sep 17 00:00:00 2001 From: Yong Date: Wed, 12 Aug 2026 16:05:36 -0700 Subject: [PATCH 28/28] ci: regenerate the release PR body on every promote (#9) --- .github/workflows/stlc-promote.yml | 59 +++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/.github/workflows/stlc-promote.yml b/.github/workflows/stlc-promote.yml index fd59332..fc3cdf7 100644 --- a/.github/workflows/stlc-promote.yml +++ b/.github/workflows/stlc-promote.yml @@ -69,6 +69,59 @@ jobs: env: GH_TOKEN: ${{ steps.prod-token.outputs.token }} run: | + # Regenerate the body on every promote. The release branch is + # force-pushed, so a body written only at gh-pr-create time freezes at + # whatever was pending the day the PR opened and never mentions + # anything promoted since. + git log --reverse --pretty=$'%H\t%s' production/main..origin/main > commits.tsv + PROD_REPO="${PRODUCTION_REPO}" python3 - commits.tsv > body.md <<'PY' + import os, re, sys + + repo = os.environ["PROD_REPO"] + rows = [l.rstrip("\n").split("\t", 1) for l in open(sys.argv[1]) if "\t" in l] + + NAMED = [("feat", "### Features"), ("fix", "### Bug Fixes"), + ("perf", "### Performance"), ("docs", "### Documentation"), + ("refactor", "### Refactors")] + CHORE = {"chore", "ci", "build", "test", "style", "release"} + NOISE = re.compile(r"^(Build SDK|Merge pull request #\d+|Merge branch )") + + named, chores, unconventional, generated = {}, [], [], [] + for sha, subject in rows: + m = re.match(r"^(\w+)(\([^)]*\))?!?:", subject) + kind = m.group(1) if m else "" + if kind in dict(NAMED): named.setdefault(kind, []).append((sha, subject)) + elif kind in CHORE: chores.append((sha, subject)) + elif NOISE.match(subject): generated.append((sha, subject)) + else: unconventional.append((sha, subject)) + + def rows_md(items): + out = [] + for sha, subject in items: + # Five-digit refs are run-llama/platform PRs; GitHub would + # otherwise autolink them to this repo's own issue numbers. + subject = re.sub(r"\(#(\d{5,})\)", + r"([#\1](https://github.com/run-llama/platform/pull/\1))", subject) + out.append(f"- {subject} ([`{sha[:7]}`](https://github.com/{repo}/commit/{sha}))") + return out + + L = [f"Promotes `stainless/release` onto `main` — **{len(rows)} commits**. " + "Merging this lets release-please cut the next release and write `CHANGELOG.md`.", ""] + for kind, title in NAMED: + if named.get(kind): + L += [title, *rows_md(named[kind]), ""] + if unconventional: + L += ["### :warning: Not conventional-commit — release-please will DROP these from `CHANGELOG.md`", + *rows_md(unconventional), ""] + for items, title in ((chores, "Chores & CI"), (generated, "Codegen & merge commits")): + if items: + L += [f"
{title} ({len(items)})", "", + *rows_md(items), "", "
", ""] + L.append("Regenerated by `stlc-promote.yml` on every promote, from " + "`main...stainless/release`.") + print("\n".join(L)) + PY + EXISTING_PR=$(gh pr list \ --repo "${PRODUCTION_REPO}" \ --head stainless/release \ @@ -81,7 +134,9 @@ jobs: --base main \ --head stainless/release \ --title "Release SDK updates" \ - --body "$(git log --oneline production/main..origin/main)" + --body-file body.md else - echo "Release PR #${EXISTING_PR} already exists. Force-push has updated it." + gh pr edit "${EXISTING_PR}" \ + --repo "${PRODUCTION_REPO}" \ + --body-file body.md fi