Skip to content

fix: public_net parsing error & add deprecation/locationAvailability to ServerType#145

Open
jprangenbergde wants to merge 5 commits intoLKDevelopment:masterfrom
jprangenbergde:master
Open

fix: public_net parsing error & add deprecation/locationAvailability to ServerType#145
jprangenbergde wants to merge 5 commits intoLKDevelopment:masterfrom
jprangenbergde:master

Conversation

@jprangenbergde
Copy link

@jprangenbergde jprangenbergde commented Mar 18, 2026

Description:

Bugfixes

public_net JSON parse error

Fixes a server creation failure where the API rejected the public_net parameter with:
failed to parse json: cannot parse type array as createServerPublicNet
The public_net parameter is now optional and handled correctly.

New Features

ServerType::$deprecation

Maps the top-level deprecation object from the Hetzner API onto ServerType. Previously this field was not available in the model, making it impossible to detect globally deprecated server types.

▎ Bugfix included: (array) null evaluates to [] not null, so an explicit !== null guard was added before casting.

ServerType::$locationAvailability

Hetzner deprecates server types not only globally but also per location via a nested locations array in the API response. This new field maps location name → deprecation info (null = still bookable), enabling consumers to filter out unavailable types per location.

// Example: filter out types deprecated in a specific location
$type->locationAvailability['fsn1'] === null // true = still bookable

jprangenbergde and others added 5 commits March 18, 2026 21:42
The Hetzner API returns a `deprecation` object for server types that are
no longer available for new bookings. Map this field so consumers can
filter out deprecated types without making a separate API call.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
(array) null evaluates to [] not null, so the null-check for filtering
deprecated server types never matched. Explicitly guard against null
before casting to array.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Hetzner deprecates server types per location via a nested locations array.
This field maps location name to its deprecation info (null = still available),
enabling per-location availability checks.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
collect() is a Laravel helper and not available in this standalone SDK.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jprangenbergde jprangenbergde changed the title Make public_net parameter optional in server management methods fix: public_net parsing error & add deprecation/locationAvailability to ServerType Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant