refs #952. First revision status endpoint ogAgent
testing/ogcore-api/pipeline/head Something is wrong with the build of this commit Details

develop-jenkins
Manuel Aranda Rosales 2024-10-22 22:07:27 +02:00
parent 4aa03d643e
commit 14ff759309
2 changed files with 8 additions and 5 deletions

View File

@ -46,17 +46,20 @@ class StatusAction extends AbstractController
try {
$response = $this->httpClient->request('POST', 'https://'.$client->getIp().':8000/ogAdmClient/status');
} catch (TransportExceptionInterface $e) {
$client->setStatus('off');
$this->entityManager->persist($client);
$this->entityManager->flush();
return new JsonResponse( data: 'An error occurred', status: Response::HTTP_INTERNAL_SERVER_ERROR);
}
$client->setStatus('active');
$this->entityManager->persist($client);
$this->entityManager->flush();
} catch (TransportExceptionInterface $e) {
$client->setStatus('off');
$this->entityManager->persist($client);
$this->entityManager->flush();
return new JsonResponse( data: 'An error occurred', status: Response::HTTP_INTERNAL_SERVER_ERROR);
}
return new JsonResponse(status: Response::HTTP_OK);
}
}

View File

@ -64,7 +64,7 @@ final class ClientInput
description: 'El estado del cliente',
example: 'active'
)]
public ?string $status = 'power-off';
public ?string $status = 'off';
#[Assert\NotNull(message: 'validators.organizational_unit.not_null')]
#[Groups(['client:write', 'client:patch'])]