]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add .bvfs_cleanup support to API
authorMarcin Haba <marcin.haba@bacula.pl>
Sat, 2 Feb 2019 05:32:12 +0000 (06:32 +0100)
committerMarcin Haba <marcin.haba@bacula.pl>
Sat, 2 Feb 2019 05:32:12 +0000 (06:32 +0100)
gui/baculum/protected/API/Class/Bconsole.php
gui/baculum/protected/API/Pages/API/BVFSCleanUp.php [new file with mode: 0644]
gui/baculum/protected/API/endpoints.xml

index c5a0b6b81ea1637278c9b50aa58544e2b0f7e3a0..ae9348a02761f21f388d68f710df9ba704bd9710 100644 (file)
@@ -55,6 +55,7 @@ class Bconsole extends APIModule {
                '.bvfs_get_jobids',
                '.bvfs_restore',
                '.bvfs_clear_cache',
+               '.bvfs_cleanup',
                'restore',
                'cancel',
                'delete',
diff --git a/gui/baculum/protected/API/Pages/API/BVFSCleanUp.php b/gui/baculum/protected/API/Pages/API/BVFSCleanUp.php
new file mode 100644 (file)
index 0000000..e413b9a
--- /dev/null
@@ -0,0 +1,41 @@
+<?php
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum   - Bacula web interface
+ *
+ * Copyright (C) 2013-2019 Kern Sibbald
+ *
+ * The main author of Baculum is Marcin Haba.
+ * The original author of Bacula is Kern Sibbald, with contributions
+ * from many others, a complete list can be found in the file AUTHORS.
+ *
+ * You may use this file and others of this release according to the
+ * license defined in the LICENSE file, which includes the Affero General
+ * Public License, v3.0 ("AGPLv3") and some additional permissions and
+ * terms pursuant to its AGPLv3 Section 7.
+ *
+ * This notice must be preserved when any source code is
+ * conveyed and/or propagated.
+ *
+ * Bacula(R) is a registered trademark of Kern Sibbald.
+ */
+class BVFSCleanUp extends BaculumAPIServer {
+
+       public function set($id, $params) {
+               $misc = $this->getModule('misc');
+               $path = property_exists($params, 'path') ? $params->path : null;
+
+               if (is_null($path) || !$misc->isValidBvfsPath($path)) {
+                       $this->output = BVFSError::MSG_ERROR_INVALID_RPATH;
+                       $this->error = BVFSError::ERROR_INVALID_RPATH;
+                       return;
+               }
+
+               $cmd = array('.bvfs_cleanup', 'path="' .  $path . '"');
+               $result = $this->getModule('bconsole')->bconsoleCommand($this->director, $cmd);
+               $this->output = $result->output;
+               $this->error = $result->exitcode;
+       }
+}
+?>
index 6f59adcb542fedc9a8b7798abe62babc2cecde62..4b6ec392f219ea821f28f86f24138e82abeae778 100644 (file)
@@ -69,6 +69,7 @@
        <url ServiceParameter="API.BVFSGetJobids" pattern="api/v1/bvfs/getjobids/" />
        <url ServiceParameter="API.BVFSRestore" pattern="api/v1/bvfs/restore/" />
        <url ServiceParameter="API.BVFSClearCache" pattern="api/v1/bvfs/clear/" />
+       <url ServiceParameter="API.BVFSCleanUp" pattern="api/v1/bvfs/cleanup/" />
        <!-- joblog endpoints -->
        <url ServiceParameter="API.JobLog" pattern="api/v1/joblog/{id}/" parameters.id="\d+" />
        <!-- fileset endpoints -->