Skip to content

Commit 3495cfe

Browse files
committed
SDK regeneration
1 parent afccc22 commit 3495cfe

File tree

7 files changed

+216
-2
lines changed

7 files changed

+216
-2
lines changed

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "scrapybara"
33

44
[tool.poetry]
55
name = "scrapybara"
6-
version = "2.3.5"
6+
version = "2.3.6"
77
description = ""
88
readme = "README.md"
99
authors = []

reference.md

+64
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ client.start()
4949
<dl>
5050
<dd>
5151

52+
**blocked_domains:** `typing.Optional[typing.Sequence[str]]`
53+
54+
</dd>
55+
</dl>
56+
57+
<dl>
58+
<dd>
59+
5260
**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
5361

5462
</dd>
@@ -861,6 +869,62 @@ client.browser.get_cdp_url(
861869
</dl>
862870

863871

872+
</dd>
873+
</dl>
874+
</details>
875+
876+
<details><summary><code>client.browser.<a href="src/scrapybara/browser/client.py">get_current_url</a>(...)</code></summary>
877+
<dl>
878+
<dd>
879+
880+
#### 🔌 Usage
881+
882+
<dl>
883+
<dd>
884+
885+
<dl>
886+
<dd>
887+
888+
```python
889+
from scrapybara import Scrapybara
890+
891+
client = Scrapybara(
892+
api_key="YOUR_API_KEY",
893+
)
894+
client.browser.get_current_url(
895+
instance_id="instance_id",
896+
)
897+
898+
```
899+
</dd>
900+
</dl>
901+
</dd>
902+
</dl>
903+
904+
#### ⚙️ Parameters
905+
906+
<dl>
907+
<dd>
908+
909+
<dl>
910+
<dd>
911+
912+
**instance_id:** `str`
913+
914+
</dd>
915+
</dl>
916+
917+
<dl>
918+
<dd>
919+
920+
**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
921+
922+
</dd>
923+
</dl>
924+
</dd>
925+
</dl>
926+
927+
864928
</dd>
865929
</dl>
866930
</details>

src/scrapybara/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
BashResponse,
66
BrowserAuthenticateResponse,
77
BrowserGetCdpUrlResponse,
8+
BrowserGetCurrentUrlResponse,
89
Button,
910
CellType,
1011
ClickMouseAction,
@@ -67,6 +68,7 @@
6768
"BashResponse",
6869
"BrowserAuthenticateResponse",
6970
"BrowserGetCdpUrlResponse",
71+
"BrowserGetCurrentUrlResponse",
7072
"Button",
7173
"CellType",
7274
"ClickMouseAction",

src/scrapybara/base_client.py

+8
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def start(
107107
*,
108108
instance_type: typing.Optional[DeploymentConfigInstanceType] = OMIT,
109109
timeout_hours: typing.Optional[float] = OMIT,
110+
blocked_domains: typing.Optional[typing.Sequence[str]] = OMIT,
110111
request_options: typing.Optional[RequestOptions] = None,
111112
) -> GetInstanceResponse:
112113
"""
@@ -116,6 +117,8 @@ def start(
116117
117118
timeout_hours : typing.Optional[float]
118119
120+
blocked_domains : typing.Optional[typing.Sequence[str]]
121+
119122
request_options : typing.Optional[RequestOptions]
120123
Request-specific configuration.
121124
@@ -139,6 +142,7 @@ def start(
139142
json={
140143
"instance_type": instance_type,
141144
"timeout_hours": timeout_hours,
145+
"blocked_domains": blocked_domains,
142146
},
143147
headers={
144148
"content-type": "application/json",
@@ -383,6 +387,7 @@ async def start(
383387
*,
384388
instance_type: typing.Optional[DeploymentConfigInstanceType] = OMIT,
385389
timeout_hours: typing.Optional[float] = OMIT,
390+
blocked_domains: typing.Optional[typing.Sequence[str]] = OMIT,
386391
request_options: typing.Optional[RequestOptions] = None,
387392
) -> GetInstanceResponse:
388393
"""
@@ -392,6 +397,8 @@ async def start(
392397
393398
timeout_hours : typing.Optional[float]
394399
400+
blocked_domains : typing.Optional[typing.Sequence[str]]
401+
395402
request_options : typing.Optional[RequestOptions]
396403
Request-specific configuration.
397404
@@ -423,6 +430,7 @@ async def main() -> None:
423430
json={
424431
"instance_type": instance_type,
425432
"timeout_hours": timeout_hours,
433+
"blocked_domains": blocked_domains,
426434
},
427435
headers={
428436
"content-type": "application/json",

src/scrapybara/browser/client.py

+121
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from json.decoder import JSONDecodeError
1212
from ..core.api_error import ApiError
1313
from ..types.browser_get_cdp_url_response import BrowserGetCdpUrlResponse
14+
from ..types.browser_get_current_url_response import BrowserGetCurrentUrlResponse
1415
from ..types.save_browser_auth_response import SaveBrowserAuthResponse
1516
from ..types.modify_browser_auth_response import ModifyBrowserAuthResponse
1617
from ..types.browser_authenticate_response import BrowserAuthenticateResponse
@@ -134,6 +135,62 @@ def get_cdp_url(
134135
raise ApiError(status_code=_response.status_code, body=_response.text)
135136
raise ApiError(status_code=_response.status_code, body=_response_json)
136137

138+
def get_current_url(
139+
self, instance_id: str, *, request_options: typing.Optional[RequestOptions] = None
140+
) -> BrowserGetCurrentUrlResponse:
141+
"""
142+
Parameters
143+
----------
144+
instance_id : str
145+
146+
request_options : typing.Optional[RequestOptions]
147+
Request-specific configuration.
148+
149+
Returns
150+
-------
151+
BrowserGetCurrentUrlResponse
152+
Successful Response
153+
154+
Examples
155+
--------
156+
from scrapybara import Scrapybara
157+
158+
client = Scrapybara(
159+
api_key="YOUR_API_KEY",
160+
)
161+
client.browser.get_current_url(
162+
instance_id="instance_id",
163+
)
164+
"""
165+
_response = self._client_wrapper.httpx_client.request(
166+
f"v1/instance/{jsonable_encoder(instance_id)}/browser/current_url",
167+
method="GET",
168+
request_options=request_options,
169+
)
170+
try:
171+
if 200 <= _response.status_code < 300:
172+
return typing.cast(
173+
BrowserGetCurrentUrlResponse,
174+
parse_obj_as(
175+
type_=BrowserGetCurrentUrlResponse, # type: ignore
176+
object_=_response.json(),
177+
),
178+
)
179+
if _response.status_code == 422:
180+
raise UnprocessableEntityError(
181+
typing.cast(
182+
HttpValidationError,
183+
parse_obj_as(
184+
type_=HttpValidationError, # type: ignore
185+
object_=_response.json(),
186+
),
187+
)
188+
)
189+
_response_json = _response.json()
190+
except JSONDecodeError:
191+
raise ApiError(status_code=_response.status_code, body=_response.text)
192+
raise ApiError(status_code=_response.status_code, body=_response_json)
193+
137194
def save_auth(
138195
self,
139196
instance_id: str,
@@ -518,6 +575,70 @@ async def main() -> None:
518575
raise ApiError(status_code=_response.status_code, body=_response.text)
519576
raise ApiError(status_code=_response.status_code, body=_response_json)
520577

578+
async def get_current_url(
579+
self, instance_id: str, *, request_options: typing.Optional[RequestOptions] = None
580+
) -> BrowserGetCurrentUrlResponse:
581+
"""
582+
Parameters
583+
----------
584+
instance_id : str
585+
586+
request_options : typing.Optional[RequestOptions]
587+
Request-specific configuration.
588+
589+
Returns
590+
-------
591+
BrowserGetCurrentUrlResponse
592+
Successful Response
593+
594+
Examples
595+
--------
596+
import asyncio
597+
598+
from scrapybara import AsyncScrapybara
599+
600+
client = AsyncScrapybara(
601+
api_key="YOUR_API_KEY",
602+
)
603+
604+
605+
async def main() -> None:
606+
await client.browser.get_current_url(
607+
instance_id="instance_id",
608+
)
609+
610+
611+
asyncio.run(main())
612+
"""
613+
_response = await self._client_wrapper.httpx_client.request(
614+
f"v1/instance/{jsonable_encoder(instance_id)}/browser/current_url",
615+
method="GET",
616+
request_options=request_options,
617+
)
618+
try:
619+
if 200 <= _response.status_code < 300:
620+
return typing.cast(
621+
BrowserGetCurrentUrlResponse,
622+
parse_obj_as(
623+
type_=BrowserGetCurrentUrlResponse, # type: ignore
624+
object_=_response.json(),
625+
),
626+
)
627+
if _response.status_code == 422:
628+
raise UnprocessableEntityError(
629+
typing.cast(
630+
HttpValidationError,
631+
parse_obj_as(
632+
type_=HttpValidationError, # type: ignore
633+
object_=_response.json(),
634+
),
635+
)
636+
)
637+
_response_json = _response.json()
638+
except JSONDecodeError:
639+
raise ApiError(status_code=_response.status_code, body=_response.text)
640+
raise ApiError(status_code=_response.status_code, body=_response_json)
641+
521642
async def save_auth(
522643
self,
523644
instance_id: str,

src/scrapybara/core/client_wrapper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def get_headers(self) -> typing.Dict[str, str]:
1616
headers: typing.Dict[str, str] = {
1717
"X-Fern-Language": "Python",
1818
"X-Fern-SDK-Name": "scrapybara",
19-
"X-Fern-SDK-Version": "2.3.5",
19+
"X-Fern-SDK-Version": "2.3.6",
2020
}
2121
headers["x-api-key"] = self.api_key
2222
return headers
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# This file was auto-generated by Fern from our API Definition.
2+
3+
from ..core.pydantic_utilities import UniversalBaseModel
4+
from ..core.pydantic_utilities import IS_PYDANTIC_V2
5+
import typing
6+
import pydantic
7+
8+
9+
class BrowserGetCurrentUrlResponse(UniversalBaseModel):
10+
current_url: str
11+
12+
if IS_PYDANTIC_V2:
13+
model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True) # type: ignore # Pydantic v2
14+
else:
15+
16+
class Config:
17+
frozen = True
18+
smart_union = True
19+
extra = pydantic.Extra.allow

0 commit comments

Comments
 (0)