File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed
Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -228,6 +228,32 @@ public function allocations(Request $request)
228228 }
229229 return $ allocations ;
230230 }
231+
232+ /**
233+ * List Node Allocation based on assigned to ID
234+ *
235+ * Returns a listing of the allocation for the specified server id.
236+ *
237+ * @Get("/nodes/allocations/{id}")
238+ * @Versions({"v1"})
239+ * @Response(200)
240+ */
241+ public function allocationsView (Request $ request , $ id )
242+ {
243+ $ query = Models \Allocation::where ('assigned_to ' , $ id )->get ();
244+ try {
245+
246+ if (empty ($ query )) {
247+ throw new NotFoundHttpException ('No allocations for that server were found. ' );
248+ }
249+
250+ return $ query ;
251+ } catch (NotFoundHttpException $ ex ) {
252+ throw $ ex ;
253+ } catch (\Exception $ ex ) {
254+ throw new BadRequestHttpException ('There was an issue with the fields passed in the request. ' );
255+ }
256+ }
231257
232258 /**
233259 * Delete Node
Original file line number Diff line number Diff line change @@ -140,6 +140,11 @@ public function map(Router $router) {
140140 'uses ' => 'Pterodactyl\Http\Controllers\API\NodeController@allocations '
141141 ]);
142142
143+ $ api ->get ('nodes/allocations/{id} ' , [
144+ 'as ' => 'api.admin.nodes.allocations ' ,
145+ 'uses ' => 'Pterodactyl\Http\Controllers\API\NodeController@allocationsView '
146+ ]);
147+
143148 $ api ->get ('nodes/{id} ' , [
144149 'as ' => 'api.admin.nodes.view ' ,
145150 'uses ' => 'Pterodactyl\Http\Controllers\API\NodeController@view '
You can’t perform that action at this time.
0 commit comments