]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add application version endpoint
authorMarcin Haba <marcin.haba@bacula.pl>
Wed, 13 Mar 2024 12:23:54 +0000 (13:23 +0100)
committerMarcin Haba <marcin.haba@bacula.pl>
Fri, 22 Mar 2024 09:34:52 +0000 (10:34 +0100)
gui/baculum/protected/API/Pages/API/AppVersion.php [new file with mode: 0644]
gui/baculum/protected/API/Pages/API/endpoints.xml
gui/baculum/protected/API/openapi_baculum.json

diff --git a/gui/baculum/protected/API/Pages/API/AppVersion.php b/gui/baculum/protected/API/Pages/API/AppVersion.php
new file mode 100644 (file)
index 0000000..36ba947
--- /dev/null
@@ -0,0 +1,42 @@
+<?php
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum   - Bacula web interface
+ *
+ * Copyright (C) 2013-2024 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.
+ */
+
+use Baculum\API\Modules\BaculumAPIServer;
+use Baculum\Common\Modules\Errors\GenericError;
+use Baculum\Common\Modules\Params;
+
+/**
+ * Get application version.
+ *
+ * @author Marcin Haba <marcin.haba@bacula.pl>
+ * @category System
+ * @package Baculum API
+ */
+class AppVersion extends BaculumAPIServer {
+
+       public function get() {
+               $this->output = [
+                       'version' => Params::BACULUM_VERSION
+               ];
+               $this->error = GenericError::ERROR_NO_ERRORS;
+       }
+}
index 867e6e6ca087fcac086bcc3267eb982ed35378e9..cb07855a27d559f1b4e38649b4ccc5a93ca0ffdc 100644 (file)
@@ -10,6 +10,8 @@
        <!-- general endpoint -->
        <url ServiceParameter="Welcome" pattern="api/v2/welcome/" />
        <url ServiceParameter="SearchItems" pattern="api/v2/search/" />
+       <!-- system endpoints -->
+       <url ServiceParameter="AppVersion" pattern="api/v2/system/app/version" />
        <!-- bconsole endpoints -->
        <url ServiceParameter="ConsoleCommand" pattern="api/v2/console/" />
        <!-- database endpoints -->
index 39ffc523d4a9c507b90e52698a470b29fc974ecd..006e3f9879bfcdbd4fb0febac6f1b661da812c08 100644 (file)
                                        }
                                ]
                        }
+               },
+               "/api/v2/system/app/version": {
+                       "get": {
+                               "tags": ["system"],
+                               "summary": "Get application version.",
+                               "description": "Get application version.",
+                               "responses": {
+                                       "200": {
+                                               "description": "Application version",
+                                               "content": {
+                                                       "application/json": {
+                                                               "schema": {
+                                                                       "type": "object",
+                                                                       "properties": {
+                                                                               "output": {
+                                                                                       "type": "object",
+                                                                                       "properties": {
+                                                                                               "version": {
+                                                                                                       "type": "string",
+                                                                                                       "description": "Application version in format X.Y.Z"
+                                                                                               }
+                                                                                       }
+                                                                               },
+                                                                               "error": {
+                                                                                       "type": "integer",
+                                                                                       "description": "Error code",
+                                                                                       "enum": [0, 1000]
+                                                                               }
+                                                                       }
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
                }
        },
        "definitions": {