]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Add joberrors filter to sources endpoint
authorMarcin Haba <marcin.haba@bacula.pl>
Wed, 31 May 2023 08:03:38 +0000 (10:03 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Thu, 1 Jun 2023 11:20:55 +0000 (13:20 +0200)
gui/baculum/protected/API/Pages/API/Sources.php
gui/baculum/protected/API/openapi_baculum.json

index d400960d35a01f96842981796e1e77e9173806e9..00aad05bfc4cfcbee36bc13dfdc8912545198589 100644 (file)
@@ -49,6 +49,10 @@ class Sources extends BaculumAPIServer {
                $order_by = $this->Request->contains('order_by') && $misc->isValidColumn($this->Request['order_by']) ? $this->Request['order_by']: null;
                $order_direction = $this->Request->contains('order_direction') && $misc->isValidOrderDirection($this->Request['order_direction']) ? $this->Request['order_direction']: 'DESC';
                $mode = ($this->Request->contains('overview') && $misc->isValidBooleanTrue($this->Request['overview'])) ? SourceManager::SOURCE_RESULT_MODE_OVERVIEW : SourceManager::SOURCE_RESULT_MODE_NORMAL;
+               $joberrors = null;
+               if ($this->Request->contains('joberrors') && $misc->isValidBoolean($this->Request['joberrors'])) {
+                       $joberrors = $misc->isValidBooleanTrue($this->Request['joberrors']) ? true : false;
+               }
 
                $allowed_sort_fields = ['job', 'client', 'fileset', 'starttime', 'endtime', 'jobid', 'content', 'type', 'jobstatus', 'joberrors'];
                if (is_string($order_by) && !in_array($order_by, $allowed_sort_fields)) {
@@ -123,6 +127,21 @@ class Sources extends BaculumAPIServer {
                        }
                }
 
+               if (!is_null($joberrors)) {
+                       if ($joberrors === true) {
+                               $params['jres.JobErrors'] = [];
+                               $params['jres.JobErrors'][] = [
+                                       'operator' => '>',
+                                       'vals' => 0
+                               ];
+                       } elseif ($joberrors === false) {
+                               $params['jres.JobErrors'] = [];
+                               $params['jres.JobErrors'][] = [
+                                       'vals' => 0
+                               ];
+                       }
+               }
+
                $sources = $this->getModule('source')->getSources(
                        $params,
                        $props,
index 986b77edae188827391d2928b60a7143a034aa19..b9c3e28e8c3a503d54bac42c5544120ef3e770da 100644 (file)
                                                        "enum": ["C", "R", "B", "T", "W", "E", "e", "f", "D", "A", "I", "F", "S", "m", "M", "s", "j", "c", "d", "t", "p", "i", "a", "l", "L"]
                                                }
                                        },
+                                       {
+                                               "name": "joberrors",
+                                               "in": "query",
+                                               "required": false,
+                                               "description": "Show objects from jobs that contain or that do not contain errors.",
+                                               "schema": {
+                                                       "type": "boolean"
+                                               }
+                                       },
                                        {
                                                "name": "hasobject",
                                                "in": "query",