diff --git a/pyproject.toml b/pyproject.toml index 12a2b97..da689cf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,7 +3,7 @@ name = "scrapybara" [tool.poetry] name = "scrapybara" -version = "2.4.9" +version = "2.5.0" description = "" readme = "README.md" authors = [] diff --git a/reference.md b/reference.md index 4f2a1a9..ffb2ff0 100644 --- a/reference.md +++ b/reference.md @@ -805,98 +805,6 @@ client.instance.file( - - - - -
client.instance.download(...) -
-
- -#### 📝 Description - -
-
- -
-
- -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 -
-
-
-
- -#### 🔌 Usage - -
-
- -
-
- -```python -from scrapybara import Scrapybara - -client = Scrapybara( - api_key="YOUR_API_KEY", -) -client.instance.download( - instance_id="instance_id", - path="path", - local_path="local_path", -) - -``` -
-
-
-
- -#### ⚙️ Parameters - -
-
- -
-
- -**instance_id:** `str` - -
-
- -
-
- -**path:** `str` - -
-
- -
-
- -**local_path:** `str` - -
-
- -
-
- -**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. - -
-
-
-
- -
diff --git a/src/scrapybara/client.py b/src/scrapybara/client.py index 77325b8..604f88e 100644 --- a/src/scrapybara/client.py +++ b/src/scrapybara/client.py @@ -981,20 +981,6 @@ def upload( request_options=request_options, ) - def download( - self, - *, - path: str, - local_path: str, - request_options: Optional[RequestOptions] = None, - ) -> FileResponse: - return self._client.instance.download( - self.id, - path=path, - local_path=local_path, - request_options=request_options, - ) - class BrowserInstance(BaseInstance): def __init__( self, @@ -1517,20 +1503,6 @@ async def upload( request_options=request_options, ) - async def download( - self, - *, - path: str, - local_path: str, - request_options: Optional[RequestOptions] = None, - ) -> FileResponse: - return await self._client.instance.download( - self.id, - path=path, - local_path=local_path, - request_options=request_options, - ) - class AsyncBrowserInstance(AsyncBaseInstance): def __init__( self, diff --git a/src/scrapybara/core/client_wrapper.py b/src/scrapybara/core/client_wrapper.py index c9d75c0..2ea88cd 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.9", + "X-Fern-SDK-Version": "2.5.0", } headers["x-api-key"] = self.api_key return headers diff --git a/src/scrapybara/instance/client.py b/src/scrapybara/instance/client.py index 4a43477..5af25d7 100644 --- a/src/scrapybara/instance/client.py +++ b/src/scrapybara/instance/client.py @@ -522,78 +522,6 @@ 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, local_path: str, request_options: typing.Optional[RequestOptions] = None - ) -> FileResponse: - """ - 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 - ---------- - instance_id : str - - path : str - - local_path : str - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - FileResponse - Successful Response - - Examples - -------- - from scrapybara import Scrapybara - - client = Scrapybara( - api_key="YOUR_API_KEY", - ) - client.instance.download( - instance_id="instance_id", - path="path", - local_path="local_path", - ) - """ - _response = self._client_wrapper.httpx_client.request( - f"v1/instance/{jsonable_encoder(instance_id)}/download", - method="GET", - params={ - "path": path, - "local_path": local_path, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - FileResponse, - parse_obj_as( - type_=FileResponse, # type: ignore - object_=_response.json(), - ), - ) - 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 upload( self, instance_id: str, *, file: core.File, path: str, request_options: typing.Optional[RequestOptions] = None ) -> UploadResponse: @@ -1385,86 +1313,6 @@ 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( - self, instance_id: str, *, path: str, local_path: str, request_options: typing.Optional[RequestOptions] = None - ) -> FileResponse: - """ - 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 - ---------- - instance_id : str - - path : str - - local_path : str - - request_options : typing.Optional[RequestOptions] - Request-specific configuration. - - Returns - ------- - FileResponse - Successful Response - - Examples - -------- - import asyncio - - from scrapybara import AsyncScrapybara - - client = AsyncScrapybara( - api_key="YOUR_API_KEY", - ) - - - async def main() -> None: - await client.instance.download( - instance_id="instance_id", - path="path", - local_path="local_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, - "local_path": local_path, - }, - request_options=request_options, - ) - try: - if 200 <= _response.status_code < 300: - return typing.cast( - FileResponse, - parse_obj_as( - type_=FileResponse, # type: ignore - object_=_response.json(), - ), - ) - 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 upload( self, instance_id: str, *, file: core.File, path: str, request_options: typing.Optional[RequestOptions] = None ) -> UploadResponse: