diff --git a/config/api_platform/SoftwareProfile.yaml b/config/api_platform/SoftwareProfile.yaml index b969510..aaf6a12 100644 --- a/config/api_platform/SoftwareProfile.yaml +++ b/config/api_platform/SoftwareProfile.yaml @@ -11,8 +11,8 @@ resources: ApiPlatform\Metadata\GetCollection: provider: App\State\Provider\SoftwareProfileProvider filters: - - 'api_platform.filter.software.order' - - 'api_platform.filter.software.search' + - 'api_platform.filter.software_profile.order' + - 'api_platform.filter.software_profile.search' ApiPlatform\Metadata\Get: provider: App\State\Provider\SoftwareProfileProvider diff --git a/config/services/api_platform.yaml b/config/services/api_platform.yaml index 395822c..d27362a 100644 --- a/config/services/api_platform.yaml +++ b/config/services/api_platform.yaml @@ -173,6 +173,18 @@ services: arguments: [ { 'id': 'exact', 'name': 'partial', type: 'exact'} ] tags: [ 'api_platform.filter' ] + api_platform.filter.software_profile.order: + parent: 'api_platform.doctrine.orm.order_filter' + arguments: + $properties: { 'id': ~, 'description': ~ } + $orderParameterName: 'order' + tags: [ 'api_platform.filter' ] + + api_platform.filter.software_profile.search: + parent: 'api_platform.doctrine.orm.search_filter' + arguments: [ { 'id': 'exact', 'description': 'partial' } ] + tags: [ 'api_platform.filter' ] + api_platform.filter.subnet.order: parent: 'api_platform.doctrine.orm.order_filter' arguments: diff --git a/src/Controller/OgBoot/OgLive/Webhook/InstallOgLiveResponseAction.php b/src/Controller/OgBoot/OgLive/Webhook/InstallOgLiveResponseAction.php index f5e7cbc..3c06b6c 100644 --- a/src/Controller/OgBoot/OgLive/Webhook/InstallOgLiveResponseAction.php +++ b/src/Controller/OgBoot/OgLive/Webhook/InstallOgLiveResponseAction.php @@ -38,15 +38,13 @@ class InstallOgLiveResponseAction extends AbstractController { $data = json_decode($request->getContent(), true); - if ($data === null || !isset($data['message'], $data['ogCoreId'], $data['details'])) { + if ($data === null || !isset($data['message'], $data['ogCoreId'], $data['status'])) { return new JsonResponse(['error' => 'Invalid or incomplete JSON data'], Response::HTTP_BAD_REQUEST); } $message = $data['message']; $ogCoreId = $data['ogCoreId']; - $details = $data['details']; $status = $data['status']; - $result = $status === self::OG_LIVE_INSTALL_SUCCESS ? $details['result'] : []; $ogLive = $this->entityManager->getRepository(OgLive::class)->findOneBy(['uuid' => $ogCoreId]); @@ -58,22 +56,22 @@ class InstallOgLiveResponseAction extends AbstractController return new JsonResponse(['error' => 'OgLive is already active'], Response::HTTP_BAD_REQUEST); } - $this->updateOgLive($ogLive, $details, $result, $status); + $this->updateOgLive($ogLive, $message, $status); return new JsonResponse(data: sprintf('OgLive %s updated successfully', $ogLive->getChecksum()), status: Response::HTTP_OK); } - private function updateOgLive (OgLive $ogLive, array $details, array $result, string $status): void + private function updateOgLive (OgLive $ogLive, array $details, string $status): void { if ($status === self::OG_LIVE_INSTALL_SUCCESS) { $ogLive->setInstalled(true); $ogLive->setSynchronized(true); - $ogLive->setChecksum($result['id']); - $ogLive->setDistribution($result['distribution']); - $ogLive->setKernel($result['kernel']); - $ogLive->setArchitecture($result['architecture']); - $ogLive->setRevision($result['revision']); - $ogLive->setDirectory($result['directory']); + $ogLive->setChecksum($details['id']); + $ogLive->setDistribution($details['distribution']); + $ogLive->setKernel($details['kernel']); + $ogLive->setArchitecture($details['architecture']); + $ogLive->setRevision($details['revision']); + $ogLive->setDirectory($details['directory']); } $ogLive->setStatus($status === self::OG_LIVE_INSTALL_SUCCESS ? OgLiveStatus::ACTIVE : OgLiveStatus::FAILED); diff --git a/src/Dto/Input/PartitionArrayInput.php b/src/Dto/Input/PartitionArrayInput.php deleted file mode 100644 index f4303d7..0000000 --- a/src/Dto/Input/PartitionArrayInput.php +++ /dev/null @@ -1,20 +0,0 @@ -setSize($this->size * 100); $partition->setCacheContent($this->cacheContent); $partition->setFilesystem($this->filesystem); - $partition->setOperativeSystem($this->operativeSystem->getEntity()); + + if ($this->operativeSystem) { + $partition->setOperativeSystem($this->operativeSystem->getEntity()); + } $partition->setClient($this->client->getEntity()); $partition->setMemoryUsage($this->memoryUsage * 100); - $partition->setImage($this->image->getEntity()); + + if ($this->image) { + $partition->setImage($this->image->getEntity()); + } return $partition; } diff --git a/src/Dto/Input/SoftwareProfileInput.php b/src/Dto/Input/SoftwareProfileInput.php index c803d82..87ee072 100644 --- a/src/Dto/Input/SoftwareProfileInput.php +++ b/src/Dto/Input/SoftwareProfileInput.php @@ -3,6 +3,7 @@ namespace App\Dto\Input; use ApiPlatform\Metadata\ApiProperty; +use App\Dto\Output\OperativeSystemOutput; use App\Dto\Output\OrganizationalUnitOutput; use App\Entity\SoftwareProfile; use Symfony\Component\Serializer\Annotation\Groups; @@ -21,6 +22,11 @@ final class SoftwareProfileInput #[ApiProperty(description: 'The organizational unit of the software profile')] public ?OrganizationalUnitOutput $organizationalUnit = null; + #[Groups(['software-profile:write'])] + #[ApiProperty(description: 'The operative system of the software profile')] + public ?OperativeSystemOutput $operativeSystem = null; + + public function __construct(?SoftwareProfile $softwareProfile = null) { if (!$softwareProfile) { @@ -32,6 +38,10 @@ final class SoftwareProfileInput if($softwareProfile->getOrganizationalUnit()) { $this->organizationalUnit = new OrganizationalUnitOutput($softwareProfile->getOrganizationalUnit()); } + + if($softwareProfile->getOperativeSystem()) { + $this->operativeSystem = new OperativeSystemOutput($softwareProfile->getOperativeSystem()); + } } public function createOrUpdateEntity(?SoftwareProfile $softwareProfile = null): SoftwareProfile @@ -46,6 +56,10 @@ final class SoftwareProfileInput $softwareProfile->setOrganizationalUnit($this->organizationalUnit->getEntity()); } + if ($this->operativeSystem) { + $softwareProfile->setOperativeSystem($this->operativeSystem->getEntity()); + } + return $softwareProfile; } } \ No newline at end of file diff --git a/src/State/Provider/ImageProvider.php b/src/State/Provider/ImageProvider.php index d807b4a..be46ddc 100644 --- a/src/State/Provider/ImageProvider.php +++ b/src/State/Provider/ImageProvider.php @@ -52,7 +52,7 @@ readonly class ImageProvider implements ProviderInterface $item = $this->itemProvider->provide($operation, $uriVariables, $context); if (!$item) { - throw new NotFoundHttpException('Menu not found'); + throw new NotFoundHttpException('Image not found'); } return new ImageOutput($item);