protected function sendCommand(IcingaApiCommand $command) { Logger::debug('Sending Icinga command "%s" to the API "%s:%u"', $command->getEndpoint(), $this->getHost(), $this->getPort()); $response = RestRequest::post($this->getUriFor($command->getEndpoint()))->authenticateWith($this->getUsername(), $this->getPassword())->sendJson()->noStrictSsl()->setPayload($command->getData())->send(); if (isset($response['error'])) { throw new CommandTransportException('Can\'t send external Icinga command: %u %s', $response['error'], $response['status']); } $result = array_pop($response['results']); if ($result['code'] < 200 || $result['code'] >= 300) { throw new CommandTransportException('Can\'t send external Icinga command: %u %s', $result['code'], $result['status']); } if ($command->hasNext()) { $this->sendCommand($command->getNext()); } }