namespace Baculum\API\Modules;
+use Baculum\Common\Modules\Logging;
+use PDO;
+
/**
* Object manager module.
*
return $result;
}
+ /**
+ * Get object records in overview.
+ *
+ * @param array $general_criteria SQL criteria to get object list
+ * @param array $object_criteria SQL object specific criteria to get object list
+ * @param mixed $limit_val result limit value
+ * @param int $offset_val result offset value
+ * @param string $sort_col column to sort
+ * @param string $sort_order sort order (asc - ascending, desc - descending)
+ * @return array object record list or empty list if no object found
+ */
+ public function getObjectsOverview($general_criteria = [], $object_criteria = [], $limit_val = null, $offset_val = 0, $sort_col = null, $sort_order = 'DESC') {
+ $connection = ObjectRecord::finder()->getDbConnection();
+ $connection->setActive(true);
+ $pdo = $connection->getPdoInstance();
+
+ $limit = is_int($limit_val) && $limit_val > 0 ? ' LIMIT ' . $limit_val : '';
+ $offset = is_int($offset_val) && $offset_val > 0 ? ' OFFSET ' . $offset_val : '';
+ $db_params = $this->getModule('api_config')->getConfig('db');
+ if ($db_params['type'] === Database::PGSQL_TYPE) {
+ $sort_col = strtolower($sort_col);
+ }
+
+ // default sorting for objects
+ $obj_order = ' ORDER BY
+ ObjectType,
+ ObjectName,
+ ObjectUUID,
+ Client.Name,
+ Job.Name ';
+ $file_order = ' ORDER BY
+ FileSet.FileSet,
+ Job.Name,
+ Client.Name ';
+
+ if (empty($sort_col)) {
+ $sort_col = 'JobTDate';
+ }
+ $order = sprintf(
+ 'ORDER BY %s %s ',
+ $sort_col,
+ $sort_order
+ );
+
+ $result = [
+ 'overview' => []
+ ];
+ $general_where = Database::getWhere($general_criteria, true);
+ $object_crit_all = array_merge($general_criteria, $object_criteria);
+ $object_where = Database::getWhere($object_crit_all);
+ try {
+ // start transaction
+ $pdo->beginTransaction();
+
+ // temporary table name
+ $objects_tname1 = 'objects_1_' . getmypid();
+ $objects_tname2 = 'objects_2_' . getmypid();
+ $objects_tname3 = 'objects_3_' . getmypid();
+ $objects_tname4 = 'objects_4_' . getmypid();
+
+ $db_params = $this->getModule('api_config')->getConfig('db');
+ if ($db_params['type'] === Database::PGSQL_TYPE) {
+ // PostgreSQL block
+
+ // create temporary table
+ $sql = 'CREATE TEMPORARY TABLE ' . $objects_tname1 . ' AS
+ SELECT DISTINCT ON (
+ ObjectType,
+ ObjectName,
+ ObjectUUID,
+ Client.Name,
+ Job.Name
+ )
+ ObjectType AS objecttype,
+ ObjectName AS objectname,
+ Client.ClientId AS clienid,
+ Client.Name AS client,
+ Job.Name AS job,
+ Job.Level AS level,
+ ObjectId AS objectid,
+ Object.JobId AS jobid,
+ JobTDate AS jobtdate,
+ Job.StartTime AS starttime,
+ ObjectCategory AS objectcategory,
+ ObjectStatus AS objectstatus,
+ Job.JobStatus AS jobstatus
+ FROM Object
+ JOIN Job USING (JobId)
+ JOIN Client USING (ClientId)
+ ' . $object_where['where'] . $obj_order;
+
+ Database::execute($sql, $object_where['params']);
+
+ // get content for files
+ $sql = 'CREATE TEMPORARY TABLE ' . $objects_tname4 . ' AS
+ SELECT DISTINCT ON (FileSet.FileSet, Job.Name, Client.Name)
+ FileSet.FileSet AS fileset,
+ Job.Name AS job,
+ Client.ClientId AS clienid,
+ Client.Name AS client,
+ JobId AS jobid,
+ Job.Level AS level,
+ JobTDate AS jobtdate,
+ StartTime AS starttime,
+ JobStatus AS jobstatus,
+ JobBytes AS jobbytes,
+ JobFiles AS jobfiles
+ FROM Job
+ JOIN FileSet USING (FileSetId)
+ JOIN Client USING (ClientId)
+ WHERE
+ FileSet.Content = \'files\'
+ ' . (!empty($general_where['where']) ? ' AND ' . $general_where['where'] : '') . $file_order;
+
+ Database::execute($sql, $general_where['params']);
+
+ } elseif ($db_params['type'] === Database::MYSQL_TYPE) {
+ // MySQL block
+
+ // create temporary table 1 for objects
+ $sql = 'CREATE TABLE ' . $objects_tname1 . ' AS
+ SELECT CONCAT(
+ ObjectType,
+ ObjectName,
+ ObjectUUID,
+ Client.Name,
+ Job.Name
+ ) AS K,
+ ObjectType AS objecttype,
+ ObjectName AS objectname,
+ Client.ClientId AS clienid,
+ Client.Name AS client,
+ Job.Name AS Job,
+ Job.Level AS level,
+ ObjectId AS objectid,
+ Object.JobId AS jobid,
+ JobTDate AS jobtdate,
+ StartTime AS starttime,
+ ObjectCategory AS objectcategory,
+ ObjectStatus AS objectstatus,
+ JobStatus AS jobstatus
+ FROM Object
+ JOIN Job USING (JobId)
+ JOIN Client USING (ClientId)' . $object_where['where'] . $obj_order;
+
+ Database::execute($sql, $object_where['params']);
+
+ // Create temporary table 2 for objects
+ $sql = 'CREATE TEMPORARY TABLE ' . $objects_tname2 . ' AS
+ SELECT ' . $objects_tname1 . '.K,
+ objecttype,
+ objectname,
+ client,
+ job,
+ objectid,
+ jobid,
+ AAA.jobtdate,
+ starttime,
+ objectcategory,
+ objectstatus,
+ jobstatus
+ FROM ' . $objects_tname1 . ' JOIN (
+ SELECT
+ AA.K,
+ MAX(AA.jobtdate) AS jobtdate
+ FROM ' . $objects_tname1 . ' AS AA
+ GROUP BY AA.K
+ ) AS AAA ON (
+ AAA.K = ' . $objects_tname1 . '.K AND AAA.jobtdate = ' . $objects_tname1 . '.jobtdate
+ ) ';
+
+ Database::execute($sql);
+
+ // Create temporary table 1 for files
+ $sql = 'CREATE TABLE ' . $objects_tname3 . ' AS
+ SELECT CONCAT(FileSet.FileSet, Job.Name, Client.Name) AS K,
+ FileSet.FileSet AS fileset,
+ Job.Name AS job,
+ Client.ClientId AS clienid,
+ Client.Name AS client,
+ JobId AS jobid,
+ Job.Level AS level,
+ JobTDate AS jobtdate,
+ StartTime AS starttime,
+ JobStatus AS jobstatus,
+ JobBytes AS jobbytes,
+ JobFiles AS jobfiles
+ FROM Job
+ JOIN FileSet USING (FileSetId)
+ JOIN Client USING (ClientId)
+ WHERE
+ FileSet.Content = \'files\'
+ ' . (!empty($general_where['where']) ? ' AND ' . $general_where['where'] : '') . $file_order;
+ Database::execute($sql, $general_where['params']);
+
+ // Create temporary table 2 for files
+ $sql = 'CREATE TEMPORARY TABLE ' . $objects_tname4 . ' AS
+ SELECT ' . $objects_tname3 . '.K,
+ fileset,
+ job,
+ clienid,
+ client,
+ jobid,
+ level,
+ AAA.jobtdate,
+ starttime,
+ jobstatus,
+ jobbytes,
+ jobfiles
+ FROM ' . $objects_tname3 . ' JOIN (
+ SELECT
+ AA.K,
+ MAX(AA.jobtdate) AS jobtdate
+ FROM ' . $objects_tname3 . ' AS AA
+ GROUP BY AA.K
+ ) AS AAA ON (
+ AAA.K = ' . $objects_tname3 . '.K AND AAA.jobtdate = ' . $objects_tname3 . '.jobtdate
+ ) ';
+ Database::execute($sql);
+ }
+
+ // count for each type
+ $sql = 'SELECT * FROM (
+ SELECT
+ ObjectType AS objecttype,
+ COUNT(1) AS count
+ FROM ' . $objects_tname1 . '
+ GROUP BY ObjectType
+ ) AS A UNION (
+ SELECT
+ \'files\' AS objecttype,
+ COUNT(1) AS count
+ FROM ' . $objects_tname4 . '
+ GROUP BY ObjectType
+ )';
+ $statement = Database::runQuery($sql);
+ $object_count = $statement->fetchAll(PDO::FETCH_ASSOC);
+
+ for ($i = 0; $i < count($object_count); $i++) {
+ $items = [];
+ if ($object_count[$i]['objecttype'] == 'files') {
+ $sql = 'SELECT *
+ FROM ' . $objects_tname4 . '
+ ' . ((stripos($sort_col, 'object') === false) ? $order : '') . $limit . $offset;
+ $statement = Database::runQuery($sql);
+ $items = $statement->fetchAll(PDO::FETCH_ASSOC);
+ } else {
+ $sql = 'SELECT *
+ FROM ' . $objects_tname1 . '
+ WHERE ObjectType = \'' . $object_count[$i]['objecttype'] . '\'
+ ' . $order . $limit . $offset;
+ $statement = Database::runQuery($sql);
+ $items = $statement->fetchAll(PDO::FETCH_ASSOC);
+ }
+ if (!key_exists($object_count[$i]['objecttype'], $result['overview'])) {
+ // type does not exists, add objects
+ $result['overview'][$object_count[$i]['objecttype']] = [
+ 'items' => $items,
+ 'count' => $object_count[$i]['count']
+ ];
+ } else {
+ // type exists, update count only
+ $result['overview'][$object_count[$i]['objecttype']]['count'] += $object_count[$i]['count'];
+ }
+ }
+
+ // drop temporary tables
+ $sql = 'DROP TABLE ' . $objects_tname1;
+ Database::execute($sql);
+
+ if ($db_params['type'] === Database::MYSQL_TYPE) {
+ $sql = 'DROP TABLE ' . $objects_tname2;
+ Database::execute($sql);
+ $sql = 'DROP TABLE ' . $objects_tname3;
+ Database::execute($sql);
+ $sql = 'DROP TABLE ' . $objects_tname4;
+ Database::execute($sql);
+ }
+ } catch(\PDOException $e) {
+ // rollback the transaction
+ //$pdo->rollBack();
+
+ // show the error message
+ $msg = 'SQL transation commit error: ' . $e->getMessage();
+ $this->getModule('logging')->log(
+ Logging::CATEGORY_EXECUTE,
+ $msg
+ );
+ }
+ return $result;
+ }
+
/**
* Get object categories based on criterias.
*
--- /dev/null
+<?php
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum - Bacula web interface
+ *
+ * Copyright (C) 2013-2023 Kern Sibbald
+ *
+ * The main author of Baculum is Marcin Haba.
+ * The original author of Bacula is Kern Sibbald, with contributions
+ * from many others, a complete list can be found in the file AUTHORS.
+ *
+ * You may use this file and others of this release according to the
+ * license defined in the LICENSE file, which includes the Affero General
+ * Public License, v3.0 ("AGPLv3") and some additional permissions and
+ * terms pursuant to its AGPLv3 Section 7.
+ *
+ * This notice must be preserved when any source code is
+ * conveyed and/or propagated.
+ *
+ * Bacula(R) is a registered trademark of Kern Sibbald.
+ */
+
+use Baculum\Common\Modules\Errors\ObjectError;
+use Baculum\API\Modules\ObjectRecord;
+use Baculum\API\Modules\ObjectManager;
+
+/**
+ * Objects overview endpoint.
+ *
+ * @author Marcin Haba <marcin.haba@bacula.pl>
+ * @category API
+ * @package Baculum API
+ */
+class ObjectsOverview extends BaculumAPIServer {
+
+ /**
+ * Allowed order columns for object overview.
+ */
+ private $overview_order_columns = [
+ 'objectname',
+ 'client',
+ 'jobstatus'
+ ];
+
+ public function get() {
+ $misc = $this->getModule('misc');
+ $limit = $this->Request->contains('limit') && $misc->isValidInteger($this->Request['limit']) ? (int)$this->Request['limit'] : 0;
+ $offset = $this->Request->contains('offset') && $misc->isValidInteger($this->Request['offset']) ? (int)$this->Request['offset'] : 0;
+ $objecttype = $this->Request->contains('objecttype') && $misc->isValidName($this->Request['objecttype']) ? $this->Request['objecttype'] : null;
+ $objectname = $this->Request->contains('objectname') && $misc->isValidNameExt($this->Request['objectname']) ? $this->Request['objectname'] : null;
+ $objectcategory = $this->Request->contains('objectcategory') && $misc->isValidName($this->Request['objectcategory']) ? $this->Request['objectcategory'] : null;
+ $objectsource = $this->Request->contains('objectsource') && $misc->isValidName($this->Request['objectsource']) ? $this->Request['objectsource'] : null;
+ $objectuuid = $this->Request->contains('objectuuid') && $misc->isValidName($this->Request['objectuuid']) ? $this->Request['objectuuid'] : null;
+ $objectstatus = $this->Request->contains('objectstatus') && $misc->isValidState($this->Request['objectstatus']) ? $this->Request['objectstatus'] : null;
+ $jobname = $this->Request->contains('jobname') && $misc->isValidName($this->Request['jobname']) ? $this->Request['jobname'] : null;
+ $jobids = $this->Request->contains('jobids') && $misc->isValidIdsList($this->Request['jobids']) ? explode(',', $this->Request['jobids']) : [];
+ $jobstatus = $this->Request->contains('jobstatus') && $misc->isValidState($this->Request['jobstatus']) ? $this->Request['jobstatus'] : null;
+ $client = $this->Request->contains('client') && $misc->isValidName($this->Request['client']) ? $this->Request['client'] : '';
+ $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;
+ $schedtime_to = $this->Request->contains('schedtime_to') && $misc->isValidInteger($this->Request['schedtime_to']) ? (int)$this->Request['schedtime_to'] : null;
+ $starttime_from = $this->Request->contains('starttime_from') && $misc->isValidInteger($this->Request['starttime_from']) ? (int)$this->Request['starttime_from'] : null;
+ $starttime_to = $this->Request->contains('starttime_to') && $misc->isValidInteger($this->Request['starttime_to']) ? (int)$this->Request['starttime_to'] : null;
+ $endtime_from = $this->Request->contains('endtime_from') && $misc->isValidInteger($this->Request['endtime_from']) ? (int)$this->Request['endtime_from'] : null;
+ $endtime_to = $this->Request->contains('endtime_to') && $misc->isValidInteger($this->Request['endtime_to']) ? (int)$this->Request['endtime_to'] : null;
+ $realendtime_from = $this->Request->contains('realendtime_from') && $misc->isValidInteger($this->Request['realendtime_from']) ? (int)$this->Request['realendtime_from'] : null;
+ $realendtime_to = $this->Request->contains('realendtime_to') && $misc->isValidInteger($this->Request['realendtime_to']) ? (int)$this->Request['realendtime_to'] : null;
+ $realstarttime_from = $this->Request->contains('realstarttime_from') && $misc->isValidInteger($this->Request['realstarttime_from']) ? (int)$this->Request['realstarttime_from'] : null;
+ $realstarttime_to = $this->Request->contains('realstarttime_to') && $misc->isValidInteger($this->Request['realstarttime_to']) ? (int)$this->Request['realstarttime_to'] : null;
+
+ // date/time values
+ $schedtime_from_date = $this->Request->contains('schedtime_from_date') && $misc->isValidBDateAndTime($this->Request['schedtime_from_date']) ? $this->Request['schedtime_from_date'] : null;
+ $schedtime_to_date = $this->Request->contains('schedtime_to_date') && $misc->isValidBDateAndTime($this->Request['schedtime_to_date']) ? $this->Request['schedtime_to_date'] : null;
+ $starttime_from_date = $this->Request->contains('starttime_from_date') && $misc->isValidBDateAndTime($this->Request['starttime_from_date']) ? $this->Request['starttime_from_date'] : null;
+ $starttime_to_date = $this->Request->contains('starttime_to_date') && $misc->isValidBDateAndTime($this->Request['starttime_to_date']) ? $this->Request['starttime_to_date'] : null;
+ $endtime_from_date = $this->Request->contains('endtime_from_date') && $misc->isValidBDateAndTime($this->Request['endtime_from_date']) ? $this->Request['endtime_from_date'] : null;
+ $endtime_to_date = $this->Request->contains('endtime_to_date') && $misc->isValidBDateAndTime($this->Request['endtime_to_date']) ? $this->Request['endtime_to_date'] : null;
+ $realstarttime_from_date = $this->Request->contains('realstarttime_from_date') && $misc->isValidBDateAndTime($this->Request['realstarttime_from_date']) ? $this->Request['realstarttime_from_date'] : null;
+ $realstarttime_to_date = $this->Request->contains('realstarttime_to_date') && $misc->isValidBDateAndTime($this->Request['realstarttime_to_date']) ? $this->Request['realstarttime_to_date'] : null;
+ $realendtime_from_date = $this->Request->contains('realendtime_from_date') && $misc->isValidBDateAndTime($this->Request['realendtime_from_date']) ? $this->Request['realendtime_from_date'] : null;
+ $realendtime_to_date = $this->Request->contains('realendtime_to_date') && $misc->isValidBDateAndTime($this->Request['realendtime_to_date']) ? $this->Request['realendtime_to_date'] : null;
+
+ $age = $this->Request->contains('age') && $misc->isValidInteger($this->Request['age']) ? (int)$this->Request['age'] : null;
+ $order_by = $this->Request->contains('order_by') && $misc->isValidColumn($this->Request['order_by']) ? $this->Request['order_by']: '';
+ $order_direction = $this->Request->contains('order_direction') && $misc->isValidOrderDirection($this->Request['order_direction']) ? $this->Request['order_direction']: 'DESC';
+
+ if (!empty($order_by)) {
+ $order_by_lc = strtolower($order_by);
+ if (!in_array($order_by_lc, $this->overview_order_columns)) {
+ $this->output = ObjectError::MSG_ERROR_INVALID_PROPERTY;
+ $this->error = ObjectError::ERROR_INVALID_PROPERTY;
+ return;
+ }
+ }
+
+ $general_params = [];
+ $object_params = [];
+ if (!empty($objecttype)) {
+ $object_params['Object.ObjectType'] = [];
+ $object_params['Object.ObjectType'][] = [
+ 'vals' => $objecttype
+ ];
+ }
+ if (!empty($objectname)) {
+ $object_params['Object.ObjectName'] = [];
+ $object_params['Object.ObjectName'][] = [
+ 'vals' => $objectname
+ ];
+ }
+ if (!empty($objectcategory)) {
+ $object_params['Object.ObjectCategory'] = [];
+ $object_params['Object.ObjectCategory'][] = [
+ 'vals' => $objectcategory
+ ];
+ }
+ if (!empty($objectsource)) {
+ $object_params['Object.ObjectSource'] = [];
+ $object_params['Object.ObjectSource'][] = [
+ 'vals' => $objectsource
+ ];
+ }
+ if (!empty($objectuuid)) {
+ $object_params['Object.ObjectUUID'] = [];
+ $object_params['Object.ObjectUUID'][] = [
+ 'vals' => $objectuuid
+ ];
+ }
+ if (!empty($objectstatus)) {
+ $object_params['Object.ObjectStatus'] = [];
+ $object_params['Object.ObjectStatus'][] = [
+ 'vals' => $objectstatus
+ ];
+ }
+ if (!empty($jobname)) {
+ $general_params['Job.Name'] = [];
+ $general_params['Job.Name'][] = [
+ 'vals' => $jobname
+ ];
+ }
+ if (count($jobids) > 0) {
+ $general_params['Job.JobId'] = [];
+ $general_params['Job.JobId'][] = [
+ 'operator' => 'IN',
+ 'vals' => $jobids
+ ];
+ }
+ if (!empty($client)) {
+ $general_params['Client.Name'] = [];
+ $general_params['Client.Name'][] = [
+ 'vals' => $client
+ ];
+ }
+ if (!is_null($joberrors)) {
+ if ($joberrors === true) {
+ $general_params['Job.JobErrors'] = [];
+ $general_params['Job.JobErrors'][] = [
+ 'operator' => '>',
+ 'vals' => 0
+ ];
+ } elseif ($joberrors === false) {
+ $general_params['Job.JobErrors'] = [];
+ $general_params['Job.JobErrors'][] = [
+ 'vals' => 0
+ ];
+ }
+ }
+ if (!empty($jobstatus)) {
+ $general_params['Job.JobStatus'] = [];
+ $general_params['Job.JobStatus'][] = [
+ 'vals' => $jobstatus
+ ];
+ }
+
+ // Scheduled time range
+ if (!empty($schedtime_from) || !empty($schedtime_to) || !empty($schedtime_from_date) || !empty($schedtime_to_date)) {
+ $general_params['Job.SchedTime'] = [];
+
+ // Schedule time from
+ $sch_t_from = '';
+ if (!empty($schedtime_from)) {
+ $sch_t_from = date('Y-m-d H:i:s', $schedtime_from);
+ } elseif (!empty($schedtime_from_date)) {
+ $sch_t_from = $schedtime_from_date;
+ }
+ if (!empty($sch_t_from)) {
+ $general_params['Job.SchedTime'][] = [
+ 'operator' => '>=',
+ 'vals' => $sch_t_from
+ ];
+ }
+
+ // Schedule time to
+ $sch_t_to = '';
+ if (!empty($schedtime_to)) {
+ $sch_t_to = date('Y-m-d H:i:s', $schedtime_to);
+ } elseif (!empty($schedtime_to_date)) {
+ $sch_t_to = $schedtime_to_date;
+ }
+ if (!empty($sch_t_to)) {
+ $general_params['Job.SchedTime'][] = [
+ 'operator' => '<=',
+ 'vals' => $sch_t_to
+ ];
+ }
+ }
+
+ // Start time range
+ if (!empty($starttime_from) || !empty($starttime_to) || !empty($starttime_from_date) || !empty($starttime_to_date)) {
+ $general_params['Job.StartTime'] = [];
+
+ // Start time from
+ $sta_t_from = '';
+ if (!empty($starttime_from)) {
+ $sta_t_from = date('Y-m-d H:i:s', $starttime_from);
+ } elseif (!empty($starttime_from_date)) {
+ $sta_t_from = $starttime_from_date;
+ }
+ if (!empty($sta_t_from)) {
+ $general_params['Job.StartTime'][] = [
+ 'operator' => '>=',
+ 'vals' => $sta_t_from
+ ];
+ }
+
+ // Start time to
+ $sta_t_to = '';
+ if (!empty($starttime_to)) {
+ $sta_t_to = date('Y-m-d H:i:s', $starttime_to);
+ } elseif (!empty($starttime_to_date)) {
+ $sta_t_to = $starttime_to_date;
+ }
+ if (!empty($sta_t_to)) {
+ $general_params['Job.StartTime'][] = [
+ 'operator' => '<=',
+ 'vals' => $sta_t_to
+ ];
+ }
+ } elseif (!empty($age)) { // Job age (now() - age)
+ $general_params['Job.StartTime'] = [];
+ $general_params['Job.StartTime'][] = [
+ 'operator' => '>=',
+ 'vals' => date('Y-m-d H:i:s', (time() - $age))
+ ];
+ }
+
+ // End time range
+ if (!empty($endtime_from) || !empty($endtime_to) || !empty($endtime_from_date) || !empty($endtime_to_date)) {
+ $general_params['Job.EndTime'] = [];
+
+ // End time from
+ $end_t_from = '';
+ if (!empty($endtime_from)) {
+ $end_t_from = date('Y-m-d H:i:s', $endtime_from);
+ } elseif (!empty($endtime_from_date)) {
+ $end_t_from = $endtime_from_date;
+ }
+ if (!empty($end_t_from)) {
+ $general_params['Job.EndTime'][] = [
+ 'operator' => '>=',
+ 'vals' => $end_t_from
+ ];
+ }
+
+ // End time to
+ $end_t_to = '';
+ if (!empty($endtime_to)) {
+ $end_t_to = date('Y-m-d H:i:s', $endtime_to);
+ } elseif (!empty($endtime_to_date)) {
+ $end_t_to = $endtime_to_date;
+ }
+ if (!empty($end_t_to)) {
+ $general_params['Job.EndTime'][] = [
+ 'operator' => '<=',
+ 'vals' => $end_t_to
+ ];
+ }
+ }
+
+ // Real start time range
+ if (!empty($realstarttime_from) || !empty($realstarttime_to) || !empty($realstarttime_from_date) || !empty($realstarttime_to_date)) {
+ $general_params['Job.RealStartTime'] = [];
+
+ // Realstart time from
+ $realstart_t_from = '';
+ if (!empty($realstarttime_from)) {
+ $realstart_t_from = date('Y-m-d H:i:s', $realstarttime_from);
+ } elseif (!empty($realstarttime_from_date)) {
+ $realstart_t_from = $realstarttime_from_date;
+ }
+ if (!empty($realstart_t_from)) {
+ $general_params['Job.RealStartTime'][] = [
+ 'operator' => '>=',
+ 'vals' => $realstart_t_from
+ ];
+ }
+
+ // Realstart time to
+ $realstart_t_to = '';
+ if (!empty($realstarttime_to)) {
+ $realstart_t_to = date('Y-m-d H:i:s', $realstarttime_to);
+ } elseif (!empty($realstarttime_to_date)) {
+ $realstart_t_to = $realstarttime_to_date;
+ }
+ if (!empty($realstart_t_to)) {
+ $general_params['Job.RealStartTime'][] = [
+ 'operator' => '<=',
+ 'vals' => $realstart_t_to
+ ];
+ }
+ }
+
+ // Real end time range
+ if (!empty($realendtime_from) || !empty($realendtime_to) || !empty($realendtime_from_date) || !empty($realendtime_to_date)) {
+ $general_params['Job.RealEndTime'] = [];
+
+ // Realend time from
+ $realend_t_from = '';
+ if (!empty($realendtime_from)) {
+ $realend_t_from = date('Y-m-d H:i:s', $realendtime_from);
+ } elseif (!empty($realendtime_from_date)) {
+ $realend_t_from = $realendtime_from_date;
+ }
+ if (!empty($realend_t_from)) {
+ $general_params['Job.RealEndTime'][] = [
+ 'operator' => '>=',
+ 'vals' => $realend_t_from
+ ];
+ }
+
+ // Realend time to
+ $realend_t_to = '';
+ if (!empty($realendtime_to)) {
+ $realend_t_to = date('Y-m-d H:i:s', $realendtime_to);
+ } elseif (!empty($realendtime_to_date)) {
+ $realend_t_to = $realendtime_to_date;
+ }
+ if (!empty($realend_t_to)) {
+ $general_params['Job.RealEndTime'][] = [
+ 'operator' => '<=',
+ 'vals' => $realend_t_to
+ ];
+ }
+ }
+
+ $objects = $this->getModule('object')->getObjectsOverview(
+ $general_params,
+ $object_params,
+ $limit,
+ $offset,
+ $order_by,
+ $order_direction
+ );
+ $this->output = $objects;
+ $this->error = ObjectError::ERROR_NO_ERRORS;
+ }
+}
<!-- object endpoints -->
<url ServiceParameter="Objects" pattern="api/v2/objects/" />
<url ServiceParameter="ObjectClass" pattern="api/v2/objects/{id}/" parameters.id="\d+" />
+ <url ServiceParameter="ObjectsOverview" pattern="api/v2/objects/overview/" />
<url ServiceParameter="ObjectVersions" pattern="api/v2/objects/versions/{uuid}" parameters.uuid="[a-zA-Z0-9:.\-_ ]+" />
<url ServiceParameter="ObjectStatsCategorySum" pattern="api/v2/objects/stats/category-sum/" />
<url ServiceParameter="ObjectStatsCategoryStatus" pattern="api/v2/objects/stats/category-status/" />
]
}
},
+ "/api/v2/objects/overview": {
+ "get": {
+ "tags": ["objects"],
+ "summary": "Object overview",
+ "description": "Get object overview.",
+ "responses": {
+ "200": {
+ "description": "Object overview",
+ "content": {
+ "application/json": {
+ "schema": {
+ "type": "object",
+ "properties": {
+ "output": {
+ "type": "object",
+ "properties": {
+ "overview": {
+ "type": "object",
+ "properties": {
+ "objecttype": {
+ "type": "object",
+ "properties": {
+ "items": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "objecttype": {
+ "type": "string",
+ "description": "Object type"
+ },
+ "objectname": {
+ "type": "string",
+ "description": "Object name"
+ },
+ "clientid": {
+ "type": "string",
+ "description": "Client identifier"
+ },
+ "client": {
+ "type": "string",
+ "description": "Client name"
+ },
+ "job": {
+ "type": "string",
+ "description": "Job name"
+ },
+ "level": {
+ "type": "string",
+ "description": "Job level"
+ },
+ "objectid": {
+ "type": "string",
+ "description": "Object identifier"
+ },
+ "jobid": {
+ "type": "string",
+ "description": " Job identifier"
+ },
+ "jobtdate": {
+ "type": "integer",
+ "description": "Job T date in UNIX timestamp form"
+ },
+ "starttime": {
+ "type": "string",
+ "description": "Job start time"
+ },
+ "objectcategory": {
+ "type": "string",
+ "description": "Object category"
+ },
+ "objectstatus": {
+ "type": "string",
+ "description": "Object status"
+ },
+ "jobstatus": {
+ "type": "string",
+ "description": "Job status"
+ }
+ }
+ }
+ }
+ }
+ },
+ "files": {
+ "type": "object",
+ "properties": {
+ "items": {
+ "type": "array",
+ "items": {
+ "type": "object",
+ "properties": {
+ "fileset": {
+ "type": "string",
+ "description": "Job fileset"
+ },
+ "job": {
+ "type": "string",
+ "description": "Job name"
+ },
+ "clientid": {
+ "type": "string",
+ "description": "Client identifier"
+ },
+ "client": {
+ "type": "string",
+ "description": "Client name"
+ },
+ "jobid": {
+ "type": "string",
+ "description": " Job identifier"
+ },
+ "level": {
+ "type": "string",
+ "description": "Job level"
+ },
+ "jobtdate": {
+ "type": "integer",
+ "description": "Job T date in UNIX timestamp form"
+ },
+ "starttime": {
+ "type": "string",
+ "description": "Job start time"
+ },
+ "jobstatus": {
+ "type": "string",
+ "description": "Job status"
+ },
+ "jobbytes": {
+ "type": "integer",
+ "description": "Job bytes"
+ },
+ "jobfiles": {
+ "type": "integer",
+ "description": "Job files"
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "error": {
+ "type": "integer",
+ "description": "Error code",
+ "enum": [0, 1, 2, 3, 4, 5, 6, 7, 11, 520, 1000]
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "parameters": [
+ {
+ "$ref": "#/components/parameters/Limit"
+ },
+ {
+ "$ref": "#/components/parameters/Offset"
+ },
+ {
+ "name": "objecttype",
+ "in": "query",
+ "required": false,
+ "description": "Object type, ex. 'm365' or 'PostgreSQL'",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "objectname",
+ "in": "query",
+ "required": false,
+ "description": "Object name",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "objectcategory",
+ "in": "query",
+ "required": false,
+ "description": "Object category, ex: 'mailbox'",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "objectsource",
+ "in": "query",
+ "required": false,
+ "description": "Object data source",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "objectuuid",
+ "in": "query",
+ "required": false,
+ "description": "Object UUID",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "objectstatus",
+ "in": "query",
+ "required": false,
+ "description": "Object status ex: 'T', 'e' ...",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "jobname",
+ "in": "query",
+ "required": false,
+ "description": "Job name",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "jobids",
+ "in": "query",
+ "required": false,
+ "description": "Job identifiers (comma separated)",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "order_by",
+ "in": "query",
+ "required": false,
+ "description": "Sort by selected object property (default objectid). There can be any object property (objectid, objectname, objectsource ...etc.) except jobname.",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "order_direction",
+ "in": "query",
+ "required": false,
+ "description": "Order direction. It can be 'asc' (ascending order) or 'desc' (descending order - default)",
+ "schema": {
+ "type": "string",
+ "enum": ["asc", "desc"]
+ }
+ },
+ {
+ "name": "schedtime_from",
+ "in": "query",
+ "required": false,
+ "description": "Scheduled time from (UNIX timestamp format, seconds)",
+ "schema": {
+ "type": "integer"
+ }
+ },
+ {
+ "name": "schedtime_from_date",
+ "in": "query",
+ "required": false,
+ "description": "Scheduled time from (date/time format YYYY-MM-DD HH:II:SS)",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "schedtime_to",
+ "in": "query",
+ "required": false,
+ "description": "Scheduled time to (UNIX timestamp format, seconds)",
+ "schema": {
+ "type": "integer"
+ }
+ },
+ {
+ "name": "schedtime_to_date",
+ "in": "query",
+ "required": false,
+ "description": "Scheduled time to (date/time format YYYY-MM-DD HH:II:SS)",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "starttime_from",
+ "in": "query",
+ "required": false,
+ "description": "Start time from (UNIX timestamp format, seconds)",
+ "schema": {
+ "type": "integer"
+ }
+ },
+ {
+ "name": "starttime_from_date",
+ "in": "query",
+ "required": false,
+ "description": "Start time from (date/time format YYYY-MM-DD HH:II:SS)",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "starttime_to",
+ "in": "query",
+ "required": false,
+ "description": "Start time to (UNIX timestamp format, seconds)",
+ "schema": {
+ "type": "integer"
+ }
+ },
+ {
+ "name": "starttime_to_date",
+ "in": "query",
+ "required": false,
+ "description": "Start time to (date/time format YYYY-MM-DD HH:II:SS)",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "realstarttime_from",
+ "in": "query",
+ "required": false,
+ "description": "Real start time from (UNIX timestamp format, seconds)",
+ "schema": {
+ "type": "integer"
+ }
+ },
+ {
+ "name": "realstarttime_from_date",
+ "in": "query",
+ "required": false,
+ "description": "Real start time from (date/time format YYYY-MM-DD HH:II:SS)",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "realstarttime_to",
+ "in": "query",
+ "required": false,
+ "description": "Real start time to (UNIX timestamp format, seconds)",
+ "schema": {
+ "type": "integer"
+ }
+ },
+ {
+ "name": "realstarttime_to_date",
+ "in": "query",
+ "required": false,
+ "description": "Real start time to (date/time format YYYY-MM-DD HH:II:SS)",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "endtime_from",
+ "in": "query",
+ "required": false,
+ "description": "End time from (UNIX timestamp format, seconds)",
+ "schema": {
+ "type": "integer"
+ }
+ },
+ {
+ "name": "endtime_from_date",
+ "in": "query",
+ "required": false,
+ "description": "End time from (date/time format YYYY-MM-DD HH:II:SS)",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "endtime_to",
+ "in": "query",
+ "required": false,
+ "description": "End time to (UNIX timestamp format, seconds)",
+ "schema": {
+ "type": "integer"
+ }
+ },
+ {
+ "name": "endtime_to_date",
+ "in": "query",
+ "required": false,
+ "description": "End time to (date/time format YYYY-MM-DD HH:II:SS)",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "realendtime_from",
+ "in": "query",
+ "required": false,
+ "description": "Real end time from (UNIX timestamp format, seconds)",
+ "schema": {
+ "type": "integer"
+ }
+ },
+ {
+ "name": "realendtime_from_date",
+ "in": "query",
+ "required": false,
+ "description": "Real end time from (date/time format YYYY-MM-DD HH:II:SS)",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+ "name": "realendtime_to",
+ "in": "query",
+ "required": false,
+ "description": "Real end time to (UNIX timestamp format, seconds)",
+ "schema": {
+ "type": "integer"
+ }
+ },
+ {
+ "name": "realendtime_to_date",
+ "in": "query",
+ "required": false,
+ "description": "Real end time to (date/time format YYYY-MM-DD HH:II:SS)",
+ "schema": {
+ "type": "string"
+ }
+ },
+ {
+
+ "name": "age",
+ "in": "query",
+ "required": false,
+ "description": "Job age in seconds (used is start time). starttime_from and starttime_to take precedence over this parameter.",
+ "schema": {
+ "type": "integer"
+ }
+ },
+ {
+ "name": "joberrors",
+ "in": "query",
+ "required": false,
+ "description": "Show objects from jobs that contain or that do not contain errors.",
+ "schema": {
+ "type": "boolean"
+ }
+ }
+ ]
+ }
+ },
"/api/v2/objects/stats/category-sum": {
"get": {
"tags": ["objects"],