-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbrowser_pool.py
More file actions
189 lines (141 loc) · 6.87 KB
/
Copy pathbrowser_pool.py
File metadata and controls
189 lines (141 loc) · 6.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from typing import Dict, List, Optional
from datetime import datetime
from typing_extensions import Literal
from .._models import BaseModel
from .browser_network_config import BrowserNetworkConfig
from .shared.browser_viewport import BrowserViewport
from .shared.browser_extension import BrowserExtension
from .browsers.browser_telemetry_config import BrowserTelemetryConfig
__all__ = ["BrowserPool", "BrowserPoolConfig", "BrowserPoolConfigProfile"]
class BrowserPoolConfigProfile(BaseModel):
"""Profile configuration for browsers in a pool.
Provide either id or name. Profiles must
be created beforehand. Unlike single browser sessions, pools load the profile read-only
and never persist changes back to it, so save_changes is omitted here. Any save_changes
value sent on a pool profile is silently ignored rather than rejected.
"""
id: Optional[str] = None
"""Profile ID to load for browsers in this pool"""
name: Optional[str] = None
"""Profile name to load for browsers in this pool (instead of id).
Must be 1-255 characters, using letters, numbers, dots, underscores, or hyphens.
"""
class BrowserPoolConfig(BaseModel):
"""Configuration used to create all browsers in this pool"""
size: int
"""Number of browsers maintained in the pool.
The maximum size is determined by your organization's pooled sessions limit (the
sum of all pool sizes cannot exceed your limit).
"""
chrome_policy: Optional[Dict[str, object]] = None
"""Custom Chrome enterprise policy overrides applied to all browsers in this pool.
Keys are Chrome enterprise policy names; values must match their expected types.
Blocked: kernel-managed policies (extensions, proxy, CDP/automation). See
https://chromeenterprise.google/policies/ The serialized JSON payload is capped
at 5 MiB.
"""
extensions: Optional[List[BrowserExtension]] = None
"""List of browser extensions to load into the session.
Provide each by id or name.
"""
fill_rate_per_minute: Optional[int] = None
"""Percentage of the pool to fill per minute.
The cap is 25 for most organizations but can be raised per-organization, so only
the lower bound is enforced here.
"""
headless: Optional[bool] = None
"""If true, launches the browser using a headless image."""
kiosk_mode: Optional[bool] = None
"""
If true, launches the browser in kiosk mode to hide address bar and tabs in live
view.
"""
name: Optional[str] = None
"""Optional name for the browser pool. Must be unique within the project."""
network: Optional[BrowserNetworkConfig] = None
"""Network configuration applied to browsers in this pool, if any.
Omitted when the pool has no network configuration.
"""
profile: Optional[BrowserPoolConfigProfile] = None
"""Profile configuration for browsers in a pool.
Provide either id or name. Profiles must be created beforehand. Unlike single
browser sessions, pools load the profile read-only and never persist changes
back to it, so save_changes is omitted here. Any save_changes value sent on a
pool profile is silently ignored rather than rejected.
"""
proxy_id: Optional[str] = None
"""Optional proxy associated to the browser session.
References a proxy in the same project as the browser session.
"""
refresh_on_profile_update: Optional[bool] = None
"""
When true, flush idle browsers when the profile the pool uses is updated, so
pool browsers pick up the latest profile data. When a profile is provided during
creation, this defaults to true. Requires a profile to be set on the pool.
"""
start_url: Optional[str] = None
"""Optional URL to navigate to when a new browser is warmed into the pool.
Best-effort: failures to navigate do not fail pool fill. Only applied to
newly-warmed browsers; browsers reused via release/acquire keep whatever URL the
previous lease left them on. Accepts any URL Chromium can resolve, including
chrome:// pages.
"""
stealth: Optional[bool] = None
"""
If true, launches the browser in stealth mode to reduce detection by anti-bot
mechanisms.
"""
telemetry: Optional[BrowserTelemetryConfig] = None
"""
Active telemetry configuration applied to browsers warmed into this pool, if
any.
"""
timeout_seconds: Optional[int] = None
"""
Default idle timeout in seconds for browsers acquired from this pool before they
are destroyed. Minimum 10, maximum 259200 (72 hours).
"""
viewport: Optional[BrowserViewport] = None
"""
Initial browser window size in pixels with optional refresh rate. If omitted,
image defaults apply (1920x1080@25). For GPU images, the default is
1920x1080@60. Arbitrary viewport dimensions and refresh rates are accepted.
Known-good presets include: 2560x1440@10, 1920x1080@25, 1920x1200@25,
1440x900@25, 1280x800@60, 1024x768@60, 1200x800@60, 768x1024@60, 390x844@60. For
GPU images, recommended presets use one of these resolutions with refresh rates
60, 30, 25, or 10: 800x600, 960x720, 1024x576, 1024x768, 1152x648, 1200x800,
1280x720, 1368x768, 1440x900, 1600x900, 1920x1080, 1920x1200, 390x844, 360x250,
768x1024, 800x1600. Viewports outside this list may exhibit unstable live view
or recording behavior. If refresh_rate is not provided, it will be automatically
determined based on the resolution (higher resolutions use lower refresh rates
to keep bandwidth reasonable).
"""
class BrowserPool(BaseModel):
"""A browser pool containing multiple identically configured browsers."""
id: str
"""Unique identifier for the browser pool"""
acquired_count: int
"""Number of browsers currently acquired from the pool"""
available_count: int
"""Number of browsers currently available in the pool"""
browser_pool_config: BrowserPoolConfig
"""Configuration used to create all browsers in this pool"""
created_at: datetime
"""Timestamp when the browser pool was created"""
extension_ids: List[str]
"""Resolved extension IDs attached to the pool, in configured load order.
Empty when no extensions are attached. Authoritative for programmatic consumers;
the extensions inside `browser_pool_config` reflect the configured selector
(echoed as sent on create).
"""
region: Literal["us-east", "eu-west"]
"""Geographic region of the browser pool. Fixed once the pool is created."""
name: Optional[str] = None
"""Browser pool name, if set"""
profile_id: Optional[str] = None
"""Resolved profile ID the pool is attached to.
Omitted when no profile is attached. Authoritative for programmatic consumers;
the profile inside `browser_pool_config` reflects the configured selector
(echoed as sent on create).
"""