]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add to API deleting volume from the catalog
authorMarcin Haba <marcin.haba@bacula.pl>
Sun, 27 Jun 2021 16:05:52 +0000 (18:05 +0200)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:03:25 +0000 (09:03 +0100)
gui/baculum/protected/API/Pages/API/Volume.php
gui/baculum/protected/API/openapi_baculum.json

index bc00c62bc4d69409029596c6251d64526d610a93..5ce86db5043648f9a8fabdbaada0eb6cb2f4324e 100644 (file)
@@ -89,6 +89,31 @@ class Volume extends BaculumAPIServer {
                        $this->error = VolumeError::ERROR_VOLUME_DOES_NOT_EXISTS;
                }
        }
+
+       public function remove() {
+               $mediaid = $this->Request->contains('id') ? intval($this->Request['id']) : 0;
+               $volume = $this->getModule('volume')->getVolumeById($mediaid);
+               if (is_object($volume)) {
+                       $result = $this->getModule('bconsole')->bconsoleCommand(
+                               $this->director,
+                               [
+                                       'delete',
+                                       'volume="' . $volume->volumename . '"',
+                                       'yes'
+                               ]
+                       );
+                       if ($result->exitcode === 0) {
+                               $this->output = $result->output;
+                               $this->error = VolumeError::ERROR_NO_ERRORS;
+                       } else {
+                               $this->output = $result->output;
+                               $this->error = VolumeError::ERROR_WRONG_EXITCODE;
+                       }
+               } else {
+                       $this->output = VolumeError::MSG_ERROR_VOLUME_DOES_NOT_EXISTS;
+                       $this->error = VolumeError::ERROR_VOLUME_DOES_NOT_EXISTS;
+               }
+       }
 }
 
 ?>
index ba18c41954ae39f98b630cf729a85deab58487da..7b66e68679e5a08122136298e40bac34fe363701 100644 (file)
                                                }
                                        }
                                ]
+                       },
+                       "delete": {
+                               "tags": ["volumes"],
+                               "summary": "Delete volume by MediaId",
+                               "description": "Delete volume from the Catalog by specific Volume/Media identifier.",
+                               "responses": {
+                                       "200": {
+                                               "description": "Volume delete output",
+                                               "content": {
+                                                       "application/json": {
+                                                               "schema": {
+                                                                       "type": "object",
+                                                                       "properties": {
+                                                                               "output": {
+                                                                                       "type": "array",
+                                                                                       "items": {
+                                                                                               "type": "string",
+                                                                                               "description": "Delete volume output"
+                                                                                       }
+                                                                               },
+                                                                               "error": {
+                                                                                       "type": "integer",
+                                                                                       "description": "Error code",
+                                                                                       "enum": [0, 1, 2, 3, 4, 5, 6, 7, 11, 30, 1000]
+                                                                               }
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               },
+                               "parameters": [
+                                       {
+                                               "$ref": "#/components/parameters/MediaId"
+                                       }
+                               ]
                        }
                },
                "/api/v2/volumes/{mediaid}/prune": {