private function validateContext() { if ($this->mozuUrl->getLocation() == UrlLocation::TENANT_POD) { if ($this->apiContext->getTenantId() < 0) { throw new \Exception("TenantId is missing"); } if (trim($this->apiContext->getTenantUrl()) == "") { $tenantResource = new TenantResource(new ApiContext()); $tenant = $tenantResource->getTenant($this->apiContext->getTenantId()); if ($tenant == null) { throw new \Exception("Tenant " . $this->apiContext->getTenantId() . " Not found"); } $this->baseAddress = HttpHelper::getUrl($tenant->domain); } else { $this->baseAddress = HttpHelper::getUrl($this->apiContext->getTenantUrl()); } } else { if ($this->mozuUrl->getLocation() == UrlLocation::PCI_POD) { if ($this->apiContext->getTenantId() < 0) { throw new \Exception("TenantId is missing"); } if (!isset(MozuConfig::$basePciUrl)) { throw new \Exception("MozuConfig basePciUrl is empty. A valid value is required"); } $this->baseAddress = MozuConfig::$basePciUrl; } else { $authentication = AppAuthenticator::getInstance(); if ($authentication == null) { throw new \Exception("App is not initialized. Use AppAuthenticator to initialize the app."); } if (!isset(MozuConfig::$baseAppAuthUrl)) { throw new \Exception("MozuConfig baseAppAuthUrl is empty. A valid value is required"); } $this->baseAddress = MozuConfig::$baseAppAuthUrl; } } }
private static function getAuthUrl($tenantId) { $tenantResource = new TenantResource(); $mozuResult = $tenantResource->GetTenantAsync($tenantId)->wait(); return HttpHelper::getUrl($mozuResult->json()->domain); }