public function get() {
$misc = $this->getModule('misc');
$limit = $this->Request->contains('limit') ? intval($this->Request['limit']) : 0;
+ $offset = $this->Request->contains('offset') && $misc->isValidInteger($this->Request['offset']) ? (int)$this->Request['offset'] : 0;
$cmd = ['messages'];
$result = $this->getModule('bconsole')->bconsoleCommand($this->director, $cmd, null, true);
$output = $result->output;
if ($result->exitcode == 0) {
- $output = $limit > 0 ? array_slice($output, -$limit) : $output;
+ if ($limit > 0 && $offset <= 0) {
+ $output = array_slice($output, -$limit);
+ } elseif ($limit > 0 && $offset > 0) {
+ $output = array_slice($output, -$offset, $limit);
+ }
}
$this->output = $output;
$this->error = $result->exitcode > 0 ? GenericError::ERROR_WRONG_EXITCODE : GenericError::ERROR_NO_ERRORS;
}
}
},
- "parameters": [{
- "name": "limit",
- "in": "query",
- "description": "Set messages log Limit.",
- "required": false,
- "default": 0,
- "schema": {
- "type": "integer"
+ "parameters": [
+ {
+ "name": "limit",
+ "in": "query",
+ "description": "Set messages log Limit. It is applyed from the end, not from the beginning. Ex. for msg1, msg2, msg3, msg4 and limit=2 it displays msg3 and msg4.",
+ "required": false,
+ "default": 0,
+ "schema": {
+ "type": "integer"
+ }
+ },
+ {
+ "name": "offset",
+ "in": "query",
+ "description": "Messages' offset must be used together with limit. It is applyed from the end, not from the beginning. Ex. for msg1, msg2, msg3, msg4 and offset=3 limit=2 it displays msg2 and msg3.",
+ "required": false,
+ "default": 0,
+ "schema": {
+ "type": "integer"
+ }
}
- }]
+ ]
}
},
"/api/v2/directors/{director_name}/status": {