IcingaEndpoint: provide getRestApiClient() helper

fixes #877
This commit is contained in:
Thomas Gelf 2017-03-28 18:08:27 +02:00
parent f885d90a0a
commit 9f2070dced

View File

@ -54,6 +54,19 @@ class IcingaEndpoint extends IcingaObject
{
$format = $this->connection->settings()->config_format;
if ($format === 'v2') {
return new CoreApi($this->getRestApiClient());
} elseif ($format === 'v1') {
return new LegacyDeploymentApi($this->connection);
} else {
throw new ProgrammingError('Unsupported config format: %s', $format);
}
}
/**
* @return RestApiClient
*/
public function getRestApiClient()
{
$client = new RestApiClient(
$this->getResolvedProperty('host', $this->getObjectName()),
$this->getResolvedProperty('port')
@ -66,12 +79,7 @@ class IcingaEndpoint extends IcingaObject
$user->password
);
return new CoreApi($client);
} elseif ($format === 'v1') {
return new LegacyDeploymentApi($this->connection);
} else {
throw new ProgrammingError('Unsupported config format: %s', $format);
}
return $client;
}
/**