From 9f2070dcedda219383eb3e534bf4c33371c94404 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 28 Mar 2017 18:08:27 +0200 Subject: [PATCH] IcingaEndpoint: provide getRestApiClient() helper fixes #877 --- library/Director/Objects/IcingaEndpoint.php | 34 +++++++++++++-------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/library/Director/Objects/IcingaEndpoint.php b/library/Director/Objects/IcingaEndpoint.php index 749335e3..da37ac1f 100644 --- a/library/Director/Objects/IcingaEndpoint.php +++ b/library/Director/Objects/IcingaEndpoint.php @@ -54,19 +54,7 @@ class IcingaEndpoint extends IcingaObject { $format = $this->connection->settings()->config_format; if ($format === 'v2') { - $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 new CoreApi($client); + return new CoreApi($this->getRestApiClient()); } elseif ($format === 'v1') { return new LegacyDeploymentApi($this->connection); } 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 *