Path: blob/1.0-develop/app/Http/Controllers/Api/Application/Nodes/NodeDeploymentController.php
10277 views
<?php12namespace Pterodactyl\Http\Controllers\Api\Application\Nodes;34use Pterodactyl\Services\Deployment\FindViableNodesService;5use Pterodactyl\Transformers\Api\Application\NodeTransformer;6use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController;7use Pterodactyl\Http\Requests\Api\Application\Nodes\GetDeployableNodesRequest;89class NodeDeploymentController extends ApplicationApiController10{11/**12* NodeDeploymentController constructor.13*/14public function __construct(private FindViableNodesService $viableNodesService)15{16parent::__construct();17}1819/**20* Finds any nodes that are available using the given deployment criteria. This works21* similarly to the server creation process, but allows you to pass the deployment object22* to this endpoint and get back a list of all Nodes satisfying the requirements.23*24* @throws \Pterodactyl\Exceptions\Service\Deployment\NoViableNodeException25*/26public function __invoke(GetDeployableNodesRequest $request): array27{28$data = $request->validated();29$nodes = $this->viableNodesService->setLocations($data['location_ids'] ?? [])30->setMemory($data['memory'])31->setDisk($data['disk'])32->handle($request->query('per_page'), $request->query('page'));3334return $this->fractal->collection($nodes)35->transformWith($this->getTransformer(NodeTransformer::class))36->toArray();37}38}394041