]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add delete client endpoint
authorMarcin Haba <marcin.haba@bacula.pl>
Fri, 15 Sep 2023 08:22:19 +0000 (10:22 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Thu, 2 Nov 2023 07:32:30 +0000 (08:32 +0100)
gui/baculum/protected/API/Pages/API/Client.php

index 9b0bfb4ed2d4ad5d08aade32cf0abae912be8295..4d65b2898a731b9932a486f311764b37867920eb 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 use Baculum\API\Modules\BaculumAPIServer;
+use Baculum\API\Modules\Delete;
 use Baculum\Common\Modules\Errors\ClientError;
 
 /**
@@ -47,13 +48,29 @@ class Client extends BaculumAPIServer {
                                $this->error = ClientError::ERROR_NO_ERRORS;
                        } else {
                                $this->output = ClientError::MSG_ERROR_CLIENT_DOES_NOT_EXISTS;
-                               $this->error =ClientError::ERROR_CLIENT_DOES_NOT_EXISTS;
+                               $this->error = ClientError::ERROR_CLIENT_DOES_NOT_EXISTS;
                        }
                } else {
                        $this->output = $result->output;
                        $this->error = $result->exitcode;
                }
        }
-}
 
+       public function remove($id) {
+               $clientid = (int)$id;
+               $client = $this->getModule('client')->getClientById($clientid);
+               if (is_object($client)) {
+                       $result = $this->getModule('delete')->delete(
+                               $this->director,
+                               Delete::TYPE_CLIENT,
+                               $client->name
+                       );
+                       $this->output = $result['output'];
+                       $this->error = $result['error'];
+               } else {
+                       $this->output = ClientError::MSG_ERROR_CLIENT_DOES_NOT_EXISTS;
+                       $this->error =ClientError::ERROR_CLIENT_DOES_NOT_EXISTS;
+               }
+       }
+}
 ?>