1 | <?php |
||
10 | class Client extends AbstractClient |
||
11 | { |
||
12 | /** |
||
13 | * @var array |
||
14 | */ |
||
15 | protected $apiList; |
||
16 | |||
17 | /** |
||
18 | * @var string |
||
19 | */ |
||
20 | private $urlApi; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | private $urlClient; |
||
|
|||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | private $urlConsole; |
||
31 | |||
32 | /** |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $apiKey; |
||
36 | |||
37 | /** |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $secretKey; |
||
41 | |||
42 | /** |
||
43 | * @var string |
||
44 | */ |
||
45 | private $responseError = 'errortext'; |
||
46 | |||
47 | /** |
||
48 | * @var string |
||
49 | */ |
||
50 | private $responseCode = 'errorcode'; |
||
51 | |||
52 | /** |
||
53 | * Constructs a new Cloudstack client instance. |
||
54 | * |
||
55 | * @param array $options |
||
56 | * An array of options to set on this client. Options include |
||
57 | * 'apiList', 'urlApi', 'urlClient', 'urlConsole', 'apiKey', |
||
58 | * 'secretKey', 'responseError' and 'responseCode'. |
||
59 | * @param array $collaborators |
||
60 | * An array of collaborators that may be used to override |
||
61 | * this provider's default behavior. Collaborators include |
||
62 | * `requestFactory` and `httpClient`. |
||
63 | * @return void |
||
64 | */ |
||
65 | public function __construct(array $options = [], array $collaborators = []) |
||
81 | |||
82 | /** |
||
83 | * Returns all options that can be configured. |
||
84 | * |
||
85 | * @return array |
||
86 | */ |
||
87 | protected function getConfigurableOptions() |
||
97 | |||
98 | /** |
||
99 | * Returns all options that are required. |
||
100 | * |
||
101 | * @return array |
||
102 | */ |
||
103 | protected function getRequiredOptions() |
||
111 | |||
112 | /** |
||
113 | * Verifies that all required options have been passed. |
||
114 | * |
||
115 | * @param array $options |
||
116 | * @return void |
||
117 | * @throws InvalidArgumentException |
||
118 | */ |
||
119 | private function assertRequiredOptions(array $options) |
||
129 | |||
130 | public function command($command, array $options = []) |
||
140 | |||
141 | /** |
||
142 | * Verifies that all required options have been passed. |
||
143 | * |
||
144 | * @param array $options |
||
145 | * @return void |
||
146 | * @throws RuntimeException |
||
147 | * @throws InvalidArgumentException |
||
148 | */ |
||
149 | private function assertRequiredCommandOptions($command, array $options = []) |
||
167 | |||
168 | /** |
||
169 | * Returns command method based on the command. |
||
170 | * |
||
171 | * @param string $command |
||
172 | * @return array |
||
173 | */ |
||
174 | public function getCommandMethod($command) |
||
182 | |||
183 | /** |
||
184 | * Builds the command URL's query string. |
||
185 | * |
||
186 | * @param array $params |
||
187 | * @return string |
||
188 | */ |
||
189 | public function getCommandQuery(array $params) |
||
193 | |||
194 | /** |
||
195 | * Builds the authorization URL. |
||
196 | * |
||
197 | * @param string $command |
||
198 | * @param array $options |
||
199 | * @return string |
||
200 | */ |
||
201 | public function getCommandUrl($command, array $options = []) |
||
209 | |||
210 | /** |
||
211 | * Returns command parameters based on provided options. |
||
212 | * |
||
213 | * @param string $command |
||
214 | * @param array $options |
||
215 | * @return array |
||
216 | */ |
||
217 | protected function getCommandParameters($command, array $options) |
||
225 | |||
226 | /** |
||
227 | * Signs the command parameters. |
||
228 | * |
||
229 | * @param array $params |
||
230 | * @return array |
||
231 | */ |
||
232 | protected function signCommandParameters(array $params = []) |
||
249 | |||
250 | /** |
||
251 | * Get Cloudstack Client API list. |
||
252 | * |
||
253 | * Tries to load the API list from the cache directory when |
||
254 | * the 'apiList' on the class is empty. |
||
255 | * |
||
256 | * @return array |
||
257 | * @throws RuntimeException |
||
258 | */ |
||
259 | public function getApiList() |
||
275 | |||
276 | /** |
||
277 | * Set Cloudstack Client API list. |
||
278 | * |
||
279 | * @param array $list |
||
280 | * @return void |
||
281 | */ |
||
282 | public function setApiList(array $apiList) |
||
286 | |||
287 | /** |
||
288 | * Returns the base URL for API requests. |
||
289 | * |
||
290 | * @return string |
||
291 | */ |
||
292 | public function getBaseApiUrl() |
||
296 | |||
297 | /** |
||
298 | * Returns the API key. |
||
299 | * |
||
300 | * @return string |
||
301 | */ |
||
302 | public function getApiKey() |
||
306 | |||
307 | /** |
||
308 | * Returns the secret key. |
||
309 | * |
||
310 | * @return string |
||
311 | */ |
||
312 | public function getSecretKey() |
||
316 | |||
317 | /** |
||
318 | * Appends a query string to a URL. |
||
319 | * |
||
320 | * @param string $url |
||
321 | * @param string $query |
||
322 | * @return string |
||
323 | */ |
||
324 | protected function appendQuery($url, $query) |
||
334 | |||
335 | /** |
||
336 | * Build a query string from an array. |
||
337 | * |
||
338 | * @param array $params |
||
339 | * @return string |
||
340 | */ |
||
341 | protected function buildQueryString(array $params) |
||
345 | |||
346 | /** |
||
347 | * Checks a provider response for errors. |
||
348 | * |
||
349 | * @param ResponseInterface $response |
||
350 | * @param array|string $data |
||
351 | * @return void |
||
352 | * @throws \PCextreme\Cloudstack\Exceptions\ClientException |
||
353 | */ |
||
354 | protected function checkResponse(ResponseInterface $response, $data) |
||
363 | |||
364 | /** |
||
365 | * Handle dynamic method calls into the method. |
||
366 | * |
||
367 | * @param string $method |
||
368 | * @param array $parameters |
||
369 | * @return mixed |
||
370 | */ |
||
371 | public function __call($method, $parameters) |
||
377 | } |
||
378 |
This check marks private properties in classes that are never used. Those properties can be removed.