<?php


namespace ModulesGarden\ProxmoxAddon\App\Listeners\Cloud;


use MGProvision\Proxmox\v2\VmFactory;
use ModulesGarden\ProxmoxAddon\App\Events\Cloud\VmEvent;
use ModulesGarden\ProxmoxAddon\App\Models\VirtualInterface;
use ModulesGarden\ProxmoxAddon\App\Services\ApiService;
use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ContainerService;
use ModulesGarden\ProxmoxAddon\App\Services\Cloud\FirewallOptionService;
use ModulesGarden\ProxmoxAddon\App\Services\Cloud\HighAvailabilityClusterService;
use ModulesGarden\ProxmoxAddon\App\Services\Cloud\HostingService;
use ModulesGarden\ProxmoxAddon\App\Services\Cloud\IpSetIpFilterService;
use ModulesGarden\ProxmoxAddon\App\Services\Cloud\NetworkService;
use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ProductService;
use ModulesGarden\ProxmoxAddon\App\Services\Cloud\UserService;
use ModulesGarden\ProxmoxAddon\App\Services\Cloud\VirtualInterfaceConverter;
use ModulesGarden\ProxmoxAddon\App\Services\EmailService;
use ModulesGarden\ProxmoxAddon\Core\UI\Traits\WhmcsParams;
use function ModulesGarden\ProxmoxAddon\Core\Helper\sl;

abstract  class VmListener
{
    use WhmcsParams;
    use ApiService;
    use UserService;
    use ProductService;
    use HostingService;

    /**
     * @var IpSetIpFilterService
     */
    protected $ipSetFilterService;
    /**
     * @var FirewallOptionService
     */
    protected $firewallOptionService;
    protected $emailService;
    protected $containerService;
    protected $networkService;

    /**
     * @var VmEvent
     */
    protected $event;

    public function __construct()
    {
        $this->ipSetFilterService = new IpSetIpFilterService();
        $this->highAvailabilityClusterService = new HighAvailabilityClusterService();
        $this->emailService       = new EmailService();
        $this->containerService   = new ContainerService();
        $this->networkService     = new NetworkService();
        $this->firewallOptionService = new FirewallOptionService();
    }

    public function initVmAnVmModel(){
        sl('Vm')->setVm((new VmFactory())->fromVmModel($this->event->getVmModel()));
        sl('Vm')->setVmModel($this->event->getVmModel());
        return $this;
    }
}