ogcore/src/Dto/Output/NetworkSettingsOutput.php

210 lines
7.0 KiB
PHP

<?php
namespace App\Dto\Output;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\Get;
use App\Entity\NetworkSettings;
use Symfony\Component\Serializer\Annotation\Groups;
#[Get(shortName: 'NetworkSettings')]
final class NetworkSettingsOutput extends AbstractOutput
{
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
#[ApiProperty(
description: 'La dirección del servidor TFTP siguiente',
example: '192.168.1.10'
)]
public ?string $nextServer = null;
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
#[ApiProperty(
description: 'El nombre del archivo de arranque',
example: 'pxelinux.0'
)]
public ?string $bootFileName = null;
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
#[ApiProperty(
description: 'La dirección del servidor proxy',
example: 'http://proxy.example.com:8080'
)]
public ?string $proxy = null;
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
#[ApiProperty(
description: 'La dirección del servidor DNS',
example: '8.8.8.8'
)]
public ?string $dns = null;
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
#[ApiProperty(
description: 'La máscara de subred',
example: '255.255.255.0'
)]
public ?string $netmask = null;
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
#[ApiProperty(
description: 'La dirección del router/gateway',
example: '192.168.1.1'
)]
public ?string $router = null;
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
#[ApiProperty(
description: 'La dirección del servidor NTP',
example: 'time.google.com'
)]
public ?string $ntp = null;
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
#[ApiProperty(
description: 'La interfaz de red',
example: 'eth0'
)]
public ?string $netiface = null;
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
#[ApiProperty(
description: 'El modo de transferencia punto a punto',
example: 'full'
)]
public ?string $p2pMode = null;
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
#[ApiProperty(
description: 'Tiempo de transferencia P2P en segundos',
example: 300
)]
public ?int $p2pTime = null;
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
#[ApiProperty(
description: 'La dirección IP multicast',
example: '239.194.2.11'
)]
public ?string $mcastIp = null;
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
#[ApiProperty(
description: 'La velocidad multicast en Mbps',
example: 100
)]
public ?int $mcastSpeed = null;
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
#[ApiProperty(
description: 'El puerto multicast',
example: 9000
)]
public ?int $mcastPort = null;
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
#[ApiProperty(
description: 'El modo multicast',
example: 'full-duplex'
)]
public ?string $mcastMode = null;
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
#[ApiProperty(
description: 'El menú de arranque configurado',
example: null
)]
public ?MenuOutput $menu = null;
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
#[ApiProperty(
description: 'El perfil de hardware configurado',
example: null
)]
public ?HardwareProfileOutput $hardwareProfile = null;
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
#[ApiProperty(
description: 'La imagen OGLive configurada',
example: null
)]
public ?OgLiveOutput $ogLive = null;
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
#[ApiProperty(
description: 'El repositorio de imágenes configurado',
example: null
)]
public ?ImageRepositoryOutput $repository = null;
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
#[ApiProperty(
description: 'La plantilla PXE configurada',
example: null
)]
public ?PxeTemplateOutput $pxeTemplate = null;
#[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
#[ApiProperty(
description: 'La ruta compartida de OGAgent',
example: '/opt/opengnsys/ogshare'
)]
public ?string $ogshare = null;
#[Groups(['organizational-unit:read'])]
#[ApiProperty(
description: 'Fecha de creación de la configuración de red',
example: '2024-01-15T10:30:00+00:00'
)]
public \DateTime $createdAt;
#[Groups(['organizational-unit:read'])]
#[ApiProperty(
description: 'Usuario que creó este registro',
example: 'admin'
)]
public ?string $createdBy = null;
public function __construct(NetworkSettings $networkSettings)
{
parent::__construct($networkSettings);
$this->nextServer = $networkSettings->getNextServer();
$this->bootFileName = $networkSettings->getBootFileName();
$this->proxy = $networkSettings->getProxy();
$this->dns = $networkSettings->getDns();
$this->netmask = $networkSettings->getNetmask();
$this->router = $networkSettings->getRouter();
$this->ntp = $networkSettings->getNtp();
$this->netiface = $networkSettings->getNetiface();
$this->p2pMode = $networkSettings->getP2pMode();
$this->p2pTime = $networkSettings->getP2pTime();
$this->mcastIp = $networkSettings->getMcastIp();
$this->mcastSpeed = $networkSettings->getMcastSpeed();
$this->mcastPort = $networkSettings->getMcastPort();
$this->mcastMode = $networkSettings->getMcastMode();
$this->ogshare = $networkSettings->getOgshare();
if ($networkSettings->getMenu()) {
$this->menu = new MenuOutput($networkSettings->getMenu());
}
if ($networkSettings->getHardwareProfile()) {
$this->hardwareProfile = new HardwareProfileOutput($networkSettings->getHardwareProfile(), false);
}
if ($networkSettings->getOgLive()) {
$this->ogLive = new OgLiveOutput($networkSettings->getOgLive());
}
if ($networkSettings->getRepository()) {
$this->repository = new ImageRepositoryOutput($networkSettings->getRepository());
}
if ($networkSettings->getPxeTemplate()) {
$this->pxeTemplate = new PxeTemplateOutput($networkSettings->getPxeTemplate());
}
$this->createdAt = $networkSettings->getCreatedAt();
$this->createdBy = $networkSettings->getCreatedBy();
}
}