10
10
from .._compat import cached_property
11
11
from .._resource import SyncAPIResource , AsyncAPIResource
12
12
from .._response import (
13
+ BinaryAPIResponse ,
14
+ AsyncBinaryAPIResponse ,
15
+ StreamedBinaryAPIResponse ,
16
+ AsyncStreamedBinaryAPIResponse ,
13
17
to_raw_response_wrapper ,
14
18
to_streamed_response_wrapper ,
15
19
async_to_raw_response_wrapper ,
20
+ to_custom_raw_response_wrapper ,
16
21
async_to_streamed_response_wrapper ,
22
+ to_custom_streamed_response_wrapper ,
23
+ async_to_custom_raw_response_wrapper ,
24
+ async_to_custom_streamed_response_wrapper ,
17
25
)
18
26
from .._base_client import make_request_options
19
27
from ..types .browser_list_response import BrowserListResponse
@@ -50,6 +58,7 @@ def create(
50
58
headless : bool | NotGiven = NOT_GIVEN ,
51
59
invocation_id : str | NotGiven = NOT_GIVEN ,
52
60
persistence : BrowserPersistenceParam | NotGiven = NOT_GIVEN ,
61
+ replay : bool | NotGiven = NOT_GIVEN ,
53
62
stealth : bool | NotGiven = NOT_GIVEN ,
54
63
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
55
64
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -69,6 +78,8 @@ def create(
69
78
70
79
persistence: Optional persistence configuration for the browser session.
71
80
81
+ replay: If true, enables replay recording of the browser session. Defaults to false.
82
+
72
83
stealth: If true, launches the browser in stealth mode to reduce detection by anti-bot
73
84
mechanisms.
74
85
@@ -87,6 +98,7 @@ def create(
87
98
"headless" : headless ,
88
99
"invocation_id" : invocation_id ,
89
100
"persistence" : persistence ,
101
+ "replay" : replay ,
90
102
"stealth" : stealth ,
91
103
},
92
104
browser_create_params .BrowserCreateParams ,
@@ -221,6 +233,40 @@ def delete_by_id(
221
233
cast_to = NoneType ,
222
234
)
223
235
236
+ def retrieve_replay (
237
+ self ,
238
+ id : str ,
239
+ * ,
240
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
241
+ # The extra values given here take precedence over values defined on the client or passed to this method.
242
+ extra_headers : Headers | None = None ,
243
+ extra_query : Query | None = None ,
244
+ extra_body : Body | None = None ,
245
+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
246
+ ) -> BinaryAPIResponse :
247
+ """
248
+ Get browser session replay.
249
+
250
+ Args:
251
+ extra_headers: Send extra headers
252
+
253
+ extra_query: Add additional query parameters to the request
254
+
255
+ extra_body: Add additional JSON properties to the request
256
+
257
+ timeout: Override the client-level default timeout for this request, in seconds
258
+ """
259
+ if not id :
260
+ raise ValueError (f"Expected a non-empty value for `id` but received { id !r} " )
261
+ extra_headers = {"Accept" : "video/mp4" , ** (extra_headers or {})}
262
+ return self ._get (
263
+ f"/browsers/{ id } /replay" ,
264
+ options = make_request_options (
265
+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
266
+ ),
267
+ cast_to = BinaryAPIResponse ,
268
+ )
269
+
224
270
225
271
class AsyncBrowsersResource (AsyncAPIResource ):
226
272
@cached_property
@@ -248,6 +294,7 @@ async def create(
248
294
headless : bool | NotGiven = NOT_GIVEN ,
249
295
invocation_id : str | NotGiven = NOT_GIVEN ,
250
296
persistence : BrowserPersistenceParam | NotGiven = NOT_GIVEN ,
297
+ replay : bool | NotGiven = NOT_GIVEN ,
251
298
stealth : bool | NotGiven = NOT_GIVEN ,
252
299
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
253
300
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -267,6 +314,8 @@ async def create(
267
314
268
315
persistence: Optional persistence configuration for the browser session.
269
316
317
+ replay: If true, enables replay recording of the browser session. Defaults to false.
318
+
270
319
stealth: If true, launches the browser in stealth mode to reduce detection by anti-bot
271
320
mechanisms.
272
321
@@ -285,6 +334,7 @@ async def create(
285
334
"headless" : headless ,
286
335
"invocation_id" : invocation_id ,
287
336
"persistence" : persistence ,
337
+ "replay" : replay ,
288
338
"stealth" : stealth ,
289
339
},
290
340
browser_create_params .BrowserCreateParams ,
@@ -421,6 +471,40 @@ async def delete_by_id(
421
471
cast_to = NoneType ,
422
472
)
423
473
474
+ async def retrieve_replay (
475
+ self ,
476
+ id : str ,
477
+ * ,
478
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
479
+ # The extra values given here take precedence over values defined on the client or passed to this method.
480
+ extra_headers : Headers | None = None ,
481
+ extra_query : Query | None = None ,
482
+ extra_body : Body | None = None ,
483
+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
484
+ ) -> AsyncBinaryAPIResponse :
485
+ """
486
+ Get browser session replay.
487
+
488
+ Args:
489
+ extra_headers: Send extra headers
490
+
491
+ extra_query: Add additional query parameters to the request
492
+
493
+ extra_body: Add additional JSON properties to the request
494
+
495
+ timeout: Override the client-level default timeout for this request, in seconds
496
+ """
497
+ if not id :
498
+ raise ValueError (f"Expected a non-empty value for `id` but received { id !r} " )
499
+ extra_headers = {"Accept" : "video/mp4" , ** (extra_headers or {})}
500
+ return await self ._get (
501
+ f"/browsers/{ id } /replay" ,
502
+ options = make_request_options (
503
+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
504
+ ),
505
+ cast_to = AsyncBinaryAPIResponse ,
506
+ )
507
+
424
508
425
509
class BrowsersResourceWithRawResponse :
426
510
def __init__ (self , browsers : BrowsersResource ) -> None :
@@ -441,6 +525,10 @@ def __init__(self, browsers: BrowsersResource) -> None:
441
525
self .delete_by_id = to_raw_response_wrapper (
442
526
browsers .delete_by_id ,
443
527
)
528
+ self .retrieve_replay = to_custom_raw_response_wrapper (
529
+ browsers .retrieve_replay ,
530
+ BinaryAPIResponse ,
531
+ )
444
532
445
533
446
534
class AsyncBrowsersResourceWithRawResponse :
@@ -462,6 +550,10 @@ def __init__(self, browsers: AsyncBrowsersResource) -> None:
462
550
self .delete_by_id = async_to_raw_response_wrapper (
463
551
browsers .delete_by_id ,
464
552
)
553
+ self .retrieve_replay = async_to_custom_raw_response_wrapper (
554
+ browsers .retrieve_replay ,
555
+ AsyncBinaryAPIResponse ,
556
+ )
465
557
466
558
467
559
class BrowsersResourceWithStreamingResponse :
@@ -483,6 +575,10 @@ def __init__(self, browsers: BrowsersResource) -> None:
483
575
self .delete_by_id = to_streamed_response_wrapper (
484
576
browsers .delete_by_id ,
485
577
)
578
+ self .retrieve_replay = to_custom_streamed_response_wrapper (
579
+ browsers .retrieve_replay ,
580
+ StreamedBinaryAPIResponse ,
581
+ )
486
582
487
583
488
584
class AsyncBrowsersResourceWithStreamingResponse :
@@ -504,3 +600,7 @@ def __init__(self, browsers: AsyncBrowsersResource) -> None:
504
600
self .delete_by_id = async_to_streamed_response_wrapper (
505
601
browsers .delete_by_id ,
506
602
)
603
+ self .retrieve_replay = async_to_custom_streamed_response_wrapper (
604
+ browsers .retrieve_replay ,
605
+ AsyncStreamedBinaryAPIResponse ,
606
+ )
0 commit comments