public function renderToggleObjectFeature(ToggleObjectFeatureCommand $command)
 {
     if ($command->getEnabled() === true) {
         $commandPrefix = 'ENABLE';
     } else {
         $commandPrefix = 'DISABLE';
     }
     switch ($command->getFeature()) {
         case ToggleObjectFeatureCommand::FEATURE_ACTIVE_CHECKS:
             $commandFormat = sprintf('%s_%%s_CHECK', $commandPrefix);
             break;
         case ToggleObjectFeatureCommand::FEATURE_PASSIVE_CHECKS:
             $commandFormat = sprintf('%s_PASSIVE_%%s_CHECKS', $commandPrefix);
             break;
         case ToggleObjectFeatureCommand::FEATURE_OBSESSING:
             if ($command->getEnabled() === true) {
                 $commandPrefix = 'START';
             } else {
                 $commandPrefix = 'STOP';
             }
             $commandFormat = sprintf('%s_OBSESSING_OVER_%%s', $commandPrefix);
             break;
         case ToggleObjectFeatureCommand::FEATURE_NOTIFICATIONS:
             $commandFormat = sprintf('%s_%%s_NOTIFICATIONS', $commandPrefix);
             break;
         case ToggleObjectFeatureCommand::FEATURE_EVENT_HANDLER:
             $commandFormat = sprintf('%s_%%s_EVENT_HANDLER', $commandPrefix);
             break;
         case ToggleObjectFeatureCommand::FEATURE_FLAP_DETECTION:
             $commandFormat = sprintf('%s_%%s_FLAP_DETECTION', $commandPrefix);
             break;
         default:
             throw new InvalidArgumentException($command->getFeature());
     }
     $object = $command->getObject();
     if ($object->getType() === ToggleObjectFeatureCommand::TYPE_HOST) {
         /** @var \Icinga\Module\Monitoring\Object\Host $object */
         $commandString = sprintf($commandFormat . ';%s', 'HOST', $object->getName());
     } else {
         /** @var \Icinga\Module\Monitoring\Object\Service $object */
         $commandString = sprintf($commandFormat . ';%s;%s', 'SVC', $object->getHost()->getName(), $object->getName());
     }
     return $commandString;
 }
 public function renderToggleObjectFeature(ToggleObjectFeatureCommand $command)
 {
     if ($command->getEnabled() === true) {
         $enabled = true;
     } else {
         $enabled = false;
     }
     switch ($command->getFeature()) {
         case ToggleObjectFeatureCommand::FEATURE_ACTIVE_CHECKS:
             $attr = 'enable_active_checks';
             break;
         case ToggleObjectFeatureCommand::FEATURE_PASSIVE_CHECKS:
             $attr = 'enable_passive_checks';
             break;
         case ToggleObjectFeatureCommand::FEATURE_NOTIFICATIONS:
             $attr = 'enable_notifications';
             break;
         case ToggleObjectFeatureCommand::FEATURE_EVENT_HANDLER:
             $attr = 'enable_event_handler';
             break;
         case ToggleObjectFeatureCommand::FEATURE_FLAP_DETECTION:
             $attr = 'enable_flapping';
             break;
         default:
             throw new InvalidArgumentException($command->getFeature());
     }
     $endpoint = 'objects/';
     $object = $command->getObject();
     if ($object->getType() === ToggleObjectFeatureCommand::TYPE_HOST) {
         /** @var \Icinga\Module\Monitoring\Object\Host $object */
         $endpoint .= 'hosts';
     } else {
         /** @var \Icinga\Module\Monitoring\Object\Service $object */
         $endpoint .= 'services';
     }
     $data = array('attrs' => array($attr => $enabled));
     $this->applyFilter($data, $object);
     return IcingaApiCommand::create($endpoint, $data);
 }