Skip to content

Commit

Permalink
update application API routes
Browse files Browse the repository at this point in the history
  • Loading branch information
ericwang401 committed Dec 5, 2023
1 parent 3e627ef commit d785179
Showing 1 changed file with 181 additions and 28 deletions.
209 changes: 181 additions & 28 deletions routes/api-application.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,199 @@
use Convoy\Http\Middleware\Admin\Server\ValidateServerStatusMiddleware;
use Illuminate\Support\Facades\Route;

Route::apiResource('locations', Admin\LocationController::class)
->only(['index', 'store', 'update', 'destroy']);
/*
|--------------------------------------------------------------------------
| Location Controller Routes
|--------------------------------------------------------------------------
|
| Endpoint: /api/application/locations
|
*/
Route::prefix('/locations')->group(function () {
Route::get('/', [Admin\LocationController::class, 'index']);
Route::post('/', [Admin\LocationController::class, 'store']);

Route::apiResource('nodes', Admin\Nodes\NodeController::class)
->only(['index', 'show', 'store', 'update', 'destroy']);
Route::prefix('/{location}')->group(function () {
Route::put('/', [Admin\LocationController::class, 'update']);
Route::delete('/', [Admin\LocationController::class, 'destroy']);
});
});

/*
|--------------------------------------------------------------------------
| Node Controller Routes
|--------------------------------------------------------------------------
|
| Endpoint: /api/application/nodes
|
*/
Route::prefix('/nodes')->group(function () {
Route::get('/', [Admin\Nodes\NodeController::class, 'index']);
Route::post('/', [Admin\Nodes\NodeController::class, 'store']);

Route::prefix('/{node}')->group(function () {
Route::get('/', [Admin\Nodes\NodeController::class, 'show']);
Route::put('/', [Admin\Nodes\NodeController::class, 'update']);
Route::delete('/', [Admin\Nodes\NodeController::class, 'destroy']);

/*
|--------------------------------------------------------------------------
| Node ISOs Controller Routes
|--------------------------------------------------------------------------
|
| Endpoint: /api/application/nodes/{node}/isos
|
*/
Route::apiResource('/isos', Admin\Nodes\IsoController::class)
->only(['index', 'store', 'update', 'destroy']);

/*
|--------------------------------------------------------------------------
| Node Templates Controller Routes
|--------------------------------------------------------------------------
|
| Endpoint: /api/application/nodes/{node}/template-groups
|
*/
Route::prefix('/template-groups')->group(function () {
Route::get('/', [Admin\Nodes\TemplateGroupController::class, 'index']);
Route::post('/', [Admin\Nodes\TemplateGroupController::class, 'store']);
Route::post(
'/reorder', [Admin\Nodes\TemplateGroupController::class, 'updateOrder'],
);

Route::prefix('/{template_group}')->group(function () {
Route::put('/', [Admin\Nodes\TemplateGroupController::class, 'update']);
Route::delete('/', [Admin\Nodes\TemplateGroupController::class, 'destroy']);
Route::prefix('/templates')->group(function () {
Route::get('/', [Admin\Nodes\TemplateController::class, 'index']);
Route::post('/', [Admin\Nodes\TemplateController::class, 'store']);
Route::post(
'/reorder',
[Admin\Nodes\TemplateController::class, 'updateOrder'],
);

Route::get('/{template}', [Admin\Nodes\TemplateController::class, 'show']);
Route::delete('/{template}', [Admin\Nodes\TemplateController::class, 'destroy'],
);
});

Route::prefix('/nodes/{node}')->group(function () {
Route::apiResource('/isos', Admin\Nodes\IsoController::class)
->only(['index', 'store', 'update', 'destroy']);
Route::apiResource('templates', Admin\Nodes\TemplateController::class)
->only(['index', 'store', 'update', 'destroy']);
});
});

Route::apiResource('template-groups', Admin\Nodes\TemplateGroupController::class)
->only(['index', 'store', 'update', 'destroy']);
Route::post('/template-groups/reorder', [Admin\Nodes\TemplateGroupController::class, 'updateOrder']);
/*
|--------------------------------------------------------------------------
| Node Addresses Controller Routes
|--------------------------------------------------------------------------
|
| Endpoint: /api/application/nodes/{node}/addresses
|
*/
Route::apiResource('addresses', Admin\Nodes\AddressController::class)
->only(['index', 'store', 'update', 'destroy']);

Route::apiResource('template-groups.templates', Admin\Nodes\TemplateController::class)
->only(['index', 'store', 'update', 'destroy']);
Route::post('/template-groups/{template_group}/templates/reorder', [Admin\Nodes\TemplateController::class, 'updateOrder']);
/*
|--------------------------------------------------------------------------
| Node Helpers Routes
|--------------------------------------------------------------------------
*/
Route::get('/tools/query-remote-file', [Admin\Nodes\IsoController::class, 'queryLink']);
});
});

/*
|--------------------------------------------------------------------------
| Server Controller Routes
|--------------------------------------------------------------------------
|
| Endpoint: /api/application/servers
|
*/
Route::prefix('/servers')->group(function () {
Route::get('/', [Admin\ServerController::class, 'index']);
Route::post('/', [Admin\ServerController::class, 'store']);

Route::group(['prefix' => '/{server}', 'middleware' => ValidateServerStatusMiddleware::class],
function () {
Route::get('/', [Admin\ServerController::class, 'show'])->withoutMiddleware(
ValidateServerStatusMiddleware::class,
);
Route::patch('/', [Admin\ServerController::class, 'update'])->withoutMiddleware(
ValidateServerStatusMiddleware::class,
);
Route::delete('/', [Admin\ServerController::class, 'destroy']);

Route::apiResource('addresses', Admin\Nodes\AddressController::class)
->only(['index', 'store', 'update', 'destroy']);
Route::prefix('/settings')->group(function () {
Route::patch('/build', [Admin\ServerController::class, 'updateBuild']);

Route::get('/tools/query-remote-file', [Admin\Nodes\IsoController::class, 'queryLink']);
Route::post('/suspend', [Admin\ServerController::class, 'suspend']);
Route::post('/unsuspend', [Admin\ServerController::class, 'unsuspend']);
});
});
});

Route::get('/servers', [Admin\ServerController::class, 'index']);
Route::post('/servers', [Admin\ServerController::class, 'store']);
Route::prefix('/servers/{server}')->middleware(ValidateServerStatusMiddleware::class)->group(function () {
Route::get('/', [Admin\ServerController::class, 'show'])->withoutMiddleware(ValidateServerStatusMiddleware::class);
Route::patch('/', [Admin\ServerController::class, 'update'])->withoutMiddleware(ValidateServerStatusMiddleware::class);
Route::delete('/', [Admin\ServerController::class, 'destroy']);
/*
|--------------------------------------------------------------------------
| Address Pool Controller Routes
|--------------------------------------------------------------------------
|
| Endpoint: /api/application/address-pools
|
*/
Route::prefix('/address-pools')->group(function () {
Route::get('/', [Admin\AddressPools\AddressPoolController::class, 'index']);
Route::post('/', [Admin\AddressPools\AddressPoolController::class, 'store']);

Route::prefix('/settings')->group(function () {
Route::patch('/build', [Admin\ServerController::class, 'updateBuild']);
Route::prefix('/{address_pool}')->group(function () {
Route::get('/', [Admin\AddressPools\AddressPoolController::class, 'show']);
Route::put('/', [Admin\AddressPools\AddressPoolController::class, 'update']);
Route::delete('/', [Admin\AddressPools\AddressPoolController::class, 'destroy']);
Route::get(
'/attached-nodes',
[Admin\AddressPools\AddressPoolController::class, 'getAttachedNodes'],
);

Route::post('/suspend', [Admin\ServerController::class, 'suspend']);
Route::post('/unsuspend', [Admin\ServerController::class, 'unsuspend']);
Route::prefix('/addresses')->group(function () {
Route::get('/', [Admin\AddressPools\AddressController::class, 'index']);
Route::post('/', [Admin\AddressPools\AddressController::class, 'store']);
Route::put('/{address}', [Admin\AddressPools\AddressController::class, 'update']);
Route::delete('/{address}', [Admin\AddressPools\AddressController::class, 'destroy']);
});
});
});

/*
|--------------------------------------------------------------------------
| User Controller Routes
|--------------------------------------------------------------------------
|
| Endpoint: /api/application/users
|
*/
Route::apiResource('users', Admin\UserController::class)
->only(['index', 'show', 'store', 'update', 'destroy']);
->only(['index', 'show', 'store', 'update', 'destroy']);

Route::post('/users/{user}/generate-sso-token', [Admin\UserController::class, 'getSSOToken']);
/*
|--------------------------------------------------------------------------
| Coterm Controller Routes
|--------------------------------------------------------------------------
|
| Endpoint: /api/application/coterms
|
*/

Route::prefix('/coterms')->group(function () {
Route::get('/', [Admin\CotermController::class, 'index']);
Route::post('/', [Admin\CotermController::class, 'store']);

Route::prefix('/{coterm}')->group(function () {
Route::get('/', [Admin\CotermController::class, 'show']);
Route::put('/', [Admin\CotermController::class, 'update']);
Route::post('/reset-coterm-token', [Admin\CotermController::class, 'resetCotermToken']);
Route::delete('/', [Admin\CotermController::class, 'destroy']);
Route::get('/nodes', [Admin\CotermController::class, 'getAttachedNodes']);
Route::put('/nodes', [Admin\CotermController::class, 'updateAttachedNodes']);
});
});

0 comments on commit d785179

Please sign in to comment.