monitoring/API: Expose removing service downtimes

refs #9606
This commit is contained in:
Eric Lippmann 2015-08-21 10:28:09 +02:00
parent c35f0976c2
commit 8207579e13
1 changed files with 29 additions and 0 deletions

View File

@ -90,4 +90,33 @@ class Monitoring_ActionsController extends Controller
->setObjects($serviceList->fetch()) ->setObjects($serviceList->fetch())
->handleRequest($this->getRequest()); ->handleRequest($this->getRequest());
} }
/**
* Remove service downtimes
*/
public function removeServiceDowntimeAction()
{
// @TODO(el): Require a filter
$downtimes = $this->backend
->select()
->from('downtime', array('host_name', 'service_description', 'id' => 'downtime_internal_id'))
->where('object_type', 'service')
->applyFilter($this->getRestriction('monitoring/filter/objects'))
->handleRequest($this->getRequest())
->fetchAll();
if (empty($downtimes)) {
// @TODO(el): Use ApiResponse class for unified response handling.
$this->getResponse()->sendJson(array(
'status' => 'fail',
'message' => 'No downtimes found matching the given filter'
));
}
$form = new DeleteDowntimesCommandForm();
$form
->setIsApiTarget(true)
->setDowntimes($downtimes)
->handleRequest($this->getRequest());
// @TODO(el): Respond w/ the downtimes deleted instead of the notifiaction added by
// DeleteDowntimesCommandForm::onSuccess().
}
} }