Skip to content

Commit 79f62ba

Browse files
Add proxy update (#61)
1 parent c17451a commit 79f62ba

File tree

5 files changed

+66
-3
lines changed

5 files changed

+66
-3
lines changed

hyperbrowser/client/managers/async_manager/session.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
SessionEventLogListResponse,
1616
SessionEventLog,
1717
UpdateSessionProfileParams,
18+
UpdateSessionProxyParams,
1819
SessionGetParams,
1920
)
2021

@@ -183,6 +184,20 @@ async def update_profile_params(
183184
)
184185
return BasicResponse(**response.data)
185186

187+
async def update_proxy_params(
188+
self,
189+
id: str,
190+
params: UpdateSessionProxyParams,
191+
) -> BasicResponse:
192+
response = await self._client.transport.put(
193+
self._client._build_url(f"/session/{id}/update"),
194+
data={
195+
"type": "proxy",
196+
"params": params.model_dump(exclude_none=True, by_alias=True),
197+
},
198+
)
199+
return BasicResponse(**response.data)
200+
186201
def _warn_update_profile_params_boolean_deprecated(self) -> None:
187202
if SessionManager._has_warned_update_profile_params_boolean_deprecated:
188203
return

hyperbrowser/client/managers/sync_manager/session.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
UploadFileResponse,
1414
SessionEventLogListParams,
1515
SessionEventLogListResponse,
16-
SessionEventLog,
1716
UpdateSessionProfileParams,
17+
UpdateSessionProxyParams,
1818
SessionGetParams,
1919
)
2020

@@ -179,6 +179,20 @@ def update_profile_params(
179179
)
180180
return BasicResponse(**response.data)
181181

182+
def update_proxy_params(
183+
self,
184+
id: str,
185+
params: UpdateSessionProxyParams,
186+
) -> BasicResponse:
187+
response = self._client.transport.put(
188+
self._client._build_url(f"/session/{id}/update"),
189+
data={
190+
"type": "proxy",
191+
"params": params.model_dump(exclude_none=True, by_alias=True),
192+
},
193+
)
194+
return BasicResponse(**response.data)
195+
182196
def _warn_update_profile_params_boolean_deprecated(self) -> None:
183197
if SessionManager._has_warned_update_profile_params_boolean_deprecated:
184198
return

hyperbrowser/models/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@
234234
UploadFileResponse,
235235
ImageCaptchaParam,
236236
UpdateSessionProfileParams,
237+
UpdateSessionProxyLocationParams,
238+
UpdateSessionProxyParams,
237239
)
238240
from .sandbox import (
239241
SandboxStatus,
@@ -485,6 +487,8 @@
485487
"UploadFileResponse",
486488
"ImageCaptchaParam",
487489
"UpdateSessionProfileParams",
490+
"UpdateSessionProxyLocationParams",
491+
"UpdateSessionProxyParams",
488492
# sandbox
489493
"SandboxStatus",
490494
"SandboxRegion",

hyperbrowser/models/session.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from datetime import datetime
22
from typing import Any, List, Literal, Optional, Union, Dict
3-
from .computer_action import ComputerActionParams, ComputerActionResponse
43

54
from pydantic import BaseModel, ConfigDict, Field, field_validator
65

@@ -70,6 +69,37 @@ class UpdateSessionProfileParams(BaseModel):
7069
)
7170

7271

72+
class UpdateSessionProxyLocationParams(BaseModel):
73+
"""
74+
Managed proxy geolocation overrides for a running session.
75+
"""
76+
77+
model_config = ConfigDict(
78+
populate_by_alias=True,
79+
)
80+
81+
country: Optional[Country] = Field(default=None, serialization_alias="country")
82+
state: Optional[State] = Field(default=None, serialization_alias="state")
83+
city: Optional[str] = Field(default=None, serialization_alias="city")
84+
85+
86+
class UpdateSessionProxyParams(BaseModel):
87+
"""
88+
Parameters for enabling, disabling, or reconfiguring a session proxy.
89+
"""
90+
91+
model_config = ConfigDict(
92+
populate_by_alias=True,
93+
)
94+
95+
enabled: bool = Field(serialization_alias="enabled")
96+
static_ip_id: Optional[str] = Field(default=None, serialization_alias="staticIpId")
97+
location: Optional[UpdateSessionProxyLocationParams] = Field(
98+
default=None,
99+
serialization_alias="location",
100+
)
101+
102+
73103
class SessionLaunchState(BaseModel):
74104
model_config = ConfigDict(
75105
populate_by_alias=True,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "hyperbrowser"
3-
version = "0.87.0"
3+
version = "0.88.0"
44
description = "Python SDK for hyperbrowser"
55
authors = ["Nikhil Shahi <nshahi1998@gmail.com>"]
66
license = "MIT"

0 commit comments

Comments
 (0)