GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 30eaeb...98f5c5 )
by Jamie
12s
created

OpenStack::metricGnocchiV1()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 0
cp 0
cc 1
eloc 3
nc 1
nop 1
crap 2
1
<?php declare(strict_types=1);
2
3
namespace OpenStack;
4
5
use GuzzleHttp\Client;
6
use GuzzleHttp\HandlerStack;
7
use OpenStack\Common\Service\Builder;
8
use OpenStack\Common\Transport\Utils;
9
use OpenStack\Identity\v3\Service;
10
11
/**
12
 * This class is the primary entry point for working with the SDK. It allows for the easy creation
13
 * of OpenStack services.
14
 *
15
 * @package OpenStack
16
 */
17
class OpenStack
18
{
19
    /** @var Builder */
20
    private $builder;
21
22
    /**
23
     * @param array    $options User-defined options
24
     *
25
     * $options['username']         = (string)            Your OpenStack username        [REQUIRED]
26
     *         ['password']         = (string)            Your OpenStack password        [REQUIRED]
27
     *         ['tenantId']         = (string)            Your tenant ID                 [REQUIRED if tenantName omitted]
28 7
     *         ['tenantName']       = (string)            Your tenant name               [REQUIRED if tenantId omitted]
29
     *         ['authUrl']          = (string)            The Keystone URL               [REQUIRED]
30 7
     *         ['debugLog']         = (bool)              Whether to enable HTTP logging [OPTIONAL]
31 7
     *         ['logger']           = (LoggerInterface)   Must set if debugLog is true   [OPTIONAL]
32
     *         ['messageFormatter'] = (MessageFormatter)  Must set if debugLog is true   [OPTIONAL]
33
     *         ['requestOptions']   = (array)             Guzzle Http request options    [OPTIONAL]
34
     *
35
     * @param Builder $builder
36
     */
37
    public function __construct(array $options = [], Builder $builder = null)
38
    {
39
        if (!isset($options['identityService'])) {
40 1
            $options['identityService'] = $this->getDefaultIdentityService($options);
41
        }
42 1
43 1
        $this->builder = $builder ?: new Builder($options, 'OpenStack');
44
    }
45
46
    /**
47
     * @param array $options
48
     *
49
     * @return Service
50
     */
51
    private function getDefaultIdentityService(array $options): Service
52
    {
53 1
        if (!isset($options['authUrl'])) {
54
            throw new \InvalidArgumentException("'authUrl' is a required option");
55 1
        }
56 1
57
        $clientOptions = [
58
            'base_uri' => Utils::normalizeUrl($options['authUrl']),
59
            'handler'  => HandlerStack::create(),
60
        ];
61
62
        if (isset($options['requestOptions'])) {
63
            $clientOptions = array_merge($options['requestOptions'], $clientOptions);
64
        }
65
66 1
        return Service::factory(new Client($clientOptions));
67
    }
68 1
69 1
    /**
70
     * Creates a new Compute v2 service.
71
     *
72
     * @param array $options Options that will be used in configuring the service.
73
     *
74
     * @return \OpenStack\Compute\v2\Service
75
     */
76
    public function computeV2(array $options = []): \OpenStack\Compute\v2\Service
77
    {
78
        $defaults = ['catalogName' => 'nova', 'catalogType' => 'compute'];
79 1
        return $this->builder->createService('Compute\\v2', array_merge($defaults, $options));
80
    }
81 1
82 1
    /**
83
     * Creates a new Networking v2 service.
84
     *
85
     * @param array $options Options that will be used in configuring the service.
86
     *
87
     * @return \OpenStack\Networking\v2\Service
88
     */
89
    public function networkingV2(array $options = []): \OpenStack\Networking\v2\Service
90
    {
91
        $defaults = ['catalogName' => 'neutron', 'catalogType' => 'network'];
92 1
        return $this->builder->createService('Networking\\v2', array_merge($defaults, $options));
93
    }
94 1
95 1
    /**
96
     * Creates a new Networking v2 Layer 3 service.
97
     *
98
     * @param array $options Options that will be used in configuring the service.
99
     *
100
     * @return \OpenStack\Networking\v2\Extensions\Layer3\Service
101
     */
102
    public function networkingV2ExtLayer3(array $options = []): \OpenStack\Networking\v2\Extensions\Layer3\Service
103
    {
104
        $defaults = ['catalogName' => 'neutron', 'catalogType' => 'network'];
105 1
        return $this->builder->createService('Networking\\v2\\Extensions\\Layer3', array_merge($defaults, $options));
106
    }
107 1
108 1
    /**
109
     * Creates a new Networking v2 Layer 3 service.
110
     *
111
     * @param array $options Options that will be used in configuring the service.
112
     *
113
     * @return \OpenStack\Networking\v2\Extensions\SecurityGroups\Service
114
     */
115
    public function networkingV2ExtSecGroups(array $options = []): \OpenStack\Networking\v2\Extensions\SecurityGroups\Service
116
    {
117
        $defaults = ['catalogName' => 'neutron', 'catalogType' => 'network'];
118 1
        return $this->builder->createService('Networking\\v2\\Extensions\\SecurityGroups', array_merge($defaults, $options));
119
    }
120 1
121 1
    /**
122
     * Creates a new Identity v2 service.
123
     *
124
     * @param array $options Options that will be used in configuring the service.
125
     *
126
     * @return \OpenStack\Identity\v2\Service
127
     */
128
    public function identityV2(array $options = []): \OpenStack\Identity\v2\Service
129
    {
130
        $defaults = ['catalogName' => 'keystone', 'catalogType' => 'identity'];
131
        return $this->builder->createService('Identity\\v2', array_merge($defaults, $options));
132
    }
133
134
    /**
135
     * Creates a new Identity v3 service.
136
     *
137
     * @param array $options Options that will be used in configuring the service.
138
     *
139
     * @return \OpenStack\Identity\v3\Service
140
     */
141
    public function identityV3(array $options = []): \OpenStack\Identity\v3\Service
142
    {
143
        $defaults = ['catalogName' => 'keystone', 'catalogType' => 'identity'];
144
        return $this->builder->createService('Identity\\v3', array_merge($defaults, $options));
145
    }
146
147
    /**
148
     * Creates a new Object Store v1 service.
149
     *
150
     * @param array $options Options that will be used in configuring the service.
151
     *
152
     * @return \OpenStack\ObjectStore\v1\Service
153
     */
154
    public function objectStoreV1(array $options = []): \OpenStack\ObjectStore\v1\Service
155
    {
156
        $defaults = ['catalogName' => 'swift', 'catalogType' => 'object-store'];
157
        return $this->builder->createService('ObjectStore\\v1', array_merge($defaults, $options));
158
    }
159
160
    /**
161
     * Creates a new Block Storage v2 service.
162
     *
163
     * @param array $options Options that will be used in configuring the service.
164
     *
165
     * @return \OpenStack\BlockStorage\v2\Service
166
     */
167
    public function blockStorageV2(array $options = []): \OpenStack\BlockStorage\v2\Service
168
    {
169
        $defaults = ['catalogName' => 'cinderv2', 'catalogType' => 'volumev2'];
170
        return $this->builder->createService('BlockStorage\\v2', array_merge($defaults, $options));
171
    }
172
173
    /**
174
     * Creates a new Images v2 service.
175
     *
176
     * @param array $options Options that will be used in configuring the service.
177
     *
178
     * @return \OpenStack\Images\v2\Service
179
     */
180
    public function imagesV2(array $options = []): \OpenStack\Images\v2\Service
181
    {
182
        $defaults = ['catalogName' => 'glance', 'catalogType' => 'image'];
183
        return $this->builder->createService('Images\\v2', array_merge($defaults, $options));
184
    }
185
186
    /**
187
     * Creates a new Gnocchi Metric service v1
188
     *
189
     * @param array $options
190
     *
191
     * @return \OpenStack\Metric\v1\Gnocchi\Service
192
     */
193
    public function metricGnocchiV1(array $options = []): \OpenStack\Metric\v1\Gnocchi\Service
194
    {
195
        $defaults = ['catalogName' => 'gnocchi', 'catalogType' => 'metric'];
196
197
        return $this->builder->createService('Metric\\v1\\Gnocchi', array_merge($defaults, $options));
198
    }
199
}
200