From: Marcin Haba Date: Mon, 24 Apr 2023 10:00:48 +0000 (+0200) Subject: baculum: Add storage filter to volumes endpoint X-Git-Tag: Release-13.0.3~56 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb80278a5fe621e2b3d84c3c7e68daa9ae973283;p=thirdparty%2Fbacula.git baculum: Add storage filter to volumes endpoint --- diff --git a/gui/baculum/protected/API/Modules/VolumeManager.php b/gui/baculum/protected/API/Modules/VolumeManager.php index 738bc6947..af124c235 100644 --- a/gui/baculum/protected/API/Modules/VolumeManager.php +++ b/gui/baculum/protected/API/Modules/VolumeManager.php @@ -144,6 +144,12 @@ class VolumeManager extends APIModule { ]; } + if (key_exists('storage', $props)) { + $criteria['Storage.Name'][] = [ + 'vals' => $props['storage'] + ]; + } + $limit = ''; if(is_int($limit_val) && $limit_val > 0) { $limit = " LIMIT $limit_val "; diff --git a/gui/baculum/protected/API/Pages/API/Volumes.php b/gui/baculum/protected/API/Pages/API/Volumes.php index eca2792c8..efe08b0b7 100644 --- a/gui/baculum/protected/API/Pages/API/Volumes.php +++ b/gui/baculum/protected/API/Pages/API/Volumes.php @@ -42,6 +42,7 @@ class Volumes extends BaculumAPIServer { } $voltype = $this->Request->contains('voltype') && $misc->isValidVolType($this->Request['voltype']) ? $this->Request['voltype'] : null; $pool = $this->Request->contains('pool') && $misc->isValidName($this->Request['pool']) ? $this->Request['pool'] : null; + $storage = $this->Request->contains('storage') && $misc->isValidName($this->Request['storage']) ? $this->Request['storage'] : null; $params = $props = []; @@ -65,6 +66,10 @@ class Volumes extends BaculumAPIServer { $props['pool'] = $pool; } + if (is_string($storage)) { + $props['storage'] = $storage; + } + $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 567810568..73a4668aa 100644 --- a/gui/baculum/protected/API/openapi_baculum.json +++ b/gui/baculum/protected/API/openapi_baculum.json @@ -3981,6 +3981,15 @@ "type": "string" } }, + { + "name": "storage", + "in": "query", + "description": "Volume storage name.", + "required": false, + "schema": { + "type": "string" + } + }, { "name": "enabled", "in": "query",