Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
add suspend/resume methods
  • Loading branch information
Chris Smit Chris Smit
Chris Smit authored and Chris Smit committed Aug 30, 2017
commit aaa36bad9b05b2d8af26c2faf636991cf2761855
24 changes: 24 additions & 0 deletions src/Compute/v2/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,30 @@ public function stopServer() : array
];
}

public function suspendServer() : array
{
return [
'method' => 'POST',
'path' => 'servers/{id}/action',
'params' => [
'id' => $this->params->urlId('server'),
'suspend' => $this->params->nullAction()
],
];
}

public function resumeServer() : array
{
return [
'method' => 'POST',
'path' => 'servers/{id}/action',
'params' => [
'id' => $this->params->urlId('server'),
'resume' => $this->params->nullAction()
],
];
}

public function rebuildServer(): array
{
return [
Expand Down
22 changes: 22 additions & 0 deletions src/Compute/v2/Models/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,28 @@ public function stop()
]);
}

/**
* Suspend server
*/
public function suspend()
{
$this->execute($this->api->suspendServer(), [
'id' => $this->id,
'suspend' => null
]);
}

/**
* Resume server
*/
public function resume()
{
$this->execute($this->api->resumeServer(), [
'id' => $this->id,
'resume' => null
]);
}

/**
* Rebuilds the server.
*
Expand Down