From 606243a137d22d40e522574eae5d0cb25f25fbc8 Mon Sep 17 00:00:00 2001 From: Marcin Haba Date: Thu, 28 Jan 2021 07:33:25 +0100 Subject: [PATCH] baculum: Add to Bvfs lsdirs and lsfiles API endpoints pathid parameter --- .../protected/API/Pages/API/BVFSLsDirs.php | 15 +++++++++---- .../protected/API/Pages/API/BVFSLsFiles.php | 15 +++++++++---- .../protected/API/openapi_baculum.json | 22 +++++++++++++++++-- 3 files changed, 42 insertions(+), 10 deletions(-) diff --git a/gui/baculum/protected/API/Pages/API/BVFSLsDirs.php b/gui/baculum/protected/API/Pages/API/BVFSLsDirs.php index 28d44f160..04684470a 100644 --- a/gui/baculum/protected/API/Pages/API/BVFSLsDirs.php +++ b/gui/baculum/protected/API/Pages/API/BVFSLsDirs.php @@ -3,7 +3,7 @@ * Bacula(R) - The Network Backup Solution * Baculum - Bacula web interface * - * Copyright (C) 2013-2019 Kern Sibbald + * Copyright (C) 2013-2021 Kern Sibbald * * The main author of Baculum is Marcin Haba. * The original author of Bacula is Kern Sibbald, with contributions @@ -36,7 +36,8 @@ class BVFSLsDirs extends ConsoleOutputPage { $limit = $this->Request->contains('limit') ? intval($this->Request['limit']) : 0; $offset = $this->Request->contains('offset') ? intval($this->Request['offset']) : 0; $jobids = $this->Request->contains('jobids') && $misc->isValidIdsList($this->Request['jobids']) ? $this->Request['jobids'] : null; - $path = $this->Request->contains('path') && $misc->isValidPath($this->Request['path']) ? $this->Request['path'] : null; + $path = $this->Request->contains('path') && $misc->isValidPath($this->Request['path']) ? $this->Request['path'] : ''; + $pathid = $this->Request->contains('pathid') ? intval($this->Request['pathid']) : null; $out_format = $this->Request->contains('output') && $this->isOutputFormatValid($this->Request['output']) ? $this->Request['output'] : parent::OUTPUT_FORMAT_RAW; if (is_null($jobids)) { @@ -54,6 +55,7 @@ class BVFSLsDirs extends ConsoleOutputPage { $params = [ 'jobids' => $jobids, 'path' => $path, + 'pathid' => $pathid, 'offset' => $offset, 'limit' => $limit ]; @@ -77,10 +79,15 @@ class BVFSLsDirs extends ConsoleOutputPage { protected function getRawOutput($params = []) { $cmd = [ '.bvfs_lsdirs', - 'jobid="' . $params['jobids'] . '"', - 'path="' . $params['path'] . '"' + 'jobid="' . $params['jobids'] . '"' ]; + if ($params['pathid']) { + array_push($cmd, 'pathid="' . $params['pathid'] . '"'); + } else { + array_push($cmd, 'path="' . $params['path'] . '"'); + } + if ($params['offset'] > 0) { array_push($cmd, 'offset="' . $params['offset'] . '"'); } diff --git a/gui/baculum/protected/API/Pages/API/BVFSLsFiles.php b/gui/baculum/protected/API/Pages/API/BVFSLsFiles.php index 9f67c6d96..743e650b1 100644 --- a/gui/baculum/protected/API/Pages/API/BVFSLsFiles.php +++ b/gui/baculum/protected/API/Pages/API/BVFSLsFiles.php @@ -3,7 +3,7 @@ * Bacula(R) - The Network Backup Solution * Baculum - Bacula web interface * - * Copyright (C) 2013-2019 Kern Sibbald + * Copyright (C) 2013-2021 Kern Sibbald * * The main author of Baculum is Marcin Haba. * The original author of Bacula is Kern Sibbald, with contributions @@ -39,7 +39,8 @@ class BVFSLsFiles extends ConsoleOutputPage { $limit = $this->Request->contains('limit') ? intval($this->Request['limit']) : 0; $offset = $this->Request->contains('offset') ? intval($this->Request['offset']) : 0; $jobids = $this->Request->contains('jobids') && $misc->isValidIdsList($this->Request['jobids']) ? $this->Request['jobids'] : null; - $path = $this->Request->contains('path') && $misc->isValidPath($this->Request['path']) ? $this->Request['path'] : null; + $path = $this->Request->contains('path') && $misc->isValidPath($this->Request['path']) ? $this->Request['path'] : ''; + $pathid = $this->Request->contains('pathid') ? intval($this->Request['pathid']) : null; $out_format = $this->Request->contains('output') && $this->isOutputFormatValid($this->Request['output']) ? $this->Request['output'] : parent::OUTPUT_FORMAT_RAW; if (is_null($jobids)) { @@ -57,6 +58,7 @@ class BVFSLsFiles extends ConsoleOutputPage { $params = [ 'jobids' => $jobids, 'path' => $path, + 'pathid' => $pathid, 'offset' => $offset, 'limit' => $limit ]; @@ -80,10 +82,15 @@ class BVFSLsFiles extends ConsoleOutputPage { protected function getRawOutput($params = []) { $cmd = [ '.bvfs_lsfiles', - 'jobid="' . $params['jobids'] . '"', - 'path="' . $params['path'] . '"' + 'jobid="' . $params['jobids'] . '"' ]; + if ($params['pathid']) { + array_push($cmd, 'pathid="' . $params['pathid'] . '"'); + } else { + array_push($cmd, 'path="' . $params['path'] . '"'); + } + if ($params['offset'] > 0) { array_push($cmd, 'offset="' . $params['offset'] . '"'); } diff --git a/gui/baculum/protected/API/openapi_baculum.json b/gui/baculum/protected/API/openapi_baculum.json index 64bdd8397..1c981320e 100644 --- a/gui/baculum/protected/API/openapi_baculum.json +++ b/gui/baculum/protected/API/openapi_baculum.json @@ -3658,12 +3658,21 @@ { "name": "path", "in": "query", - "description": "Path to list", + "description": "Path to list (used instead of pathid parameter)", "required": true, "schema": { "type": "string" } }, + { + "name": "pathid", + "in": "query", + "description": "Path identifier to list path (used instead of path parameter)", + "required": true, + "schema": { + "type": "integer" + } + }, { "name": "offset", "in": "query", @@ -3732,12 +3741,21 @@ { "name": "path", "in": "query", - "description": "Path to list", + "description": "Path to list (used instead of pathid parameter)", "required": true, "schema": { "type": "string" } }, + { + "name": "pathid", + "in": "query", + "description": "Path identifier to list path (used instead of path parameter)", + "required": true, + "schema": { + "type": "integer" + } + }, { "name": "offset", "in": "query", -- 2.47.3