diff --git a/app/Http/Controllers/API/NodeController.php b/app/Http/Controllers/API/NodeController.php index 6a60427b4..50c16ad0d 100755 --- a/app/Http/Controllers/API/NodeController.php +++ b/app/Http/Controllers/API/NodeController.php @@ -228,6 +228,32 @@ class NodeController extends BaseController } return $allocations; } + + /** + * List Node Allocation based on assigned to ID + * + * Returns a listing of the allocation for the specified server id. + * + * @Get("/nodes/allocations/{id}") + * @Versions({"v1"}) + * @Response(200) + */ + public function allocationsView(Request $request, $id) + { + $query = Models\Allocation::where('assigned_to', $id)->get(); + try { + + if (empty($query)) { + throw new NotFoundHttpException('No allocations for that server were found.'); + } + + return $query; + } catch (NotFoundHttpException $ex) { + throw $ex; + } catch (\Exception $ex) { + throw new BadRequestHttpException('There was an issue with the fields passed in the request.'); + } + } /** * Delete Node diff --git a/app/Http/Routes/APIRoutes.php b/app/Http/Routes/APIRoutes.php index 33d3d7177..b08da5a61 100755 --- a/app/Http/Routes/APIRoutes.php +++ b/app/Http/Routes/APIRoutes.php @@ -140,6 +140,11 @@ class APIRoutes 'uses' => 'Pterodactyl\Http\Controllers\API\NodeController@allocations' ]); + $api->get('nodes/allocations/{id}', [ + 'as' => 'api.admin.nodes.allocations', + 'uses' => 'Pterodactyl\Http\Controllers\API\NodeController@allocationsView' + ]); + $api->get('nodes/{id}', [ 'as' => 'api.admin.nodes.view', 'uses' => 'Pterodactyl\Http\Controllers\API\NodeController@view'