Skip to content

Commit 430c07f

Browse files
feat: Auto-flush pools when a managed auth profile re-authenticates
1 parent 7c29a16 commit 430c07f

6 files changed

Lines changed: 107 additions & 67 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: 125
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-f6795e5d85e37b74f59876434c74b598e34171f99bc598c85b789abbb60614f1.yml
3-
openapi_spec_hash: 98e86fcbf0710a693bb1e03170ca85c3
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel/kernel-58ad412d62b3d94e3258c911d7028716d71191358ff769ce494c4b2d87027254.yml
3+
openapi_spec_hash: 45d710b7d2a9beadff021514bb997ba1
44
config_hash: 06186eb40e0058a2a87ac251fc07415d

src/kernel/resources/browser_pools.py

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def create(
6969
name: str | Omit = omit,
7070
profile: browser_pool_create_params.Profile | Omit = omit,
7171
proxy_id: str | Omit = omit,
72+
refresh_on_profile_update: bool | Omit = omit,
7273
start_url: str | Omit = omit,
7374
stealth: bool | Omit = omit,
7475
timeout_seconds: int | Omit = omit,
@@ -110,16 +111,19 @@ def create(
110111
111112
name: Optional name for the browser pool. Must be unique within the project.
112113
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.
114+
profile: Profile configuration for browsers in a pool. Provide either id or name.
115+
Profiles must be created beforehand. Unlike single browser sessions, pools load
116+
the profile read-only and never persist changes back to it, so save_changes is
117+
omitted here. Any save_changes value sent on a pool profile is silently ignored
118+
rather than rejected.
119119
120120
proxy_id: Optional proxy to associate to the browser session. Must reference a proxy in
121121
the same project as the browser session.
122122
123+
refresh_on_profile_update: When true, flush idle browsers when the profile the pool uses is updated, so
124+
pool browsers pick up the latest profile data. Requires a profile to be set on
125+
the pool.
126+
123127
start_url: Optional URL to navigate to when a new browser is warmed into the pool.
124128
Best-effort: failures to navigate do not fail pool fill. Only applied to
125129
newly-warmed browsers; browsers reused via release/acquire keep whatever URL the
@@ -166,6 +170,7 @@ def create(
166170
"name": name,
167171
"profile": profile,
168172
"proxy_id": proxy_id,
173+
"refresh_on_profile_update": refresh_on_profile_update,
169174
"start_url": start_url,
170175
"stealth": stealth,
171176
"timeout_seconds": timeout_seconds,
@@ -225,6 +230,7 @@ def update(
225230
name: str | Omit = omit,
226231
profile: browser_pool_update_params.Profile | Omit = omit,
227232
proxy_id: str | Omit = omit,
233+
refresh_on_profile_update: bool | Omit = omit,
228234
size: int | Omit = omit,
229235
start_url: str | Omit = omit,
230236
stealth: bool | Omit = omit,
@@ -241,7 +247,9 @@ def update(
241247
242248
As with creation,
243249
save_changes on the pool profile is ignored (not rejected); pooled browsers
244-
never persist changes back to the profile.
250+
never persist changes back to the profile. To clear the profile reference, send
251+
`profile: { "id": "" }`. Clearing the profile also disables
252+
`refresh_on_profile_update`.
245253
246254
Args:
247255
chrome_policy: Custom Chrome enterprise policy overrides applied to all browsers in this pool.
@@ -269,16 +277,19 @@ def update(
269277
270278
name: Optional name for the browser pool. Must be unique within the project.
271279
272-
profile: Profile selection for browsers in a pool. Provide either id or name. The
273-
matching profile is loaded into every browser in the pool. Profiles must be
274-
created beforehand. Unlike single browser sessions, pools load the profile
275-
read-only and never persist changes back to it, so save_changes is omitted here.
276-
Any save_changes value sent on a pool profile is silently ignored rather than
277-
rejected, so callers reusing a single-session profile object will not error.
280+
profile: Profile configuration for browsers in a pool. Provide either id or name.
281+
Profiles must be created beforehand. Unlike single browser sessions, pools load
282+
the profile read-only and never persist changes back to it, so save_changes is
283+
omitted here. Any save_changes value sent on a pool profile is silently ignored
284+
rather than rejected.
278285
279286
proxy_id: Optional proxy to associate to the browser session. Must reference a proxy in
280287
the same project as the browser session.
281288
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.
292+
282293
size: Number of browsers to maintain in the pool. The maximum size is determined by
283294
your organization's pooled sessions limit (the sum of all pool sizes cannot
284295
exceed your limit).
@@ -331,6 +342,7 @@ def update(
331342
"name": name,
332343
"profile": profile,
333344
"proxy_id": proxy_id,
345+
"refresh_on_profile_update": refresh_on_profile_update,
334346
"size": size,
335347
"start_url": start_url,
336348
"stealth": stealth,
@@ -624,6 +636,7 @@ async def create(
624636
name: str | Omit = omit,
625637
profile: browser_pool_create_params.Profile | Omit = omit,
626638
proxy_id: str | Omit = omit,
639+
refresh_on_profile_update: bool | Omit = omit,
627640
start_url: str | Omit = omit,
628641
stealth: bool | Omit = omit,
629642
timeout_seconds: int | Omit = omit,
@@ -665,16 +678,19 @@ async def create(
665678
666679
name: Optional name for the browser pool. Must be unique within the project.
667680
668-
profile: Profile selection for browsers in a pool. Provide either id or name. The
669-
matching profile is loaded into every browser in the pool. Profiles must be
670-
created beforehand. Unlike single browser sessions, pools load the profile
671-
read-only and never persist changes back to it, so save_changes is omitted here.
672-
Any save_changes value sent on a pool profile is silently ignored rather than
673-
rejected, so callers reusing a single-session profile object will not error.
681+
profile: Profile configuration for browsers in a pool. Provide either id or name.
682+
Profiles must be created beforehand. Unlike single browser sessions, pools load
683+
the profile read-only and never persist changes back to it, so save_changes is
684+
omitted here. Any save_changes value sent on a pool profile is silently ignored
685+
rather than rejected.
674686
675687
proxy_id: Optional proxy to associate to the browser session. Must reference a proxy in
676688
the same project as the browser session.
677689
690+
refresh_on_profile_update: When true, flush idle browsers when the profile the pool uses is updated, so
691+
pool browsers pick up the latest profile data. Requires a profile to be set on
692+
the pool.
693+
678694
start_url: Optional URL to navigate to when a new browser is warmed into the pool.
679695
Best-effort: failures to navigate do not fail pool fill. Only applied to
680696
newly-warmed browsers; browsers reused via release/acquire keep whatever URL the
@@ -721,6 +737,7 @@ async def create(
721737
"name": name,
722738
"profile": profile,
723739
"proxy_id": proxy_id,
740+
"refresh_on_profile_update": refresh_on_profile_update,
724741
"start_url": start_url,
725742
"stealth": stealth,
726743
"timeout_seconds": timeout_seconds,
@@ -780,6 +797,7 @@ async def update(
780797
name: str | Omit = omit,
781798
profile: browser_pool_update_params.Profile | Omit = omit,
782799
proxy_id: str | Omit = omit,
800+
refresh_on_profile_update: bool | Omit = omit,
783801
size: int | Omit = omit,
784802
start_url: str | Omit = omit,
785803
stealth: bool | Omit = omit,
@@ -796,7 +814,9 @@ async def update(
796814
797815
As with creation,
798816
save_changes on the pool profile is ignored (not rejected); pooled browsers
799-
never persist changes back to the profile.
817+
never persist changes back to the profile. To clear the profile reference, send
818+
`profile: { "id": "" }`. Clearing the profile also disables
819+
`refresh_on_profile_update`.
800820
801821
Args:
802822
chrome_policy: Custom Chrome enterprise policy overrides applied to all browsers in this pool.
@@ -824,16 +844,19 @@ async def update(
824844
825845
name: Optional name for the browser pool. Must be unique within the project.
826846
827-
profile: Profile selection for browsers in a pool. Provide either id or name. The
828-
matching profile is loaded into every browser in the pool. Profiles must be
829-
created beforehand. Unlike single browser sessions, pools load the profile
830-
read-only and never persist changes back to it, so save_changes is omitted here.
831-
Any save_changes value sent on a pool profile is silently ignored rather than
832-
rejected, so callers reusing a single-session profile object will not error.
847+
profile: Profile configuration for browsers in a pool. Provide either id or name.
848+
Profiles must be created beforehand. Unlike single browser sessions, pools load
849+
the profile read-only and never persist changes back to it, so save_changes is
850+
omitted here. Any save_changes value sent on a pool profile is silently ignored
851+
rather than rejected.
833852
834853
proxy_id: Optional proxy to associate to the browser session. Must reference a proxy in
835854
the same project as the browser session.
836855
856+
refresh_on_profile_update: When true, flush idle browsers when the profile the pool uses is updated, so
857+
pool browsers pick up the latest profile data. Requires a profile to be set on
858+
the pool.
859+
837860
size: Number of browsers to maintain in the pool. The maximum size is determined by
838861
your organization's pooled sessions limit (the sum of all pool sizes cannot
839862
exceed your limit).
@@ -886,6 +909,7 @@ async def update(
886909
"name": name,
887910
"profile": profile,
888911
"proxy_id": proxy_id,
912+
"refresh_on_profile_update": refresh_on_profile_update,
889913
"size": size,
890914
"start_url": start_url,
891915
"stealth": stealth,

src/kernel/types/browser_pool.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,12 @@
1111

1212

1313
class BrowserPoolConfigProfile(BaseModel):
14-
"""Profile selection for browsers in a pool.
14+
"""Profile configuration for browsers in a pool.
1515
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.
16+
Provide either id or name. Profiles must
17+
be created beforehand. Unlike single browser sessions, pools load the profile read-only
18+
and never persist changes back to it, so save_changes is omitted here. Any save_changes
19+
value sent on a pool profile is silently ignored rather than rejected.
2120
"""
2221

2322
id: Optional[str] = None
@@ -74,14 +73,12 @@ class BrowserPoolConfig(BaseModel):
7473
"""Optional name for the browser pool. Must be unique within the project."""
7574

7675
profile: Optional[BrowserPoolConfigProfile] = None
77-
"""Profile selection for browsers in a pool.
76+
"""Profile configuration for browsers in a pool.
7877
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.
78+
Provide either id or name. Profiles must be created beforehand. Unlike single
79+
browser sessions, pools load the profile read-only and never persist changes
80+
back to it, so save_changes is omitted here. Any save_changes value sent on a
81+
pool profile is silently ignored rather than rejected.
8582
"""
8683

8784
proxy_id: Optional[str] = None
@@ -90,6 +87,13 @@ class BrowserPoolConfig(BaseModel):
9087
Must reference a proxy in the same project as the browser session.
9188
"""
9289

90+
refresh_on_profile_update: Optional[bool] = None
91+
"""
92+
When true, flush idle browsers when the profile the pool uses is updated, so
93+
pool browsers pick up the latest profile data. Requires a profile to be set on
94+
the pool.
95+
"""
96+
9397
start_url: Optional[str] = None
9498
"""Optional URL to navigate to when a new browser is warmed into the pool.
9599

src/kernel/types/browser_pool_create_params.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,12 @@ class BrowserPoolCreateParams(TypedDict, total=False):
5353
"""Optional name for the browser pool. Must be unique within the project."""
5454

5555
profile: Profile
56-
"""Profile selection for browsers in a pool.
56+
"""Profile configuration for browsers in a pool.
5757
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.
58+
Provide either id or name. Profiles must be created beforehand. Unlike single
59+
browser sessions, pools load the profile read-only and never persist changes
60+
back to it, so save_changes is omitted here. Any save_changes value sent on a
61+
pool profile is silently ignored rather than rejected.
6462
"""
6563

6664
proxy_id: str
@@ -69,6 +67,13 @@ class BrowserPoolCreateParams(TypedDict, total=False):
6967
Must reference a proxy in the same project as the browser session.
7068
"""
7169

70+
refresh_on_profile_update: bool
71+
"""
72+
When true, flush idle browsers when the profile the pool uses is updated, so
73+
pool browsers pick up the latest profile data. Requires a profile to be set on
74+
the pool.
75+
"""
76+
7277
start_url: str
7378
"""Optional URL to navigate to when a new browser is warmed into the pool.
7479
@@ -108,13 +113,12 @@ class BrowserPoolCreateParams(TypedDict, total=False):
108113

109114

110115
class Profile(TypedDict, total=False):
111-
"""Profile selection for browsers in a pool.
116+
"""Profile configuration for browsers in a pool.
112117
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+
Provide either id or name. Profiles must
119+
be created beforehand. Unlike single browser sessions, pools load the profile read-only
120+
and never persist changes back to it, so save_changes is omitted here. Any save_changes
121+
value sent on a pool profile is silently ignored rather than rejected.
118122
"""
119123

120124
id: str

src/kernel/types/browser_pool_update_params.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,12 @@ class BrowserPoolUpdateParams(TypedDict, total=False):
5656
"""Optional name for the browser pool. Must be unique within the project."""
5757

5858
profile: Profile
59-
"""Profile selection for browsers in a pool.
59+
"""Profile configuration for browsers in a pool.
6060
61-
Provide either id or name. The matching profile is loaded into every browser in
62-
the pool. Profiles must be created beforehand. Unlike single browser sessions,
63-
pools load the profile read-only and never persist changes back to it, so
64-
save_changes is omitted here. Any save_changes value sent on a pool profile is
65-
silently ignored rather than rejected, so callers reusing a single-session
66-
profile object will not error.
61+
Provide either id or name. Profiles must be created beforehand. Unlike single
62+
browser sessions, pools load the profile read-only and never persist changes
63+
back to it, so save_changes is omitted here. Any save_changes value sent on a
64+
pool profile is silently ignored rather than rejected.
6765
"""
6866

6967
proxy_id: str
@@ -72,6 +70,13 @@ class BrowserPoolUpdateParams(TypedDict, total=False):
7270
Must reference a proxy in the same project as the browser session.
7371
"""
7472

73+
refresh_on_profile_update: bool
74+
"""
75+
When true, flush idle browsers when the profile the pool uses is updated, so
76+
pool browsers pick up the latest profile data. Requires a profile to be set on
77+
the pool.
78+
"""
79+
7580
size: int
7681
"""Number of browsers to maintain in the pool.
7782
@@ -118,13 +123,12 @@ class BrowserPoolUpdateParams(TypedDict, total=False):
118123

119124

120125
class Profile(TypedDict, total=False):
121-
"""Profile selection for browsers in a pool.
126+
"""Profile configuration for browsers in a pool.
122127
123-
Provide either id or name. The matching profile is
124-
loaded into every browser in the pool. Profiles must be created beforehand. Unlike single
125-
browser sessions, pools load the profile read-only and never persist changes back to it, so
126-
save_changes is omitted here. Any save_changes value sent on a pool profile is silently
127-
ignored rather than rejected, so callers reusing a single-session profile object will not error.
128+
Provide either id or name. Profiles must
129+
be created beforehand. Unlike single browser sessions, pools load the profile read-only
130+
and never persist changes back to it, so save_changes is omitted here. Any save_changes
131+
value sent on a pool profile is silently ignored rather than rejected.
128132
"""
129133

130134
id: str

tests/api_resources/test_browser_pools.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def test_method_create_with_all_params(self, client: Kernel) -> None:
5050
"name": "name",
5151
},
5252
proxy_id="proxy_id",
53+
refresh_on_profile_update=True,
5354
start_url="https://example.com",
5455
stealth=True,
5556
timeout_seconds=10,
@@ -159,6 +160,7 @@ def test_method_update_with_all_params(self, client: Kernel) -> None:
159160
"name": "name",
160161
},
161162
proxy_id="proxy_id",
163+
refresh_on_profile_update=True,
162164
size=10,
163165
start_url="https://example.com",
164166
stealth=True,
@@ -484,6 +486,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncKernel) ->
484486
"name": "name",
485487
},
486488
proxy_id="proxy_id",
489+
refresh_on_profile_update=True,
487490
start_url="https://example.com",
488491
stealth=True,
489492
timeout_seconds=10,
@@ -593,6 +596,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncKernel) ->
593596
"name": "name",
594597
},
595598
proxy_id="proxy_id",
599+
refresh_on_profile_update=True,
596600
size=10,
597601
start_url="https://example.com",
598602
stealth=True,

0 commit comments

Comments
 (0)