]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add joberrors parameter to jobs endpoint
authorMarcin Haba <marcin.haba@bacula.pl>
Tue, 31 Oct 2023 10:01:00 +0000 (11:01 +0100)
committerEric Bollengier <eric@baculasystems.com>
Tue, 31 Oct 2023 15:00:30 +0000 (16:00 +0100)
gui/baculum/protected/API/Pages/API/Jobs.php
gui/baculum/protected/API/openapi_baculum.json

index 93246ad671d6d23a7a0db1b3d48c45fff0228ddb..ae545ad7d209715cf1e862da56c23dd69c1974ef 100644 (file)
@@ -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(
index b50efc7a944ad63b84971588dcc78c65b3b3bbc6..8d812a6cff5e64985203ee2c32020df28622c1a2 100644 (file)
                                                        "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",