22
33use Blesta \Core \Util \Common \Traits \Container ;
44
5- class UpcloudvpsApi
5+ class UpcloudVpsApi
66{
77 use Container;
88
@@ -149,7 +149,7 @@ public function delete($url, $data = null)
149149 *
150150 * @return array The API response
151151 */
152- public function GetAccountInfo ()
152+ public function getAccountInfo ()
153153 {
154154 return $ this ->get ('account ' );
155155 }
@@ -159,7 +159,7 @@ public function GetAccountInfo()
159159 *
160160 * @return array The API response
161161 */
162- public function GetPrices ()
162+ public function getPrices ()
163163 {
164164 return $ this ->get ('price ' );
165165 }
@@ -169,7 +169,7 @@ public function GetPrices()
169169 *
170170 * @return array The API response
171171 */
172- public function GetZones ()
172+ public function getZones ()
173173 {
174174 return $ this ->get ('zone ' );
175175 }
@@ -179,7 +179,7 @@ public function GetZones()
179179 *
180180 * @return array The API response
181181 */
182- public function GetTimezones ()
182+ public function getTimezones ()
183183 {
184184 return $ this ->get ('timezone ' );
185185 }
@@ -189,7 +189,7 @@ public function GetTimezones()
189189 *
190190 * @return array The API response
191191 */
192- public function GetPlans ()
192+ public function getPlans ()
193193 {
194194 return $ this ->get ('plan ' );
195195 }
@@ -199,7 +199,7 @@ public function GetPlans()
199199 *
200200 * @return array The API response
201201 */
202- public function GetServerConfigurations ()
202+ public function getServerConfigurations ()
203203 {
204204 return $ this ->get ('server_size ' );
205205 }
@@ -209,7 +209,7 @@ public function GetServerConfigurations()
209209 *
210210 * @return array The API response
211211 */
212- public function GetAllServers ()
212+ public function getAllServers ()
213213 {
214214 return $ this ->get ('server ' );
215215 }
@@ -220,7 +220,7 @@ public function GetAllServers()
220220 * @param string $ServerUUID The UUID of the server
221221 * @return array The API response
222222 */
223- public function GetServer ($ ServerUUID )
223+ public function getServer ($ ServerUUID )
224224 {
225225 return $ this ->get ('server/ ' . rawurlencode ($ ServerUUID ));
226226 }
@@ -230,7 +230,7 @@ public function GetServer($ServerUUID)
230230 *
231231 * @return array The API response
232232 */
233- public function GetTemplate ()
233+ public function getTemplate ()
234234 {
235235 return $ this ->get ('storage/template ' );
236236 }
@@ -245,17 +245,17 @@ public function GetTemplate()
245245 * - template (string) The template UUID
246246 * @return array The API response
247247 */
248- public function CreateServer ($ params )
248+ public function createServer ($ params )
249249 {
250- $ Templates = $ this ->GetTemplate ()['response ' ]['storages ' ]['storage ' ];
250+ $ Templates = $ this ->getTemplate ()['response ' ]['storages ' ]['storage ' ];
251251 foreach ($ Templates as $ Template ) {
252252 if ($ Template ['uuid ' ] == $ params ['template ' ]) {
253253 $ TemplateTitle = $ Template ['title ' ];
254254 $ TemplateUUID = $ Template ['uuid ' ];
255255 break ;
256256 }
257257 }
258- $ AllPlans = $ this ->Getplans ()['response ' ]['plans ' ]['plan ' ];
258+ $ AllPlans = $ this ->getPlans ()['response ' ]['plans ' ]['plan ' ];
259259 foreach ($ AllPlans as $ Plans ) {
260260 if ($ Plans ['name ' ] == $ params ['plan ' ]) {
261261 $ PlanName = $ Plans ['name ' ];
@@ -271,16 +271,16 @@ public function CreateServer($params)
271271 'zone ' => $ params ['zone ' ], // GetZones()
272272 'title ' => $ params ['title ' ], // hostname
273273 'hostname ' => $ params ['title ' ], // hostname
274- 'plan ' => $ PlanName , // Getplans ()
274+ 'plan ' => $ PlanName , // getPlans ()
275275 // "simple_backup" => "0430,weeklies",
276276 'remote_access_enabled ' => 'yes ' ,
277277 'storage_devices ' => [
278278 'storage_device ' => [
279279 [
280280 'action ' => 'clone ' ,
281281 'storage ' => $ TemplateUUID , // GetTemplates()
282- 'size ' => $ PlanSize , // storage_size from Getplans ()
283- 'tier ' => $ PlanTier , // storage_tier from Getplans ()
282+ 'size ' => $ PlanSize , // storage_size from getPlans ()
283+ 'tier ' => $ PlanTier , // storage_tier from getPlans ()
284284 'title ' => $ TemplateTitle , // OS Name
285285 ]
286286 ]
@@ -315,7 +315,7 @@ public function serverOperation($action, $ServerUUID, $stop_type = null)
315315 * @param string $ServerUUID The UUID of the server
316316 * @return array The API response
317317 */
318- public function StartServer ($ ServerUUID )
318+ public function startServer ($ ServerUUID )
319319 {
320320 return $ this ->serverOperation ('start ' , $ ServerUUID );
321321 }
@@ -326,7 +326,7 @@ public function StartServer($ServerUUID)
326326 * @param string $ServerUUID The UUID of the server
327327 * @return array The API response
328328 */
329- public function StopServer ($ ServerUUID )
329+ public function stopServer ($ ServerUUID )
330330 {
331331 return $ this ->serverOperation ('stop ' , $ ServerUUID , 'hard ' );
332332 }
@@ -337,7 +337,7 @@ public function StopServer($ServerUUID)
337337 * @param string $ServerUUID The UUID of the server
338338 * @return array The API response
339339 */
340- public function RestartServer ($ ServerUUID )
340+ public function restartServer ($ ServerUUID )
341341 {
342342 return $ this ->serverOperation ('restart ' , $ ServerUUID , 'hard ' );
343343 }
@@ -348,7 +348,7 @@ public function RestartServer($ServerUUID)
348348 * @param string $ServerUUID The UUID of the server
349349 * @return array The API response
350350 */
351- public function CancelServer ($ ServerUUID )
351+ public function cancelServer ($ ServerUUID )
352352 {
353353 return $ this ->serverOperation ('cancel ' , $ ServerUUID );
354354 }
@@ -359,7 +359,7 @@ public function CancelServer($ServerUUID)
359359 * @param string $ServerUUID The UUID of the server
360360 * @return array The API response
361361 */
362- public function DeleteServer ($ ServerUUID )
362+ public function deleteServer ($ ServerUUID )
363363 {
364364 return $ this ->delete ('server/ ' . rawurlencode ($ ServerUUID ));
365365 }
@@ -372,10 +372,10 @@ public function DeleteServer($ServerUUID)
372372 * @param string $Plan The name of the target plan
373373 * @return array The API response from the final operation (storage resize or plan change)
374374 */
375- public function ModifyServer ($ uuid , $ Plan )
375+ public function modifyServer ($ uuid , $ Plan )
376376 {
377377 $ this ->stopServerAndWait ($ uuid );
378- $ allPlans = $ this ->Getplans ()['response ' ]['plans ' ]['plan ' ];
378+ $ allPlans = $ this ->getPlans ()['response ' ]['plans ' ]['plan ' ];
379379 foreach ($ allPlans as $ plan ) {
380380 if ($ plan ['name ' ] == $ Plan ) {
381381 $ planSize = $ plan ['storage_size ' ];
@@ -387,7 +387,7 @@ public function ModifyServer($uuid, $Plan)
387387 if ($ upgradePlan ['response ' ]['error ' ]['error_message ' ]) {
388388 return $ upgradePlan ;
389389 } else {
390- $ storages = $ this ->GetServer ($ uuid )['response ' ]['server ' ]['storage_devices ' ]['storage_device ' ];
390+ $ storages = $ this ->getServer ($ uuid )['response ' ]['server ' ]['storage_devices ' ]['storage_device ' ];
391391 foreach ($ storages as $ storage ) {
392392 if ($ storage ['part_of_plan ' ] == "yes " ) {
393393 $ storageId = $ storage ['storage ' ];
@@ -397,7 +397,7 @@ public function ModifyServer($uuid, $Plan)
397397 }
398398 if ($ storageId && $ planSize > $ existingStorageSize ) {
399399 $ modeyStorage = $ this ->modifyStorage ($ storageId , $ planSize );
400- $ this ->StartServer ($ uuid );
400+ $ this ->startServer ($ uuid );
401401 return $ modeyStorage ;
402402 }
403403 }
@@ -428,7 +428,7 @@ public function modifyStorage($storageId, $planSize)
428428 * @param string $ServerUUID The UUID of the server
429429 * @return array The API response from the delete operation
430430 */
431- public function DeleteServerAndStorage ($ ServerUUID )
431+ public function deleteServerAndStorage ($ ServerUUID )
432432 {
433433 $ this ->stopServerAndWait ($ ServerUUID );
434434 return $ this ->delete (sprintf ('server/%s?storages=1 ' , rawurlencode ($ ServerUUID )));
@@ -441,7 +441,7 @@ public function DeleteServerAndStorage($ServerUUID)
441441 * @param string $ServerUUID The UUID of the server
442442 * @return array The API response from the delete operation
443443 */
444- public function DeleteServerAndStorageAndBackups ($ ServerUUID )
444+ public function deleteServerAndStorageAndBackups ($ ServerUUID )
445445 {
446446 $ this ->stopServerAndWait ($ ServerUUID );
447447 return $ this ->delete (sprintf ('server/%s?storages=1&backups=delete ' , rawurlencode ($ ServerUUID )));
@@ -454,17 +454,17 @@ public function DeleteServerAndStorageAndBackups($ServerUUID)
454454 */
455455 public function stopServerAndWait ($ ServerUUID )
456456 {
457- $ result = $ this ->GetServer ($ ServerUUID );
457+ $ result = $ this ->getServer ($ ServerUUID );
458458 $ state = $ result ['response ' ]['server ' ]['state ' ];
459459 if ($ state == 'started ' ) {
460- $ this ->StopServer ($ ServerUUID );
460+ $ this ->stopServer ($ ServerUUID );
461461 }
462462
463463 $ times = 0 ;
464464 // If VM delete takes time please increase it but when tested working within 45 second
465465 while ($ state != 'stopped ' && $ times < 45 ) {
466466 sleep (2 );
467- $ result = $ this ->GetServer ($ ServerUUID );
467+ $ result = $ this ->getServer ($ ServerUUID );
468468 $ state = $ result ['response ' ]['server ' ]['state ' ];
469469 ++$ times ;
470470 }
@@ -480,7 +480,7 @@ public function stopServerAndWait($ServerUUID)
480480 * @param string $IPAddress The IP address
481481 * @return array The API response
482482 */
483- public function GetIPaddress ($ IPAddress )
483+ public function getIpAddress ($ IPAddress )
484484 {
485485 return $ this ->get ('ip_address/ ' . rawurlencode ($ IPAddress ));
486486 }
@@ -493,9 +493,9 @@ public function GetIPaddress($IPAddress)
493493 * @param string $ptr_record The new PTR record value
494494 * @return array The API response
495495 */
496- public function ModifyIPaddress ($ instanceId , $ IP , $ ptr_record )
496+ public function modifyIpAddress ($ instanceId , $ IP , $ ptr_record )
497497 {
498- if (!($ this ->GetIPaddress ($ IP )['response ' ]['ip_address ' ]['server ' ] == $ instanceId )) {
498+ if (!($ this ->getIpAddress ($ IP )['response ' ]['ip_address ' ]['server ' ] == $ instanceId )) {
499499 $ this ->logger ->error ('IP does not belong to your server ' );
500500 }
501501 return $ this ->put ('ip_address/ ' . rawurlencode ($ IP ), ['ip_address ' => ['ptr_record ' => $ ptr_record ]]);
@@ -533,7 +533,7 @@ public function vncEnableDisable($instanceId, $vncType)
533533 * @param array $serverConfig An array containing server settings to modify (e.g., ['title' => 'new_title'])
534534 * @return array The API response
535535 */
536- public function modifyVPS ($ instanceId , $ serverConfig )
536+ public function modifyVps ($ instanceId , $ serverConfig )
537537 {
538538 return $ this ->put ('server/ ' . rawurlencode ($ instanceId ), $ serverConfig );
539539 }
@@ -544,7 +544,7 @@ public function modifyVPS($instanceId, $serverConfig)
544544 * @param int $bytes The number of bytes
545545 * @return float The value in GB
546546 */
547- public function formatSizeBytestoGB ($ bytes )
547+ public function formatSizeBytestoGb ($ bytes )
548548 {
549549 return round ($ bytes / 1024 / 1024 / 1024 , 2 );
550550 }
0 commit comments