http://modulesgarden.com * CONTACT -> contact@modulesgarden.com * * * This software is furnished under a license and may be used and copied * only in accordance with the terms of such license and with the * inclusion of the above copyright notice. This software or any other * copies thereof may not be provided or otherwise made available to any * other person. No title to and ownership of the software is hereby * transferred. * * * ******************************************************************** */ namespace MGProvision\Proxmox\v2\models; use MGProvision\Proxmox\v2 as proxmox; /** * Description of FirewallOptions * * @author Pawel Kopec * @version 1.0.0 */ class FirewallOptions extends AbstractObject { protected $path; protected $enable; protected $ipfilter; protected $policy_in; protected $policy_out; protected $log_level_in; protected $log_level_out; protected $dhcp; protected $ndp; protected $macfilter; protected $radv; public function setPath($path) { if (!preg_match('/[0-9]\/firewall\/options$/', $path)) { throw new proxmox\ProxmoxApiException(sprintf("Firewall Path ('%s') is not valid", $path)); } $this->path = $path; return $this; } public function read() { if (empty($this->path)) throw new proxmox\ProxmoxApiException('Path can\'t be blank'); $attributes = $this->api()->get($this->path); if(!isset($attributes['dhcp'])){ $attributes['dhcp'] = 1; } $this->setAttributes($attributes); return $this; } public function update() { if (empty($this->path)) throw new proxmox\ProxmoxApiException('Path can\'t be blank'); $attributes = array(); if ($this->enable !== null) { $attributes['enable'] = $this->getEnable(); } if ($this->dhcp !== null) { $attributes['dhcp'] = $this->getDhcp(); } if ($this->ndp !== null) { $attributes['ndp'] = $this->getNdp(); } if ($this->radv !== null) { $attributes['radv'] = $this->getRadv(); } if ($this->macfilter !== null) { $attributes['macfilter'] = $this->getMacfilter(); } if ($this->ipfilter !== null) { $attributes['ipfilter'] = $this->getIpfilter(); } if ($this->log_level_in !== null) { $attributes['log_level_in'] = $this->getLog_level_in(); } if ($this->log_level_out !== null) { $attributes['log_level_out'] = $this->getLog_level_out(); } if ($this->policy_in !== null) { $attributes['policy_in'] = $this->getPolicy_in(); } if ($this->policy_out !== null) { $attributes['policy_out'] = $this->getPolicy_out(); } return $this->api()->put($this->path, $attributes); } public function getEnable() { return $this->enable; } public function getIpfilter() { return $this->ipfilter; } public function getPolicy_in() { return $this->policy_in; } public function getPolicy_out() { return $this->policy_out; } public function getLog_level_in() { return $this->log_level_in; } public function getLog_level_out() { return $this->log_level_out; } public function getDhcp() { return $this->dhcp; } public function getNdp() { return $this->ndp; } public function getMacfilter() { return $this->macfilter; } public function getRadv() { return $this->radv; } public function setEnable($enable) { $this->enable = $enable; return $this; } public function setIpfilter($ipfilter) { $this->ipfilter = $ipfilter; return $this; } public function setPolicy_in($policy_in) { $this->policy_in = $policy_in; return $this; } public function setPolicy_out($policy_out) { $this->policy_out = $policy_out; return $this; } public function setLog_level_in($log_level_in) { $this->log_level_in = $log_level_in; return $this; } public function setLog_level_out($log_level_out) { $this->log_level_out = $log_level_out; return $this; } public function setDhcp($dhcp) { $this->dhcp = $dhcp; return $this; } public function setNdp($ndp) { $this->ndp = $ndp; return $this; } public function setMacfilter($macfilter) { $this->macfilter = $macfilter; return $this; } public function setRadv($radv) { $this->radv = $radv; return $this; } public function getAttributes() { return [ 'enable' => $this->getEnable() ? $this->getEnable() : 0 , 'dhcp' => $this->getDhcp() ? $this->getDhcp() : 0, 'ndp' => is_null($this->ndp) || $this->ndp ? 1 :0, 'radv' => $this->getRadv() ? $this->getRadv() : 0, 'macfilter' => is_null($this->macfilter) || $this->macfilter ? 1 :0, 'ipfilter' => $this->getIpfilter() ? $this->getIpfilter() : 0, 'log_level_in' => $this->getLog_level_in() ? $this->getLog_level_in() : "nolog", 'log_level_out' => $this->getLog_level_out() ? $this->getLog_level_out() : "nolog", 'policy_in' => $this->getPolicy_in() ? $this->getPolicy_in() : "DROP", 'policy_out' => $this->getPolicy_out() ? $this->getPolicy_out() : "ACCEPT", ]; } }