<?php

namespace App\Dto\Output;

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"])]
    public ?string $nextServer = null;

    #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
    public ?string $bootFileName = null;

    #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
    public ?string $proxy = null;

    #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
    public ?string $dns = null;

    #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
    public ?string $netmask = null;

    #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
    public ?string $router = null;

    #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
    public ?string $ntp = null;

    #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
    public ?string $netiface = null;

    #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
    public ?string $p2pMode = null;

    #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
    public ?int $p2pTime = null;

    #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
    public ?string $mcastIp = null;

    #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
    public ?int $mcastSpeed = null;

    #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
    public ?int $mcastPort = null;

    #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
    public ?string $mcastMode = null;

    #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
    public ?MenuOutput $menu = null;

    #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
    public ?HardwareProfileOutput $hardwareProfile = null;

    #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
    public ?OgLiveOutput $ogLive = null;

    #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
    public ?ImageRepositoryOutput $repository = null;

    #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
    public ?PxeTemplateOutput $pxeTemplate = null;

    #[Groups(['network-settings:read', "organizational-unit:read", "client:read"])]
    public ?string $ogshare = null;

    #[Groups(['organizational-unit:read'])]
    public \DateTime $createdAt;

    #[Groups(['organizational-unit:read'])]
    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());
        }

        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();
    }
}