]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add storage filter to volumes endpoint
authorMarcin Haba <marcin.haba@bacula.pl>
Mon, 24 Apr 2023 10:00:48 +0000 (12:00 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Mon, 1 May 2023 11:18:25 +0000 (13:18 +0200)
gui/baculum/protected/API/Modules/VolumeManager.php
gui/baculum/protected/API/Pages/API/Volumes.php
gui/baculum/protected/API/openapi_baculum.json

index 738bc6947e8d460bf5fa03a06a77822dc46c5d52..af124c23571308a86861b508e2ff4338640a812c 100644 (file)
@@ -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 ";
index eca2792c841f54466a8fe0b948936b1ca2e3eb31..efe08b0b767c60e21a271770dbad092056ab4bcd 100644 (file)
@@ -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,
index 5678105682cd3a03d7b97a9b5d6a9f8a9718b4b8..73a4668aacaf664e5fa6ddbdbdbb8217a2f3e3e6 100644 (file)
                                                        "type": "string"
                                                }
                                        },
+                                       {
+                                               "name": "storage",
+                                               "in": "query",
+                                               "description": "Volume storage name.",
+                                               "required": false,
+                                               "schema": {
+                                                       "type": "string"
+                                               }
+                                       },
                                        {
                                                "name": "enabled",
                                                "in": "query",