Skip to content

Commit 52bcaa1

Browse files
feat(api): adding support for browser profiles
1 parent 72b0862 commit 52bcaa1

16 files changed

+1055
-6
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: 41
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-a7c1df5070fe59642d7a1f168aa902a468227752bfc930cbf38930f7c205dbb6.yml
3-
openapi_spec_hash: eab65e39aef4f0a0952b82adeecf6b5b
4-
config_hash: 5de78bc29ac060562575cb54bb26826c
1+
configured_endpoints: 46
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-e98d46c55826cdf541a9ee0df04ce92806ac6d4d92957ae79f897270b7d85b23.yml
3+
openapi_spec_hash: 8a1af54fc0a4417165b8a52e6354b685
4+
config_hash: 043ddc54629c6d8b889123770cb4769f

api.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ Types:
6666
```python
6767
from kernel.types import (
6868
BrowserPersistence,
69+
Profile,
6970
BrowserCreateResponse,
7071
BrowserRetrieveResponse,
7172
BrowserListResponse,
@@ -161,3 +162,19 @@ Methods:
161162
Methods:
162163

163164
- <code title="get /browsers/{id}/logs/stream">client.browsers.logs.<a href="./src/kernel/resources/browsers/logs.py">stream</a>(id, \*\*<a href="src/kernel/types/browsers/log_stream_params.py">params</a>) -> <a href="./src/kernel/types/shared/log_event.py">LogEvent</a></code>
165+
166+
# Profiles
167+
168+
Types:
169+
170+
```python
171+
from kernel.types import ProfileListResponse
172+
```
173+
174+
Methods:
175+
176+
- <code title="post /profiles">client.profiles.<a href="./src/kernel/resources/profiles.py">create</a>(\*\*<a href="src/kernel/types/profile_create_params.py">params</a>) -> <a href="./src/kernel/types/profile.py">Profile</a></code>
177+
- <code title="get /profiles/{id_or_name}">client.profiles.<a href="./src/kernel/resources/profiles.py">retrieve</a>(id_or_name) -> <a href="./src/kernel/types/profile.py">Profile</a></code>
178+
- <code title="get /profiles">client.profiles.<a href="./src/kernel/resources/profiles.py">list</a>() -> <a href="./src/kernel/types/profile_list_response.py">ProfileListResponse</a></code>
179+
- <code title="delete /profiles/{id_or_name}">client.profiles.<a href="./src/kernel/resources/profiles.py">delete</a>(id_or_name) -> None</code>
180+
- <code title="get /profiles/{id_or_name}/download">client.profiles.<a href="./src/kernel/resources/profiles.py">download</a>(id_or_name) -> BinaryAPIResponse</code>

src/kernel/_client.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
)
2222
from ._utils import is_given, get_async_library
2323
from ._version import __version__
24-
from .resources import apps, deployments, invocations
24+
from .resources import apps, profiles, deployments, invocations
2525
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
2626
from ._exceptions import KernelError, APIStatusError
2727
from ._base_client import (
@@ -54,6 +54,7 @@ class Kernel(SyncAPIClient):
5454
apps: apps.AppsResource
5555
invocations: invocations.InvocationsResource
5656
browsers: browsers.BrowsersResource
57+
profiles: profiles.ProfilesResource
5758
with_raw_response: KernelWithRawResponse
5859
with_streaming_response: KernelWithStreamedResponse
5960

@@ -139,6 +140,7 @@ def __init__(
139140
self.apps = apps.AppsResource(self)
140141
self.invocations = invocations.InvocationsResource(self)
141142
self.browsers = browsers.BrowsersResource(self)
143+
self.profiles = profiles.ProfilesResource(self)
142144
self.with_raw_response = KernelWithRawResponse(self)
143145
self.with_streaming_response = KernelWithStreamedResponse(self)
144146

@@ -254,6 +256,7 @@ class AsyncKernel(AsyncAPIClient):
254256
apps: apps.AsyncAppsResource
255257
invocations: invocations.AsyncInvocationsResource
256258
browsers: browsers.AsyncBrowsersResource
259+
profiles: profiles.AsyncProfilesResource
257260
with_raw_response: AsyncKernelWithRawResponse
258261
with_streaming_response: AsyncKernelWithStreamedResponse
259262

@@ -339,6 +342,7 @@ def __init__(
339342
self.apps = apps.AsyncAppsResource(self)
340343
self.invocations = invocations.AsyncInvocationsResource(self)
341344
self.browsers = browsers.AsyncBrowsersResource(self)
345+
self.profiles = profiles.AsyncProfilesResource(self)
342346
self.with_raw_response = AsyncKernelWithRawResponse(self)
343347
self.with_streaming_response = AsyncKernelWithStreamedResponse(self)
344348

@@ -455,6 +459,7 @@ def __init__(self, client: Kernel) -> None:
455459
self.apps = apps.AppsResourceWithRawResponse(client.apps)
456460
self.invocations = invocations.InvocationsResourceWithRawResponse(client.invocations)
457461
self.browsers = browsers.BrowsersResourceWithRawResponse(client.browsers)
462+
self.profiles = profiles.ProfilesResourceWithRawResponse(client.profiles)
458463

459464

460465
class AsyncKernelWithRawResponse:
@@ -463,6 +468,7 @@ def __init__(self, client: AsyncKernel) -> None:
463468
self.apps = apps.AsyncAppsResourceWithRawResponse(client.apps)
464469
self.invocations = invocations.AsyncInvocationsResourceWithRawResponse(client.invocations)
465470
self.browsers = browsers.AsyncBrowsersResourceWithRawResponse(client.browsers)
471+
self.profiles = profiles.AsyncProfilesResourceWithRawResponse(client.profiles)
466472

467473

468474
class KernelWithStreamedResponse:
@@ -471,6 +477,7 @@ def __init__(self, client: Kernel) -> None:
471477
self.apps = apps.AppsResourceWithStreamingResponse(client.apps)
472478
self.invocations = invocations.InvocationsResourceWithStreamingResponse(client.invocations)
473479
self.browsers = browsers.BrowsersResourceWithStreamingResponse(client.browsers)
480+
self.profiles = profiles.ProfilesResourceWithStreamingResponse(client.profiles)
474481

475482

476483
class AsyncKernelWithStreamedResponse:
@@ -479,6 +486,7 @@ def __init__(self, client: AsyncKernel) -> None:
479486
self.apps = apps.AsyncAppsResourceWithStreamingResponse(client.apps)
480487
self.invocations = invocations.AsyncInvocationsResourceWithStreamingResponse(client.invocations)
481488
self.browsers = browsers.AsyncBrowsersResourceWithStreamingResponse(client.browsers)
489+
self.profiles = profiles.AsyncProfilesResourceWithStreamingResponse(client.profiles)
482490

483491

484492
Client = Kernel

src/kernel/resources/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@
1616
BrowsersResourceWithStreamingResponse,
1717
AsyncBrowsersResourceWithStreamingResponse,
1818
)
19+
from .profiles import (
20+
ProfilesResource,
21+
AsyncProfilesResource,
22+
ProfilesResourceWithRawResponse,
23+
AsyncProfilesResourceWithRawResponse,
24+
ProfilesResourceWithStreamingResponse,
25+
AsyncProfilesResourceWithStreamingResponse,
26+
)
1927
from .deployments import (
2028
DeploymentsResource,
2129
AsyncDeploymentsResource,
@@ -58,4 +66,10 @@
5866
"AsyncBrowsersResourceWithRawResponse",
5967
"BrowsersResourceWithStreamingResponse",
6068
"AsyncBrowsersResourceWithStreamingResponse",
69+
"ProfilesResource",
70+
"AsyncProfilesResource",
71+
"ProfilesResourceWithRawResponse",
72+
"AsyncProfilesResourceWithRawResponse",
73+
"ProfilesResourceWithStreamingResponse",
74+
"AsyncProfilesResourceWithStreamingResponse",
6175
]

src/kernel/resources/browsers/browsers.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def create(
9898
headless: bool | NotGiven = NOT_GIVEN,
9999
invocation_id: str | NotGiven = NOT_GIVEN,
100100
persistence: BrowserPersistenceParam | NotGiven = NOT_GIVEN,
101+
profile: browser_create_params.Profile | NotGiven = NOT_GIVEN,
101102
stealth: bool | NotGiven = NOT_GIVEN,
102103
timeout_seconds: int | NotGiven = NOT_GIVEN,
103104
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -118,6 +119,10 @@ def create(
118119
119120
persistence: Optional persistence configuration for the browser session.
120121
122+
profile: Profile selection for the browser session. Provide either id or name. If
123+
specified, the matching profile will be loaded into the browser session.
124+
Profiles must be created beforehand.
125+
121126
stealth: If true, launches the browser in stealth mode to reduce detection by anti-bot
122127
mechanisms.
123128
@@ -140,6 +145,7 @@ def create(
140145
"headless": headless,
141146
"invocation_id": invocation_id,
142147
"persistence": persistence,
148+
"profile": profile,
143149
"stealth": stealth,
144150
"timeout_seconds": timeout_seconds,
145151
},
@@ -318,6 +324,7 @@ async def create(
318324
headless: bool | NotGiven = NOT_GIVEN,
319325
invocation_id: str | NotGiven = NOT_GIVEN,
320326
persistence: BrowserPersistenceParam | NotGiven = NOT_GIVEN,
327+
profile: browser_create_params.Profile | NotGiven = NOT_GIVEN,
321328
stealth: bool | NotGiven = NOT_GIVEN,
322329
timeout_seconds: int | NotGiven = NOT_GIVEN,
323330
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -338,6 +345,10 @@ async def create(
338345
339346
persistence: Optional persistence configuration for the browser session.
340347
348+
profile: Profile selection for the browser session. Provide either id or name. If
349+
specified, the matching profile will be loaded into the browser session.
350+
Profiles must be created beforehand.
351+
341352
stealth: If true, launches the browser in stealth mode to reduce detection by anti-bot
342353
mechanisms.
343354
@@ -360,6 +371,7 @@ async def create(
360371
"headless": headless,
361372
"invocation_id": invocation_id,
362373
"persistence": persistence,
374+
"profile": profile,
363375
"stealth": stealth,
364376
"timeout_seconds": timeout_seconds,
365377
},

0 commit comments

Comments
 (0)