| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- <?php
- /* * ********************************************************************
- * ProxmoxVPS product developed. (2017-01-11)
- * *
- *
- * CREATED BY MODULESGARDEN -> 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 <pawelk@modulesgarden.com>
- * @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",
- ];
- }
- }
|