]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add delete object endpoint
authorMarcin Haba <marcin.haba@bacula.pl>
Fri, 15 Sep 2023 08:22:39 +0000 (10:22 +0200)
committerEric Bollengier <eric@baculasystems.com>
Tue, 31 Oct 2023 15:00:30 +0000 (16:00 +0100)
gui/baculum/protected/API/Pages/API/ObjectClass.php

index 8276a5c5ce55db02b18b3ae376f341576fb9b73c..edc32074ca43492f2f0347cb4e30c2d5e3eeec71 100644 (file)
@@ -20,6 +20,7 @@
  * Bacula(R) is a registered trademark of Kern Sibbald.
  */
 
+use Baculum\API\Modules\Delete;
 use Baculum\Common\Modules\Errors\ObjectError;
 
 /**
@@ -43,4 +44,21 @@ class ObjectClass extends BaculumAPIServer {
                        $this->error = ObjectError::ERROR_OBJECT_DOES_NOT_EXISTS;
                }
        }
+
+       public function remove($id) {
+               $objectid = (int)$id;
+               $object = $this->getModule('object')->getObjectById($objectid);
+               if (is_object($object)) {
+                       $result = $this->getModule('delete')->delete(
+                               $this->director,
+                               Delete::TYPE_OBJECT,
+                               $object->objectid
+                       );
+                       $this->output = $result['output'];
+                       $this->error = $result['error'];
+               } else {
+                       $this->output = ObjectError::MSG_ERROR_OBJECT_DOES_NOT_EXISTS;
+                       $this->error = ObjectError::ERROR_OBJECT_DOES_NOT_EXISTS;
+               }
+       }
 }