API: ability to search for an allocation based on the assigned server id (#194)
This commit is contained in:
parent
e3587966e2
commit
f687fab9a2
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in New Issue