Add database list endpoint, add more resource name magic

This commit is contained in:
Dane Everitt 2018-01-25 21:26:06 -06:00
parent 407120a854
commit 2bd691efad
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
36 changed files with 416 additions and 187 deletions

View file

@ -2,7 +2,7 @@
namespace Pterodactyl\Extensions\Spatie\Fractalistic;
use Illuminate\Database\Eloquent\Model;
use League\Fractal\TransformerAbstract;
use League\Fractal\Serializer\JsonApiSerializer;
use Spatie\Fractalistic\Fractal as SpatieFractal;
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
@ -31,21 +31,14 @@ class Fractal extends SpatieFractal
$this->paginator = new IlluminatePaginatorAdapter($this->data);
}
// Automatically set the resource name if the response data is a model
// and the resource name is available on the model.
if (is_null($this->resourceName) && $this->data instanceof Model) {
if (defined(get_class($this->data) . '::RESOURCE_NAME')) {
$this->resourceName = constant(get_class($this->data) . '::RESOURCE_NAME');
}
}
if (is_null($this->resourceName) && $this->data instanceof LengthAwarePaginator) {
$item = collect($this->data->items())->first();
if ($item instanceof Model) {
if (defined(get_class($item) . '::RESOURCE_NAME')) {
$this->resourceName = constant(get_class($item) . '::RESOURCE_NAME');
}
}
// If the resource name is not set attempt to pull it off the transformer
// itself and set it automatically.
if (
is_null($this->resourceName)
&& $this->transformer instanceof TransformerAbstract
&& method_exists($this->transformer, 'getResourceName')
) {
$this->resourceName = $this->transformer->getResourceName();
}
return parent::createData();

View file

@ -16,7 +16,7 @@ abstract class ApplicationApiController extends Controller
private $request;
/**
* @var \Spatie\Fractalistic\Fractal
* @var \Pterodactyl\Extensions\Spatie\Fractalistic\Fractal
*/
protected $fractal;

View file

@ -0,0 +1,44 @@
<?php
namespace Pterodactyl\Http\Controllers\Api\Application\Servers;
use Pterodactyl\Models\Server;
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
use Pterodactyl\Transformers\Api\Application\ServerDatabaseTransformer;
use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;
class DatabaseController extends ApplicationApiController
{
/**
* @var \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface
*/
private $repository;
/**
* DatabaseController constructor.
*
* @param \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface $repository
*/
public function __construct(DatabaseRepositoryInterface $repository)
{
parent::__construct();
$this->repository = $repository;
}
/**
* Return a listing of all databases currently available to a single
* server.
*
* @param \Pterodactyl\Models\Server $server
* @return array
*/
public function index(Server $server): array
{
$databases = $this->repository->getDatabasesForServer($server->id);
return $this->fractal->collection($databases)
->transformWith($this->getTransformer(ServerDatabaseTransformer::class))
->toArray();
}
}

View file

@ -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\Models;

View file

@ -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\Models;
@ -19,6 +12,12 @@ class Allocation extends Model implements CleansAttributes, ValidableContract
{
use Eloquence, Validable;
/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
*/
const RESOURCE_NAME = 'allocation';
/**
* The table associated with the model.
*

View file

@ -50,7 +50,8 @@ class ApiKey extends Model implements CleansAttributes, ValidableContract
'user_id' => 'int',
'r_' . AdminAcl::RESOURCE_USERS => 'int',
'r_' . AdminAcl::RESOURCE_ALLOCATIONS => 'int',
'r_' . AdminAcl::RESOURCE_DATABASES => 'int',
'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'int',
'r_' . AdminAcl::RESOURCE_SERVER_DATABASES => 'int',
'r_' . AdminAcl::RESOURCE_EGGS => 'int',
'r_' . AdminAcl::RESOURCE_LOCATIONS => 'int',
'r_' . AdminAcl::RESOURCE_NESTS => 'int',
@ -108,7 +109,8 @@ class ApiKey extends Model implements CleansAttributes, ValidableContract
'last_used_at' => 'nullable|date',
'r_' . AdminAcl::RESOURCE_USERS => 'integer|min:0|max:3',
'r_' . AdminAcl::RESOURCE_ALLOCATIONS => 'integer|min:0|max:3',
'r_' . AdminAcl::RESOURCE_DATABASES => 'integer|min:0|max:3',
'r_' . AdminAcl::RESOURCE_DATABASE_HOSTS => 'integer|min:0|max:3',
'r_' . AdminAcl::RESOURCE_SERVER_DATABASES => 'integer|min:0|max:3',
'r_' . AdminAcl::RESOURCE_EGGS => 'integer|min:0|max:3',
'r_' . AdminAcl::RESOURCE_LOCATIONS => 'integer|min:0|max:3',
'r_' . AdminAcl::RESOURCE_NESTS => 'integer|min:0|max:3',

View file

@ -1,38 +0,0 @@
<?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\Models;
use Illuminate\Database\Eloquent\Model;
class Checksum extends Model
{
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'checksums';
/**
* Fields that are not mass assignable.
*
* @var array
*/
protected $guarded = ['id', 'created_at', 'updated_at'];
/**
* Cast values to correct type.
*
* @var array
*/
protected $casts = [
'service' => 'integer',
];
}

View file

@ -1,26 +1,4 @@
<?php
/*
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
namespace Pterodactyl\Models;

View file

@ -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\Models;
@ -19,6 +12,12 @@ class Database extends Model implements CleansAttributes, ValidableContract
{
use Eloquence, Validable;
/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
*/
const RESOURCE_NAME = 'server_database';
/**
* The table associated with the model.
*

View file

@ -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\Models;
@ -19,6 +12,12 @@ class DatabaseHost extends Model implements CleansAttributes, ValidableContract
{
use Eloquence, Validable;
/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
*/
const RESOURCE_NAME = 'database_host';
/**
* The table associated with the model.
*

View file

@ -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\Models;
@ -19,6 +12,12 @@ class Egg extends Model implements CleansAttributes, ValidableContract
{
use Eloquence, Validable;
/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
*/
const RESOURCE_NAME = 'egg';
/**
* The table associated with the model.
*

View file

@ -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\Models;
@ -19,6 +12,12 @@ class EggVariable extends Model implements CleansAttributes, ValidableContract
{
use Eloquence, Validable;
/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
*/
const RESOURCE_NAME = 'egg_variable';
/**
* Reserved environment variable names.
*

View file

@ -12,6 +12,12 @@ class Location extends Model implements CleansAttributes, ValidableContract
{
use Eloquence, Validable;
/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
*/
const RESOURCE_NAME = 'location';
/**
* The table associated with the model.
*

View file

@ -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\Models;
@ -19,6 +12,12 @@ class Nest extends Model implements CleansAttributes, ValidableContract
{
use Eloquence, Validable;
/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
*/
const RESOURCE_NAME = 'nest';
/**
* The table associated with the model.
*

View file

@ -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\Models;
@ -20,6 +13,12 @@ class Node extends Model implements CleansAttributes, ValidableContract
{
use Eloquence, Notifiable, Validable;
/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
*/
const RESOURCE_NAME = 'node';
const DAEMON_SECRET_LENGTH = 36;
/**

View file

@ -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\Models;
@ -19,6 +12,12 @@ class Pack extends Model implements CleansAttributes, ValidableContract
{
use Eloquence, Validable;
/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
*/
const RESOURCE_NAME = 'pack';
/**
* The table associated with the model.
*

View file

@ -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\Models;
@ -19,6 +12,12 @@ class Permission extends Model implements CleansAttributes, ValidableContract
{
use Eloquence, Validable;
/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
*/
const RESOURCE_NAME = 'subuser_permission';
/**
* Should timestamps be used on this model.
*

View file

@ -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\Models;
@ -19,6 +12,12 @@ class Schedule extends Model implements CleansAttributes, ValidableContract
{
use Eloquence, Validable;
/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
*/
const RESOURCE_NAME = 'server_schedule';
/**
* The table associated with the model.
*

View file

@ -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\Models;

View file

@ -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\Models;
@ -13,6 +6,12 @@ use Illuminate\Database\Eloquent\Model;
class ServerVariable extends Model
{
/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
*/
const RESOURCE_NAME = 'server_variable';
/**
* The table associated with the model.
*

View file

@ -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\Models;
@ -20,6 +13,12 @@ class Subuser extends Model implements CleansAttributes, ValidableContract
{
use Eloquence, Notifiable, Validable;
/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
*/
const RESOURCE_NAME = 'server_subuser';
/**
* The table associated with the model.
*

View file

@ -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\Models;
@ -20,6 +13,12 @@ class Task extends Model implements CleansAttributes, ValidableContract
{
use BelongsToThrough, Eloquence, Validable;
/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
*/
const RESOURCE_NAME = 'schedule_task';
/**
* The table associated with the model.
*

View file

@ -37,6 +37,12 @@ class User extends Model implements
const FILTER_LEVEL_ADMIN = 2;
const FILTER_LEVEL_SUBUSER = 3;
/**
* The resource name for this model when it is transformed into an
* API representation using fractal.
*/
const RESOURCE_NAME = 'user';
/**
* Level of servers to display when using access() on a user.
*

View file

@ -32,7 +32,8 @@ class AdminAcl
const RESOURCE_LOCATIONS = 'locations';
const RESOURCE_NESTS = 'nests';
const RESOURCE_EGGS = 'eggs';
const RESOURCE_DATABASES = 'databases';
const RESOURCE_DATABASE_HOSTS = 'database_hosts';
const RESOURCE_SERVER_DATABASES = 'server_databases';
const RESOURCE_PACKS = 'packs';
/**

View file

@ -14,6 +14,16 @@ class AllocationTransformer extends BaseTransformer
*/
protected $availableIncludes = ['node', 'server'];
/**
* Return the resource name for the JSONAPI output.
*
* @return string
*/
public function getResourceName(): string
{
return Allocation::RESOURCE_NAME;
}
/**
* Return a generic transformed allocation array.
*

View file

@ -17,6 +17,13 @@ abstract class BaseTransformer extends TransformerAbstract
*/
private $key;
/**
* Return the resource name for the JSONAPI output.
*
* @return string
*/
abstract public function getResourceName(): string;
/**
* BaseTransformer constructor.
*/

View file

@ -0,0 +1,69 @@
<?php
namespace Pterodactyl\Transformers\Api\Application;
use Cake\Chronos\Chronos;
use Pterodactyl\Models\Database;
use Pterodactyl\Models\DatabaseHost;
use Pterodactyl\Services\Acl\Api\AdminAcl;
class DatabaseHostTransformer extends BaseTransformer
{
/**
* @var array
*/
protected $availableIncludes = [
'databases',
];
/**
* Return the resource name for the JSONAPI output.
*
* @return string
*/
public function getResourceName(): string
{
return DatabaseHost::RESOURCE_NAME;
}
/**
* Transform database host into a representation for the application API.
*
* @param \Pterodactyl\Models\DatabaseHost $model
* @return array
*/
public function transform(DatabaseHost $model)
{
return [
'id' => $model->id,
'name' => $model->name,
'host' => $model->host,
'port' => $model->port,
'username' => $model->username,
'node' => $model->node_id,
'created_at' => Chronos::createFromFormat(Chronos::DEFAULT_TO_STRING_FORMAT, $model->created_at)
->setTimezone(config('app.timezone'))
->toIso8601String(),
'updated_at' => Chronos::createFromFormat(Chronos::DEFAULT_TO_STRING_FORMAT, $model->updated_at)
->setTimezone(config('app.timezone'))
->toIso8601String(),
];
}
/**
* Include the databases associated with this host.
*
* @param \Pterodactyl\Models\DatabaseHost $model
* @return \League\Fractal\Resource\Collection|\League\Fractal\Resource\NullResource
*/
public function includeDatabases(DatabaseHost $model)
{
if (! $this->authorize(AdminAcl::RESOURCE_SERVER_DATABASES)) {
return $this->null();
}
$model->loadMissing('databases');
return $this->collection($model->getRelation('databases'), $this->makeTransformer(ServerDatabaseTransformer::class), Database::RESOURCE_NAME);
}
}

View file

@ -2,10 +2,21 @@
namespace Pterodactyl\Transformers\Api\Application;
use Pterodactyl\Models\Egg;
use Pterodactyl\Models\EggVariable;
class EggVariableTransformer extends BaseTransformer
{
/**
* Return the resource name for the JSONAPI output.
*
* @return string
*/
public function getResourceName(): string
{
return Egg::RESOURCE_NAME;
}
public function transform(EggVariable $model)
{
return $model->toArray();

View file

@ -14,6 +14,16 @@ class LocationTransformer extends BaseTransformer
*/
protected $availableIncludes = ['nodes', 'servers'];
/**
* Return the resource name for the JSONAPI output.
*
* @return string
*/
public function getResourceName(): string
{
return Location::RESOURCE_NAME;
}
/**
* Return a generic transformed pack array.
*

View file

@ -14,6 +14,16 @@ class NodeTransformer extends BaseTransformer
*/
protected $availableIncludes = ['allocations', 'location', 'servers'];
/**
* Return the resource name for the JSONAPI output.
*
* @return string
*/
public function getResourceName(): string
{
return Node::RESOURCE_NAME;
}
/**
* Return a node transformed into a format that can be consumed by the
* external administrative API.

View file

@ -0,0 +1,104 @@
<?php
namespace Pterodactyl\Transformers\Api\Application;
use Cake\Chronos\Chronos;
use Pterodactyl\Models\Database;
use League\Fractal\Resource\Item;
use Pterodactyl\Models\DatabaseHost;
use Pterodactyl\Services\Acl\Api\AdminAcl;
use Illuminate\Contracts\Encryption\Encrypter;
class ServerDatabaseTransformer extends BaseTransformer
{
/**
* @var array
*/
protected $availableIncludes = ['password', 'host'];
/**
* @var Encrypter
*/
private $encrypter;
/**
* Perform dependency injection.
*
* @param \Illuminate\Contracts\Encryption\Encrypter $encrypter
*/
public function handle(Encrypter $encrypter)
{
$this->encrypter = $encrypter;
}
/**
* Return the resource name for the JSONAPI output.
*
* @return string
*/
public function getResourceName(): string
{
return Database::RESOURCE_NAME;
}
/**
* Transform a database model in a representation for the application API.
*
* @param \Pterodactyl\Models\Database $model
* @return array
*/
public function transform(Database $model): array
{
return [
'id' => $model->id,
'server' => $model->server_id,
'host' => $model->database_host_id,
'database' => $model->database,
'username' => $model->username,
'remote' => $model->remote,
'created_at' => Chronos::createFromFormat(Chronos::DEFAULT_TO_STRING_FORMAT, $model->created_at)
->setTimezone(config('app.timezone'))
->toIso8601String(),
'updated_at' => Chronos::createFromFormat(Chronos::DEFAULT_TO_STRING_FORMAT, $model->updated_at)
->setTimezone(config('app.timezone'))
->toIso8601String(),
];
}
/**
* Include the database password in the request.
*
* @param \Pterodactyl\Models\Database $model
* @return \League\Fractal\Resource\Item
*/
public function includePassword(Database $model): Item
{
return $this->item($model, function (Database $model) {
return [
'id' => $model->id,
'password' => $this->encrypter->decrypt($model->password),
];
}, 'database_password');
}
/**
* Return the database host relationship for this server database.
*
* @param \Pterodactyl\Models\Database $model
* @return \League\Fractal\Resource\Item|\League\Fractal\Resource\NullResource
*/
public function includeHost(Database $model)
{
if (! $this->authorize(AdminAcl::RESOURCE_DATABASE_HOSTS)) {
return $this->null();
}
$model->loadMissing('host');
return $this->item(
$model->getRelation('host'),
$this->makeTransformer(DatabaseHostTransformer::class),
DatabaseHost::RESOURCE_NAME
);
}
}

View file

@ -41,6 +41,16 @@ class ServerTransformer extends BaseTransformer
$this->environmentService = $environmentService;
}
/**
* Return the resource name for the JSONAPI output.
*
* @return string
*/
public function getResourceName(): string
{
return Server::RESOURCE_NAME;
}
/**
* Return a generic transformed server array.
*

View file

@ -14,6 +14,16 @@ class ServerVariableTransformer extends BaseTransformer
*/
protected $availableIncludes = ['parent'];
/**
* Return the resource name for the JSONAPI output.
*
* @return string
*/
public function getResourceName(): string
{
return ServerVariable::RESOURCE_NAME;
}
/**
* Return a generic transformed server variable array.
*

View file

@ -14,6 +14,16 @@ class UserTransformer extends BaseTransformer
*/
protected $availableIncludes = ['servers'];
/**
* Return the resource name for the JSONAPI output.
*
* @return string
*/
public function getResourceName(): string
{
return User::RESOURCE_NAME;
}
/**
* Return a generic transformed subuser array.
*

View file

@ -23,7 +23,8 @@ class AddApiKeyPermissionColumns extends Migration
$table->unsignedTinyInteger('r_locations')->default(0);
$table->unsignedTinyInteger('r_nests')->default(0);
$table->unsignedTinyInteger('r_eggs')->default(0);
$table->unsignedTinyInteger('r_databases')->default(0);
$table->unsignedTinyInteger('r_database_hosts')->default(0);
$table->unsignedTinyInteger('r_server_databases')->default(0);
$table->unsignedTinyInteger('r_packs')->default(0);
});
}
@ -52,7 +53,8 @@ class AddApiKeyPermissionColumns extends Migration
'r_locations',
'r_nests',
'r_eggs',
'r_databases',
'r_database_hosts',
'r_server_databases',
'r_packs',
]);
});

View file

@ -82,4 +82,15 @@ Route::group(['prefix' => '/servers'], function () {
Route::delete('/{server}', 'Servers\ServerController@delete');
Route::delete('/{server}/{force?}', 'Servers\ServerController@delete');
// Database Management Endpoint
Route::group(['prefix' => '/{server}/databases'], function () {
Route::get('/', 'Servers\DatabaseController@index')->name('api.application.servers.databases');
Route::get('/{database}', 'Servers\DatabaseController@view')->name('api.application.servers.databases.view');
Route::post('/', 'Servers\DatabaseController@store');
Route::patch('/{database}', 'Servers\DatabaseController@update');
Route::delete('/{database}', 'Servers\DatabaseController@delete');
});
});