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 */ 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; } }