Skip to content

Commit 34423fb

Browse files
fix(api): browser pool profile omits save_changes (BrowserPoolProfile)
1 parent 0beb2b9 commit 34423fb

6 files changed

Lines changed: 139 additions & 49 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 124
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-4fb45d71a99648425c84bdc8e5780920105cede4ee2d4eac67276d0609ac1e94.yml
3-
openapi_spec_hash: 1f04cb5b36e92db81dfa264c2a59c32a
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-4c243ff089133bd49322d98a6943647589972f71ecadc993fe9e5029972b3995.yml
3+
openapi_spec_hash: a2cb637a19a070d07a1a4343c75444ee
44
config_hash: fb167e754ebb3a14649463725891c9d0

src/kernel/resources/browser_pools.py

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
from ..types.tags_param import TagsParam
3030
from ..types.browser_pool import BrowserPool
3131
from ..types.browser_pool_acquire_response import BrowserPoolAcquireResponse
32-
from ..types.shared_params.browser_profile import BrowserProfile
3332
from ..types.shared_params.browser_viewport import BrowserViewport
3433
from ..types.shared_params.browser_extension import BrowserExtension
3534

@@ -68,7 +67,7 @@ def create(
6867
headless: bool | Omit = omit,
6968
kiosk_mode: bool | Omit = omit,
7069
name: str | Omit = omit,
71-
profile: BrowserProfile | Omit = omit,
70+
profile: browser_pool_create_params.Profile | Omit = omit,
7271
proxy_id: str | Omit = omit,
7372
start_url: str | Omit = omit,
7473
stealth: bool | Omit = omit,
@@ -81,8 +80,12 @@ def create(
8180
extra_body: Body | None = None,
8281
timeout: float | httpx.Timeout | None | NotGiven = not_given,
8382
) -> BrowserPool:
84-
"""
85-
Create a new browser pool with the specified configuration and size.
83+
"""Create a new browser pool with the specified configuration and size.
84+
85+
Pooled
86+
browsers load their profile read-only: any save_changes on the profile is
87+
ignored (not rejected), so pooled browsers never persist changes back to the
88+
profile.
8689
8790
Args:
8891
size: Number of browsers to maintain in the pool. The maximum size is determined by
@@ -107,9 +110,12 @@ def create(
107110
108111
name: Optional name for the browser pool. Must be unique within the project.
109112
110-
profile: Profile selection for the browser session. Provide either id or name. If
111-
specified, the matching profile will be loaded into the browser session.
112-
Profiles must be created beforehand.
113+
profile: Profile selection for browsers in a pool. Provide either id or name. The
114+
matching profile is loaded into every browser in the pool. Profiles must be
115+
created beforehand. Unlike single browser sessions, pools load the profile
116+
read-only and never persist changes back to it, so save_changes is omitted here.
117+
Any save_changes value sent on a pool profile is silently ignored rather than
118+
rejected, so callers reusing a single-session profile object will not error.
113119
114120
proxy_id: Optional proxy to associate to the browser session. Must reference a proxy in
115121
the same project as the browser session.
@@ -217,7 +223,7 @@ def update(
217223
headless: bool | Omit = omit,
218224
kiosk_mode: bool | Omit = omit,
219225
name: str | Omit = omit,
220-
profile: BrowserProfile | Omit = omit,
226+
profile: browser_pool_update_params.Profile | Omit = omit,
221227
proxy_id: str | Omit = omit,
222228
size: int | Omit = omit,
223229
start_url: str | Omit = omit,
@@ -231,8 +237,11 @@ def update(
231237
extra_body: Body | None = None,
232238
timeout: float | httpx.Timeout | None | NotGiven = not_given,
233239
) -> BrowserPool:
234-
"""
235-
Updates the configuration used to create browsers in the pool.
240+
"""Updates the configuration used to create browsers in the pool.
241+
242+
As with creation,
243+
save_changes on the pool profile is ignored (not rejected); pooled browsers
244+
never persist changes back to the profile.
236245
237246
Args:
238247
chrome_policy: Custom Chrome enterprise policy overrides applied to all browsers in this pool.
@@ -256,9 +265,12 @@ def update(
256265
257266
name: Optional name for the browser pool. Must be unique within the project.
258267
259-
profile: Profile selection for the browser session. Provide either id or name. If
260-
specified, the matching profile will be loaded into the browser session.
261-
Profiles must be created beforehand.
268+
profile: Profile selection for browsers in a pool. Provide either id or name. The
269+
matching profile is loaded into every browser in the pool. Profiles must be
270+
created beforehand. Unlike single browser sessions, pools load the profile
271+
read-only and never persist changes back to it, so save_changes is omitted here.
272+
Any save_changes value sent on a pool profile is silently ignored rather than
273+
rejected, so callers reusing a single-session profile object will not error.
262274
263275
proxy_id: Optional proxy to associate to the browser session. Must reference a proxy in
264276
the same project as the browser session.
@@ -603,7 +615,7 @@ async def create(
603615
headless: bool | Omit = omit,
604616
kiosk_mode: bool | Omit = omit,
605617
name: str | Omit = omit,
606-
profile: BrowserProfile | Omit = omit,
618+
profile: browser_pool_create_params.Profile | Omit = omit,
607619
proxy_id: str | Omit = omit,
608620
start_url: str | Omit = omit,
609621
stealth: bool | Omit = omit,
@@ -616,8 +628,12 @@ async def create(
616628
extra_body: Body | None = None,
617629
timeout: float | httpx.Timeout | None | NotGiven = not_given,
618630
) -> BrowserPool:
619-
"""
620-
Create a new browser pool with the specified configuration and size.
631+
"""Create a new browser pool with the specified configuration and size.
632+
633+
Pooled
634+
browsers load their profile read-only: any save_changes on the profile is
635+
ignored (not rejected), so pooled browsers never persist changes back to the
636+
profile.
621637
622638
Args:
623639
size: Number of browsers to maintain in the pool. The maximum size is determined by
@@ -642,9 +658,12 @@ async def create(
642658
643659
name: Optional name for the browser pool. Must be unique within the project.
644660
645-
profile: Profile selection for the browser session. Provide either id or name. If
646-
specified, the matching profile will be loaded into the browser session.
647-
Profiles must be created beforehand.
661+
profile: Profile selection for browsers in a pool. Provide either id or name. The
662+
matching profile is loaded into every browser in the pool. Profiles must be
663+
created beforehand. Unlike single browser sessions, pools load the profile
664+
read-only and never persist changes back to it, so save_changes is omitted here.
665+
Any save_changes value sent on a pool profile is silently ignored rather than
666+
rejected, so callers reusing a single-session profile object will not error.
648667
649668
proxy_id: Optional proxy to associate to the browser session. Must reference a proxy in
650669
the same project as the browser session.
@@ -752,7 +771,7 @@ async def update(
752771
headless: bool | Omit = omit,
753772
kiosk_mode: bool | Omit = omit,
754773
name: str | Omit = omit,
755-
profile: BrowserProfile | Omit = omit,
774+
profile: browser_pool_update_params.Profile | Omit = omit,
756775
proxy_id: str | Omit = omit,
757776
size: int | Omit = omit,
758777
start_url: str | Omit = omit,
@@ -766,8 +785,11 @@ async def update(
766785
extra_body: Body | None = None,
767786
timeout: float | httpx.Timeout | None | NotGiven = not_given,
768787
) -> BrowserPool:
769-
"""
770-
Updates the configuration used to create browsers in the pool.
788+
"""Updates the configuration used to create browsers in the pool.
789+
790+
As with creation,
791+
save_changes on the pool profile is ignored (not rejected); pooled browsers
792+
never persist changes back to the profile.
771793
772794
Args:
773795
chrome_policy: Custom Chrome enterprise policy overrides applied to all browsers in this pool.
@@ -791,9 +813,12 @@ async def update(
791813
792814
name: Optional name for the browser pool. Must be unique within the project.
793815
794-
profile: Profile selection for the browser session. Provide either id or name. If
795-
specified, the matching profile will be loaded into the browser session.
796-
Profiles must be created beforehand.
816+
profile: Profile selection for browsers in a pool. Provide either id or name. The
817+
matching profile is loaded into every browser in the pool. Profiles must be
818+
created beforehand. Unlike single browser sessions, pools load the profile
819+
read-only and never persist changes back to it, so save_changes is omitted here.
820+
Any save_changes value sent on a pool profile is silently ignored rather than
821+
rejected, so callers reusing a single-session profile object will not error.
797822
798823
proxy_id: Optional proxy to associate to the browser session. Must reference a proxy in
799824
the same project as the browser session.

src/kernel/types/browser_pool.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,30 @@
44
from datetime import datetime
55

66
from .._models import BaseModel
7-
from .shared.browser_profile import BrowserProfile
87
from .shared.browser_viewport import BrowserViewport
98
from .shared.browser_extension import BrowserExtension
109

11-
__all__ = ["BrowserPool", "BrowserPoolConfig"]
10+
__all__ = ["BrowserPool", "BrowserPoolConfig", "BrowserPoolConfigProfile"]
11+
12+
13+
class BrowserPoolConfigProfile(BaseModel):
14+
"""Profile selection for browsers in a pool.
15+
16+
Provide either id or name. The matching profile is
17+
loaded into every browser in the pool. Profiles must be created beforehand. Unlike single
18+
browser sessions, pools load the profile read-only and never persist changes back to it, so
19+
save_changes is omitted here. Any save_changes value sent on a pool profile is silently
20+
ignored rather than rejected, so callers reusing a single-session profile object will not error.
21+
"""
22+
23+
id: Optional[str] = None
24+
"""Profile ID to load for browsers in this pool"""
25+
26+
name: Optional[str] = None
27+
"""Profile name to load for browsers in this pool (instead of id).
28+
29+
Must be 1-255 characters, using letters, numbers, dots, underscores, or hyphens.
30+
"""
1231

1332

1433
class BrowserPoolConfig(BaseModel):
@@ -54,11 +73,15 @@ class BrowserPoolConfig(BaseModel):
5473
name: Optional[str] = None
5574
"""Optional name for the browser pool. Must be unique within the project."""
5675

57-
profile: Optional[BrowserProfile] = None
58-
"""Profile selection for the browser session.
76+
profile: Optional[BrowserPoolConfigProfile] = None
77+
"""Profile selection for browsers in a pool.
5978
60-
Provide either id or name. If specified, the matching profile will be loaded
61-
into the browser session. Profiles must be created beforehand.
79+
Provide either id or name. The matching profile is loaded into every browser in
80+
the pool. Profiles must be created beforehand. Unlike single browser sessions,
81+
pools load the profile read-only and never persist changes back to it, so
82+
save_changes is omitted here. Any save_changes value sent on a pool profile is
83+
silently ignored rather than rejected, so callers reusing a single-session
84+
profile object will not error.
6285
"""
6386

6487
proxy_id: Optional[str] = None

src/kernel/types/browser_pool_create_params.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
from typing import Dict, Iterable
66
from typing_extensions import Required, TypedDict
77

8-
from .shared_params.browser_profile import BrowserProfile
98
from .shared_params.browser_viewport import BrowserViewport
109
from .shared_params.browser_extension import BrowserExtension
1110

12-
__all__ = ["BrowserPoolCreateParams"]
11+
__all__ = ["BrowserPoolCreateParams", "Profile"]
1312

1413

1514
class BrowserPoolCreateParams(TypedDict, total=False):
@@ -53,11 +52,15 @@ class BrowserPoolCreateParams(TypedDict, total=False):
5352
name: str
5453
"""Optional name for the browser pool. Must be unique within the project."""
5554

56-
profile: BrowserProfile
57-
"""Profile selection for the browser session.
55+
profile: Profile
56+
"""Profile selection for browsers in a pool.
5857
59-
Provide either id or name. If specified, the matching profile will be loaded
60-
into the browser session. Profiles must be created beforehand.
58+
Provide either id or name. The matching profile is loaded into every browser in
59+
the pool. Profiles must be created beforehand. Unlike single browser sessions,
60+
pools load the profile read-only and never persist changes back to it, so
61+
save_changes is omitted here. Any save_changes value sent on a pool profile is
62+
silently ignored rather than rejected, so callers reusing a single-session
63+
profile object will not error.
6164
"""
6265

6366
proxy_id: str
@@ -102,3 +105,23 @@ class BrowserPoolCreateParams(TypedDict, total=False):
102105
based on the resolution (higher resolutions use lower refresh rates to keep
103106
bandwidth reasonable).
104107
"""
108+
109+
110+
class Profile(TypedDict, total=False):
111+
"""Profile selection for browsers in a pool.
112+
113+
Provide either id or name. The matching profile is
114+
loaded into every browser in the pool. Profiles must be created beforehand. Unlike single
115+
browser sessions, pools load the profile read-only and never persist changes back to it, so
116+
save_changes is omitted here. Any save_changes value sent on a pool profile is silently
117+
ignored rather than rejected, so callers reusing a single-session profile object will not error.
118+
"""
119+
120+
id: str
121+
"""Profile ID to load for browsers in this pool"""
122+
123+
name: str
124+
"""Profile name to load for browsers in this pool (instead of id).
125+
126+
Must be 1-255 characters, using letters, numbers, dots, underscores, or hyphens.
127+
"""

src/kernel/types/browser_pool_update_params.py

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
from typing import Dict, Iterable
66
from typing_extensions import TypedDict
77

8-
from .shared_params.browser_profile import BrowserProfile
98
from .shared_params.browser_viewport import BrowserViewport
109
from .shared_params.browser_extension import BrowserExtension
1110

12-
__all__ = ["BrowserPoolUpdateParams"]
11+
__all__ = ["BrowserPoolUpdateParams", "Profile"]
1312

1413

1514
class BrowserPoolUpdateParams(TypedDict, total=False):
@@ -52,11 +51,15 @@ class BrowserPoolUpdateParams(TypedDict, total=False):
5251
name: str
5352
"""Optional name for the browser pool. Must be unique within the project."""
5453

55-
profile: BrowserProfile
56-
"""Profile selection for the browser session.
54+
profile: Profile
55+
"""Profile selection for browsers in a pool.
5756
58-
Provide either id or name. If specified, the matching profile will be loaded
59-
into the browser session. Profiles must be created beforehand.
57+
Provide either id or name. The matching profile is loaded into every browser in
58+
the pool. Profiles must be created beforehand. Unlike single browser sessions,
59+
pools load the profile read-only and never persist changes back to it, so
60+
save_changes is omitted here. Any save_changes value sent on a pool profile is
61+
silently ignored rather than rejected, so callers reusing a single-session
62+
profile object will not error.
6063
"""
6164

6265
proxy_id: str
@@ -108,3 +111,23 @@ class BrowserPoolUpdateParams(TypedDict, total=False):
108111
based on the resolution (higher resolutions use lower refresh rates to keep
109112
bandwidth reasonable).
110113
"""
114+
115+
116+
class Profile(TypedDict, total=False):
117+
"""Profile selection for browsers in a pool.
118+
119+
Provide either id or name. The matching profile is
120+
loaded into every browser in the pool. Profiles must be created beforehand. Unlike single
121+
browser sessions, pools load the profile read-only and never persist changes back to it, so
122+
save_changes is omitted here. Any save_changes value sent on a pool profile is silently
123+
ignored rather than rejected, so callers reusing a single-session profile object will not error.
124+
"""
125+
126+
id: str
127+
"""Profile ID to load for browsers in this pool"""
128+
129+
name: str
130+
"""Profile name to load for browsers in this pool (instead of id).
131+
132+
Must be 1-255 characters, using letters, numbers, dots, underscores, or hyphens.
133+
"""

tests/api_resources/test_browser_pools.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ def test_method_create_with_all_params(self, client: Kernel) -> None:
4848
profile={
4949
"id": "id",
5050
"name": "name",
51-
"save_changes": True,
5251
},
5352
proxy_id="proxy_id",
5453
start_url="https://example.com",
@@ -158,7 +157,6 @@ def test_method_update_with_all_params(self, client: Kernel) -> None:
158157
profile={
159158
"id": "id",
160159
"name": "name",
161-
"save_changes": True,
162160
},
163161
proxy_id="proxy_id",
164162
size=10,
@@ -484,7 +482,6 @@ async def test_method_create_with_all_params(self, async_client: AsyncKernel) ->
484482
profile={
485483
"id": "id",
486484
"name": "name",
487-
"save_changes": True,
488485
},
489486
proxy_id="proxy_id",
490487
start_url="https://example.com",
@@ -594,7 +591,6 @@ async def test_method_update_with_all_params(self, async_client: AsyncKernel) ->
594591
profile={
595592
"id": "id",
596593
"name": "name",
597-
"save_changes": True,
598594
},
599595
proxy_id="proxy_id",
600596
size=10,

0 commit comments

Comments
 (0)