Skip to content

Commit bc509c6

Browse files
committed
Prepare next Release 1.1.0
1 parent 4ff8bf4 commit bc509c6

File tree

9 files changed

+107
-99
lines changed

9 files changed

+107
-99
lines changed

CHANGELOG.md

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

33

4-
## unreleased
4+
## 1.1.0 (14.08.2018)
55
+ Add `update`-Method to `\LKDev\HetznerCloud\Models\Servers\Server`-Model for easily updateing the server meta data
66
```php
77
$server->update(['name' => 'my-updated-server-name']);
88
````
99
+ Soft Deprecating the `changeName`-Method on `\LKDev\HetznerCloud\Models\Servers\Server`-Model, please use the `update`-Method now. As of Version 1.5.0 this method will trigger a `Deprecated`
10+
+ Rename `ApiResponse` to `APIResponse
1011
---
1112
## 1.0.0 (09.08.2018)
1213
##### Breaking Changes

src/APIException.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
class APIException extends \Exception
1313
{
1414
/**
15-
* @var ApiResponse
15+
* @var APIResponse
1616
*/
17-
public $response;
17+
protected $response;
1818

1919
/**
2020
* APIException constructor.
@@ -24,9 +24,16 @@ class APIException extends \Exception
2424
* @param int $code
2525
* @param \Throwable|null $previous
2626
*/
27-
public function __construct(ApiResponse $response, string $message = "", int $code = 0, \Throwable $previous = null)
27+
public function __construct(APIResponse $response, string $message = "", int $code = 0, \Throwable $previous = null)
2828
{
2929
$this->response = $response;
3030
parent::__construct($message, $code, $previous);
3131
}
32+
33+
/**
34+
* @return APIResponse
35+
*/
36+
public function getApiResponse(){
37+
return $this->response;
38+
}
3239
}

