Skip to content

Commit 383d071

Browse files
feat: Neil/kernel 872 templates v3
1 parent 5b2a8a2 commit 383d071

File tree

6 files changed

+239
-4
lines changed

6 files changed

+239
-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: 97
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-c955031ac0bb644c0aa1d1120e288f703168abeb0e44a166f55119295f737cc5.yml
3-
openapi_spec_hash: 9fbc24cdaccdd21264e995df40b52d3f
4-
config_hash: b470456b217bb9502f5212311d395a6f
1+
configured_endpoints: 98
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-ccbe854895eb34a9562e33979f5f43cd6ad1f529d5924ee56e56f0c94dcf0454.yml
3+
openapi_spec_hash: 2fa4ecbe742fc46fdde481188c1d885e
4+
config_hash: dd218aae3f852dff79e77febc2077b8e

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ from kernel.types import (
5959
InvocationUpdateResponse,
6060
InvocationListResponse,
6161
InvocationFollowResponse,
62+
InvocationListBrowsersResponse,
6263
)
6364
```
6465

@@ -70,6 +71,7 @@ Methods:
7071
- <code title="get /invocations">client.invocations.<a href="./src/kernel/resources/invocations.py">list</a>(\*\*<a href="src/kernel/types/invocation_list_params.py">params</a>) -> <a href="./src/kernel/types/invocation_list_response.py">SyncOffsetPagination[InvocationListResponse]</a></code>
7172
- <code title="delete /invocations/{id}/browsers">client.invocations.<a href="./src/kernel/resources/invocations.py">delete_browsers</a>(id) -> None</code>
7273
- <code title="get /invocations/{id}/events">client.invocations.<a href="./src/kernel/resources/invocations.py">follow</a>(id, \*\*<a href="src/kernel/types/invocation_follow_params.py">params</a>) -> <a href="./src/kernel/types/invocation_follow_response.py">InvocationFollowResponse</a></code>
74+
- <code title="get /invocations/{id}/browsers">client.invocations.<a href="./src/kernel/resources/invocations.py">list_browsers</a>(id) -> <a href="./src/kernel/types/invocation_list_browsers_response.py">InvocationListBrowsersResponse</a></code>
7375

7476
# Browsers
7577

src/kernel/resources/invocations.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from ..types.invocation_follow_response import InvocationFollowResponse
2727
from ..types.invocation_update_response import InvocationUpdateResponse
2828
from ..types.invocation_retrieve_response import InvocationRetrieveResponse
29+
from ..types.invocation_list_browsers_response import InvocationListBrowsersResponse
2930

3031
__all__ = ["InvocationsResource", "AsyncInvocationsResource"]
3132

@@ -347,6 +348,39 @@ def follow(
347348
stream_cls=Stream[InvocationFollowResponse],
348349
)
349350

351+
def list_browsers(
352+
self,
353+
id: str,
354+
*,
355+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
356+
# The extra values given here take precedence over values defined on the client or passed to this method.
357+
extra_headers: Headers | None = None,
358+
extra_query: Query | None = None,
359+
extra_body: Body | None = None,
360+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
361+
) -> InvocationListBrowsersResponse:
362+
"""
363+
Returns all active browser sessions created within the specified invocation.
364+
365+
Args:
366+
extra_headers: Send extra headers
367+
368+
extra_query: Add additional query parameters to the request
369+
370+
extra_body: Add additional JSON properties to the request
371+
372+
timeout: Override the client-level default timeout for this request, in seconds
373+
"""
374+
if not id:
375+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
376+
return self._get(
377+
f"/invocations/{id}/browsers",
378+
options=make_request_options(
379+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
380+
),
381+
cast_to=InvocationListBrowsersResponse,
382+
)
383+
350384

351385
class AsyncInvocationsResource(AsyncAPIResource):
352386
@cached_property
@@ -665,6 +699,39 @@ async def follow(
665699
stream_cls=AsyncStream[InvocationFollowResponse],
666700
)
667701

702+
async def list_browsers(
703+
self,
704+
id: str,
705+
*,
706+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
707+
# The extra values given here take precedence over values defined on the client or passed to this method.
708+
extra_headers: Headers | None = None,
709+
extra_query: Query | None = None,
710+
extra_body: Body | None = None,
711+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
712+
) -> InvocationListBrowsersResponse:
713+
"""
714+
Returns all active browser sessions created within the specified invocation.
715+
716+
Args:
717+
extra_headers: Send extra headers
718+
719+
extra_query: Add additional query parameters to the request
720+
721+
extra_body: Add additional JSON properties to the request
722+
723+
timeout: Override the client-level default timeout for this request, in seconds
724+
"""
725+
if not id:
726+
raise ValueError(f"Expected a non-empty value for `id` but received {id!r}")
727+
return await self._get(
728+
f"/invocations/{id}/browsers",
729+
options=make_request_options(
730+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
731+
),
732+
cast_to=InvocationListBrowsersResponse,
733+
)
734+
668735

669736
class InvocationsResourceWithRawResponse:
670737
def __init__(self, invocations: InvocationsResource) -> None:
@@ -688,6 +755,9 @@ def __init__(self, invocations: InvocationsResource) -> None:
688755
self.follow = to_raw_response_wrapper(
689756
invocations.follow,
690757
)
758+
self.list_browsers = to_raw_response_wrapper(
759+
invocations.list_browsers,
760+
)
691761

692762

693763
class AsyncInvocationsResourceWithRawResponse:
@@ -712,6 +782,9 @@ def __init__(self, invocations: AsyncInvocationsResource) -> None:
712782
self.follow = async_to_raw_response_wrapper(
713783
invocations.follow,
714784
)
785+
self.list_browsers = async_to_raw_response_wrapper(
786+
invocations.list_browsers,
787+
)
715788

716789

717790
class InvocationsResourceWithStreamingResponse:
@@ -736,6 +809,9 @@ def __init__(self, invocations: InvocationsResource) -> None:
736809
self.follow = to_streamed_response_wrapper(
737810
invocations.follow,
738811
)
812+
self.list_browsers = to_streamed_response_wrapper(
813+
invocations.list_browsers,
814+
)
739815

740816

741817
class AsyncInvocationsResourceWithStreamingResponse:
@@ -760,3 +836,6 @@ def __init__(self, invocations: AsyncInvocationsResource) -> None:
760836
self.follow = async_to_streamed_response_wrapper(
761837
invocations.follow,
762838
)
839+
self.list_browsers = async_to_streamed_response_wrapper(
840+
invocations.list_browsers,
841+
)

src/kernel/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
from .credential_provider_create_params import CredentialProviderCreateParams as CredentialProviderCreateParams
7575
from .credential_provider_list_response import CredentialProviderListResponse as CredentialProviderListResponse
7676
from .credential_provider_update_params import CredentialProviderUpdateParams as CredentialProviderUpdateParams
77+
from .invocation_list_browsers_response import InvocationListBrowsersResponse as InvocationListBrowsersResponse
7778
from .extension_download_from_chrome_store_params import (
7879
ExtensionDownloadFromChromeStoreParams as ExtensionDownloadFromChromeStoreParams,
7980
)
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import List, Optional
4+
from datetime import datetime
5+
6+
from .profile import Profile
7+
from .._models import BaseModel
8+
from .browser_persistence import BrowserPersistence
9+
from .shared.browser_viewport import BrowserViewport
10+
11+
__all__ = ["InvocationListBrowsersResponse", "Browser"]
12+
13+
14+
class Browser(BaseModel):
15+
cdp_ws_url: str
16+
"""Websocket URL for Chrome DevTools Protocol connections to the browser session"""
17+
18+
created_at: datetime
19+
"""When the browser session was created."""
20+
21+
headless: bool
22+
"""Whether the browser session is running in headless mode."""
23+
24+
session_id: str
25+
"""Unique identifier for the browser session"""
26+
27+
stealth: bool
28+
"""Whether the browser session is running in stealth mode."""
29+
30+
timeout_seconds: int
31+
"""The number of seconds of inactivity before the browser session is terminated."""
32+
33+
browser_live_view_url: Optional[str] = None
34+
"""Remote URL for live viewing the browser session.
35+
36+
Only available for non-headless browsers.
37+
"""
38+
39+
deleted_at: Optional[datetime] = None
40+
"""When the browser session was soft-deleted. Only present for deleted sessions."""
41+
42+
kiosk_mode: Optional[bool] = None
43+
"""Whether the browser session is running in kiosk mode."""
44+
45+
persistence: Optional[BrowserPersistence] = None
46+
"""DEPRECATED: Use timeout_seconds (up to 72 hours) and Profiles instead."""
47+
48+
profile: Optional[Profile] = None
49+
"""Browser profile metadata."""
50+
51+
proxy_id: Optional[str] = None
52+
"""ID of the proxy associated with this browser session, if any."""
53+
54+
viewport: Optional[BrowserViewport] = None
55+
"""Initial browser window size in pixels with optional refresh rate.
56+
57+
If omitted, image defaults apply (1920x1080@25). Only specific viewport
58+
configurations are supported. The server will reject unsupported combinations.
59+
Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25,
60+
1440x900@25, 1280x800@60, 1024x768@60, 1200x800@60 If refresh_rate is not
61+
provided, it will be automatically determined from the width and height if they
62+
match a supported configuration exactly. Note: Higher resolutions may affect the
63+
responsiveness of live view browser
64+
"""
65+
66+
67+
class InvocationListBrowsersResponse(BaseModel):
68+
browsers: List[Browser]

tests/api_resources/test_invocations.py

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
InvocationCreateResponse,
1515
InvocationUpdateResponse,
1616
InvocationRetrieveResponse,
17+
InvocationListBrowsersResponse,
1718
)
1819
from kernel.pagination import SyncOffsetPagination, AsyncOffsetPagination
1920

@@ -309,6 +310,48 @@ def test_path_params_follow(self, client: Kernel) -> None:
309310
id="",
310311
)
311312

313+
@pytest.mark.skip(reason="Prism tests are disabled")
314+
@parametrize
315+
def test_method_list_browsers(self, client: Kernel) -> None:
316+
invocation = client.invocations.list_browsers(
317+
"id",
318+
)
319+
assert_matches_type(InvocationListBrowsersResponse, invocation, path=["response"])
320+
321+
@pytest.mark.skip(reason="Prism tests are disabled")
322+
@parametrize
323+
def test_raw_response_list_browsers(self, client: Kernel) -> None:
324+
response = client.invocations.with_raw_response.list_browsers(
325+
"id",
326+
)
327+
328+
assert response.is_closed is True
329+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
330+
invocation = response.parse()
331+
assert_matches_type(InvocationListBrowsersResponse, invocation, path=["response"])
332+
333+
@pytest.mark.skip(reason="Prism tests are disabled")
334+
@parametrize
335+
def test_streaming_response_list_browsers(self, client: Kernel) -> None:
336+
with client.invocations.with_streaming_response.list_browsers(
337+
"id",
338+
) as response:
339+
assert not response.is_closed
340+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
341+
342+
invocation = response.parse()
343+
assert_matches_type(InvocationListBrowsersResponse, invocation, path=["response"])
344+
345+
assert cast(Any, response.is_closed) is True
346+
347+
@pytest.mark.skip(reason="Prism tests are disabled")
348+
@parametrize
349+
def test_path_params_list_browsers(self, client: Kernel) -> None:
350+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
351+
client.invocations.with_raw_response.list_browsers(
352+
"",
353+
)
354+
312355

313356
class TestAsyncInvocations:
314357
parametrize = pytest.mark.parametrize(
@@ -600,3 +643,45 @@ async def test_path_params_follow(self, async_client: AsyncKernel) -> None:
600643
await async_client.invocations.with_raw_response.follow(
601644
id="",
602645
)
646+
647+
@pytest.mark.skip(reason="Prism tests are disabled")
648+
@parametrize
649+
async def test_method_list_browsers(self, async_client: AsyncKernel) -> None:
650+
invocation = await async_client.invocations.list_browsers(
651+
"id",
652+
)
653+
assert_matches_type(InvocationListBrowsersResponse, invocation, path=["response"])
654+
655+
@pytest.mark.skip(reason="Prism tests are disabled")
656+
@parametrize
657+
async def test_raw_response_list_browsers(self, async_client: AsyncKernel) -> None:
658+
response = await async_client.invocations.with_raw_response.list_browsers(
659+
"id",
660+
)
661+
662+
assert response.is_closed is True
663+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
664+
invocation = await response.parse()
665+
assert_matches_type(InvocationListBrowsersResponse, invocation, path=["response"])
666+
667+
@pytest.mark.skip(reason="Prism tests are disabled")
668+
@parametrize
669+
async def test_streaming_response_list_browsers(self, async_client: AsyncKernel) -> None:
670+
async with async_client.invocations.with_streaming_response.list_browsers(
671+
"id",
672+
) as response:
673+
assert not response.is_closed
674+
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
675+
676+
invocation = await response.parse()
677+
assert_matches_type(InvocationListBrowsersResponse, invocation, path=["response"])
678+
679+
assert cast(Any, response.is_closed) is True
680+
681+
@pytest.mark.skip(reason="Prism tests are disabled")
682+
@parametrize
683+
async def test_path_params_list_browsers(self, async_client: AsyncKernel) -> None:
684+
with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"):
685+
await async_client.invocations.with_raw_response.list_browsers(
686+
"",
687+
)

0 commit comments

Comments
 (0)