File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace OpenStack ;
4
4
5
+ use GuzzleHttp \Client ;
6
+ use GuzzleHttp \HandlerStack ;
5
7
use OpenCloud \Common \Service \Builder ;
8
+ use OpenCloud \Common \Transport \Utils ;
9
+ use OpenStack \Identity \v3 \Service ;
6
10
7
11
/**
8
12
* This class is the primary entry point for working with the SDK. It allows for the easy creation
@@ -27,9 +31,30 @@ class OpenStack
27
31
*/
28
32
public function __construct (array $ options = [], Builder $ builder = null )
29
33
{
34
+ if (!isset ($ options ['identityService ' ])) {
35
+ $ options ['identityService ' ] = $ this ->getDefaultIdentityService ($ options );
36
+ }
37
+
30
38
$ this ->builder = $ builder ?: new Builder ($ options , 'OpenStack ' );
31
39
}
32
40
41
+ /**
42
+ * @param array $options
43
+ *
44
+ * @return Service
45
+ */
46
+ private function getDefaultIdentityService (array $ options ): Service
47
+ {
48
+ if (!isset ($ options ['authUrl ' ])) {
49
+ throw new \InvalidArgumentException ("'authUrl' is a required option " );
50
+ }
51
+
52
+ return Service::factory (new Client ([
53
+ 'base_uri ' => Utils::normalizeUrl ($ options ['authUrl ' ]),
54
+ 'handler ' => HandlerStack::create (),
55
+ ]));
56
+ }
57
+
33
58
/**
34
59
* Creates a new Compute v2 service.
35
60
*
You can’t perform that action at this time.
0 commit comments