]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add enabled flag filter to volumes endpoint
authorMarcin Haba <marcin.haba@bacula.pl>
Mon, 24 Apr 2023 07:57:59 +0000 (09:57 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Mon, 1 May 2023 11:18:25 +0000 (13:18 +0200)
gui/baculum/protected/API/Pages/API/Volumes.php

index 4eb97596519cf2db83217f9951f7fba3b5ca58bf..e75628d850ed01b8dea9a41af827d534ab6ed45e 100644 (file)
@@ -36,14 +36,25 @@ class Volumes extends BaculumAPIServer {
                $limit = $this->Request->contains('limit') && $misc->isValidInteger($this->Request['limit']) ? (int)$this->Request['limit'] : 0;
                $offset = $this->Request->contains('offset') && $misc->isValidInteger($this->Request['offset']) ? (int)$this->Request['offset'] : 0;
                $voltype = $this->Request->contains('voltype') && $misc->isValidVolType($this->Request['voltype']) ? $this->Request['voltype'] : null;
+               $enabled = null;
+               if ($this->Request->contains('enabled') && $misc->isValidBoolean($this->Request['enabled'])) {
+                       $enabled = $misc->isValidBooleanTrue($this->Request['enabled']) ? 1 : 0;
+               }
+
+               $params = $props = [];
 
-               $props = [];
                if (is_string($voltype)) {
                        $props['voltype'] = $voltype;
                }
 
+               if (is_int($enabled)) {
+                       $params['Media.Enabled'][] = [
+                               'vals' => $enabled,
+                       ];
+               }
+
                $result = $this->getModule('volume')->getVolumes(
-                       [],
+                       $params,
                        $props,
                        $limit,
                        $offset