Skip to content
Closed
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
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.7"
version = "2.4.8"
description = ""
readme = "README.md"
authors = []
Expand Down
79 changes: 79 additions & 0 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,85 @@ client.instance.file(
</dl>


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

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

#### 📝 Description

<dl>
<dd>

<dl>
<dd>

Download a file from the instance.
</dd>
</dl>
</dd>
</dl>

#### 🔌 Usage

<dl>
<dd>

<dl>
<dd>

```python
from scrapybara import Scrapybara

client = Scrapybara(
api_key="YOUR_API_KEY",
)
client.instance.download_file(
instance_id="instance_id",
path="path",
)

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

#### ⚙️ Parameters

<dl>
<dd>

<dl>
<dd>

**instance_id:** `str`

</dd>
</dl>

<dl>
<dd>

**path:** `str`

</dd>
</dl>

<dl>
<dd>

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

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


</dd>
</dl>
</details>
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.7",
"X-Fern-SDK-Version": "2.4.8",
}
headers["x-api-key"] = self.api_key
return headers
Expand Down
122 changes: 122 additions & 0 deletions src/scrapybara/instance/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
Loading