Example #1
0
 /**
  * @param array $options
  *
  * @return Service
  */
 private function getDefaultIdentityService(array $options) : Service
 {
     if (!isset($options['authUrl'])) {
         throw new \InvalidArgumentException("'authUrl' is a required option");
     }
     $clientOptions = ['base_uri' => Utils::normalizeUrl($options['authUrl']), 'handler' => HandlerStack::create()];
     if (isset($options['requestOptions'])) {
         $clientOptions = array_merge($options['requestOptions'], $clientOptions);
     }
     return Service::factory(new Client($clientOptions));
 }
Example #2
0
 public static function getAuthOptsV2()
 {
     $httpClient = new Client(['base_uri' => CommonUtils::normalizeUrl(getenv('OS_AUTH_URL')), 'handler' => HandlerStack::create()]);
     return ['authUrl' => getenv('OS_AUTH_URL'), 'region' => getenv('OS_REGION_NAME'), 'username' => getenv('OS_USERNAME'), 'password' => getenv('OS_PASSWORD'), 'tenantName' => getenv('OS_TENANT_NAME'), 'identityService' => new Service($httpClient, new Api())];
 }
<?php

require 'vendor/autoload.php';
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use OpenStack\Identity\v2\Service;
use OpenStack\Common\Transport\Utils as TransportUtils;
use OpenStack\OpenStack;
$authUrl = 'https://example.com:5000/v2.0';
$httpClient = new Client(['base_uri' => TransportUtils::normalizeUrl($authUrl), 'handler' => HandlerStack::create()]);
$options = ['authUrl' => $authUrl, 'region' => 'RegionOne', 'username' => 'foo', 'password' => 'bar', 'tenantName' => 'baz', 'identityService' => Service::factory($httpClient)];
$openstack = new OpenStack($options);
Example #4
0
 private function httpClient(string $baseUrl, HandlerStack $stack) : ClientInterface
 {
     $clientOptions = ['base_uri' => Utils::normalizeUrl($baseUrl), 'handler' => $stack];
     if (isset($this->globalOptions['requestOptions'])) {
         $clientOptions = array_merge($this->globalOptions['requestOptions'], $clientOptions);
     }
     return new Client($clientOptions);
 }
Example #5
0
 private function httpClient($baseUrl, HandlerStack $stack)
 {
     return new Client(['base_uri' => Utils::normalizeUrl($baseUrl), 'handler' => $stack]);
 }