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 BackupSchedule * * @author Pawel Kopec * @version 1.0.0 */ class BackupSchedule extends AbstractObject { protected $path; protected $starttime; protected $enabled; protected $mailto; protected $dow; protected $vmid; protected $storage; protected $quiet; protected $id; protected $remove; protected $compress; protected $mode; protected $maxfiles; protected $node; public function getStarttime() { return $this->starttime; } public function getEnabled() { return $this->enabled; } public function getMailto() { return $this->mailto; } public function getDow() { return $this->dow; } public function getVmid() { return $this->vmid; } public function getStorage() { return $this->storage; } public function getQuiet() { return $this->quiet; } public function getId() { return $this->id; } public function getRemove() { return $this->remove; } public function getCompress() { return $this->compress; } public function getMode() { return $this->mode; } public function getMaxfiles() { return $this->maxfiles; } public function getNode() { return $this->node; } public function setStarttime($starttime) { $this->starttime = $starttime; return $this; } public function setEnabled($enabled) { $this->enabled = $enabled; return $this; } public function setMailto($mailto) { $this->mailto = $mailto; return $this; } public function setDow($dow) { $this->dow = $dow; return $this; } public function setVmid($vmid) { $this->vmid = $vmid; return $this; } public function setStorage($storage) { $this->storage = $storage; return $this; } public function setQuiet($quiet) { $this->quiet = $quiet; return $this; } public function setId($id) { $this->id = $id; return $this; } public function setRemove($remove) { $this->remove = $remove; return $this; } public function setCompress($compress) { $this->compress = $compress; return $this; } public function setMode($mode) { $this->mode = $mode; return $this; } public function setMaxfiles($maxfiles) { $this->maxfiles = $maxfiles; return $this; } public function setNode($node) { $this->node = $node; return $this; } public function setPath($path) { $this->path = $path; return $this; } public function delete() { if (empty($this->id)) throw new proxmox\ProxmoxApiException('Backup Schedule [id] - property is missing and it is not optional'); return $this->api()->delete("/cluster/backup/".$this->getId()); } private function fill() { $data = array( "vmid" => $this->getVmid(), "starttime" => $this->getStarttime(), ); if($this->getMaxfiles()){ $data['maxfiles'] = (int) $this->getMaxfiles(); } if ($this->getStorage()) $data['storage'] = $this->getStorage(); if ($this->getRemove()) $data['remove'] = $this->getRemove(); if ($this->getDow()) $data['dow'] = $this->getDow(); if (!is_null($this->mode)) $data['mode'] = $this->getMode(); if (!is_null($this->compress)) $data['compress'] = $this->getCompress(); if ($this->getMailto()) $data['mailto'] = $this->getMailto(); return $data; } public function create() { $data = $this->fill(); return $this->api()->post("/cluster/backup", $data); } public function update() { $data = $this->fill(); return $this->api()->put("/cluster/backup/" . $this->getId(), $data); } public function getAttributes() { return array( 'displayId' => preg_replace('/^(.*):/', '', $this->getId()), "starttime" => $this->getStarttime(), "days" => explode(",", $this->dow), "compress" => $this->getCompress(), "mode" => $this->getMode(), "mailto" => $this->getMailto(), "id" => $this->getId(), "dow" => $this->getDow() ); } }