Skip to content

Commit f6c75c3

Browse files
committed
Add volumes and automount to Servers::create* Methods
Add created property to Server
1 parent cd1efec commit f6c75c3

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

CHANGELOG.md

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

3+
## 1.6.2 (27.05.2019)
4+
+ Add `volumes` and `automount` parameters to `LKDev\HetznerCloud\Models\Servers\Servers` - `createInDatacenter` and `createInLocation`
5+
+ Add `created` property to `LKDev\HetznerCloud\Models\Servers\Server`
6+
37
## 1.6.1 (27.05.2019)
4-
+ Add `automount` and `format` Parameters to `LKDev\HetznerCloud\Models\Volumes\Volumes` - `create`
8+
+ Add `automount` and `format` parameters to `LKDev\HetznerCloud\Models\Volumes\Volumes` - `create`
59
+ Add `created` property to `LKDev\HetznerCloud\Models\FloatingIps\FloatingIp`
610
+ Improve test coverage
711
+ Add `root_passwort` to response of `LKDev\HetznerCloud\Models\Servers\Server` - `rebuildFromImage` (https://github.com/LKDevelopment/hetzner-cloud-php-sdk/issues/17)

src/Models/Servers/Server.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ public function setAdditionalData($data)
135135
$this->publicNet = $data->public_net ?: null;
136136
$this->serverType = $data->server_type ?: ServerType::parse($data->server_type);
137137
$this->datacenter = $data->datacenter ?: Datacenter::parse($data->datacenter);
138+
$this->created = $data->created;
138139
$this->image = $data->image ?: Image::parse($data->image);
139140
$this->iso = $data->iso ?: ISO::parse($data->iso);
140141
$this->rescueEnabled = $data->rescue_enabled ?: null;

src/Models/Servers/Servers.php

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ public function getByName(string $serverName)
9191
* @param array $ssh_keys
9292
* @param bool $startAfterCreate
9393
* @param string $user_data
94+
* @param array $volumes
95+
* @param bool $automount
9496
* @return APIResponse
9597
* @throws \LKDev\HetznerCloud\APIException
9698
*/
@@ -101,7 +103,9 @@ public function createInDatacenter(
101103
Datacenter $datacenter = null,
102104
$ssh_keys = [],
103105
$startAfterCreate = true,
104-
$user_data = ''
106+
$user_data = '',
107+
$volumes = [],
108+
$automount = false
105109
): APIResponse
106110
{
107111
$response = $this->httpClient->post('servers', [
@@ -113,6 +117,8 @@ public function createInDatacenter(
113117
'start_after_create' => $startAfterCreate,
114118
'user_data' => $user_data,
115119
'ssh_keys' => $ssh_keys,
120+
'volumes' => $volumes,
121+
'automount' => $automount
116122
],
117123
]);
118124
if (!HetznerAPIClient::hasError($response)) {
@@ -137,6 +143,8 @@ public function createInDatacenter(
137143
* @param array $ssh_keys
138144
* @param bool $startAfterCreate
139145
* @param string $user_data
146+
* @param array $volumes
147+
* @param bool $automount
140148
* @return APIResponse
141149
* @throws \LKDev\HetznerCloud\APIException
142150
*/
@@ -146,7 +154,10 @@ public function createInLocation(string $name,
146154
Location $location = null,
147155
$ssh_keys = [],
148156
$startAfterCreate = true,
149-
$user_data = ''): APIResponse
157+
$user_data = '',
158+
$volumes = [],
159+
$automount = false
160+
): APIResponse
150161
{
151162
$response = $this->httpClient->post('servers', [
152163
'json' => [
@@ -157,6 +168,8 @@ public function createInLocation(string $name,
157168
'start_after_create' => $startAfterCreate,
158169
'user_data' => $user_data,
159170
'ssh_keys' => $ssh_keys,
171+
'volumes' => $volumes,
172+
'automount' => $automount
160173
],
161174
]);
162175
if (!HetznerAPIClient::hasError($response)) {
@@ -176,11 +189,13 @@ public function createInLocation(string $name,
176189
*/
177190
public function setAdditionalData($input)
178191
{
179-
$this->servers = collect($input->servers)->map(function ($server, $key) {
180-
if ($server != null) {
181-
return Server::parse($server);
182-
}
183-
})->toArray();
192+
$this->servers = collect($input->servers)
193+
->map(function ($server) {
194+
if ($server != null) {
195+
return Server::parse($server);
196+
}
197+
})
198+
->toArray();
184199

185200
return $this;
186201
}

0 commit comments

Comments
 (0)