| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- <?php
- /* * ********************************************************************
- * ProxmoxVPS product developed. (2016-12-13)
- * *
- *
- * 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 BackupSchedule
- *
- * @author Pawel Kopec <pawelk@modulesgarden.com>
- * @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()
- );
- }
- }
|