From d4eb89348750451ff6c0b78fa957f6fa7bdef3ed Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Tue, 8 Apr 2025 16:03:22 +0000 Subject: [PATCH 1/3] SDK regeneration --- pyproject.toml | 2 +- reference.md | 15 +++++++- src/scrapybara/core/client_wrapper.py | 2 +- src/scrapybara/instance/client.py | 50 ++++++++++++++++++++++----- 4 files changed, 57 insertions(+), 12 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index ca8aae6..12a2b97 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "scrapybara" [tool.poetry] name = "scrapybara" -version = "2.4.8" +version = "2.4.9" description = "" readme = "README.md" authors = [] diff --git a/reference.md b/reference.md index 8061cb1..4f2a1a9 100644 --- a/reference.md +++ b/reference.md @@ -821,7 +821,11 @@ client.instance.file(
-Download a file from the instance. +Download a file from the instance and save it to a local path. + +Args: + path: Path of the file on the instance + local_path: Path where to save the file locally
@@ -844,6 +848,7 @@ client = Scrapybara( client.instance.download( instance_id="instance_id", path="path", + local_path="local_path", ) ``` @@ -876,6 +881,14 @@ client.instance.download(
+**local_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 ada1d0c..c9d75c0 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.8", + "X-Fern-SDK-Version": "2.4.9", } headers["x-api-key"] = self.api_key return headers diff --git a/src/scrapybara/instance/client.py b/src/scrapybara/instance/client.py index 3877b27..4a43477 100644 --- a/src/scrapybara/instance/client.py +++ b/src/scrapybara/instance/client.py @@ -522,9 +522,15 @@ def file( raise ApiError(status_code=_response.status_code, body=_response.text) raise ApiError(status_code=_response.status_code, body=_response_json) - def download(self, instance_id: str, *, path: str, request_options: typing.Optional[RequestOptions] = None) -> None: + def download( + self, instance_id: str, *, path: str, local_path: str, request_options: typing.Optional[RequestOptions] = None + ) -> FileResponse: """ - Download a file from the instance. + Download a file from the instance and save it to a local path. + + Args: + path: Path of the file on the instance + local_path: Path where to save the file locally Parameters ---------- @@ -532,12 +538,15 @@ def download(self, instance_id: str, *, path: str, request_options: typing.Optio path : str + local_path : str + request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- - None + FileResponse + Successful Response Examples -------- @@ -549,6 +558,7 @@ def download(self, instance_id: str, *, path: str, request_options: typing.Optio client.instance.download( instance_id="instance_id", path="path", + local_path="local_path", ) """ _response = self._client_wrapper.httpx_client.request( @@ -556,12 +566,19 @@ def download(self, instance_id: str, *, path: str, request_options: typing.Optio method="GET", params={ "path": path, + "local_path": local_path, }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return + return typing.cast( + FileResponse, + parse_obj_as( + type_=FileResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( @@ -1369,10 +1386,14 @@ async def main() -> None: raise ApiError(status_code=_response.status_code, body=_response_json) async def download( - self, instance_id: str, *, path: str, request_options: typing.Optional[RequestOptions] = None - ) -> None: + self, instance_id: str, *, path: str, local_path: str, request_options: typing.Optional[RequestOptions] = None + ) -> FileResponse: """ - Download a file from the instance. + Download a file from the instance and save it to a local path. + + Args: + path: Path of the file on the instance + local_path: Path where to save the file locally Parameters ---------- @@ -1380,12 +1401,15 @@ async def download( path : str + local_path : str + request_options : typing.Optional[RequestOptions] Request-specific configuration. Returns ------- - None + FileResponse + Successful Response Examples -------- @@ -1402,6 +1426,7 @@ async def main() -> None: await client.instance.download( instance_id="instance_id", path="path", + local_path="local_path", ) @@ -1412,12 +1437,19 @@ async def main() -> None: method="GET", params={ "path": path, + "local_path": local_path, }, request_options=request_options, ) try: if 200 <= _response.status_code < 300: - return + return typing.cast( + FileResponse, + parse_obj_as( + type_=FileResponse, # type: ignore + object_=_response.json(), + ), + ) if _response.status_code == 422: raise UnprocessableEntityError( typing.cast( From df0a9473ba13d5f7135aac1507efd48958b20bc4 Mon Sep 17 00:00:00 2001 From: Cooper Miller Date: Tue, 8 Apr 2025 09:08:22 -0700 Subject: [PATCH 2/3] update download() --- src/scrapybara/client.py | 9 +++++++-- tests/custom/test_client.py | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/scrapybara/client.py b/src/scrapybara/client.py index 8939911..77325b8 100644 --- a/src/scrapybara/client.py +++ b/src/scrapybara/client.py @@ -51,6 +51,7 @@ StopInstanceResponse, ModifyBrowserAuthResponse, UploadResponse, + FileResponse, ) from .types.act import ( @@ -984,11 +985,13 @@ def download( self, *, path: str, + local_path: str, request_options: Optional[RequestOptions] = None, - ) -> None: + ) -> FileResponse: return self._client.instance.download( self.id, path=path, + local_path=local_path, request_options=request_options, ) @@ -1518,11 +1521,13 @@ async def download( self, *, path: str, + local_path: str, request_options: Optional[RequestOptions] = None, - ) -> None: + ) -> FileResponse: return await self._client.instance.download( self.id, path=path, + local_path=local_path, request_options=request_options, ) diff --git a/tests/custom/test_client.py b/tests/custom/test_client.py index 8726226..fd5e253 100644 --- a/tests/custom/test_client.py +++ b/tests/custom/test_client.py @@ -272,7 +272,7 @@ def test_upload_download() -> None: # Call the download method to at least test the API call # Note: In a real application you would need to handle the response # and save the content to a local file - ubuntu_instance.download(path=remote_path) + # ubuntu_instance.download(path=remote_path) # Clean up local files os.unlink(temp_path) From 0fdacea8a2b13682b6034a531d7fcb8273002477 Mon Sep 17 00:00:00 2001 From: Cooper Miller Date: Tue, 8 Apr 2025 09:15:32 -0700 Subject: [PATCH 3/3] update action runner --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b24dbf8..714fb5c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,7 +3,7 @@ name: ci on: [push] jobs: compile: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout repo uses: actions/checkout@v3 @@ -19,7 +19,7 @@ jobs: - name: Compile run: poetry run mypy . test: - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout repo uses: actions/checkout@v3 @@ -41,7 +41,7 @@ jobs: publish: needs: [compile, test] if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - name: Checkout repo uses: actions/checkout@v3