2017-07-15 16:52:34 +00:00
|
|
|
<?php
|
2017-09-26 02:43:01 +00:00
|
|
|
/**
|
2017-07-15 16:52:34 +00:00
|
|
|
* Pterodactyl - Panel
|
|
|
|
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
|
|
|
*
|
2017-09-26 02:43:01 +00:00
|
|
|
* This software is licensed under the terms of the MIT license.
|
|
|
|
* https://opensource.org/licenses/MIT
|
2017-07-15 16:52:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Pterodactyl\Contracts\Repository;
|
|
|
|
|
2017-10-19 03:32:19 +00:00
|
|
|
use Illuminate\Support\Collection;
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the connection to execute statements aganist.
|
|
|
|
*
|
|
|
|
* @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;
|
|
|
|
|
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
|
2017-07-15 16:52:34 +00:00
|
|
|
* @return mixed
|
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\DisplayException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
|
|
|
*/
|
|
|
|
public function createIfNotExists(array $data);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
2017-10-19 03:32:19 +00:00
|
|
|
public function createDatabase($database);
|
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
|
2017-07-15 16:52:34 +00:00
|
|
|
* @return bool
|
|
|
|
*/
|
2017-10-19 03:32:19 +00:00
|
|
|
public function createUser($username, $remote, $password);
|
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
|
|
|
|
*/
|
2017-10-19 03:32:19 +00:00
|
|
|
public function assignUserToDatabase($database, $username, $remote);
|
2017-07-15 16:52:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Flush the privileges for a given connection.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2017-10-19 03:32:19 +00:00
|
|
|
public function flush();
|
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
|
|
|
|
*/
|
2017-10-19 03:32:19 +00:00
|
|
|
public function dropDatabase($database);
|
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
|
|
|
|
*/
|
2017-10-19 03:32:19 +00:00
|
|
|
public function dropUser($username, $remote);
|
2017-07-15 16:52:34 +00:00
|
|
|
}
|