50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Controller\OgDhcp\Subnet;
|
|
|
|
use App\Controller\OgDhcp\AbstractOgDhcpController;
|
|
use App\Dto\Input\SubnetAddHostInput;
|
|
use App\Entity\Client;
|
|
use App\Entity\Subnet;
|
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\HttpKernel\Attribute\AsController;
|
|
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
|
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
|
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
|
|
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
|
|
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
|
|
|
#[AsController]
|
|
class PutHostAction extends AbstractOgDhcpController
|
|
{
|
|
/**
|
|
* @throws TransportExceptionInterface
|
|
* @throws ServerExceptionInterface
|
|
* @throws RedirectionExceptionInterface
|
|
* @throws ClientExceptionInterface
|
|
*/
|
|
public function __invoke(SubnetAddHostInput $input, Subnet $subnet): JsonResponse
|
|
{
|
|
$clients = $input->clients;
|
|
|
|
foreach ($clients as $client) {
|
|
/** @var Client $clientEntity */
|
|
$clientEntity = $client->getEntity();
|
|
$data = [
|
|
'host' => $clientEntity->getName(),
|
|
'oldMacAddress' => '',
|
|
'macAddress' => '',
|
|
'address' => '',
|
|
];
|
|
|
|
$params = [
|
|
'json' => $data
|
|
];
|
|
|
|
$content = $this->createRequest('PUT', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$subnet->getId().'/hosts', $params);
|
|
}
|
|
|
|
return new JsonResponse(status: Response::HTTP_OK);
|
|
}
|
|
} |