Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add actor reboot method to the RunClient #140

Merged
merged 3 commits into from
Aug 22, 2023
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
34 changes: 34 additions & 0 deletions docs/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1964,6 +1964,7 @@ Sub-client for manipulating a single actor run.
* [wait\_for\_finish()](#runclient-wait\_for\_finish)
* [metamorph()](#runclient-metamorph)
* [resurrect()](#runclient-resurrect)
* [reboot()](#runclient-reboot)
* [dataset()](#runclient-dataset)
* [key\_value\_store()](#runclient-key\_value\_store)
* [request\_queue()](#runclient-request\_queue)
Expand Down Expand Up @@ -2108,6 +2109,22 @@ Run status will be updated to RUNNING and its container will be restarted with t

***

#### [](#runclient-reboot) `RunClient.reboot()`

Reboot an Actor run. Only runs that are running, i.e. runs with status RUNNING can be rebooted.

[https://docs.apify.com/api/v2#/reference/actor-runs/reboot-run/reboot-run](https://docs.apify.com/api/v2#/reference/actor-runs/reboot-run/reboot-run)

* **Returns**

The Actor run data.

* **Return type**

`dict`

***

#### [](#runclient-dataset) `RunClient.dataset()`

Get the client for the default dataset of the actor run.
Expand Down Expand Up @@ -4416,6 +4433,7 @@ Async sub-client for manipulating a single actor run.
* [async wait\_for\_finish()](#runclientasync-wait\_for\_finish)
* [async metamorph()](#runclientasync-metamorph)
* [async resurrect()](#runclientasync-resurrect)
* [async reboot()](#runclientasync-reboot)
* [dataset()](#runclientasync-dataset)
* [key\_value\_store()](#runclientasync-key\_value\_store)
* [request\_queue()](#runclientasync-request\_queue)
Expand Down Expand Up @@ -4560,6 +4578,22 @@ Run status will be updated to RUNNING and its container will be restarted with t

***

#### [](#runclientasync-reboot) `async RunClientAsync.reboot()`

Reboot an Actor run. Only runs that are running, i.e. runs with status RUNNING can be rebooted.

[https://docs.apify.com/api/v2#/reference/actor-runs/reboot-run/reboot-run](https://docs.apify.com/api/v2#/reference/actor-runs/reboot-run/reboot-run)

* **Returns**

The Actor run data.

* **Return type**

`dict`

***

#### [](#runclientasync-dataset) `RunClientAsync.dataset()`

Get the client for the default dataset of the actor run.
Expand Down
28 changes: 28 additions & 0 deletions src/apify_client/clients/resource_clients/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,20 @@ def resurrect(

return parse_date_fields(_pluck_data(response.json()))

def reboot(self) -> Dict:
"""Reboot an Actor run. Only runs that are running, i.e. runs with status RUNNING can be rebooted.
https://docs.apify.com/api/v2#/reference/actor-runs/reboot-run/reboot-run
Returns:
dict: The Actor run data.
"""
response = self.http_client.call(
url=self._url('reboot'),
method='POST',
)
return parse_date_fields(_pluck_data(response.json()))

def dataset(self) -> DatasetClient:
"""Get the client for the default dataset of the actor run.
Expand Down Expand Up @@ -349,6 +363,20 @@ async def resurrect(

return parse_date_fields(_pluck_data(response.json()))

async def reboot(self) -> Dict:
"""Reboot an Actor run. Only runs that are running, i.e. runs with status RUNNING can be rebooted.
https://docs.apify.com/api/v2#/reference/actor-runs/reboot-run/reboot-run
Returns:
dict: The Actor run data.
"""
response = await self.http_client.call(
url=self._url('reboot'),
method='POST',
)
return parse_date_fields(_pluck_data(response.json()))

def dataset(self) -> DatasetClientAsync:
"""Get the client for the default dataset of the actor run.
Expand Down