Skip to content

Commit

Permalink
Keep Hetzner's snake_case for properties (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasLandauer authored Aug 6, 2021
1 parent 0973ff8 commit 0556491
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/Models/Datacenters/Datacenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class Datacenter extends Model implements Resource
/**
* @var array
*/
public $server_types;
/**
* @var array
* @deprecated Use $server_types instead
*/
public $serverTypes;

/**
Expand All @@ -60,6 +65,7 @@ public function __construct(
$this->name = $name;
$this->description = $description;
$this->location = $location;
$this->server_types = $server_types;
$this->serverTypes = $server_types;
parent::__construct();
}
Expand Down
8 changes: 7 additions & 1 deletion src/Models/Firewalls/Firewall.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,15 @@ class Firewall extends Model implements Resource
/**
* @var FirewallResource[]
*/
public $applied_to;
/**
* @var FirewallResource[]
* @deprecated Use $applied_to instead
*/
public $appliedTo;

/**
* FloatingIp constructor.
* Firewall constructor.
*
* @param int $id
* @param string $name
Expand All @@ -72,6 +77,7 @@ public function __construct(
$this->created = $created;
$this->name = $name;
$this->rules = $rules;
$this->applied_to = $appliedTo;
$this->appliedTo = $appliedTo;
parent::__construct();
}
Expand Down
12 changes: 12 additions & 0 deletions src/Models/FloatingIps/FloatingIp.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,21 @@ class FloatingIp extends Model implements Resource
/**
* @var array
*/
public $dns_ptr;
/**
* @var array
* @deprecated Use $dns_ptr instead
*/
public $dnsPtr;

/**
* @var \LKDev\HetznerCloud\Models\Locations\Location
*/
public $home_location;
/**
* @var \LKDev\HetznerCloud\Models\Locations\Location
* @deprecated Use $home_location instead
*/
public $homeLocation;

/**
Expand Down Expand Up @@ -112,7 +122,9 @@ public function __construct(
$this->ip = $ip;
$this->type = $type;
$this->server = $server;
$this->dns_ptr = $dnsPtr;
$this->dnsPtr = $dnsPtr;
$this->home_location = $homeLocation;
$this->homeLocation = $homeLocation;
$this->blocked = $blocked;
$this->protection = $protection;
Expand Down
42 changes: 42 additions & 0 deletions src/Models/Images/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,21 @@ class Image extends Model implements Resource
/**
* @var float
*/
public $image_size;
/**
* @var float
* @deprecated Use $image_size instead
*/
public $imageSize;

/**
* @var int
*/
public $disk_size;
/**
* @var int
* @deprecated Use $disk_size instead
*/
public $diskSize;

/**
Expand All @@ -64,26 +74,51 @@ class Image extends Model implements Resource
/**
* @var \LKDev\HetznerCloud\Models\Servers\Server
*/
public $created_from;
/**
* @var \LKDev\HetznerCloud\Models\Servers\Server
* @deprecated Use $created_from instead
*/
public $createdFrom;

/**
* @var int
*/
public $bound_to;
/**
* @var int
* @deprecated Use $bound_to instead
*/
public $boundTo;

/**
* @var string
*/
public $os_flavor;
/**
* @var string
* @deprecated Use $os_flavor instead
*/
public $osFlavor;

/**
* @var string
*/
public $os_version;
/**
* @var string
* @deprecated Use $os_version instead
*/
public $osVersion;

/**
* @var bool
*/
public $rapid_deploy;
/**
* @var bool
* @deprecated Use $rapid_deploy instead
*/
public $rapidDeploy;

/**
Expand Down Expand Up @@ -137,13 +172,20 @@ public function __construct(
$this->status = $status;
$this->name = $name;
$this->description = $description;
$this->image_size = $imageSize;
$this->imageSize = $imageSize;
$this->disk_size = $diskSize;
$this->diskSize = $diskSize;
$this->created = $created;
$this->created_from = $createdFrom;
$this->createdFrom = $createdFrom;
$this->bound_to = $boundTo;
$this->boundTo = $boundTo;
$this->os_flavor = $osFlavor;
$this->osFlavor = $osFlavor;
$this->os_version = $osVersion;
$this->osVersion = $osVersion;
$this->rapid_deploy = $rapidDeploy;
$this->rapidDeploy = $rapidDeploy;
$this->protection = $protection;
$this->labels = $labels;
Expand Down
6 changes: 6 additions & 0 deletions src/Models/Locations/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ class Location extends Model implements Resource
/**
* @var string
*/
public $network_zone;
/**
* @var string
* @deprecated Use $network_zone instead
*/
public $networkZone;

