getId()) { throw new BadRequestHttpException('Id is required'); } $params = [ 'json' => [ 'mask' => $data->getNetmask(), 'address' => $data->getIpAddress(), 'nextServer' => $data->getNextServer(), 'bootFileName' => $data->getBootFileName(), 'router' => $data->getRouter(), 'DNS' => $data->getDns() ] ]; $dhcpServer = $data->getDhcpServer(); if (!$dhcpServer) { throw new \Exception('La subred no tiene un servidor DHCP asociado.'); } $port = $dhcpServer->getApiPort() ?? 8081; $url = sprintf('http://%s:%d/ogdhcp/v1/subnets/%d', $dhcpServer->getIp(), $port, $data->getServerId()); $content = $this->createRequest('PUT', $url, $params); $this->entityManager->persist($data); $this->entityManager->flush(); return new JsonResponse(data: $content, status: Response::HTTP_OK); } }