2020-04-12 17:20:09 -07:00
|
|
|
<?php
|
|
|
|
|
|
2024-03-12 22:39:16 -04:00
|
|
|
namespace App\Http\Controllers\Admin;
|
2020-04-12 17:20:09 -07:00
|
|
|
|
2024-03-12 22:39:16 -04:00
|
|
|
use App\Models\Node;
|
|
|
|
|
use App\Http\Controllers\Controller;
|
2024-10-27 02:43:19 +02:00
|
|
|
use App\Services\Nodes\NodeAutoDeployService;
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
use Illuminate\Http\JsonResponse;
|
2020-04-12 17:20:09 -07:00
|
|
|
|
|
|
|
|
class NodeAutoDeployController extends Controller
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* NodeAutoDeployController constructor.
|
|
|
|
|
*/
|
|
|
|
|
public function __construct(
|
2024-10-27 02:43:19 +02:00
|
|
|
private readonly NodeAutoDeployService $nodeAutoDeployService
|
2020-04-12 17:20:09 -07:00
|
|
|
) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-10-27 02:43:19 +02:00
|
|
|
* Handles the API request and returns the deployment command.
|
2020-04-12 17:20:09 -07:00
|
|
|
*
|
2024-03-12 22:39:16 -04:00
|
|
|
* @throws \App\Exceptions\Model\DataValidationException
|
2020-04-12 17:20:09 -07:00
|
|
|
*/
|
2022-10-14 10:59:20 -06:00
|
|
|
public function __invoke(Request $request, Node $node): JsonResponse
|
2020-04-12 17:20:09 -07:00
|
|
|
{
|
2024-10-27 02:43:19 +02:00
|
|
|
$command = $this->nodeAutoDeployService->handle($request, $node);
|
2020-04-12 17:20:09 -07:00
|
|
|
|
2024-10-27 02:43:19 +02:00
|
|
|
return new JsonResponse(['command' => $command]);
|
2020-04-12 17:20:09 -07:00
|
|
|
}
|
|
|
|
|
}
|