From: Marcin Haba Date: Fri, 5 Jan 2024 15:22:26 +0000 (+0100) Subject: baculum: Add jobdefs list endpoint X-Git-Tag: Beta-15.0.1~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81c7d7ec3f7a9f8cb52419390f823fe343a2a472;p=thirdparty%2Fbacula.git baculum: Add jobdefs list endpoint --- diff --git a/gui/baculum/protected/API/Pages/API/JobDefsResNames.php b/gui/baculum/protected/API/Pages/API/JobDefsResNames.php new file mode 100644 index 000000000..dd727e51b --- /dev/null +++ b/gui/baculum/protected/API/Pages/API/JobDefsResNames.php @@ -0,0 +1,57 @@ + + * @category API + * @package Baculum API + */ +class JobDefsResNames extends BaculumAPIServer { + + public function get() { + $component_type = 'dir'; + $resource_type = 'JobDefs'; + + // Role valid. Access granted + $config = $this->getModule('bacula_setting')->getConfig( + $component_type, + $resource_type + ); + if ($config['exitcode'] === 0) { + $jobdefs = []; + for ($i = 0; $i < count($config['output']); $i++) { + $jobdefs[] = $config['output'][$i]['JobDefs']['Name']; + } + sort($jobdefs); + $this->output = $jobdefs; + $this->error = GenericError::ERROR_NO_ERRORS; + } else { + $this->output = GenericError::MSG_ERROR_WRONG_EXITCODE . ' Exitcode=>' . $config['exitcode']; + $this->error = GenericError::ERROR_WRONG_EXITCODE; + } + } +} diff --git a/gui/baculum/protected/API/Pages/API/endpoints.xml b/gui/baculum/protected/API/Pages/API/endpoints.xml index 00a6e9026..0e261779e 100644 --- a/gui/baculum/protected/API/Pages/API/endpoints.xml +++ b/gui/baculum/protected/API/Pages/API/endpoints.xml @@ -130,6 +130,8 @@ + +