diff --git a/src/Models/Servers/Servers.php b/src/Models/Servers/Servers.php index 6334137..ce7c7f9 100644 --- a/src/Models/Servers/Servers.php +++ b/src/Models/Servers/Servers.php @@ -174,7 +174,7 @@ public function createInDatacenter( $networks = [], array $labels = [], array $firewalls = [], - array $public_net = [], + ?array $public_net = null, ?int $placement_group = null ): ?APIResponse { $parameters = [ @@ -188,7 +188,6 @@ public function createInDatacenter( 'volumes' => $volumes, 'automount' => $automount, 'networks' => $networks, - 'public_net' => $public_net, ]; if (! empty($labels)) { $parameters['labels'] = $labels; @@ -199,6 +198,9 @@ public function createInDatacenter( if ($placement_group != null) { $parameters['placement_group'] = $placement_group; } + if ($public_net != null) { + $parameters['public_net'] = $public_net; + } $response = $this->httpClient->post('servers', [ 'json' => $parameters, ]); @@ -252,7 +254,7 @@ public function createInLocation(string $name, array $networks = [], array $labels = [], array $firewalls = [], - array $public_net = [], + ?array $public_net = null, ?int $placement_group = null ): ?APIResponse { $parameters = [ @@ -266,7 +268,6 @@ public function createInLocation(string $name, 'volumes' => $volumes, 'automount' => $automount, 'networks' => $networks, - 'public_net' => $public_net, ]; if (! empty($labels)) { $parameters['labels'] = $labels; @@ -277,6 +278,9 @@ public function createInLocation(string $name, if ($placement_group != null) { $parameters['placement_group'] = $placement_group; } + if ($public_net != null) { + $parameters['public_net'] = $public_net; + } $response = $this->httpClient->post('servers', [ 'json' => $parameters, ]); diff --git a/src/Models/Servers/Types/ServerType.php b/src/Models/Servers/Types/ServerType.php index 71851d6..f760216 100644 --- a/src/Models/Servers/Types/ServerType.php +++ b/src/Models/Servers/Types/ServerType.php @@ -63,6 +63,21 @@ class ServerType extends Model */ public $architecture; + /** + * Deprecation info if the server type is deprecated, null otherwise. + * + * @var array{announced: string, unavailable_after: string}|null + */ + public $deprecation; + + /** + * Per-location availability info, keyed by location name. + * Each entry contains a deprecation object or null if still available. + * + * @var array + */ + public $locationAvailability = []; + /** * ServerType constructor. * @@ -91,6 +106,12 @@ public function setAdditionalData($input) $this->storageType = $input->storage_type ?? null; $this->cpuType = $input->cpu_type ?? null; $this->architecture = property_exists($input, 'architecture') ? $input->architecture : null; + $this->deprecation = (property_exists($input, 'deprecation') && $input->deprecation !== null) ? (array) $input->deprecation : null; + $locationAvailability = []; + foreach ($input->locations ?? [] as $loc) { + $locationAvailability[$loc->name] = ($loc->deprecation !== null) ? (array) $loc->deprecation : null; + } + $this->locationAvailability = $locationAvailability; return $this; }