refs #2137. Removed subred fixed
testing/ogcore-api/pipeline/head There was a failure building this commit
Details
testing/ogcore-api/pipeline/head There was a failure building this commit
Details
parent
6abf065dec
commit
b86e51e1bb
|
@ -7,6 +7,7 @@ use App\Entity\Subnet;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpKernel\Attribute\AsController;
|
use Symfony\Component\HttpKernel\Attribute\AsController;
|
||||||
|
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||||
use Symfony\Component\Validator\Exception\ValidatorException;
|
use Symfony\Component\Validator\Exception\ValidatorException;
|
||||||
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
|
||||||
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
|
||||||
|
@ -29,11 +30,23 @@ class DeleteAction extends AbstractOgDhcpController
|
||||||
throw new ValidatorException('Data Id is required');
|
throw new ValidatorException('Data Id is required');
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = $this->createRequest('DELETE', 'http://'.$this->ogDhcpApiUrl.'/ogdhcp/v1/subnets/'.$data->getServerId());
|
try {
|
||||||
|
$content = $this->createRequest(
|
||||||
|
'DELETE',
|
||||||
|
'http://' . $this->ogDhcpApiUrl . '/ogdhcp/v1/subnets/' . $data->getServerId()
|
||||||
|
);
|
||||||
|
} catch (HttpException $e) {
|
||||||
|
if ($e->getStatusCode() === 404) {
|
||||||
|
$content = ['message' => 'Subnet not found on external API, proceeding with local deletion'];
|
||||||
|
} else {
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->entityManager->remove($data);
|
$this->entityManager->remove($data);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
|
||||||
return new JsonResponse(data: $content, status: Response::HTTP_OK);
|
return new JsonResponse(data: $content, status: Response::HTTP_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue