From 0a75ddb5daec8ba8ad5874720f65fa216b302679 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Sat, 5 Apr 2025 22:56:44 +0000 Subject: [PATCH] SDK regeneration --- poetry.lock | 6 +- pyproject.toml | 2 +- reference.md | 79 +++++++++++++++++ src/scrapybara/core/client_wrapper.py | 2 +- src/scrapybara/instance/client.py | 122 ++++++++++++++++++++++++++ 5 files changed, 206 insertions(+), 5 deletions(-) diff --git a/poetry.lock b/poetry.lock index b603c94..d1637e3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -525,13 +525,13 @@ files = [ [[package]] name = "typing-extensions" -version = "4.13.0" +version = "4.13.1" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" files = [ - {file = "typing_extensions-4.13.0-py3-none-any.whl", hash = "sha256:c8dd92cc0d6425a97c18fbb9d1954e5ff92c1ca881a309c45f06ebc0b79058e5"}, - {file = "typing_extensions-4.13.0.tar.gz", hash = "sha256:0a4ac55a5820789d87e297727d229866c9650f6521b64206413c4fbada24d95b"}, + {file = "typing_extensions-4.13.1-py3-none-any.whl", hash = "sha256:4b6cf02909eb5495cfbc3f6e8fd49217e6cc7944e145cdda8caa3734777f9e69"}, + {file = "typing_extensions-4.13.1.tar.gz", hash = "sha256:98795af00fb9640edec5b8e31fc647597b4691f099ad75f469a2616be1a76dff"}, ] [metadata] diff --git a/pyproject.toml b/pyproject.toml index c9b2011..ca8aae6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "scrapybara" [tool.poetry] name = "scrapybara" -version = "2.4.7" +version = "2.4.8" description = "" readme = "README.md" authors = [] diff --git a/reference.md b/reference.md index 3e91211..f6109ba 100644 --- a/reference.md +++ b/reference.md @@ -805,6 +805,85 @@ client.instance.file( + + + + +
client.instance.download_file(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Download a file from the instance. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from scrapybara import Scrapybara + +client = Scrapybara( + api_key="YOUR_API_KEY", +) +client.instance.download_file( + instance_id="instance_id", + path="path", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**instance_id:** `str` + +
+
+ +
+
+ +**path:** `str` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ +
diff --git a/src/scrapybara/core/client_wrapper.py b/src/scrapybara/core/client_wrapper.py index 0f89336..ada1d0c 100644 --- a/src/scrapybara/core/client_wrapper.py +++ b/src/scrapybara/core/client_wrapper.py @@ -16,7 +16,7 @@ def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { "X-Fern-Language": "Python", "X-Fern-SDK-Name": "scrapybara", - "X-Fern-SDK-Version": "2.4.7", + "X-Fern-SDK-Version": "2.4.8", } headers["x-api-key"] = self.api_key return headers diff --git a/src/scrapybara/instance/client.py b/src/scrapybara/instance/client.py index 2ea47ac..07db9a0 100644 --- a/src/scrapybara/instance/client.py +++ b/src/scrapybara/instance/client.py @@ -520,6 +520,63 @@ def file( raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) + def download_file( + self, instance_id: str, *, path: str, request_options: typing.Optional[RequestOptions] = None + ) -> None: + """ + Download a file from the instance. + + Parameters + ---------- + instance_id : str + + path : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + from scrapybara import Scrapybara + + client = Scrapybara( + api_key="YOUR_API_KEY", + ) + client.instance.download_file( + instance_id="instance_id", + path="path", + ) + """ + _response = self._client_wrapper.httpx_client.request( + f"v1/instance/{jsonable_encoder(instance_id)}/download", + method="GET", + params={ + "path": path, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast( + HttpValidationError, + parse_obj_as( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + def stop( self, instance_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> StopInstanceResponse: @@ -1240,6 +1297,71 @@ async def main() -> None: raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) + async def download_file( + self, instance_id: str, *, path: str, request_options: typing.Optional[RequestOptions] = None + ) -> None: + """ + Download a file from the instance. + + Parameters + ---------- + instance_id : str + + path : str + + request_options : typing.Optional[RequestOptions] + Request-specific configuration. + + Returns + ------- + None + + Examples + -------- + import asyncio + + from scrapybara import AsyncScrapybara + + client = AsyncScrapybara( + api_key="YOUR_API_KEY", + ) + + + async def main() -> None: + await client.instance.download_file( + instance_id="instance_id", + path="path", + ) + + + asyncio.run(main()) + """ + _response = await self._client_wrapper.httpx_client.request( + f"v1/instance/{jsonable_encoder(instance_id)}/download", + method="GET", + params={ + "path": path, + }, + request_options=request_options, + ) + try: + if 200 <= _response.status_code < 300: + return + if _response.status_code == 422: + raise UnprocessableEntityError( + typing.cast( + HttpValidationError, + parse_obj_as( + type_=HttpValidationError, # type: ignore + object_=_response.json(), + ), + ) + ) + _response_json = _response.json() + except JSONDecodeError: + raise ApiError(status_code=_response.status_code, body=_response.text) + raise ApiError(status_code=_response.status_code, body=_response_json) + async def stop( self, instance_id: str, *, request_options: typing.Optional[RequestOptions] = None ) -> StopInstanceResponse: