Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "scrapybara"

[tool.poetry]
name = "scrapybara"
version = "2.4.9"
version = "2.5.0"
description = ""
readme = "README.md"
authors = []
Expand Down
92 changes: 0 additions & 92 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -805,98 +805,6 @@ client.instance.file(
</dl>


</dd>
</dl>
</details>

<details><summary><code>client.instance.<a href="src/scrapybara/instance/client.py">download</a>(...)</code></summary>
<dl>
<dd>

#### 📝 Description

<dl>
<dd>

<dl>
<dd>

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
</dd>
</dl>
</dd>
</dl>

#### 🔌 Usage

<dl>
<dd>

<dl>
<dd>

```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",
)

```
</dd>
</dl>
</dd>
</dl>

#### ⚙️ Parameters

<dl>
<dd>

<dl>
<dd>

**instance_id:** `str`

</dd>
</dl>

<dl>
<dd>

**path:** `str`

</dd>
</dl>

<dl>
<dd>

**local_path:** `str`

</dd>
</dl>

<dl>
<dd>

**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.

</dd>
</dl>
</dd>
</dl>


</dd>
</dl>
</details>
Expand Down
28 changes: 0 additions & 28 deletions src/scrapybara/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/scrapybara/core/client_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
152 changes: 0 additions & 152 deletions src/scrapybara/instance/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down