[#3896cn] Clean up code handling server suspension
This commit is contained in:
parent
2eee6f35d4
commit
ed50259484
3 changed files with 45 additions and 54 deletions
|
@ -87,13 +87,25 @@ class DaemonServerRepository extends DaemonRepository
|
|||
throw new BadMethodCallException('Method is not implemented.');
|
||||
}
|
||||
|
||||
public function suspend(): void
|
||||
/**
|
||||
* By default this function will suspend a server instance on the daemon. However, passing
|
||||
* "true" as the first argument will unsuspend the server.
|
||||
*
|
||||
* @param bool $unsuspend
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Http\Connection\DaemonConnectionException
|
||||
*/
|
||||
public function suspend(bool $unsuspend = false): void
|
||||
{
|
||||
throw new BadMethodCallException('Method is not implemented.');
|
||||
}
|
||||
Assert::isInstanceOf($this->server, Server::class);
|
||||
|
||||
public function unsuspend(): void
|
||||
{
|
||||
throw new BadMethodCallException('Method is not implemented.');
|
||||
try {
|
||||
$this->getHttpClient()->patch(
|
||||
'/api/servers/' . $this->server->uuid,
|
||||
['json' => ['suspended' => ! $unsuspend]]
|
||||
);
|
||||
} catch (TransferException $exception) {
|
||||
throw new DaemonConnectionException($exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue