Skip to content

Commit 2bfe95a

Browse files
committed
fix: Refactor VM creation method parameters and structure.
Updated the parameter list for the `create` method to include more flexible and descriptive fields like `os`, `hostsystem`, and `allowFallbackIPs`. Adjusted internal parameter mapping for better consistency with the API request format. This change improves clarity and future extensibility.
1 parent 2243821 commit 2bfe95a

File tree

1 file changed

+35
-27
lines changed

1 file changed

+35
-27
lines changed

src/RootServer/RootServer.php

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -465,44 +465,52 @@ public function reinstall(int $vm_id, ?string $os = null): mixed
465465
}
466466

467467
/**
468-
* Creates a new virtual machine with the specified configuration.
469-
*
470-
* @param int $cores Number of CPU cores for the virtual machine
471-
* @param int $ram Amount of RAM in GB for the virtual machine
472-
* @param int $disk Storage space in GB for the virtual machine
473-
* @param int $ipv4 Number of IPv4 addresses to assign
474-
* @param int $ipv6 Number of IPv6 addresses to assign
475-
* @param int $os_id Operating system ID to install
476-
* @param int $backups Number of backup slots to allocate
477-
* @param string|null $host_name The hostname for the virtual machine (optional)
478-
* @param string|null $custom_name Custom name for the virtual machine (optional)
479-
* @param string|null $root_password Root password for the virtual machine (optional)
480-
* @return mixed Response from the API containing the created virtual machine details
468+
* @param int $cores
469+
* @param int $ram
470+
* @param int $disk
471+
* @param string $os
472+
* @param string $hostsystem
473+
* @param int|null $ips
474+
* @param int|null $backups
475+
* @param int|null $network_speed
476+
* @param string|null $hostname
477+
* @param int|null $storage
478+
* @param string|null $ssh_key
479+
* @param string|null $ssh_jey_displayname
480+
* @param bool|null $allowFallbackIPs
481+
* @return mixed
481482
* @throws GuzzleException
482483
*/
483484
public function create(
484485
int $cores,
485486
int $ram,
486487
int $disk,
487-
int $ipv4,
488-
int $ipv6,
489-
int $os_id,
490-
int $backups,
491-
?string $host_name = null,
492-
?string $custom_name = null,
493-
?string $root_password = null
488+
string $os,
489+
string $hostsystem,
490+
?int $ips = null,
491+
?int $backups = null,
492+
?int $network_speed = null,
493+
?string $hostname = null,
494+
?int $storage = null,
495+
?string $ssh_key = null,
496+
?string $ssh_key_displayname = null,
497+
?bool $allowFallbackIPs = null,
498+
494499
): mixed {
495500
$params = array_filter([
496501
'cores' => $cores,
497502
'ram' => $ram,
498503
'disk' => $disk,
499-
'ipv4' => $ipv4,
500-
'ipv6' => $ipv6,
501-
'os_id' => $os_id,
502-
'backups' => $backups,
503-
'hostname' => $host_name,
504-
'custom_name' => $custom_name,
505-
'root_password' => $root_password
504+
'os' => $os,
505+
'hostsystem' => $hostsystem,
506+
'ips' => $ips,
507+
'backup_slots' => $backups,
508+
'network_speed' => $network_speed,
509+
'hostname' => $hostname,
510+
'storage' => $storage,
511+
'ssh_key' => $ssh_key,
512+
'ssh_key_displayname' => $ssh_key_displayname,
513+
'allowFallbackIPs' => $allowFallbackIPs,
506514
]);
507515

508516
return $this->client->post('vm/create', $params);

0 commit comments

Comments
 (0)