-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsession.py
More file actions
160 lines (103 loc) · 5.32 KB
/
session.py
File metadata and controls
160 lines (103 loc) · 5.32 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
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
from typing import List, Optional
from datetime import datetime
from typing_extensions import Literal
from pydantic import Field as FieldInfo
from .._models import BaseModel
__all__ = ["Session", "Dimensions", "OptimizeBandwidth", "DebugConfig", "DeviceConfig", "StealthConfig"]
class Dimensions(BaseModel):
"""Viewport and browser window dimensions for the session"""
height: int
"""Height of the browser window"""
width: int
"""Width of the browser window"""
class OptimizeBandwidth(BaseModel):
"""Bandwidth optimizations that were applied to the session."""
block_hosts: Optional[List[str]] = FieldInfo(alias="blockHosts", default=None)
block_images: Optional[bool] = FieldInfo(alias="blockImages", default=None)
block_media: Optional[bool] = FieldInfo(alias="blockMedia", default=None)
block_stylesheets: Optional[bool] = FieldInfo(alias="blockStylesheets", default=None)
block_url_patterns: Optional[List[str]] = FieldInfo(alias="blockUrlPatterns", default=None)
class DebugConfig(BaseModel):
"""Configuration for the debug URL and session viewer.
Controls interaction capabilities and cursor visibility.
"""
interactive: Optional[bool] = None
"""Whether interaction is allowed via the debug URL viewer.
When false, the session viewer is view-only.
"""
system_cursor: Optional[bool] = FieldInfo(alias="systemCursor", default=None)
"""
Whether the OS-level mouse cursor is shown in the WebRTC stream (headful mode
only).
"""
class DeviceConfig(BaseModel):
"""Device configuration for the session"""
device: Optional[Literal["desktop", "mobile"]] = None
class StealthConfig(BaseModel):
"""Stealth configuration for the session"""
auto_captcha_solving: Optional[bool] = FieldInfo(alias="autoCaptchaSolving", default=None)
"""When true, captchas will be automatically solved when detected.
When false, use the solve endpoints to manually initiate solving.
"""
humanize_interactions: Optional[bool] = FieldInfo(alias="humanizeInteractions", default=None)
"""
This flag will make the browser act more human-like by moving the mouse in a
more natural way
"""
skip_fingerprint_injection: Optional[bool] = FieldInfo(alias="skipFingerprintInjection", default=None)
"""This flag will skip the fingerprint generation for the session."""
class Session(BaseModel):
"""
Represents the data structure for a browser session, including its configuration and status.
"""
id: str
"""Unique identifier for the session"""
created_at: datetime = FieldInfo(alias="createdAt")
"""Timestamp when the session started"""
credits_used: int = FieldInfo(alias="creditsUsed")
"""Amount of credits consumed by the session"""
debug_url: str = FieldInfo(alias="debugUrl")
"""URL for debugging the session"""
dimensions: Dimensions
"""Viewport and browser window dimensions for the session"""
duration: int
"""Duration of the session in milliseconds"""
event_count: int = FieldInfo(alias="eventCount")
"""Number of events processed in the session"""
optimize_bandwidth: OptimizeBandwidth = FieldInfo(alias="optimizeBandwidth")
"""Bandwidth optimizations that were applied to the session."""
proxy_bytes_used: int = FieldInfo(alias="proxyBytesUsed")
"""Amount of data transmitted through the proxy"""
proxy_source: Optional[Literal["steel", "external"]] = FieldInfo(alias="proxySource", default=None)
"""Source of the proxy used for the session"""
session_viewer_url: str = FieldInfo(alias="sessionViewerUrl")
"""URL to view session details"""
status: Literal["live", "released", "failed"]
"""Status of the session"""
timeout: int
"""Session timeout duration in milliseconds"""
websocket_url: str = FieldInfo(alias="websocketUrl")
"""URL for the session's WebSocket connection"""
debug_config: Optional[DebugConfig] = FieldInfo(alias="debugConfig", default=None)
"""Configuration for the debug URL and session viewer.
Controls interaction capabilities and cursor visibility.
"""
device_config: Optional[DeviceConfig] = FieldInfo(alias="deviceConfig", default=None)
"""Device configuration for the session"""
headless: Optional[bool] = None
"""Indicates if the session is headless or headful"""
is_selenium: Optional[bool] = FieldInfo(alias="isSelenium", default=None)
"""Indicates if Selenium is used in the session"""
persist_profile: Optional[bool] = FieldInfo(alias="persistProfile", default=None)
"""This flag will persist the profile for the session."""
profile_id: Optional[str] = FieldInfo(alias="profileId", default=None)
"""The ID of the profile associated with the session"""
region: Optional[Literal["lax", "ord", "iad", "scl", "fra", "nrt"]] = None
"""The region where the session was created"""
solve_captcha: Optional[bool] = FieldInfo(alias="solveCaptcha", default=None)
"""Indicates if captcha solving is enabled"""
stealth_config: Optional[StealthConfig] = FieldInfo(alias="stealthConfig", default=None)
"""Stealth configuration for the session"""
user_agent: Optional[str] = FieldInfo(alias="userAgent", default=None)
"""User agent string used in the session"""