Skip to content

Commit caadfe0

Browse files
feat: feat hide cursor v2
1 parent cb304d4 commit caadfe0

File tree

7 files changed

+227
-4
lines changed

7 files changed

+227
-4
lines changed

.stats.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 65
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-8c7e0b9069a18bc9437269618cde251ba15568771f2b4811d57f0d5f0fd5692d.yml
3-
openapi_spec_hash: aa2544d0bf0e7e875939aaa8e2e114d3
4-
config_hash: 0fbdda3a736cc2748ca33371871e61b3
1+
configured_endpoints: 66
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-86854c41729a6b26f71e26c906f665f69939f23e2d7adcc43380aee64cf6d056.yml
3+
openapi_spec_hash: 270a40c8af29e83cbda77d3700fd456a
4+
config_hash: 9421eb86b7f3f4b274f123279da3858e

api.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,12 @@ Methods:
168168

169169
## Computer
170170

171+
Types:
172+
173+
```python
174+
from kernel.types.browsers import ComputerSetCursorVisibilityResponse
175+
```
176+
171177
Methods:
172178

173179
- <code title="post /browsers/{id}/computer/screenshot">client.browsers.computer.<a href="./src/kernel/resources/browsers/computer.py">capture_screenshot</a>(id, \*\*<a href="src/kernel/types/browsers/computer_capture_screenshot_params.py">params</a>) -> BinaryAPIResponse</code>
@@ -176,6 +182,7 @@ Methods:
176182
- <code title="post /browsers/{id}/computer/move_mouse">client.browsers.computer.<a href="./src/kernel/resources/browsers/computer.py">move_mouse</a>(id, \*\*<a href="src/kernel/types/browsers/computer_move_mouse_params.py">params</a>) -> None</code>
177183
- <code title="post /browsers/{id}/computer/press_key">client.browsers.computer.<a href="./src/kernel/resources/browsers/computer.py">press_key</a>(id, \*\*<a href="src/kernel/types/browsers/computer_press_key_params.py">params</a>) -> None</code>
178184
- <code title="post /browsers/{id}/computer/scroll">client.browsers.computer.<a href="./src/kernel/resources/browsers/computer.py">scroll</a>(id, \*\*<a href="src/kernel/types/browsers/computer_scroll_params.py">params</a>) -> None</code>
185+
- <code title="post /browsers/{id}/computer/cursor">client.browsers.computer.<a href="./src/kernel/resources/browsers/computer.py">set_cursor_visibility</a>(id, \*\*<a href="src/kernel/types/browsers/computer_set_cursor_visibility_params.py">params</a>) -> <a href="./src/kernel/types/browsers/computer_set_cursor_visibility_response.py">ComputerSetCursorVisibilityResponse</a></code>
179186
- <code title="post /browsers/{id}/computer/type">client.browsers.computer.<a href="./src/kernel/resources/browsers/computer.py">type_text</a>(id, \*\*<a href="src/kernel/types/browsers/computer_type_text_params.py">params</a>) -> None</code>
180187

181188
## Playwright

src/kernel/resources/browsers/computer.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
computer_move_mouse_params,
3535
computer_click_mouse_params,
3636
computer_capture_screenshot_params,
37+
computer_set_cursor_visibility_params,
3738
)
39+
from ...types.browsers.computer_set_cursor_visibility_response import ComputerSetCursorVisibilityResponse
3840

3941
__all__ = ["ComputerResource", "AsyncComputerResource"]
4042

@@ -390,6 +392,45 @@ def scroll(
390392
cast_to=NoneType,
391393
)
392394

