Refactor how repositories for the daemon work.
This commit is contained in:
parent
5f9fe4a69b
commit
d2afc29a80
58 changed files with 388 additions and 997 deletions
|
@ -1,68 +1,65 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Contracts\Repository\Daemon;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use Pterodactyl\Models\Node;
|
||||
use Pterodactyl\Models\Server;
|
||||
|
||||
interface BaseRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Set the node model to be used for this daemon connection.
|
||||
*
|
||||
* @param int $id
|
||||
* @param \Pterodactyl\Models\Node $node
|
||||
* @return $this
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function setNode($id);
|
||||
public function setNode(Node $node);
|
||||
|
||||
/**
|
||||
* Return the node model being used.
|
||||
*
|
||||
* @return \Pterodactyl\Models\Node
|
||||
*/
|
||||
public function getNode();
|
||||
public function getNode(): Node;
|
||||
|
||||
/**
|
||||
* Set the UUID for the server to be used in the X-Access-Server header for daemon requests.
|
||||
* Set the Server model to use when requesting information from the Daemon.
|
||||
*
|
||||
* @param null|string $server
|
||||
* @param \Pterodactyl\Models\Server $server
|
||||
* @return $this
|
||||
*/
|
||||
public function setAccessServer($server = null);
|
||||
public function setServer(Server $server);
|
||||
|
||||
/**
|
||||
* Return the UUID of the server being used in requests.
|
||||
* Return the Server model.
|
||||
*
|
||||
* @return string
|
||||
* @return \Pterodactyl\Models\Server|null
|
||||
*/
|
||||
public function getAccessServer();
|
||||
public function getServer();
|
||||
|
||||
/**
|
||||
* Set the token to be used in the X-Access-Token header for requests to the daemon.
|
||||
*
|
||||
* @param null|string $token
|
||||
* @param string $token
|
||||
* @return $this
|
||||
*/
|
||||
public function setAccessToken($token = null);
|
||||
public function setToken(string $token);
|
||||
|
||||
/**
|
||||
* Return the access token being used for requests.
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAccessToken();
|
||||
public function getToken();
|
||||
|
||||
/**
|
||||
* Return an instance of the Guzzle HTTP Client to be used for requests.
|
||||
*
|
||||
* @param array $headers
|
||||
* @return \GuzzleHttp\Client
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||
*/
|
||||
public function getHttpClient(array $headers = []);
|
||||
public function getHttpClient(array $headers = []): Client;
|
||||
}
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Contracts\Repository\Daemon;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
interface CommandRepositoryInterface extends BaseRepositoryInterface
|
||||
{
|
||||
/**
|
||||
|
@ -17,5 +12,5 @@ interface CommandRepositoryInterface extends BaseRepositoryInterface
|
|||
* @param string $command
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function send($command);
|
||||
public function send(string $command): ResponseInterface;
|
||||
}
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Contracts\Repository\Daemon;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
interface ConfigurationRepositoryInterface extends BaseRepositoryInterface
|
||||
{
|
||||
/**
|
||||
|
@ -17,5 +12,5 @@ interface ConfigurationRepositoryInterface extends BaseRepositoryInterface
|
|||
* @param array $overrides
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function update(array $overrides = []);
|
||||
public function update(array $overrides = []): ResponseInterface;
|
||||
}
|
||||
|
|
|
@ -1,35 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Contracts\Repository\Daemon;
|
||||
|
||||
use stdClass;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
interface FileRepositoryInterface extends BaseRepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Return stat information for a given file.
|
||||
*
|
||||
* @param string $path
|
||||
* @return object
|
||||
* @return \stdClass
|
||||
*
|
||||
* @throws \GuzzleHttp\Exception\RequestException
|
||||
*/
|
||||
public function getFileStat($path);
|
||||
public function getFileStat(string $path): stdClass;
|
||||
|
||||
/**
|
||||
* Return the contents of a given file if it can be edited in the Panel.
|
||||
*
|
||||
* @param string $path
|
||||
* @return object
|
||||
* @return \stdClass
|
||||
*
|
||||
* @throws \GuzzleHttp\Exception\RequestException
|
||||
*/
|
||||
public function getContent($path);
|
||||
public function getContent(string $path): stdClass;
|
||||
|
||||
/**
|
||||
* Save new contents to a given file.
|
||||
|
@ -40,7 +36,7 @@ interface FileRepositoryInterface extends BaseRepositoryInterface
|
|||
*
|
||||
* @throws \GuzzleHttp\Exception\RequestException
|
||||
*/
|
||||
public function putContent($path, $content);
|
||||
public function putContent(string $path, string $content): ResponseInterface;
|
||||
|
||||
/**
|
||||
* Return a directory listing for a given path.
|
||||
|
@ -50,5 +46,5 @@ interface FileRepositoryInterface extends BaseRepositoryInterface
|
|||
*
|
||||
* @throws \GuzzleHttp\Exception\RequestException
|
||||
*/
|
||||
public function getDirectory($path);
|
||||
public function getDirectory(string $path): array;
|
||||
}
|
||||
|
|
|
@ -1,14 +1,9 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Contracts\Repository\Daemon;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
interface PowerRepositoryInterface extends BaseRepositoryInterface
|
||||
{
|
||||
const SIGNAL_START = 'start';
|
||||
|
@ -24,5 +19,5 @@ interface PowerRepositoryInterface extends BaseRepositoryInterface
|
|||
*
|
||||
* @throws \Pterodactyl\Exceptions\Repository\Daemon\InvalidPowerSignalException
|
||||
*/
|
||||
public function sendSignal($signal);
|
||||
public function sendSignal(string $signal): ResponseInterface;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Contracts\Repository\Daemon;
|
||||
|
||||
|
@ -30,7 +23,7 @@ interface ServerRepositoryInterface extends BaseRepositoryInterface
|
|||
* @param array $data
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function update(array $data);
|
||||
public function update(array $data): ResponseInterface;
|
||||
|
||||
/**
|
||||
* Mark a server to be reinstalled on the system.
|
||||
|
@ -38,42 +31,42 @@ interface ServerRepositoryInterface extends BaseRepositoryInterface
|
|||
* @param array|null $data
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function reinstall($data = null);
|
||||
public function reinstall(array $data = null): ResponseInterface;
|
||||
|
||||
/**
|
||||
* Mark a server as needing a container rebuild the next time the server is booted.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function rebuild();
|
||||
public function rebuild(): ResponseInterface;
|
||||
|
||||
/**
|
||||
* Suspend a server on the daemon.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function suspend();
|
||||
public function suspend(): ResponseInterface;
|
||||
|
||||
/**
|
||||
* Un-suspend a server on the daemon.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function unsuspend();
|
||||
public function unsuspend(): ResponseInterface;
|
||||
|
||||
/**
|
||||
* Delete a server on the daemon.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function delete();
|
||||
public function delete(): ResponseInterface;
|
||||
|
||||
/**
|
||||
* Return detials on a specific server.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface
|
||||
*/
|
||||
public function details();
|
||||
public function details(): ResponseInterface;
|
||||
|
||||
/**
|
||||
* Revoke an access key on the daemon before the time is expired.
|
||||
|
@ -83,5 +76,5 @@ interface ServerRepositoryInterface extends BaseRepositoryInterface
|
|||
*
|
||||
* @throws \GuzzleHttp\Exception\RequestException
|
||||
*/
|
||||
public function revokeAccessKey($key);
|
||||
public function revokeAccessKey($key): ResponseInterface;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue