From: Marcin Haba Date: Tue, 31 Oct 2023 10:01:00 +0000 (+0100) Subject: baculum: Add joberrors parameter to jobs endpoint X-Git-Tag: Beta-15.0.0~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4aa6e6c8b357ea1152e62893c0821bb6f0e5b54e;p=thirdparty%2Fbacula.git baculum: Add joberrors parameter to jobs endpoint --- diff --git a/gui/baculum/protected/API/Pages/API/Jobs.php b/gui/baculum/protected/API/Pages/API/Jobs.php index 93246ad67..ae545ad7d 100644 --- a/gui/baculum/protected/API/Pages/API/Jobs.php +++ b/gui/baculum/protected/API/Pages/API/Jobs.php @@ -45,6 +45,10 @@ class Jobs extends BaculumAPIServer { $type = $this->Request->contains('type') && $misc->isValidJobType($this->Request['type']) ? $this->Request['type'] : ''; $jobname = $this->Request->contains('name') && $misc->isValidName($this->Request['name']) ? $this->Request['name'] : ''; $clientid = $this->Request->contains('clientid') ? $this->Request['clientid'] : ''; + $joberrors = null; + if ($this->Request->contains('joberrors') && $misc->isValidBoolean($this->Request['joberrors'])) { + $joberrors = $misc->isValidBooleanTrue($this->Request['joberrors']) ? true : false; + } // UNIX timestamp values $schedtime_from = $this->Request->contains('schedtime_from') && $misc->isValidInteger($this->Request['schedtime_from']) ? (int)$this->Request['schedtime_from'] : null; @@ -401,6 +405,20 @@ class Jobs extends BaculumAPIServer { $this->error = $result->exitcode; } } + if (!is_null($joberrors)) { + if ($joberrors === true) { + $params['Job.JobErrors'] = []; + $params['Job.JobErrors'][] = [ + 'operator' => '>', + 'vals' => 0 + ]; + } elseif ($joberrors === false) { + $params['Job.JobErrors'] = []; + $params['Job.JobErrors'][] = [ + 'vals' => 0 + ]; + } + } if ($error === false) { $result = $this->getModule('job')->getJobs( diff --git a/gui/baculum/protected/API/openapi_baculum.json b/gui/baculum/protected/API/openapi_baculum.json index b50efc7a9..8d812a6cf 100644 --- a/gui/baculum/protected/API/openapi_baculum.json +++ b/gui/baculum/protected/API/openapi_baculum.json @@ -1036,6 +1036,15 @@ "type": "string" } }, + { + "name": "joberrors", + "in": "query", + "required": false, + "description": "Show jobs that contain or that do not contain errors.", + "schema": { + "type": "boolean" + } + }, { "name": "schedtime_from", "in": "query",