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
1 changed files with 21 additions and 13 deletions

View File

@ -54,19 +54,7 @@ class IcingaEndpoint extends IcingaObject
{ {
$format = $this->connection->settings()->config_format; $format = $this->connection->settings()->config_format;
if ($format === 'v2') { if ($format === 'v2') {
$client = new RestApiClient( return new CoreApi($this->getRestApiClient());
$this->getResolvedProperty('host', $this->getObjectName()),
$this->getResolvedProperty('port')
);
$user = $this->getApiUser();
$client->setCredentials(
// TODO: $user->client_dn,
$user->object_name,
$user->password
);
return new CoreApi($client);
} elseif ($format === 'v1') { } elseif ($format === 'v1') {
return new LegacyDeploymentApi($this->connection); return new LegacyDeploymentApi($this->connection);
} else { } else {
@ -74,6 +62,26 @@ class IcingaEndpoint extends IcingaObject
} }
} }
/**
* @return RestApiClient
*/
public function getRestApiClient()
{
$client = new RestApiClient(
$this->getResolvedProperty('host', $this->getObjectName()),
$this->getResolvedProperty('port')
);
$user = $this->getApiUser();
$client->setCredentials(
// TODO: $user->client_dn,
$user->object_name,
$user->password
);
return $client;
}
/** /**
* Use duration time renderer helper * Use duration time renderer helper
* *