From: Marcin Haba Date: Mon, 24 Apr 2023 08:26:15 +0000 (+0200) Subject: baculum: Add volumename filter to volumes endpoint X-Git-Tag: Release-13.0.3~59 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e5622e698a8f1a9bda3732f82c66e5602429ac2f;p=thirdparty%2Fbacula.git baculum: Add volumename filter to volumes endpoint --- diff --git a/gui/baculum/protected/API/Pages/API/Volumes.php b/gui/baculum/protected/API/Pages/API/Volumes.php index e75628d85..3286e50c5 100644 --- a/gui/baculum/protected/API/Pages/API/Volumes.php +++ b/gui/baculum/protected/API/Pages/API/Volumes.php @@ -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, diff --git a/gui/baculum/protected/API/openapi_baculum.json b/gui/baculum/protected/API/openapi_baculum.json index f5b782df0..f00723cc5 100644 --- a/gui/baculum/protected/API/openapi_baculum.json +++ b/gui/baculum/protected/API/openapi_baculum.json @@ -4052,6 +4052,24 @@ "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" + } } ] }