]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add volumename filter to volumes endpoint
authorMarcin Haba <marcin.haba@bacula.pl>
Mon, 24 Apr 2023 08:26:15 +0000 (10:26 +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
gui/baculum/protected/API/openapi_baculum.json

index e75628d850ed01b8dea9a41af827d534ab6ed45e..3286e50c5afe3eb5e553396b93e31a672ff4c856 100644 (file)
@@ -35,24 +35,31 @@ class Volumes extends BaculumAPIServer {
                $misc = $this->getModule('misc');
                $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;
+               $volumename = $this->Request->contains('volumename') && $misc->isValidName($this->Request['volumename']) ? $this->Request['volumename'] : null;
                $enabled = null;
                if ($this->Request->contains('enabled') && $misc->isValidBoolean($this->Request['enabled'])) {
                        $enabled = $misc->isValidBooleanTrue($this->Request['enabled']) ? 1 : 0;
                }
+               $voltype = $this->Request->contains('voltype') && $misc->isValidVolType($this->Request['voltype']) ? $this->Request['voltype'] : null;
 
                $params = $props = [];
 
-               if (is_string($voltype)) {
-                       $props['voltype'] = $voltype;
+               if (is_string($volumename)) {
+                       $params['Media.VolumeName'][] = [
+                               'vals' => $volumename
+                       ];
                }
 
                if (is_int($enabled)) {
                        $params['Media.Enabled'][] = [
-                               'vals' => $enabled,
+                               'vals' => $enabled
                        ];
                }
 
+               if (is_string($voltype)) {
+                       $props['voltype'] = $voltype;
+               }
+
                $result = $this->getModule('volume')->getVolumes(
                        $params,
                        $props,
index f5b782df09f7d80cd473c56e8483f5de050585b6..f00723cc50467e47424f205f20c4db560726aab5 100644 (file)
                                                "schema": {
                                                        "type": "string"
                                                }
+                                       },
+                                       {
+                                               "name": "volumename",
+                                               "in": "query",
+                                               "description": "Volume name.",
+                                               "required": false,
+                                               "schema": {
+                                                       "type": "string"
+                                               }
+                                       },
+                                       {
+                                               "name": "enabled",
+                                               "in": "query",
+                                               "description": "Volume enabled flag.",
+                                               "required": false,
+                                               "schema": {
+                                                       "type": "boolean"
+                                               }
                                        }
                                ]
                        }