[#3896cn] Clean up code handling server suspension

This commit is contained in:
Dane Everitt 2019-11-30 15:37:13 -08:00
parent 2eee6f35d4
commit ed50259484
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
3 changed files with 45 additions and 54 deletions

View file

@ -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);
}
}
}