395+
def set_cursor_visibility(
396+
self,
397+
id: str,
398+
*,
399+
hidden: bool,
400+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
401+
# The extra values given here take precedence over values defined on the client or passed to this method.
402+
extra_headers: Headers | None = None,
403+
extra_query: Query | None = None,
404+
extra_body: Body | None = None,
405+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
406+
) -> ComputerSetCursorVisibilityResponse:
407+
"""
408+
Set cursor visibility
409+
410+
Args:
411+
hidden: Whether the cursor should be hidden or visible
412+
413+
extra_headers: Send extra headers
414+
415+
extra_query: Add additional query parameters to the request
416+
417+
extra_body: Add additional JSON properties to the request
418+
419+
timeout: Override the client-level default timeout for this request, in seconds
420+
"""
421+
if not id:
422+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
423+
return self._post(
424+
f"/browsers/{id}/computer/cursor",
425+
body=maybe_transform(
426+
{"hidden": hidden}, computer_set_cursor_visibility_params.ComputerSetCursorVisibilityParams
427+
),
428+
options=make_request_options(
429+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
430+
),
431+
cast_to=ComputerSetCursorVisibilityResponse,
432+
)
433+
393434
def type_text(
394435
self,
395436
id: str,
@@ -789,6 +830,45 @@ async def scroll(
789830
cast_to=NoneType,
790831
)
791832

833+
async def set_cursor_visibility(
834+
self,
835+
id: str,
836+
*,
837+
hidden: bool,
838+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
839+
# The extra values given here take precedence over values defined on the client or passed to this method.
840+
extra_headers: Headers | None = None,
841+
extra_query: Query | None = None,
842+
extra_body: Body | None = None,
843+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
844+
) -> ComputerSetCursorVisibilityResponse:
845+
"""
846+
Set cursor visibility
847+
848+
Args:
849+
hidden: Whether the cursor should be hidden or visible
850+
851+
extra_headers: Send extra headers
852+
853+
extra_query: Add additional query parameters to the request
854+
855+
extra_body: Add additional JSON properties to the request
856+
857+
timeout: Override the client-level default timeout for this request, in seconds
858+
"""
859+
if not id:
860+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
861+
return await self._post(
862+
f"/browsers/{id}/computer/cursor",
863+
body=await async_maybe_transform(
864+
{"hidden": hidden}, computer_set_cursor_visibility_params.ComputerSetCursorVisibilityParams
865+
),
866+
options=make_request_options(
867+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
868+
),
869+
cast_to=ComputerSetCursorVisibilityResponse,
870+
)
871+
792872
async def type_text(
793873
self,
794874
id: str,
@@ -860,6 +940,9 @@ def __init__(self, computer: ComputerResource) -> None:
860940
self.scroll = to_raw_response_wrapper(
861941
computer.scroll,
862942
)
943+
self.set_cursor_visibility = to_raw_response_wrapper(
944+
computer.set_cursor_visibility,
945+
)
863946
self.type_text = to_raw_response_wrapper(
864947
computer.type_text,
865948
)
@@ -888,6 +971,9 @@ def __init__(self, computer: AsyncComputerResource) -> None:
888971
self.scroll = async_to_raw_response_wrapper(
889972
computer.scroll,
890973
)
974+
self.set_cursor_visibility = async_to_raw_response_wrapper(
975+
computer.set_cursor_visibility,
976+
)
891977
self.type_text = async_to_raw_response_wrapper(
892978
computer.type_text,
893979
)
@@ -916,6 +1002,9 @@ def __init__(self, computer: ComputerResource) -> None:
9161002
self.scroll = to_streamed_response_wrapper(
9171003
computer.scroll,
9181004
)
1005+
self.set_cursor_visibility = to_streamed_response_wrapper(
1006+
computer.set_cursor_visibility,
1007+
)
9191008
self.type_text = to_streamed_response_wrapper(
9201009
computer.type_text,
9211010
)
@@ -944,6 +1033,9 @@ def __init__(self, computer: AsyncComputerResource) -> None:
9441033
self.scroll = async_to_streamed_response_wrapper(
9451034
computer.scroll,
9461035
)
1036+
self.set_cursor_visibility = async_to_streamed_response_wrapper(
1037+
computer.set_cursor_visibility,
1038+
)
9471039
self.type_text = async_to_streamed_response_wrapper(
9481040
computer.type_text,
9491041
)

src/kernel/types/browsers/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,9 @@
3939
from .f_set_file_permissions_params import FSetFilePermissionsParams as FSetFilePermissionsParams
4040
from .process_stdout_stream_response import ProcessStdoutStreamResponse as ProcessStdoutStreamResponse
4141
from .computer_capture_screenshot_params import ComputerCaptureScreenshotParams as ComputerCaptureScreenshotParams
42+
from .computer_set_cursor_visibility_params import (
43+
ComputerSetCursorVisibilityParams as ComputerSetCursorVisibilityParams,
44+
)
45+
from .computer_set_cursor_visibility_response import (
46+
ComputerSetCursorVisibilityResponse as ComputerSetCursorVisibilityResponse,
47+
)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from __future__ import annotations
4+
5+
from typing_extensions import Required, TypedDict
6+
7+
__all__ = ["ComputerSetCursorVisibilityParams"]
8+
9+
10+
class ComputerSetCursorVisibilityParams(TypedDict, total=False):
11+
hidden: Required[bool]
12+
"""Whether the cursor should be hidden or visible"""
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from ..._models import BaseModel
4+
5+
__all__ = ["ComputerSetCursorVisibilityResponse"]
6+
7+
8+
class ComputerSetCursorVisibilityResponse(BaseModel):
9+
ok: bool
10+
"""Indicates success."""

tests/api_resources/browsers/test_computer.py

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@
1010
from respx import MockRouter
1111

1212
from kernel import Kernel, AsyncKernel
13+
from tests.utils import assert_matches_type
1314
from kernel._response import (
1415
BinaryAPIResponse,
1516
AsyncBinaryAPIResponse,
1617
StreamedBinaryAPIResponse,
1718
AsyncStreamedBinaryAPIResponse,
1819
)
20+
from kernel.types.browsers import (
21+
ComputerSetCursorVisibilityResponse,
22+
)
1923

2024
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
2125

@@ -396,6 +400,52 @@ def test_path_params_scroll(self, client: Kernel) -> None:
396400
y=0,
397401
)
398402

403+
@pytest.mark.skip(reason="Prism tests are disabled")
404+
@parametrize
405+
def test_method_set_cursor_visibility(self, client: Kernel) -> None:
406+
computer = client.browsers.computer.set_cursor_visibility(
407+
id="id",
408+
hidden=True,
409+
)
410+
assert_matches_type(ComputerSetCursorVisibilityResponse, computer, path=["response"])
411+
412+
@pytest.mark.skip(reason="Prism tests are disabled")
413+
@parametrize
414+
def test_raw_response_set_cursor_visibility(self, client: Kernel) -> None:
415+
response = client.browsers.computer.with_raw_response.set_cursor_visibility(
416+
id="id",
417+
hidden=True,
418+
)
419+
420+
assert response.is_closed is True
421+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
422+
computer = response.parse()
423+
assert_matches_type(ComputerSetCursorVisibilityResponse, computer, path=["response"])
424+
425+
@pytest.mark.skip(reason="Prism tests are disabled")
426+
@parametrize
427+
def test_streaming_response_set_cursor_visibility(self, client: Kernel) -> None:
428+
with client.browsers.computer.with_streaming_response.set_cursor_visibility(
429+
id="id",
430+
hidden=True,
431+
) as response:
432+
assert not response.is_closed
433+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
434+
435+
computer = response.parse()
436+
assert_matches_type(ComputerSetCursorVisibilityResponse, computer, path=["response"])
437+
438+
assert cast(Any, response.is_closed) is True
439+
440+
@pytest.mark.skip(reason="Prism tests are disabled")
441+
@parametrize
442+
def test_path_params_set_cursor_visibility(self, client: Kernel) -> None:
443+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
444+
client.browsers.computer.with_raw_response.set_cursor_visibility(
445+
id="",
446+
hidden=True,
447+
)
448+
399449
@pytest.mark.skip(reason="Prism tests are disabled")
400450
@parametrize
401451
def test_method_type_text(self, client: Kernel) -> None:
@@ -835,6 +885,52 @@ async def test_path_params_scroll(self, async_client: AsyncKernel) -> None:
835885
y=0,
836886
)
837887

