Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for admin/databases creation through application api #5222

Open
1 task done
CODEHUBHQ opened this issue Sep 26, 2024 · 0 comments
Open
1 task done

Add support for admin/databases creation through application api #5222

CODEHUBHQ opened this issue Sep 26, 2024 · 0 comments
Labels
feature request A request for a new feature.

Comments

@CODEHUBHQ
Copy link

CODEHUBHQ commented Sep 26, 2024

Is there an existing feature request for this?

  • I have searched the existing issues before opening this feature request.

Describe the feature you would like to see.

It would be great if the panel has the ability to create admin/databases using api-application route instead of creating the database host manulally.

Describe the solution you'd like.

I think we can add the following to api-application route
in the file routes\api-application.php we can add Route::post('/', [Admin\DatabaseController::class, 'create']);

under Endpoint: /api/application/nodes and modify the create method instead of returning redirect response to be the same as the return response from this endpoint Route::post('/', [Application\Servers\DatabaseController::class, 'store']);

this way we can call api/application/nodes/admin/databases and create a the host database

Simple workaround was to add the following code to panel api-application.

1- routes/api-application.php

// added use admin controller at the top
use Pterodactyl\Http\Controllers\Admin;

/*
|--------------------------------------------------------------------------
| Node Controller Routes
|--------------------------------------------------------------------------
|
| Endpoint: /api/application/nodes
|
*/
Route::group(['prefix' => '/nodes'], function () {
    // databases
    Route::post('/admin/databases', [Admin\DatabaseController::class, 'createdb']);
    Route::delete('/admin/databases/{host:id}', [Admin\DatabaseController::class, 'deletedb']);

    ... the rest of the code
});

2- app/Http/Controllers/Admin/DatabaseController.php

// added use Response at the top
use Illuminate\Http\Response;

/**
* Handle request to create a new database host.
*
* @throws \Throwable
*/
public function createdb(DatabaseHostFormRequest $request): Response
{
    $host = $this->creationService->handle($request->normalize());

    return response($host, 200);
}

/**
* Handle request to delete a database host.
*
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
*/
public function deletedb(int $host): Response
{
    $this->deletionService->handle($host);

    return response('', 204);
}
@CODEHUBHQ CODEHUBHQ added the feature request A request for a new feature. label Sep 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A request for a new feature.
Projects
None yet
Development

No branches or pull requests

1 participant