Skip to content

Commit 03aba2e

Browse files
committed
Start/stop server method
1 parent b5ace79 commit 03aba2e

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

src/Compute/v2/Api.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,30 @@ public function rebootServer(): array
289289
];
290290
}
291291

292+
public function startServer() : array
293+
{
294+
return [
295+
'method' => 'POST',
296+
'path' => 'servers/{id}/action',
297+
'params' => [
298+
'id' => $this->params->urlId('server'),
299+
'os-start' => $this->params->nullAction()
300+
],
301+
];
302+
}
303+
304+
public function stopServer() : array
305+
{
306+
return [
307+
'method' => 'POST',
308+
'path' => 'servers/{id}/action',
309+
'params' => [
310+
'id' => $this->params->urlId('server'),
311+
'os-stop' => $this->params->nullAction()
312+
],
313+
];
314+
}
315+
292316
public function rebuildServer(): array
293317
{
294318
return [

src/Compute/v2/Models/Server.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,28 @@ public function reboot(string $type = Enum::REBOOT_SOFT)
162162
]);
163163
}
164164

165+
/**
166+
* Starts server
167+
*/
168+
public function start()
169+
{
170+
$this->execute($this->api->startServer(), [
171+
'id' => $this->id,
172+
'os-start' => null
173+
]);
174+
}
175+
176+
/**
177+
* Stops server
178+
*/
179+
public function stop()
180+
{
181+
$this->execute($this->api->stopServer(), [
182+
'id' => $this->id,
183+
'os-stop' => null
184+
]);
185+
}
186+
165187
/**
166188
* Rebuilds the server.
167189
*

0 commit comments

Comments
 (0)