Skip to content

Commit ce653b8

Browse files
authored
Fix labels (#27)
1 parent 4ed8881 commit ce653b8

File tree

9 files changed

+17
-12
lines changed

9 files changed

+17
-12
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Changelog
22

3+
## 1.8.1 (21.10.2019)
4+
+ Fix labels translation from json to array in `Image`, `Network`, `SSHKey` and `Volume`
5+
36
## 1.8.0 (18.09.2019)
4-
+ Add ability to get `Datacenters`,`FloatingIPs`,`Images`,`Locations` and `ServerTypes` per name (`getByName`)
7+
+ Add ability to get `Datacenters`, `FloatingIPs`, `Images`, `Locations` and `ServerTypes` per name (`getByName`)
58
+ Add `name` support to Floating IPs
69

710
## 1.7.1 (01.08.2019)

src/HetznerAPIClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class HetznerAPIClient
2424
/**
2525
* Version of the API Client
2626
*/
27-
const VERSION = "1.8.0";
27+
const VERSION = "1.8.1";
2828

2929
/**
3030
* @var string

src/Models/Images/Image.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,6 @@ public static function parse($input)
228228
return null;
229229
}
230230

231-
return new self($input->id, $input->type, (property_exists($input, 'status') ? $input->status : null), $input->name, $input->description, $input->image_size, $input->disk_size, $input->created, $input->created_from, $input->bound_to, $input->os_flavor, $input->os_version, $input->rapid_deploy, Protection::parse($input->protection));
231+
return new self($input->id, $input->type, (property_exists($input, 'status') ? $input->status : null), $input->name, $input->description, $input->image_size, $input->disk_size, $input->created, $input->created_from, $input->bound_to, $input->os_flavor, $input->os_version, $input->rapid_deploy, Protection::parse($input->protection), get_object_vars($input->labels));
232232
}
233233
}

src/Models/Networks/Network.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ private function setAdditionalData($data)
186186
})->toArray();
187187
$this->protection = Protection::parse($data->protection);
188188

189-
190-
$this->labels = $data->labels;
189+
$this->labels = get_object_vars($data->labels);
191190
$this->created = $data->created;
192191
return $this;
193192
}

src/Models/Networks/Networks.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66

77
use LKDev\HetznerCloud\APIResponse;
88
use LKDev\HetznerCloud\HetznerAPIClient;
9-
use LKDev\HetznerCloud\Models\Actions\Action;
109
use LKDev\HetznerCloud\Models\Model;
11-
use LKDev\HetznerCloud\Models\Volumes\Volume;
1210
use LKDev\HetznerCloud\RequestOpts;
1311

1412
/**

src/Models/SSHKeys/SSHKey.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class SSHKey extends Model
4848
* @param string $name
4949
* @param string $fingerprint
5050
* @param string $publicKey
51+
* @param array $labels
5152
*/
5253
public function __construct(int $id, string $name, string $fingerprint, string $publicKey, array $labels = [])
5354
{
@@ -113,6 +114,6 @@ public function delete(): bool
113114
*/
114115
public static function parse($input)
115116
{
116-
return new self($input->id, $input->name, $input->fingerprint, $input->public_key);
117+
return new self($input->id, $input->name, $input->fingerprint, $input->public_key, get_object_vars($input->labels));
117118
}
118-
}
119+
}

src/Models/Volumes/Volume.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function setAdditionalData($data)
8888
$this->server = $data->server;
8989
$this->location = Location::parse($data->location);
9090
$this->protection = $data->protection ?: Protection::parse($data->protection);
91-
$this->labels = $data->labels;
91+
$this->labels = get_object_vars($data->labels);
9292

9393
return $this;
9494
}

tests/Integration/Images/ImagesTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public function testGet()
3939
$image = $this->images->get(4711);
4040
$this->assertEquals($image->id, 4711);
4141
$this->assertEquals($image->name, 'ubuntu-16.04');
42+
43+
$this->assertEmpty($image->labels);
4244
}
4345
/**
4446
*
@@ -48,6 +50,8 @@ public function testGetByName()
4850
$image = $this->images->getByName('ubuntu-16.04');
4951
$this->assertEquals($image->id, 4711);
5052
$this->assertEquals($image->name, 'ubuntu-16.04');
53+
54+
$this->assertEmpty($image->labels);
5155
}
5256

5357
/**

tests/Integration/Networks/NetworksTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function testGetByName()
6060

6161
$this->assertInstanceOf(Protection::class, $network->protection);
6262

63-
$this->assertEmpty(get_object_vars($network->labels));
63+
$this->assertEmpty($network->labels);
6464

6565
}
6666

@@ -84,7 +84,7 @@ public function testGet()
8484

8585
$this->assertInstanceOf(Protection::class, $network->protection);
8686

87-
$this->assertEmpty(get_object_vars($network->labels));
87+
$this->assertEmpty($network->labels);
8888
}
8989

9090
/**

0 commit comments

Comments
 (0)