2017-07-15 11:52:34 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Contracts\Repository;
|
|
|
|
|
2018-01-04 22:49:50 -06:00
|
|
|
use Pterodactyl\Models\Database;
|
2017-10-18 22:32:19 -05:00
|
|
|
use Illuminate\Support\Collection;
|
2018-03-03 17:52:35 -06:00
|
|
|
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
2017-10-18 22:32:19 -05:00
|
|
|
|
2017-07-15 11:52:34 -05:00
|
|
|
interface DatabaseRepositoryInterface extends RepositoryInterface
|
|
|
|
{
|
2021-01-23 12:33:34 -08:00
|
|
|
public const DEFAULT_CONNECTION_NAME = 'dynamic';
|
2017-10-18 22:32:19 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the connection name to execute statements against.
|
|
|
|
*
|
|
|
|
* @return $this
|
|
|
|
*/
|
|
|
|
public function setConnection(string $connection);
|
|
|
|
|
|
|
|
/**
|
2018-05-13 10:50:56 -04:00
|
|
|
* Return the connection to execute statements against.
|
2017-10-18 22:32:19 -05:00
|
|
|
*/
|
|
|
|
public function getConnection(): string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return all of the databases belonging to a server.
|
|
|
|
*/
|
|
|
|
public function getDatabasesForServer(int $server): Collection;
|
|
|
|
|
2018-03-03 17:52:35 -06:00
|
|
|
/**
|
|
|
|
* Return all of the databases for a given host with the server relationship loaded.
|
|
|
|
*/
|
|
|
|
public function getDatabasesForHost(int $host, int $count = 25): LengthAwarePaginator;
|
|
|
|
|
2017-07-15 11:52:34 -05:00
|
|
|
/**
|
|
|
|
* Create a new database on a given connection.
|
|
|
|
*/
|
2018-01-04 22:49:50 -06:00
|
|
|
public function createDatabase(string $database): bool;
|
2017-07-15 11:52:34 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new database user on a given connection.
|
|
|
|
*/
|
2021-10-30 13:41:38 -07:00
|
|
|
public function createUser(string $username, string $remote, string $password, int $max_connections): bool;
|
2017-07-15 11:52:34 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Give a specific user access to a given database.
|
|
|
|
*/
|
2018-01-04 22:49:50 -06:00
|
|
|
public function assignUserToDatabase(string $database, string $username, string $remote): bool;
|
2017-07-15 11:52:34 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Flush the privileges for a given connection.
|
|
|
|
*/
|
2018-01-04 22:49:50 -06:00
|
|
|
public function flush(): bool;
|
2017-07-15 11:52:34 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Drop a given database on a specific connection.
|
|
|
|
*/
|
2018-01-04 22:49:50 -06:00
|
|
|
public function dropDatabase(string $database): bool;
|
2017-07-15 11:52:34 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Drop a given user on a specific connection.
|
|
|
|
*/
|
2018-01-04 22:49:50 -06:00
|
|
|
public function dropUser(string $username, string $remote): bool;
|
2017-07-15 11:52:34 -05:00
|
|
|
}
|