Commit efa85058 authored by Marcin Haba's avatar Marcin Haba
Browse files

baculum: Add age parameter to jobs and objects endpoints

parent bae2036f
......@@ -49,6 +49,7 @@ class Jobs extends BaculumAPIServer {
$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;
$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']: 'JobId';
$order_direction = $this->Request->contains('order_direction') && $misc->isValidOrderDirection($this->Request['order_direction']) ? $this->Request['order_direction']: 'DESC';
......@@ -145,6 +146,12 @@ class Jobs extends BaculumAPIServer {
'vals' => date('Y-m-d H:i:s', $starttime_to)
];
}
} elseif (!empty($age)) { // Job age (now() - age)
$params['Job.StartTime'] = [];
$params['Job.StartTime'][] = [
'operator' => '>=',
'vals' => date('Y-m-d H:i:s', (time() - $age))
];
}
// End time range
......
......@@ -53,6 +53,7 @@ class Objects extends BaculumAPIServer {
$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;
$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']: 'ObjectId';
$order_direction = $this->Request->contains('order_direction') && $misc->isValidOrderDirection($this->Request['order_direction']) ? $this->Request['order_direction']: 'DESC';
......@@ -178,6 +179,12 @@ class Objects extends BaculumAPIServer {
'vals' => date('Y-m-d H:i:s', $starttime_to)
];
}
} elseif (!empty($age)) { // Job age (now() - age)
$params['Job.StartTime'] = [];
$params['Job.StartTime'][] = [
'operator' => '>=',
'vals' => date('Y-m-d H:i:s', (time() - $age))
];
}
// End time range
......
......@@ -959,6 +959,16 @@
"type": "integer"
}
},
{
"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": "order_by",
"in": "query",
......@@ -6602,6 +6612,16 @@
"schema": {
"type": "integer"
}
},
{
"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"
}
}
]
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment