]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add objectid parameter to Bvfs restore endpoint
authorMarcin Haba <marcin.haba@bacula.pl>
Tue, 28 Feb 2023 09:52:00 +0000 (10:52 +0100)
committerMarcin Haba <marcin.haba@bacula.pl>
Sun, 5 Mar 2023 06:06:30 +0000 (07:06 +0100)
gui/baculum/protected/API/Pages/API/BVFSRestore.php
gui/baculum/protected/API/openapi_baculum.json
gui/baculum/protected/Common/Modules/Errors/BVFSError.php

index ec24046ca45a96a058e5c220c95238ceeebc1462..93c6db3495644bd4cdc2a4089a125da14c6806b9 100644 (file)
@@ -38,6 +38,7 @@ class BVFSRestore extends BaculumAPIServer {
                $fileids = property_exists($params, 'fileid') ? $params->fileid : null;
                $dirids = property_exists($params, 'dirid') ? $params->dirid : null;
                $findexes = property_exists($params, 'findex') ? $params->findex : null;
+               $objectids = property_exists($params, 'objectid') ? $params->objectid : null;
                $path = property_exists($params, 'path') ? $params->path : null;
 
                if (!is_null($jobids) && !$misc->isValidIdsList($jobids)) {
@@ -60,6 +61,11 @@ class BVFSRestore extends BaculumAPIServer {
                        $this->error = BVFSError::ERROR_INVALID_FILEINDEX_LIST;
                        return;
                }
+               if (!is_null($objectids) && !$misc->isValidIdsList($objectids)) {
+                       $this->output = BVFSError::MSG_ERROR_INVALID_OBJECTID_LIST;
+                       $this->error = BVFSError::ERROR_INVALID_OBJECTID_LIST;
+                       return;
+               }
 
                if (!is_null($path) && !$misc->isValidBvfsPath($path)) {
                        $this->output = BVFSError::MSG_ERROR_INVALID_RPATH;
@@ -77,6 +83,9 @@ class BVFSRestore extends BaculumAPIServer {
                if (is_string($findexes)) {
                        array_push($cmd, 'hardlink="' . $findexes . '"');
                }
+               if (is_string($objectids)) {
+                       array_push($cmd, 'objectid="' . $objectids . '"');
+               }
 
                $result = $this->getModule('bconsole')->bconsoleCommand($this->director, $cmd);
                $this->output = $result->output;
index 2fe931dc8905c2eefcb270c3a049e58e65ca43dc..7c25719fb139a501b8fab8ce4d845fcd00112273 100644 (file)
                                                                                "error": {
                                                                                        "type": "integer",
                                                                                        "description": "Error code",
-                                                                                       "enum": [0, 1, 2, 3, 4, 5, 6, 7, 11, 71, 73, 74, 75, 76, 1000]
+                                                                                       "enum": [0, 1, 2, 3, 4, 5, 6, 7, 11, 71, 73, 74, 75, 76, 79, 1000]
                                                                                }
                                                                        }
                                                                }
                                                "schema": {
                                                        "type": "string"
                                                }
+                                       },
+                                       {
+                                               "name": "objectid",
+                                               "in": "body",
+                                               "description": "Comma seprated object identifiers",
+                                               "required": false,
+                                               "schema": {
+                                                       "type": "string"
+                                               }
                                        }
                                ]
                        }
index 3969ed8c07ce851a235143cb0fa79182b722df22..ac0a40633f8c51f4f0fbd8b1dccef4a27d59afef 100644 (file)
@@ -38,6 +38,7 @@ class BVFSError extends GenericError {
        const ERROR_INVALID_DIRID_LIST = 76;
        const ERROR_INVALID_CLIENT = 77;
        const ERROR_INVALID_JOBID = 78;
+       const ERROR_INVALID_OBJECTID_LIST = 79;
 
        const MSG_ERROR_INVALID_RPATH = 'Inputted path for restore is invalid. Proper format is b2[0-9]+.';
        const MSG_ERROR_INVALID_RESTORE_PATH = 'Inputted BVFS path param is invalid.';
@@ -47,4 +48,5 @@ class BVFSError extends GenericError {
        const MSG_ERROR_INVALID_DIRID_LIST = 'Invalid dirid list.';
        const MSG_ERROR_INVALID_CLIENT = 'Invalid client name.';
        const MSG_ERROR_INVALID_JOBID = 'Invalid jobid.';
+       const MSG_ERROR_INVALID_OBJECTID_LIST = 'Invalid objectid list.';
 }