Skip to content

Commit

Permalink
Add actor reboot method to the RunClient (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
vdusek authored Aug 22, 2023
1 parent 52b211f commit dc9e56b
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
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

0 comments on commit dc9e56b

Please sign in to comment.