Skip to content

Commit 20b3a7e

Browse files
feat: Make the browser pool OpenAPI contract truthful
1 parent 6011556 commit 20b3a7e

5 files changed

Lines changed: 108 additions & 108 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: 127
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-b20fcf2fc1cdb91b51ffd354adcd12d63b950ea98b69e13bee6a78a58498c2cd.yml
3-
openapi_spec_hash: bc8b527a963dd2c2d74b6f9e6ca56652
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-d7ab1ecb886cb7f86e7ce0926207db423a6650e8e12e7283a71f8682fbb472ae.yml
3+
openapi_spec_hash: 9323b0ba38d2d50b8506be4d7401c04d
44
config_hash: 77ee715aa17061166f9a02b264a21b8d

src/kernel/resources/browser_pools.py

Lines changed: 62 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ def create(
9696
chrome_policy: Custom Chrome enterprise policy overrides applied to all browsers in this pool.
9797
Keys are Chrome enterprise policy names; values must match their expected types.
9898
Blocked: kernel-managed policies (extensions, proxy, CDP/automation). See
99-
https://chromeenterprise.google/policies/
99+
https://chromeenterprise.google/policies/ The serialized JSON payload is capped
100+
at 5 MiB.
100101
101102
extensions: List of browser extensions to load into the session. Provide each by id or name.
102103
@@ -107,7 +108,7 @@ def create(
107108
headless: If true, launches the browser using a headless image. Defaults to false.
108109
109110
kiosk_mode: If true, launches the browser in kiosk mode to hide address bar and tabs in live
110-
view.
111+
view. Defaults to false.
111112
112113
name: Optional name for the browser pool. Must be unique within the project.
113114
@@ -131,7 +132,7 @@ def create(
131132
chrome:// pages.
132133
133134
stealth: If true, launches the browser in stealth mode to reduce detection by anti-bot
134-
mechanisms.
135+
mechanisms. Defaults to false.
135136
136137
timeout_seconds: Default idle timeout in seconds for browsers acquired from this pool before they
137138
are destroyed. Defaults to 600 seconds. Minimum 10, maximum 259200 (72 hours).
@@ -252,10 +253,12 @@ def update(
252253
`refresh_on_profile_update`.
253254
254255
Args:
255-
chrome_policy: Custom Chrome enterprise policy overrides applied to all browsers in this pool.
256-
Keys are Chrome enterprise policy names; values must match their expected types.
256+
chrome_policy: If provided, replaces the custom Chrome enterprise policy overrides applied to
257+
all browsers in this pool. Empty object clears any previously-set policy. Keys
258+
are Chrome enterprise policy names; values must match their expected types.
257259
Blocked: kernel-managed policies (extensions, proxy, CDP/automation). See
258-
https://chromeenterprise.google/policies/
260+
https://chromeenterprise.google/policies/ The serialized JSON payload is capped
261+
at 5 MiB.
259262
260263
discard_all_idle: Whether to discard all idle browsers and rebuild them immediately with the new
261264
configuration. Defaults to false. Only browsers that are idle when the update
@@ -264,47 +267,44 @@ def update(
264267
pool with that stale configuration until it is discarded (by this flag on a
265268
later update, or by flushing the pool).
266269
267-
extensions: List of browser extensions to load into the session. Provide each by id or name.
270+
extensions: If provided, replaces the extension list. Empty array clears all
271+
previously-selected extensions. Omit this field to leave extensions unchanged.
268272
269-
fill_rate_per_minute: Percentage of the pool to fill per minute. Defaults to 10. The cap is 25 for
270-
most organizations but can be raised per-organization, so only the lower bound
271-
is enforced here.
273+
fill_rate_per_minute: If provided, replaces the percentage of the pool to fill per minute. The cap is
274+
25 for most organizations but can be raised per-organization, so only the lower
275+
bound is enforced here.
272276
273-
headless: If true, launches the browser using a headless image. Defaults to false.
277+
headless: If provided, replaces whether browsers launch using a headless image.
274278
275-
kiosk_mode: If true, launches the browser in kiosk mode to hide address bar and tabs in live
276-
view.
279+
kiosk_mode: If provided, replaces whether browsers launch in kiosk mode.
277280
278-
name: Optional name for the browser pool. Must be unique within the project.
281+
name: If provided, replaces the pool name. Empty string is a no-op; the pool name
282+
cannot be cleared or reset to empty once assigned.
279283
280284
profile: Profile configuration for browsers in a pool. Provide either id or name.
281285
Profiles must be created beforehand. Unlike single browser sessions, pools load
282286
the profile read-only and never persist changes back to it, so save_changes is
283287
omitted here. Any save_changes value sent on a pool profile is silently ignored
284288
rather than rejected.
285289
286-
proxy_id: Optional proxy to associate to the browser session. Must reference a proxy in
287-
the same project as the browser session.
290+
proxy_id: Empty string clears the previously-selected proxy. Omit this field to leave the
291+
proxy unchanged.
288292
289-
refresh_on_profile_update: When true, flush idle browsers when the profile the pool uses is updated, so
290-
pool browsers pick up the latest profile data. Requires a profile to be set on
291-
the pool.
293+
refresh_on_profile_update: If provided, replaces whether idle browsers are flushed when the profile the
294+
pool uses is updated. Requires a profile to be set on the pool.
292295
293-
size: Number of browsers to maintain in the pool. The maximum size is determined by
294-
your organization's pooled sessions limit (the sum of all pool sizes cannot
295-
exceed your limit).
296+
size: If provided, replaces the number of browsers to maintain in the pool. The
297+
maximum size is determined by your organization's pooled sessions limit (the sum
298+
of all pool sizes cannot exceed your limit).
296299
297-
start_url: Optional URL to navigate to when a new browser is warmed into the pool.
298-
Best-effort: failures to navigate do not fail pool fill. Only applied to
299-
newly-warmed browsers; browsers reused via release/acquire keep whatever URL the
300-
previous lease left them on. Accepts any URL Chromium can resolve, including
301-
chrome:// pages.
300+
start_url: If provided, replaces the URL to navigate to when a new browser is warmed into
301+
the pool. Empty string clears the previously-set URL. Omit this field to leave
302+
it unchanged.
302303
303-
stealth: If true, launches the browser in stealth mode to reduce detection by anti-bot
304-
mechanisms.
304+
stealth: If provided, replaces whether browsers launch in stealth mode.
305305
306-
timeout_seconds: Default idle timeout in seconds for browsers acquired from this pool before they
307-
are destroyed. Defaults to 600 seconds. Minimum 10, maximum 259200 (72 hours).
306+
timeout_seconds: If provided, replaces the default idle timeout in seconds for browsers acquired
307+
from this pool before they are destroyed. Minimum 10, maximum 259200 (72 hours).
308308
309309
viewport: Initial browser window size in pixels with optional refresh rate. If omitted,
310310
image defaults apply (1920x1080@25). For GPU images, the default is
@@ -671,7 +671,8 @@ async def create(
671671
chrome_policy: Custom Chrome enterprise policy overrides applied to all browsers in this pool.
672672
Keys are Chrome enterprise policy names; values must match their expected types.
673673
Blocked: kernel-managed policies (extensions, proxy, CDP/automation). See
674-
https://chromeenterprise.google/policies/
674+
https://chromeenterprise.google/policies/ The serialized JSON payload is capped
675+
at 5 MiB.
675676
676677
extensions: List of browser extensions to load into the session. Provide each by id or name.
677678
@@ -682,7 +683,7 @@ async def create(
682683
headless: If true, launches the browser using a headless image. Defaults to false.
683684
684685
kiosk_mode: If true, launches the browser in kiosk mode to hide address bar and tabs in live
685-
view.
686+
view. Defaults to false.
686687
687688
name: Optional name for the browser pool. Must be unique within the project.
688689
@@ -706,7 +707,7 @@ async def create(
706707
chrome:// pages.
707708
708709
stealth: If true, launches the browser in stealth mode to reduce detection by anti-bot
709-
mechanisms.
710+
mechanisms. Defaults to false.
710711
711712
timeout_seconds: Default idle timeout in seconds for browsers acquired from this pool before they
712713
are destroyed. Defaults to 600 seconds. Minimum 10, maximum 259200 (72 hours).
@@ -827,10 +828,12 @@ async def update(
827828
`refresh_on_profile_update`.
828829
829830
Args:
830-
chrome_policy: Custom Chrome enterprise policy overrides applied to all browsers in this pool.
831-
Keys are Chrome enterprise policy names; values must match their expected types.
831+
chrome_policy: If provided, replaces the custom Chrome enterprise policy overrides applied to
832+
all browsers in this pool. Empty object clears any previously-set policy. Keys
833+
are Chrome enterprise policy names; values must match their expected types.
832834
Blocked: kernel-managed policies (extensions, proxy, CDP/automation). See
833-
https://chromeenterprise.google/policies/
835+
https://chromeenterprise.google/policies/ The serialized JSON payload is capped
836+
at 5 MiB.
834837
835838
discard_all_idle: Whether to discard all idle browsers and rebuild them immediately with the new
836839
configuration. Defaults to false. Only browsers that are idle when the update
@@ -839,47 +842,44 @@ async def update(
839842
pool with that stale configuration until it is discarded (by this flag on a
840843
later update, or by flushing the pool).
841844
842-
extensions: List of browser extensions to load into the session. Provide each by id or name.
845+
extensions: If provided, replaces the extension list. Empty array clears all
846+
previously-selected extensions. Omit this field to leave extensions unchanged.
843847
844-
fill_rate_per_minute: Percentage of the pool to fill per minute. Defaults to 10. The cap is 25 for
845-
most organizations but can be raised per-organization, so only the lower bound
846-
is enforced here.
848+
fill_rate_per_minute: If provided, replaces the percentage of the pool to fill per minute. The cap is
849+
25 for most organizations but can be raised per-organization, so only the lower
850+
bound is enforced here.
847851
848-
headless: If true, launches the browser using a headless image. Defaults to false.
852+
headless: If provided, replaces whether browsers launch using a headless image.
849853
850-
kiosk_mode: If true, launches the browser in kiosk mode to hide address bar and tabs in live
851-
view.
854+
kiosk_mode: If provided, replaces whether browsers launch in kiosk mode.
852855
853-
name: Optional name for the browser pool. Must be unique within the project.
856+
name: If provided, replaces the pool name. Empty string is a no-op; the pool name
857+
cannot be cleared or reset to empty once assigned.
854858
855859
profile: Profile configuration for browsers in a pool. Provide either id or name.
856860
Profiles must be created beforehand. Unlike single browser sessions, pools load
857861
the profile read-only and never persist changes back to it, so save_changes is
858862
omitted here. Any save_changes value sent on a pool profile is silently ignored
859863
rather than rejected.
860864
861-
proxy_id: Optional proxy to associate to the browser session. Must reference a proxy in
862-
the same project as the browser session.
865+
proxy_id: Empty string clears the previously-selected proxy. Omit this field to leave the
866+
proxy unchanged.
863867
864-
refresh_on_profile_update: When true, flush idle browsers when the profile the pool uses is updated, so
865-
pool browsers pick up the latest profile data. Requires a profile to be set on
866-
the pool.
868+
refresh_on_profile_update: If provided, replaces whether idle browsers are flushed when the profile the
869+
pool uses is updated. Requires a profile to be set on the pool.
867870
868-
size: Number of browsers to maintain in the pool. The maximum size is determined by
869-
your organization's pooled sessions limit (the sum of all pool sizes cannot
870-
exceed your limit).
871+
size: If provided, replaces the number of browsers to maintain in the pool. The
872+
maximum size is determined by your organization's pooled sessions limit (the sum
873+
of all pool sizes cannot exceed your limit).
871874
872-
start_url: Optional URL to navigate to when a new browser is warmed into the pool.
873-
Best-effort: failures to navigate do not fail pool fill. Only applied to
874-
newly-warmed browsers; browsers reused via release/acquire keep whatever URL the
875-
previous lease left them on. Accepts any URL Chromium can resolve, including
876-
chrome:// pages.
875+
start_url: If provided, replaces the URL to navigate to when a new browser is warmed into
876+
the pool. Empty string clears the previously-set URL. Omit this field to leave
877+
it unchanged.
877878
878-
stealth: If true, launches the browser in stealth mode to reduce detection by anti-bot
879-
mechanisms.
879+
stealth: If provided, replaces whether browsers launch in stealth mode.
880880
881-
timeout_seconds: Default idle timeout in seconds for browsers acquired from this pool before they
882-
are destroyed. Defaults to 600 seconds. Minimum 10, maximum 259200 (72 hours).
881+
timeout_seconds: If provided, replaces the default idle timeout in seconds for browsers acquired
882+
from this pool before they are destroyed. Minimum 10, maximum 259200 (72 hours).
883883
884884
viewport: Initial browser window size in pixels with optional refresh rate. If omitted,
885885
image defaults apply (1920x1080@25). For GPU images, the default is

src/kernel/types/browser_pool.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class BrowserPoolConfig(BaseModel):
3333
"""Configuration used to create all browsers in this pool"""
3434

3535
size: int
36-
"""Number of browsers to maintain in the pool.
36+
"""Number of browsers maintained in the pool.
3737
3838
The maximum size is determined by your organization's pooled sessions limit (the
3939
sum of all pool sizes cannot exceed your limit).
@@ -44,7 +44,8 @@ class BrowserPoolConfig(BaseModel):
4444
4545
Keys are Chrome enterprise policy names; values must match their expected types.
4646
Blocked: kernel-managed policies (extensions, proxy, CDP/automation). See
47-
https://chromeenterprise.google/policies/
47+
https://chromeenterprise.google/policies/ The serialized JSON payload is capped
48+
at 5 MiB.
4849
"""
4950

5051
extensions: Optional[List[BrowserExtension]] = None
@@ -56,12 +57,12 @@ class BrowserPoolConfig(BaseModel):
5657
fill_rate_per_minute: Optional[int] = None
5758
"""Percentage of the pool to fill per minute.
5859
59-
Defaults to 10. The cap is 25 for most organizations but can be raised
60-
per-organization, so only the lower bound is enforced here.
60+
The cap is 25 for most organizations but can be raised per-organization, so only
61+
the lower bound is enforced here.
6162
"""
6263

6364
headless: Optional[bool] = None
64-
"""If true, launches the browser using a headless image. Defaults to false."""
65+
"""If true, launches the browser using a headless image."""
6566

6667
kiosk_mode: Optional[bool] = None
6768
"""
@@ -82,9 +83,9 @@ class BrowserPoolConfig(BaseModel):
8283
"""
8384

8485
proxy_id: Optional[str] = None
85-
"""Optional proxy to associate to the browser session.
86+
"""Optional proxy associated to the browser session.
8687
87-
Must reference a proxy in the same project as the browser session.
88+
References a proxy in the same project as the browser session.
8889
"""
8990

9091
refresh_on_profile_update: Optional[bool] = None
@@ -112,7 +113,7 @@ class BrowserPoolConfig(BaseModel):
112113
timeout_seconds: Optional[int] = None
113114
"""
114115
Default idle timeout in seconds for browsers acquired from this pool before they
115-
are destroyed. Defaults to 600 seconds. Minimum 10, maximum 259200 (72 hours).
116+
are destroyed. Minimum 10, maximum 259200 (72 hours).
116117
"""
117118

118119
viewport: Optional[BrowserViewport] = None

src/kernel/types/browser_pool_create_params.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ class BrowserPoolCreateParams(TypedDict, total=False):
2424
2525
Keys are Chrome enterprise policy names; values must match their expected types.
2626
Blocked: kernel-managed policies (extensions, proxy, CDP/automation). See
27-
https://chromeenterprise.google/policies/
27+
https://chromeenterprise.google/policies/ The serialized JSON payload is capped
28+
at 5 MiB.
2829
"""
2930

3031
extensions: Iterable[BrowserExtension]
@@ -46,7 +47,7 @@ class BrowserPoolCreateParams(TypedDict, total=False):
4647
kiosk_mode: bool
4748
"""
4849
If true, launches the browser in kiosk mode to hide address bar and tabs in live
49-
view.
50+
view. Defaults to false.
5051
"""
5152

5253
name: str
@@ -86,7 +87,7 @@ class BrowserPoolCreateParams(TypedDict, total=False):
8687
stealth: bool
8788
"""
8889
If true, launches the browser in stealth mode to reduce detection by anti-bot
89-
mechanisms.
90+
mechanisms. Defaults to false.
9091
"""
9192

9293
timeout_seconds: int

0 commit comments

Comments
 (0)