2017-07-15 16:52:34 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Contracts\Repository;
|
|
|
|
|
2018-01-05 04:49:50 +00:00
|
|
|
use Pterodactyl\Models\Database;
|
2017-10-19 03:32:19 +00:00
|
|
|
use Illuminate\Support\Collection;
|
2018-03-03 23:52:35 +00:00
|
|
|
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
2017-10-19 03:32:19 +00:00
|
|
|
|
2017-07-15 16:52:34 +00:00
|
|
|
interface DatabaseRepositoryInterface extends RepositoryInterface
|
|
|
|
{
|
2017-10-19 03:32:19 +00:00
|
|
|
const DEFAULT_CONNECTION_NAME = 'dynamic';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the connection name to execute statements against.
|
|
|
|
*
|
|
|
|
* @param string $connection
|
|
|
|
* @return $this
|
|
|
|
*/
|
|
|
|
public function setConnection(string $connection);
|
|
|
|
|
|
|
|
/**
|
2018-05-13 14:50:56 +00:00
|
|
|
* Return the connection to execute statements against.
|
2017-10-19 03:32:19 +00:00
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getConnection(): string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return all of the databases belonging to a server.
|
|
|
|
*
|
|
|
|
* @param int $server
|
|
|
|
* @return \Illuminate\Support\Collection
|
|
|
|
*/
|
|
|
|
public function getDatabasesForServer(int $server): Collection;
|
|
|
|
|
2018-03-03 23:52:35 +00:00
|
|
|
/**
|
|
|
|
* Return all of the databases for a given host with the server relationship loaded.
|
|
|
|
*
|
|
|
|
* @param int $host
|
|
|
|
* @param int $count
|
|
|
|
* @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
|
|
|
|
*/
|
|
|
|
public function getDatabasesForHost(int $host, int $count = 25): LengthAwarePaginator;
|
|
|
|
|
2017-07-15 16:52:34 +00:00
|
|
|
/**
|
|
|
|
* Create a new database if it does not already exist on the host with
|
|
|
|
* the provided details.
|
|
|
|
*
|
2017-08-22 03:10:48 +00:00
|
|
|
* @param array $data
|
2018-01-05 04:49:50 +00:00
|
|
|
* @return \Pterodactyl\Models\Database
|
2017-07-15 16:52:34 +00:00
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
2018-01-05 04:49:50 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\DuplicateDatabaseNameException
|
2017-07-15 16:52:34 +00:00
|
|
|
*/
|
2018-01-05 04:49:50 +00:00
|
|
|
public function createIfNotExists(array $data): Database;
|
2017-07-15 16:52:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new database on a given connection.
|
|
|
|
*
|
2017-10-19 03:32:19 +00:00
|
|
|
* @param string $database
|
2017-07-15 16:52:34 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
2018-01-05 04:49:50 +00:00
|
|
|
public function createDatabase(string $database): bool;
|
2017-07-15 16:52:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new database user on a given connection.
|
|
|
|
*
|
2017-10-19 03:32:19 +00:00
|
|
|
* @param string $username
|
|
|
|
* @param string $remote
|
|
|
|
* @param string $password
|
2020-04-23 14:45:44 +00:00
|
|
|
* @param $max_connections
|
2017-07-15 16:52:34 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
2020-04-22 10:00:04 +00:00
|
|
|
public function createUser(string $username, string $remote, string $password, string $max_connections): bool;
|
2017-07-15 16:52:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Give a specific user access to a given database.
|
|
|
|
*
|
2017-10-19 03:32:19 +00:00
|
|
|
* @param string $database
|
|
|
|
* @param string $username
|
|
|
|
* @param string $remote
|
2017-07-15 16:52:34 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
2018-01-05 04:49:50 +00:00
|
|
|
public function assignUserToDatabase(string $database, string $username, string $remote): bool;
|
2017-07-15 16:52:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Flush the privileges for a given connection.
|
|
|
|
*
|
2018-01-05 04:49:50 +00:00
|
|
|
* @return bool
|
2017-07-15 16:52:34 +00:00
|
|
|
*/
|
2018-01-05 04:49:50 +00:00
|
|
|
public function flush(): bool;
|
2017-07-15 16:52:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Drop a given database on a specific connection.
|
|
|
|
*
|
2017-10-19 03:32:19 +00:00
|
|
|
* @param string $database
|
2017-07-15 16:52:34 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
2018-01-05 04:49:50 +00:00
|
|
|
public function dropDatabase(string $database): bool;
|
2017-07-15 16:52:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Drop a given user on a specific connection.
|
|
|
|
*
|
2017-10-19 03:32:19 +00:00
|
|
|
* @param string $username
|
|
|
|
* @param string $remote
|
2017-07-15 16:52:34 +00:00
|
|
|
* @return mixed
|
|
|
|
*/
|
2018-01-05 04:49:50 +00:00
|
|
|
public function dropUser(string $username, string $remote): bool;
|
2017-07-15 16:52:34 +00:00
|
|
|
}
|