33package com.browserbase.api.models.sessions
44
55import com.browserbase.api.core.Enum
6+ import com.browserbase.api.core.ExcludeMissing
67import com.browserbase.api.core.JsonField
8+ import com.browserbase.api.core.JsonMissing
79import com.browserbase.api.core.JsonValue
810import com.browserbase.api.core.Params
9- import com.browserbase.api.core.checkRequired
1011import com.browserbase.api.core.http.Headers
1112import com.browserbase.api.core.http.QueryParams
1213import com.browserbase.api.errors.StagehandInvalidDataException
14+ import com.fasterxml.jackson.annotation.JsonAnyGetter
15+ import com.fasterxml.jackson.annotation.JsonAnySetter
1316import com.fasterxml.jackson.annotation.JsonCreator
17+ import com.fasterxml.jackson.annotation.JsonProperty
1418import java.time.OffsetDateTime
1519import java.time.format.DateTimeFormatter
20+ import java.util.Collections
1621import java.util.Objects
1722import java.util.Optional
1823import kotlin.jvm.optionals.getOrNull
@@ -25,7 +30,7 @@ private constructor(
2530 private val xSdkVersion: String? ,
2631 private val xSentAt: OffsetDateTime ? ,
2732 private val xStreamResponse: XStreamResponse ? ,
28- private val body: JsonValue ,
33+ private val body: Body ,
2934 private val additionalHeaders: Headers ,
3035 private val additionalQueryParams: QueryParams ,
3136) : Params {
@@ -45,7 +50,9 @@ private constructor(
4550 /* * Whether to stream the response via SSE */
4651 fun xStreamResponse (): Optional <XStreamResponse > = Optional .ofNullable(xStreamResponse)
4752
48- fun body (): JsonValue = body
53+ fun __forceBody (): JsonValue = body.__forceBody ()
54+
55+ fun _additionalBodyProperties (): Map <String , JsonValue > = body._additionalProperties ()
4956
5057 /* * Additional headers to send with the request. */
5158 fun _additionalHeaders (): Headers = additionalHeaders
@@ -57,14 +64,9 @@ private constructor(
5764
5865 companion object {
5966
60- /* *
61- * Returns a mutable builder for constructing an instance of [SessionEndParams].
62- *
63- * The following fields are required:
64- * ```java
65- * .body()
66- * ```
67- */
67+ @JvmStatic fun none (): SessionEndParams = builder().build()
68+
69+ /* * Returns a mutable builder for constructing an instance of [SessionEndParams]. */
6870 @JvmStatic fun builder () = Builder ()
6971 }
7072
@@ -76,7 +78,7 @@ private constructor(
7678 private var xSdkVersion: String? = null
7779 private var xSentAt: OffsetDateTime ? = null
7880 private var xStreamResponse: XStreamResponse ? = null
79- private var body: JsonValue ? = null
81+ private var body: Body . Builder = Body .builder()
8082 private var additionalHeaders: Headers .Builder = Headers .builder()
8183 private var additionalQueryParams: QueryParams .Builder = QueryParams .builder()
8284
@@ -87,7 +89,7 @@ private constructor(
8789 xSdkVersion = sessionEndParams.xSdkVersion
8890 xSentAt = sessionEndParams.xSentAt
8991 xStreamResponse = sessionEndParams.xStreamResponse
90- body = sessionEndParams.body
92+ body = sessionEndParams.body.toBuilder()
9193 additionalHeaders = sessionEndParams.additionalHeaders.toBuilder()
9294 additionalQueryParams = sessionEndParams.additionalQueryParams.toBuilder()
9395 }
@@ -125,7 +127,35 @@ private constructor(
125127 fun xStreamResponse (xStreamResponse : Optional <XStreamResponse >) =
126128 xStreamResponse(xStreamResponse.getOrNull())
127129
128- fun body (body : JsonValue ) = apply { this .body = body }
130+ /* *
131+ * Sets the entire request body.
132+ *
133+ * This is generally only useful if you are already constructing the body separately.
134+ * Otherwise, it's more convenient to use the top-level setters instead:
135+ * - [_forceBody]
136+ */
137+ fun body (body : Body ) = apply { this .body = body.toBuilder() }
138+
139+ fun _forceBody (_forceBody : JsonValue ) = apply { body._forceBody (_forceBody ) }
140+
141+ fun additionalBodyProperties (additionalBodyProperties : Map <String , JsonValue >) = apply {
142+ body.additionalProperties(additionalBodyProperties)
143+ }
144+
145+ fun putAdditionalBodyProperty (key : String , value : JsonValue ) = apply {
146+ body.putAdditionalProperty(key, value)
147+ }
148+
149+ fun putAllAdditionalBodyProperties (additionalBodyProperties : Map <String , JsonValue >) =
150+ apply {
151+ body.putAllAdditionalProperties(additionalBodyProperties)
152+ }
153+
154+ fun removeAdditionalBodyProperty (key : String ) = apply { body.removeAdditionalProperty(key) }
155+
156+ fun removeAllAdditionalBodyProperties (keys : Set <String >) = apply {
157+ body.removeAllAdditionalProperties(keys)
158+ }
129159
130160 fun additionalHeaders (additionalHeaders : Headers ) = apply {
131161 this .additionalHeaders.clear()
@@ -229,13 +259,6 @@ private constructor(
229259 * Returns an immutable instance of [SessionEndParams].
230260 *
231261 * Further updates to this [Builder] will not mutate the returned instance.
232- *
233- * The following fields are required:
234- * ```java
235- * .body()
236- * ```
237- *
238- * @throws IllegalStateException if any required field is unset.
239262 */
240263 fun build (): SessionEndParams =
241264 SessionEndParams (
@@ -244,13 +267,13 @@ private constructor(
244267 xSdkVersion,
245268 xSentAt,
246269 xStreamResponse,
247- checkRequired( " body" , body ),
270+ body.build( ),
248271 additionalHeaders.build(),
249272 additionalQueryParams.build(),
250273 )
251274 }
252275
253- fun _body (): JsonValue = body
276+ fun _body (): Body = body
254277
255278 fun _pathParam (index : Int ): String =
256279 when (index) {
@@ -271,6 +294,123 @@ private constructor(
271294
272295 override fun _queryParams (): QueryParams = additionalQueryParams
273296
297+ class Body
298+ @JsonCreator(mode = JsonCreator .Mode .DISABLED )
299+ private constructor (
300+ private val _forceBody : JsonValue ,
301+ private val additionalProperties: MutableMap <String , JsonValue >,
302+ ) {
303+
304+ @JsonCreator
305+ private constructor (
306+ @JsonProperty(" _forceBody" ) @ExcludeMissing _forceBody : JsonValue = JsonMissing .of()
307+ ) : this (_forceBody , mutableMapOf ())
308+
309+ @JsonProperty(" _forceBody" ) @ExcludeMissing fun __forceBody (): JsonValue = _forceBody
310+
311+ @JsonAnySetter
312+ private fun putAdditionalProperty (key : String , value : JsonValue ) {
313+ additionalProperties.put(key, value)
314+ }
315+
316+ @JsonAnyGetter
317+ @ExcludeMissing
318+ fun _additionalProperties (): Map <String , JsonValue > =
319+ Collections .unmodifiableMap(additionalProperties)
320+
321+ fun toBuilder () = Builder ().from(this )
322+
323+ companion object {
324+
325+ /* * Returns a mutable builder for constructing an instance of [Body]. */
326+ @JvmStatic fun builder () = Builder ()
327+ }
328+
329+ /* * A builder for [Body]. */
330+ class Builder internal constructor() {
331+
332+ private var _forceBody : JsonValue = JsonMissing .of()
333+ private var additionalProperties: MutableMap <String , JsonValue > = mutableMapOf ()
334+
335+ @JvmSynthetic
336+ internal fun from (body : Body ) = apply {
337+ _forceBody = body._forceBody
338+ additionalProperties = body.additionalProperties.toMutableMap()
339+ }
340+
341+ fun _forceBody (_forceBody : JsonValue ) = apply { this ._forceBody = _forceBody }
342+
343+ fun additionalProperties (additionalProperties : Map <String , JsonValue >) = apply {
344+ this .additionalProperties.clear()
345+ putAllAdditionalProperties(additionalProperties)
346+ }
347+
348+ fun putAdditionalProperty (key : String , value : JsonValue ) = apply {
349+ additionalProperties.put(key, value)
350+ }
351+
352+ fun putAllAdditionalProperties (additionalProperties : Map <String , JsonValue >) = apply {
353+ this .additionalProperties.putAll(additionalProperties)
354+ }
355+
356+ fun removeAdditionalProperty (key : String ) = apply { additionalProperties.remove(key) }
357+
358+ fun removeAllAdditionalProperties (keys : Set <String >) = apply {
359+ keys.forEach(::removeAdditionalProperty)
360+ }
361+
362+ /* *
363+ * Returns an immutable instance of [Body].
364+ *
365+ * Further updates to this [Builder] will not mutate the returned instance.
366+ */
367+ fun build (): Body = Body (_forceBody , additionalProperties.toMutableMap())
368+ }
369+
370+ private var validated: Boolean = false
371+
372+ fun validate (): Body = apply {
373+ if (validated) {
374+ return @apply
375+ }
376+
377+ validated = true
378+ }
379+
380+ fun isValid (): Boolean =
381+ try {
382+ validate()
383+ true
384+ } catch (e: StagehandInvalidDataException ) {
385+ false
386+ }
387+
388+ /* *
389+ * Returns a score indicating how many valid values are contained in this object
390+ * recursively.
391+ *
392+ * Used for best match union deserialization.
393+ */
394+ @JvmSynthetic internal fun validity (): Int = 0
395+
396+ override fun equals (other : Any? ): Boolean {
397+ if (this == = other) {
398+ return true
399+ }
400+
401+ return other is Body &&
402+ _forceBody == other._forceBody &&
403+ additionalProperties == other.additionalProperties
404+ }
405+
406+ private val hashCode: Int by lazy { Objects .hash(_forceBody , additionalProperties) }
407+
408+ override fun hashCode (): Int = hashCode
409+
410+ override fun toString () =
411+ " Body{_forceBody=$_forceBody , additionalProperties=$additionalProperties }"
412+ }
413+
274414 /* * Client SDK language */
275415 class XLanguage @JsonCreator private constructor(private val value : JsonField <String >) : Enum {
276416
0 commit comments