2727)
2828from ..._base_client import make_request_options
2929from ...types .browsers import (
30+ computer_batch_params ,
3031 computer_scroll_params ,
3132 computer_press_key_params ,
3233 computer_type_text_params ,
3637 computer_capture_screenshot_params ,
3738 computer_set_cursor_visibility_params ,
3839)
40+ from ...types .browsers .computer_get_mouse_position_response import ComputerGetMousePositionResponse
3941from ...types .browsers .computer_set_cursor_visibility_response import ComputerSetCursorVisibilityResponse
4042
4143__all__ = ["ComputerResource" , "AsyncComputerResource" ]
@@ -61,6 +63,46 @@ def with_streaming_response(self) -> ComputerResourceWithStreamingResponse:
6163 """
6264 return ComputerResourceWithStreamingResponse (self )
6365
66+ def batch (
67+ self ,
68+ id : str ,
69+ * ,
70+ actions : Iterable [computer_batch_params .Action ],
71+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
72+ # The extra values given here take precedence over values defined on the client or passed to this method.
73+ extra_headers : Headers | None = None ,
74+ extra_query : Query | None = None ,
75+ extra_body : Body | None = None ,
76+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
77+ ) -> None :
78+ """
79+ Send an array of computer actions to execute in order on the browser instance.
80+ Execution stops on the first error. This reduces network latency compared to
81+ sending individual action requests.
82+
83+ Args:
84+ actions: Ordered list of actions to execute. Execution stops on the first error.
85+
86+ extra_headers: Send extra headers
87+
88+ extra_query: Add additional query parameters to the request
89+
90+ extra_body: Add additional JSON properties to the request
91+
92+ timeout: Override the client-level default timeout for this request, in seconds
93+ """
94+ if not id :
95+ raise ValueError (f"Expected a non-empty value for `id` but received { id !r} " )
96+ extra_headers = {"Accept" : "*/*" , ** (extra_headers or {})}
97+ return self ._post (
98+ f"/browsers/{ id } /computer/batch" ,
99+ body = maybe_transform ({"actions" : actions }, computer_batch_params .ComputerBatchParams ),
100+ options = make_request_options (
101+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
102+ ),
103+ cast_to = NoneType ,
104+ )
105+
64106 def capture_screenshot (
65107 self ,
66108 id : str ,
@@ -227,6 +269,39 @@ def drag_mouse(
227269 cast_to = NoneType ,
228270 )
229271
272+ def get_mouse_position (
273+ self ,
274+ id : str ,
275+ * ,
276+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
277+ # The extra values given here take precedence over values defined on the client or passed to this method.
278+ extra_headers : Headers | None = None ,
279+ extra_query : Query | None = None ,
280+ extra_body : Body | None = None ,
281+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
282+ ) -> ComputerGetMousePositionResponse :
283+ """
284+ Get the current mouse cursor position on the browser instance
285+
286+ Args:
287+ extra_headers: Send extra headers
288+
289+ extra_query: Add additional query parameters to the request
290+
291+ extra_body: Add additional JSON properties to the request
292+
293+ timeout: Override the client-level default timeout for this request, in seconds
294+ """
295+ if not id :
296+ raise ValueError (f"Expected a non-empty value for `id` but received { id !r} " )
297+ return self ._post (
298+ f"/browsers/{ id } /computer/get_mouse_position" ,
299+ options = make_request_options (
300+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
301+ ),
302+ cast_to = ComputerGetMousePositionResponse ,
303+ )
304+
230305 def move_mouse (
231306 self ,
232307 id : str ,
@@ -499,6 +574,46 @@ def with_streaming_response(self) -> AsyncComputerResourceWithStreamingResponse:
499574 """
500575 return AsyncComputerResourceWithStreamingResponse (self )
501576
577+ async def batch (
578+ self ,
579+ id : str ,
580+ * ,
581+ actions : Iterable [computer_batch_params .Action ],
582+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
583+ # The extra values given here take precedence over values defined on the client or passed to this method.
584+ extra_headers : Headers | None = None ,
585+ extra_query : Query | None = None ,
586+ extra_body : Body | None = None ,
587+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
588+ ) -> None :
589+ """
590+ Send an array of computer actions to execute in order on the browser instance.
591+ Execution stops on the first error. This reduces network latency compared to
592+ sending individual action requests.
593+
594+ Args:
595+ actions: Ordered list of actions to execute. Execution stops on the first error.
596+
597+ extra_headers: Send extra headers
598+
599+ extra_query: Add additional query parameters to the request
600+
601+ extra_body: Add additional JSON properties to the request
602+
603+ timeout: Override the client-level default timeout for this request, in seconds
604+ """
605+ if not id :
606+ raise ValueError (f"Expected a non-empty value for `id` but received { id !r} " )
607+ extra_headers = {"Accept" : "*/*" , ** (extra_headers or {})}
608+ return await self ._post (
609+ f"/browsers/{ id } /computer/batch" ,
610+ body = await async_maybe_transform ({"actions" : actions }, computer_batch_params .ComputerBatchParams ),
611+ options = make_request_options (
612+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
613+ ),
614+ cast_to = NoneType ,
615+ )
616+
502617 async def capture_screenshot (
503618 self ,
504619 id : str ,
@@ -665,6 +780,39 @@ async def drag_mouse(
665780 cast_to = NoneType ,
666781 )
667782
783+ async def get_mouse_position (
784+ self ,
785+ id : str ,
786+ * ,
787+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
788+ # The extra values given here take precedence over values defined on the client or passed to this method.
789+ extra_headers : Headers | None = None ,
790+ extra_query : Query | None = None ,
791+ extra_body : Body | None = None ,
792+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
793+ ) -> ComputerGetMousePositionResponse :
794+ """
795+ Get the current mouse cursor position on the browser instance
796+
797+ Args:
798+ extra_headers: Send extra headers
799+
800+ extra_query: Add additional query parameters to the request
801+
802+ extra_body: Add additional JSON properties to the request
803+
804+ timeout: Override the client-level default timeout for this request, in seconds
805+ """
806+ if not id :
807+ raise ValueError (f"Expected a non-empty value for `id` but received { id !r} " )
808+ return await self ._post (
809+ f"/browsers/{ id } /computer/get_mouse_position" ,
810+ options = make_request_options (
811+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
812+ ),
813+ cast_to = ComputerGetMousePositionResponse ,
814+ )
815+
668816 async def move_mouse (
669817 self ,
670818 id : str ,
@@ -921,6 +1069,9 @@ class ComputerResourceWithRawResponse:
9211069 def __init__ (self , computer : ComputerResource ) -> None :
9221070 self ._computer = computer
9231071
1072+ self .batch = to_raw_response_wrapper (
1073+ computer .batch ,
1074+ )
9241075 self .capture_screenshot = to_custom_raw_response_wrapper (
9251076 computer .capture_screenshot ,
9261077 BinaryAPIResponse ,
@@ -931,6 +1082,9 @@ def __init__(self, computer: ComputerResource) -> None:
9311082 self .drag_mouse = to_raw_response_wrapper (
9321083 computer .drag_mouse ,
9331084 )
1085+ self .get_mouse_position = to_raw_response_wrapper (
1086+ computer .get_mouse_position ,
1087+ )
9341088 self .move_mouse = to_raw_response_wrapper (
9351089 computer .move_mouse ,
9361090 )
@@ -952,6 +1106,9 @@ class AsyncComputerResourceWithRawResponse:
9521106 def __init__ (self , computer : AsyncComputerResource ) -> None :
9531107 self ._computer = computer
9541108
1109+ self .batch = async_to_raw_response_wrapper (
1110+ computer .batch ,
1111+ )
9551112 self .capture_screenshot = async_to_custom_raw_response_wrapper (
9561113 computer .capture_screenshot ,
9571114 AsyncBinaryAPIResponse ,
@@ -962,6 +1119,9 @@ def __init__(self, computer: AsyncComputerResource) -> None:
9621119 self .drag_mouse = async_to_raw_response_wrapper (
9631120 computer .drag_mouse ,
9641121 )
1122+ self .get_mouse_position = async_to_raw_response_wrapper (
1123+ computer .get_mouse_position ,
1124+ )
9651125 self .move_mouse = async_to_raw_response_wrapper (
9661126 computer .move_mouse ,
9671127 )
@@ -983,6 +1143,9 @@ class ComputerResourceWithStreamingResponse:
9831143 def __init__ (self , computer : ComputerResource ) -> None :
9841144 self ._computer = computer
9851145
1146+ self .batch = to_streamed_response_wrapper (
1147+ computer .batch ,
1148+ )
9861149 self .capture_screenshot = to_custom_streamed_response_wrapper (
9871150 computer .capture_screenshot ,
9881151 StreamedBinaryAPIResponse ,
@@ -993,6 +1156,9 @@ def __init__(self, computer: ComputerResource) -> None:
9931156 self .drag_mouse = to_streamed_response_wrapper (
9941157 computer .drag_mouse ,
9951158 )
1159+ self .get_mouse_position = to_streamed_response_wrapper (
1160+ computer .get_mouse_position ,
1161+ )
9961162 self .move_mouse = to_streamed_response_wrapper (
9971163 computer .move_mouse ,
9981164 )
@@ -1014,6 +1180,9 @@ class AsyncComputerResourceWithStreamingResponse:
10141180 def __init__ (self , computer : AsyncComputerResource ) -> None :
10151181 self ._computer = computer
10161182
1183+ self .batch = async_to_streamed_response_wrapper (
1184+ computer .batch ,
1185+ )
10171186 self .capture_screenshot = async_to_custom_streamed_response_wrapper (
10181187 computer .capture_screenshot ,
10191188 AsyncStreamedBinaryAPIResponse ,
@@ -1024,6 +1193,9 @@ def __init__(self, computer: AsyncComputerResource) -> None:
10241193 self .drag_mouse = async_to_streamed_response_wrapper (
10251194 computer .drag_mouse ,
10261195 )
1196+ self .get_mouse_position = async_to_streamed_response_wrapper (
1197+ computer .get_mouse_position ,
1198+ )
10271199 self .move_mouse = async_to_streamed_response_wrapper (
10281200 computer .move_mouse ,
10291201 )
0 commit comments