clients as $clientEntity) { /** @var Client $client */ $client = $clientEntity->getEntity(); if (!$client->getIp()) { throw new BadRequestHttpException('IP is required'); } $endpoint = $client->getStatus() === ClientStatus::OG_LIVE ? 'opengnsys/Reiniciar' : '/opengnsys/reboot'; $data = [ 'nfn' => 'Reiniciar', 'ids' => '0' ]; $response = $this->createRequest( method: 'POST', url: 'https://'.$client->getIp().':8000/'.$endpoint, params: [ 'json' => $data, ], token: $client->getToken(), ); if (isset($response['error']) && $response['code'] === Response::HTTP_INTERNAL_SERVER_ERROR) { throw new BadRequestHttpException('Error deploying image'); } $this->logger->info('Rebooting client', ['client' => $client->getId()]); $jobId = $response['job_id']; $client->setStatus(ClientStatus::INITIALIZING); $this->entityManager->persist($client); $this->entityManager->flush(); $this->createService->__invoke($client, CommandTypes::REBOOT, TraceStatus::SUCCESS, $jobId, []); } return new JsonResponse(data: $client, status: Response::HTTP_OK); } }