888+
@pytest.mark.skip(reason="Prism tests are disabled")
889+
@parametrize
890+
async def test_method_set_cursor_visibility(self, async_client: AsyncKernel) -> None:
891+
computer = await async_client.browsers.computer.set_cursor_visibility(
892+
id="id",
893+
hidden=True,
894+
)
895+
assert_matches_type(ComputerSetCursorVisibilityResponse, computer, path=["response"])
896+
897+
@pytest.mark.skip(reason="Prism tests are disabled")
898+
@parametrize
899+
async def test_raw_response_set_cursor_visibility(self, async_client: AsyncKernel) -> None:
900+
response = await async_client.browsers.computer.with_raw_response.set_cursor_visibility(
901+
id="id",
902+
hidden=True,
903+
)
904+
905+
assert response.is_closed is True
906+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
907+
computer = await response.parse()
908+
assert_matches_type(ComputerSetCursorVisibilityResponse, computer, path=["response"])
909+
910+
@pytest.mark.skip(reason="Prism tests are disabled")
911+
@parametrize
912+
async def test_streaming_response_set_cursor_visibility(self, async_client: AsyncKernel) -> None:
913+
async with async_client.browsers.computer.with_streaming_response.set_cursor_visibility(
914+
id="id",
915+
hidden=True,
916+
) as response:
917+
assert not response.is_closed
918+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
919+
920+
computer = await response.parse()
921+
assert_matches_type(ComputerSetCursorVisibilityResponse, computer, path=["response"])
922+
923+
assert cast(Any, response.is_closed) is True
924+
925+
@pytest.mark.skip(reason="Prism tests are disabled")
926+
@parametrize
927+
async def test_path_params_set_cursor_visibility(self, async_client: AsyncKernel) -> None:
928+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
929+
await async_client.browsers.computer.with_raw_response.set_cursor_visibility(
930+
id="",
931+
hidden=True,
932+
)
933+
838934
@pytest.mark.skip(reason="Prism tests are disabled")
839935
@parametrize
840936
async def test_method_type_text(self, async_client: AsyncKernel) -> None:

0 commit comments

Comments
 (0)