| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- /* * ********************************************************************
- * ProxmoxAddon product developed. (Mar 9, 2018)
- * *
- *
- * 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\ProxmoxApiException;
- /**
- * Description of IpCidr
- *
- * @author Pawel Kopec <pawelk@modulesgardne.com>
- */
- class IpCidr extends AbstractObject
- {
- private $cidr;
- private $comment;
- function __construct($path = null)
- {
- if (!is_null($path))
- {
- $this->setPath($path);
- }
- }
- /**
- *
- * @param string $path /api2/json/nodes/{node}/qemu/{vmid}/firewall/ipset/{$name}
- * @throws proxmox\ProxmoxApiException
- */
- public function setPath($path)
- {
- if (!preg_match('/ipset/', $path))
- {
- throw new ProxmoxApiException(sprintf("IpCidr path ('%s') is not valid", $path));
- }
- $this->path = $path;
- return $this;
- }
- public function getCidr()
- {
- return $this->cidr;
- }
- public function getComment()
- {
- return $this->comment;
- }
- public function setCidr($cidr)
- {
- $this->cidr = $cidr;
- return $this;
- }
- public function setComment($comment)
- {
- $this->comment = $comment;
- return $this;
- }
- public function create()
- {
- if (empty($this->path))
- {
- throw new ProxmoxApiException("IpCidr path is empty");
- }
- $this->api()->post($this->path, ['cidr' => $this->cidr, "comment" => $this->comment]);
- $this->setPath($this->path . "/{$this->cidr}");
- return $this;
- }
- public function delete()
- {
- if (empty($this->path))
- {
- throw new ProxmoxApiException("IpSet path is empty");
- }
- $this->api()->delete($this->path);
- return $this;
- }
- }
|