src/ApiResponse.php renamed to src/APIResponse.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Class ApiResponse
1616
* @package LKDev\HetznerCloud
1717
*/
18-
class ApiResponse
18+
class APIResponse
1919
{
2020
/**
2121
* @var array
@@ -49,11 +49,11 @@ public function setResponse(array $response)
4949

5050
/**
5151
* @param array $response
52-
* @return ApiResponse
52+
* @return APIResponse
5353
*/
5454
public static function create(array $response)
5555
{
56-
$apiResponse = new ApiResponse();
56+
$apiResponse = new APIResponse();
5757
$apiResponse->setResponse($response);
5858
return $apiResponse;
5959
}

src/HetznerAPIClient.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,11 @@ public static function throwError(ResponseInterface $response)
106106
$body = (string)$response->getBody();
107107
if (strlen($body) > 0) {
108108
$error = \GuzzleHttp\json_decode($body);
109-
throw new APIException(ApiResponse::create([
109+
throw new APIException(APIResponse::create([
110110
'error' => $error->error
111111
]), $error->error->message);
112112
}
113-
throw new APIException(ApiResponse::create([
113+
throw new APIException(APIResponse::create([
114114
'response' => $response
115115
]), 'The response is not parseable');
116116
}

src/Models/FloatingIps/FloatingIp.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace LKDev\HetznerCloud\Models\FloatingIps;
1010

11-
use LKDev\HetznerCloud\ApiResponse;
11+
use LKDev\HetznerCloud\APIResponse;
1212
use LKDev\HetznerCloud\HetznerAPIClient;
1313
use LKDev\HetznerCloud\Models\Actions\Action;
1414
use LKDev\HetznerCloud\Models\Locations\Location;
@@ -142,18 +142,18 @@ public function delete(): bool
142142
*
143143
* @see https://docs.hetzner.cloud/#resources-floating-ip-actions-post-3
144144
* @param bool $delete
145-
* @return ApiResponse
145+
* @return APIResponse
146146
* @throws \LKDev\HetznerCloud\APIException
147147
*/
148-
public function changeProtection(bool $delete = true): ApiResponse
148+
public function changeProtection(bool $delete = true): APIResponse
149149
{
150150
$response = $this->httpClient->post('floating_ips/' . $this->id . '/actions/change_protection', [
151151
'json' => [
152152
'delete' => $delete,
153153
],
154154
]);
155155
if (!HetznerAPIClient::hasError($response)) {
156-
return ApiResponse::create([
156+
return APIResponse::create([
157157
'action' => Action::parse(json_decode((string)$response->getBody())->action)
158158
]);
159159
}
@@ -164,18 +164,18 @@ public function changeProtection(bool $delete = true): ApiResponse
164164
*
165165
* @see https://docs.hetzner.cloud/#floating-ip-actions-assign-a-floating-ip-to-a-server
166166
* @param Server $server
167-
* @return ApiResponse
167+
* @return APIResponse
168168
* @throws \LKDev\HetznerCloud\APIException
169169
*/
170-
public function assignTo(Server $server): ApiResponse
170+
public function assignTo(Server $server): APIResponse
171171
{
172172
$response = $this->httpClient->post('floating_ips/' . $this->id . '/actions/assign', [
173173
'json' => [
174174
'server' => $server->id,
175175
],
176176
]);
177177
if (!HetznerAPIClient::hasError($response)) {
178-
return ApiResponse::create([
178+
return APIResponse::create([
179179
'action' => Action::parse(json_decode((string)$response->getBody())->action)
180180
]);
181181
}
@@ -185,14 +185,14 @@ public function assignTo(Server $server): ApiResponse
185185
* Unassigns a Floating IP, resulting in it being unreachable. You may assign it to a server again at a later time.
186186
*
187187
* @see https://docs.hetzner.cloud/#floating-ip-actions-unassign-a-floating-ip
188-
* @return ApiResponse
188+
* @return APIResponse
189189
* @throws \LKDev\HetznerCloud\APIException
190190
*/
191-
public function unassign(): ApiResponse
191+
public function unassign(): APIResponse
192192
{
193193
$response = $this->httpClient->post('floating_ips/' . $this->id . '/actions/unassign');
194194
if (!HetznerAPIClient::hasError($response)) {
195-
return ApiResponse::create([
195+
return APIResponse::create([
196196
'action' => Action::parse(json_decode((string)$response->getBody())->action)
197197
]);
198198
}
@@ -204,10 +204,10 @@ public function unassign(): ApiResponse
204204
* @see https://docs.hetzner.cloud/#floating-ip-actions-change-reverse-dns-entry-for-a-floating-ip
205205
* @param string $ip
206206
* @param string $dnsPtr
207-
* @return ApiResponse
207+
* @return APIResponse
208208
* @throws \LKDev\HetznerCloud\APIException
209209
*/
210-
public function changeReverseDNS(string $ip, string $dnsPtr): ApiResponse
210+
public function changeReverseDNS(string $ip, string $dnsPtr): APIResponse
211211
{
212212
$response = $this->httpClient->post('floating_ips/' . $this->id . '/actions/change_dns_ptr', [
213213
'json' => [
@@ -216,7 +216,7 @@ public function changeReverseDNS(string $ip, string $dnsPtr): ApiResponse
216216
],
217217
]);
218218
if (!HetznerAPIClient::hasError($response)) {
219-
return ApiResponse::create([
219+
return APIResponse::create([
220220
'action' => Action::parse(json_decode((string)$response->getBody())->action)
221221
]);
222222
}

src/Models/Images/Image.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
namespace LKDev\HetznerCloud\Models\Images;
1010

11-
use LKDev\HetznerCloud\ApiResponse;
11+
use LKDev\HetznerCloud\APIResponse;
1212
use LKDev\HetznerCloud\HetznerAPIClient;
1313
use LKDev\HetznerCloud\Models\Actions\Action;
1414
use LKDev\HetznerCloud\Models\Model;
@@ -169,18 +169,18 @@ public function update(string $description = null, string $type = null): Image
169169
*
170170
* @see https://docs.hetzner.cloud/#resources-image-actions-post
171171
* @param bool $delete
172-
* @return ApiResponse
172+
* @return APIResponse
173173
* @throws \LKDev\HetznerCloud\APIException
174174
*/
175-
public function changeProtection(bool $delete = true): ApiResponse
175+
public function changeProtection(bool $delete = true): APIResponse
176176
{
177177
$response = $this->httpClient->post('images/' . $this->id . '/actions/change_protection', [
178178
'json' => [
179179
'delete' => $delete,
180180
],
181181
]);
182182
if (!HetznerAPIClient::hasError($response)) {
183-
return ApiResponse::create([
183+
return APIResponse::create([
184184
'action' => Action::parse(json_decode((string)$response->getBody())->action)
185185
]);
186186
}

0 commit comments

Comments
 (0)