Lance Pioch da195fd2fe
PHPstan updates (#1047)
* Not found property rule

* Make these “better”

* Day 1

* Day 2

* Day 3

* Dat 4

* Remove disabled check

* Day 4 continued

* Run pint

* Final changes hopefully

* Pint fixes

* Fix again

* Reset these

* Update app/Filament/Admin/Pages/Health.php

Co-authored-by: MartinOscar <40749467+rmartinoscar@users.noreply.github.com>

* Update app/Traits/CheckMigrationsTrait.php

Co-authored-by: MartinOscar <40749467+rmartinoscar@users.noreply.github.com>

---------

Co-authored-by: MartinOscar <40749467+rmartinoscar@users.noreply.github.com>
2025-03-03 14:41:19 -05:00

44 lines
1.4 KiB
PHP

<?php
namespace App\Http\Controllers\Api\Application\Nodes;
use App\Services\Deployment\FindViableNodesService;
use App\Transformers\Api\Application\NodeTransformer;
use App\Http\Controllers\Api\Application\ApplicationApiController;
use App\Http\Requests\Api\Application\Nodes\GetDeployableNodesRequest;
use Dedoc\Scramble\Attributes\Group;
#[Group('Node', weight: 2)]
class NodeDeploymentController extends ApplicationApiController
{
public function __construct(private FindViableNodesService $viableNodesService)
{
parent::__construct();
}
/**
* Get deployable nodes
*
* Finds any nodes that are available using the given deployment criteria. This works
* similarly to the server creation process, but allows you to pass the deployment object
* to this endpoint and get back a list of all Nodes satisfying the requirements.
*
* @return array<mixed>
*/
public function __invoke(GetDeployableNodesRequest $request): array
{
$data = $request->validated();
$nodes = $this->viableNodesService->handle(
$data['memory'] ?? 0,
$data['disk'] ?? 0,
$data['cpu'] ?? 0,
$data['tags'] ?? $data['location_ids'] ?? [],
);
return $this->fractal->collection($nodes)
->transformWith($this->getTransformer(NodeTransformer::class))
->toArray();
}
}