[icinga-checkins] icinga.org: icingaweb2-module-director/master: CliCommand: provide api helper

git at icinga.org git at icinga.org
Wed Feb 17 16:44:59 CET 2016


Module: icingaweb2-module-director
Branch: master
Commit: e250c7c6f6a85801eac00e2761b1007034b31cd0
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=e250c7c6f6a85801eac00e2761b1007034b31cd0

Author: Thomas Gelf <thomas at gelf.net>
Date:   Wed Feb 17 16:43:29 2016 +0100

CliCommand: provide api helper

---

 library/Director/Cli/Command.php |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/library/Director/Cli/Command.php b/library/Director/Cli/Command.php
index b010c1d..34cbbaa 100644
--- a/library/Director/Cli/Command.php
+++ b/library/Director/Cli/Command.php
@@ -4,11 +4,29 @@ namespace Icinga\Module\Director\Cli;
 
 use Icinga\Cli\Command as CliCommand;
 use Icinga\Module\Director\Db;
+use Icinga\Module\Director\Objects\IcingaEndpoint;
 
 class Command extends CliCommand
 {
     protected $db;
 
+    private $api;
+
+    protected function api($endpointName = null)
+    {
+        if ($this->api === null) {
+            if ($endpointName === null) {
+                $endpoint = $this->db()->getDeploymentEndpoint();
+            } else {
+                $endpoint = IcingaEndpoint::load($endpointName, $this->db());
+            }
+
+            $this->api = $endpoint->api();
+        }
+
+        return $this->api;
+    }
+
     protected function db()
     {
         if ($this->db === null) {



More information about the icinga-checkins mailing list