1 | <?php |
||
11 | class Client extends AbstractClient |
||
12 | { |
||
13 | use UrlHelpersTrait; |
||
14 | |||
15 | /** |
||
16 | * @var array |
||
17 | */ |
||
18 | protected $apiList; |
||
19 | |||
20 | /** |
||
21 | * @var string |
||
22 | */ |
||
23 | private $urlApi; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | private $urlClient; |
||
|
|||
29 | |||
30 | /** |
||
31 | * @var string |
||
32 | */ |
||
33 | private $urlConsole; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $apiKey; |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $secretKey; |
||
44 | |||
45 | /** |
||
46 | * @var string |
||
47 | */ |
||
48 | protected $ssoKey; |
||
49 | |||
50 | /** |
||
51 | * @var string |
||
52 | */ |
||
53 | private $responseError = 'errortext'; |
||
54 | |||
55 | /** |
||
56 | * @var string |
||
57 | */ |
||
58 | private $responseCode = 'errorcode'; |
||
59 | |||
60 | /** |
||
61 | * @var bool |
||
62 | */ |
||
63 | private $ssoEnabled = false; |
||
64 | |||
65 | /** |
||
66 | * Constructs a new Cloudstack client instance. |
||
67 | * |
||
68 | * @param array $options |
||
69 | * An array of options to set on this client. Options include |
||
70 | * 'apiList', 'urlApi', 'urlClient', 'urlConsole', 'apiKey', |
||
71 | * 'secretKey', 'responseError' and 'responseCode'. |
||
72 | * @param array $collaborators |
||
73 | * An array of collaborators that may be used to override |
||
74 | * this provider's default behavior. Collaborators include |
||
75 | * `requestFactory` and `httpClient`. |
||
76 | */ |
||
77 | public function __construct(array $options = [], array $collaborators = []) |
||
93 | |||
94 | /** |
||
95 | * Returns all options that can be configured. |
||
96 | * |
||
97 | * @return array |
||
98 | */ |
||
99 | protected function getConfigurableOptions() |
||
110 | |||
111 | /** |
||
112 | * Returns all options that are required. |
||
113 | * |
||
114 | * @return array |
||
115 | */ |
||
116 | protected function getRequiredOptions() |
||
124 | |||
125 | /** |
||
126 | * Verifies that all required options have been passed. |
||
127 | * |
||
128 | * @param array $options |
||
129 | * @return void |
||
130 | * @throws InvalidArgumentException |
||
131 | */ |
||
132 | private function assertRequiredOptions(array $options) |
||
142 | |||
143 | public function command($command, array $options = []) |
||
153 | |||
154 | /** |
||
155 | * Verifies that all required options have been passed. |
||
156 | * |
||
157 | * @param array $options |
||
158 | * @return void |
||
159 | * @throws RuntimeException |
||
160 | * @throws InvalidArgumentException |
||
161 | */ |
||
162 | private function assertRequiredCommandOptions($command, array $options = []) |
||
180 | |||
181 | /** |
||
182 | * Returns command method based on the command. |
||
183 | * |
||
184 | * @param string $command |
||
185 | * @return array |
||
186 | */ |
||
187 | public function getCommandMethod($command) |
||
195 | |||
196 | /** |
||
197 | * Builds the command URL's query string. |
||
198 | * |
||
199 | * @param array $params |
||
200 | * @return string |
||
201 | */ |
||
202 | public function getCommandQuery(array $params) |
||
206 | |||
207 | /** |
||
208 | * Builds the authorization URL. |
||
209 | * |
||
210 | * @param string $command |
||
211 | * @param array $options |
||
212 | * @return string |
||
213 | */ |
||
214 | public function getCommandUrl($command, array $options = []) |
||
222 | |||
223 | /** |
||
224 | * Returns command parameters based on provided options. |
||
225 | * |
||
226 | * @param string $command |
||
227 | * @param array $options |
||
228 | * @return array |
||
229 | */ |
||
230 | protected function getCommandParameters($command, array $options) |
||
238 | |||
239 | /** |
||
240 | * Signs the command parameters. |
||
241 | * |
||
242 | * @param array $params |
||
243 | * @return array |
||
244 | */ |
||
245 | protected function signCommandParameters(array $params = []) |
||
272 | |||
273 | /** |
||
274 | * Get Cloudstack Client API list. |
||
275 | * |
||
276 | * Tries to load the API list from the cache directory when |
||
277 | * the 'apiList' on the class is empty. |
||
278 | * |
||
279 | * @return array |
||
280 | * @throws RuntimeException |
||
281 | */ |
||
282 | public function getApiList() |
||
298 | |||
299 | /** |
||
300 | * Set Cloudstack Client API list. |
||
301 | * |
||
302 | * @param array $apiList |
||
303 | * @return void |
||
304 | */ |
||
305 | public function setApiList(array $apiList) |
||
309 | |||
310 | /** |
||
311 | * Appends a query string to a URL. |
||
312 | * |
||
313 | * @param string $url |
||
314 | * @param string $query |
||
315 | * @return string |
||
316 | */ |
||
317 | protected function appendQuery($url, $query) |
||
327 | |||
328 | /** |
||
329 | * Build a query string from an array. |
||
330 | * |
||
331 | * @param array $params |
||
332 | * @return string |
||
333 | */ |
||
334 | protected function buildQueryString(array $params) |
||
338 | |||
339 | /** |
||
340 | * Checks a provider response for errors. |
||
341 | * |
||
342 | * @param ResponseInterface $response |
||
343 | * @param array|string $data |
||
344 | * @return void |
||
345 | * @throws \PCextreme\Cloudstack\Exceptions\ClientException |
||
346 | */ |
||
347 | protected function checkResponse(ResponseInterface $response, $data) |
||
362 | |||
363 | /** |
||
364 | * Enable SSO key signing for the next request. |
||
365 | * |
||
366 | * @param bool $enable |
||
367 | * @return self |
||
368 | */ |
||
369 | public function enableSso($enable = true) |
||
375 | /** |
||
376 | * Determine if SSO signing is enabled. |
||
377 | * |
||
378 | * @return bool |
||
379 | */ |
||
380 | public function isSsoEnabled() |
||
384 | |||
385 | /** |
||
386 | * Handle dynamic method calls into the method. |
||
387 | * |
||
388 | * @param string $method |
||
389 | * @param array $parameters |
||
390 | * @return mixed |
||
391 | */ |
||
392 | public function __call($method, $parameters) |
||
398 | } |
||
399 |
This check marks private properties in classes that are never used. Those properties can be removed.