]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add joberrors filter to jobs objects endpoint
authorMarcin Haba <marcin.haba@bacula.pl>
Wed, 26 Apr 2023 11:02:09 +0000 (13:02 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Mon, 1 May 2023 11:18:25 +0000 (13:18 +0200)
gui/baculum/protected/API/Pages/API/JobsObjects.php
gui/baculum/protected/API/openapi_baculum.json

index 8bfb2dbbf74b8d34e550986298e887f484602557..68f0b03e5dff653d9729b6cbaded8ea560589189 100644 (file)
@@ -51,6 +51,10 @@ class JobsObjects extends BaculumAPIServer {
                $clientid = $this->Request->contains('clientid') ? $this->Request['clientid'] : null;
                $client = $this->Request->contains('client') ? $this->Request['client'] : null;
                $objecttype = $this->Request->contains('objecttype') && $misc->isValidName($this->Request['objecttype']) ? $this->Request['objecttype'] : null;
+               $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;
@@ -356,6 +360,20 @@ class JobsObjects extends BaculumAPIServer {
                                ];
                        }
                }
+               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
+                               ];
+                       }
+               }
 
                $result = $this->getModule('bconsole')->bconsoleCommand(
                        $this->director,
index 83c1601cdc4152d336fcb4e3745a624009a6064a..9f693ba8c721775d96cf8fd91a68a2596fbea2f7 100644 (file)
                                                        "type": "string",
                                                        "enum": ["basic", "full"]
                                                }
+                                       },
+                                       {
+                                               "name": "joberrors",
+                                               "in": "query",
+                                               "required": false,
+                                               "description": "Show objects from jobs that contain or that do not contain errors.",
+                                               "schema": {
+                                                       "type": "boolean"
+                                               }
                                        }
                                ]
                        }