/**
Expand Down Expand Up @@ -83,6 +88,7 @@ public function __construct(
$this->city = $city;
$this->latitude = $latitude;
$this->longitude = $longitude;
$this->network_zone = $networkZone;
$this->networkZone = $networkZone;
parent::__construct();
}
Expand Down
14 changes: 14 additions & 0 deletions src/Models/Networks/Network.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,47 @@ class Network extends Model implements Resource
* @var int
*/
public $id;

/**
* @var string
*/
public $name;

/**
* @var string
*/
public $ip_range;
/**
* @var string
* @deprecated Use $ip_range instead
*/
public $ipRange;

/**
* @var array
*/
public $subnets;

/**
* @var array
*/
public $routes;

/**
* @var array
*/
public $servers;

/**
* @var Protection
*/
public $protection;

/**
* @var array
*/
public $labels;

/**
* @var string
*/
Expand Down Expand Up @@ -175,6 +188,7 @@ public function changeProtection(bool $delete = true): ?APIResponse
private function setAdditionalData($data)
{
$this->name = $data->name;
$this->ip_range = $data->ip_range;
$this->ipRange = $data->ip_range;
$this->subnets = Subnet::parse($data->subnets, $this->httpClient);
$this->routes = Route::parse($data->routes, $this->httpClient);
Expand Down
55 changes: 55 additions & 0 deletions src/Models/Servers/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,31 @@ class Server extends Model implements Resource
/**
* @var array
*/
public $public_net;
/**
* @var array
* @deprecated Use $public_net instead
*/
public $publicNet;

/**
* @var array
*/
public $private_net;
/**
* @var array
* @deprecated Use $private_net instead
*/
public $privateNet;

/**
* @var ServerType
*/
public $server_type;
/**
* @var ServerType
* @deprecated Use $server_type instead
*/
public $serverType;

/**
Expand All @@ -75,6 +91,11 @@ class Server extends Model implements Resource
/**
* @var bool
*/
public $rescue_enabled;
/**
* @var bool
* @deprecated Use $rescue_enabled instead
*/
public $rescueEnabled;

/**
Expand All @@ -85,21 +106,41 @@ class Server extends Model implements Resource
/**
* @var string
*/
public $backup_window;
/**
* @var string
* @deprecated Use $backup_window instead
*/
public $backupWindow;

/**
* @var int
*/
public $outgoing_traffic;
/**
* @var int
* @deprecated Use $outgoing_traffic instead
*/
public $outgoingTraffic;

/**
* @var int
*/
public $ingoing_traffic;
/**
* @var int
* @deprecated Use $ingoing_traffic instead
*/
public $ingoingTraffic;

/**
* @var int
*/
public $included_traffic;
/**
* @var int
* @deprecated Use $included_traffic instead
*/
public $includedTraffic;

/**
Expand All @@ -120,6 +161,11 @@ class Server extends Model implements Resource
/**
* @var int
*/
public $primary_disk_size;
/**
* @var int
* @deprecated Use $primary_disk_size instead
*/
public $primaryDiskSize;

/**
Expand All @@ -140,22 +186,31 @@ public function setAdditionalData($data)
{
$this->name = $data->name;
$this->status = $data->status ?: null;
$this->public_net = $data->public_net ?: null;
$this->publicNet = $data->public_net ?: null;
$this->private_net = property_exists($data, 'private_net') ? $data->private_net : [];
$this->privateNet = property_exists($data, 'private_net') ? $data->private_net : [];
$this->server_type = $data->server_type ?: ServerType::parse($data->server_type);
$this->serverType = $data->server_type ?: ServerType::parse($data->server_type);
$this->datacenter = $data->datacenter ?: Datacenter::parse($data->datacenter);
$this->created = $data->created;
$this->image = $data->image ?: Image::parse($data->image);
$this->iso = $data->iso ?: ISO::parse($data->iso);
$this->rescue_enabled = $data->rescue_enabled ?: null;
$this->rescueEnabled = $data->rescue_enabled ?: null;
$this->locked = $data->locked ?: null;
$this->backup_window = $data->backup_window ?: null;
$this->backupWindow = $data->backup_window ?: null;
$this->outgoing_traffic = $data->outgoing_traffic ?: null;
$this->outgoingTraffic = $data->outgoing_traffic ?: null;
$this->ingoing_traffic = $data->ingoing_traffic ?: null;
$this->ingoingTraffic = $data->ingoing_traffic ?: null;
$this->included_traffic = $data->included_traffic ?: null;
$this->includedTraffic = $data->included_traffic ?: null;
$this->volumes = property_exists($data, 'volumes') ? $data->volumes : [];
$this->protection = $data->protection ?: Protection::parse($data->protection);
$this->labels = $data->labels;
$this->primary_disk_size = $data->primary_disk_size ?: null;
$this->primaryDiskSize = $data->primary_disk_size ?: null;

return $this;
Expand Down

0 comments on commit 0556491

Please sign in to comment.