monitoring/API: Require a filter when scheduling host downtimes

refs #9606
This commit is contained in:
Eric Lippmann 2015-08-25 09:24:47 +02:00
parent 04ae298c0c
commit a0ff09da84
1 changed files with 6 additions and 2 deletions

View File

@ -19,11 +19,15 @@ class Monitoring_ActionsController extends Controller
*/
public function scheduleHostDowntimeAction()
{
// @TODO(el): Require a filter
$filter = Filter::fromQueryString((string) $this->params);
/** @var Filter $filter */
if ($filter->isEmpty()) {
$this->httpBadRequest('Filter must not be empty');
}
// @TODO(el): $this->backend->list('host')->handleRequest()->fetchAll()
$hostList = new HostList($this->backend);
$this->applyRestriction('monitoring/filter/objects', $hostList);
$hostList->addFilter(Filter::fromQueryString((string) $this->params));
$hostList->addFilter($filter);
if (! $hostList->count()) {
// @TODO(el): Use ApiResponse class for unified response handling.
$this->getResponse()->sendJson(array(