Skip to content

Commit 201cd45

Browse files
Merge branch 'LKDevelopment:master' into master
2 parents a73dee4 + f0b2c33 commit 201cd45

87 files changed

Lines changed: 713 additions & 131 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
matrix:
1010
operating-system: [ubuntu-latest]
11-
php-versions: [ '8.0', '8.1', '8.2', '8.3' ]
11+
php-versions: [ '8.1', '8.2', '8.3', '8.4']
1212
steps:
1313
- uses: actions/checkout@v2
1414
- name: Setup PHP

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ foreach ($hetznerClient->servers()->all() as $server) {
2020
echo 'ID: '.$server->id.' Name:'.$server->name.' Status: '.$server->status.PHP_EOL;
2121
}
2222
```
23+
### PHP Support
24+
25+
We test on all supported PHP Versions. The library can still work on older versions, however it is no longer actively tested.
2326

2427
### Old Releases: v1.x
2528
[Version 1.x](https://github.com/LKDevelopment/hetzner-cloud-php-sdk/tree/v1) is abandoned and will not receive any new updates or features. V2 was created with Backward Compatibility in mind. So it should work as a drop-in replacement. Therefor it does not give a "Migration to v2"-Guide. It should just work!

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lkdevelopment/hetzner-cloud-php-sdk",
3-
"description": "A inofficial PHP SDK for the Hetzner Cloud API.",
3+
"description": "An unofficial PHP SDK for the Hetzner Cloud API.",
44
"type": "library",
55
"keywords": [
66
"hetzner",
@@ -9,14 +9,14 @@
99
"cloud php library"
1010
],
1111
"require": {
12-
"php": "^7.1|^8.0",
12+
"php": "^8.1",
1313
"ext-json": "*",
1414
"guzzlehttp/guzzle": "^6.3|^7.0",
15-
"illuminate/collections": "^5.5|^v6.18|^7.0|^8.0|^11.0"
15+
"illuminate/collections": "^5.5|^v6.18|^7.0|^8.0|^9.0|^10.0|^11.0|^12.0"
1616
},
1717
"require-dev": {
1818
"phpunit/phpunit": "^7.0|^8.5.5|^9.0",
19-
"phpstan/phpstan": "^0.12.43"
19+
"phpstan/phpstan": "^0.12.43 || ^1.0.0"
2020
},
2121
"license": "MIT",
2222
"authors": [

src/APIException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class APIException extends \Exception
1717
* @param int $code
1818
* @param \Throwable|null $previous
1919
*/
20-
public function __construct(APIResponse $response, string $message = '', int $code = 0, \Throwable $previous = null)
20+
public function __construct(APIResponse $response, string $message = '', int $code = 0, ?\Throwable $previous = null)
2121
{
2222
$this->response = $response;
2323
parent::__construct($message, $code, $previous);

src/APIResponse.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Created by PhpStorm.
45
* User: lkaemmerling
@@ -36,7 +37,7 @@ public function getResponse(): array
3637
* @param string|null $resource
3738
* @return Model|string|bool
3839
*/
39-
public function getResponsePart(string $resource = null)
40+
public function getResponsePart(?string $resource = null)
4041
{
4142
return (array_key_exists($resource, $this->response)) ? $this->response[$resource] : false;
4243
}

src/Clients/GuzzleClient.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
use GuzzleHttp\Client;
66
use LKDev\HetznerCloud\HetznerAPIClient;
77

8-
class GuzzleClient extends Client
8+
class GuzzleClient
99
{
10+
protected Client $client;
11+
1012
/**
1113
* @param HetznerAPIClient $client
1214
* @param array $additionalGuzzleConfig
@@ -21,6 +23,11 @@ public function __construct(HetznerAPIClient $client, $additionalGuzzleConfig =
2123
'User-Agent' => ((strlen($client->getUserAgent()) > 0) ? $client->getUserAgent().' ' : '').'hcloud-php/'.HetznerAPIClient::VERSION,
2224
],
2325
], $additionalGuzzleConfig);
24-
parent::__construct($guzzleConfig);
26+
$this->client = new Client($guzzleConfig);
27+
}
28+
29+
public function __call($name, $arguments)
30+
{
31+
return $this->client->$name(...$arguments);
2532
}
2633
}

src/HetznerAPIClient.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use LKDev\HetznerCloud\Models\LoadBalancers\LoadBalancers;
1515
use LKDev\HetznerCloud\Models\LoadBalancerTypes\LoadBalancerTypes;
1616
use LKDev\HetznerCloud\Models\Networks\Networks;
17+
use LKDev\HetznerCloud\Models\PlacementGroups\PlacementGroups;
1718
use LKDev\HetznerCloud\Models\Prices\Prices;
1819
use LKDev\HetznerCloud\Models\PrimaryIps\PrimaryIps;
1920
use LKDev\HetznerCloud\Models\Servers\Servers;
@@ -30,7 +31,7 @@ class HetznerAPIClient
3031
/**
3132
* Version of the API Client.
3233
*/
33-
const VERSION = '2.7.1';
34+
const VERSION = '2.8.1';
3435

3536
const MAX_ENTITIES_PER_PAGE = 50;
3637

@@ -286,6 +287,14 @@ public function networks()
286287
return new Networks($this->httpClient);
287288
}
288289

290+
/**
291+
* @return PlacementGroups
292+
*/
293+
public function placementGroups()
294+
{
295+
return new PlacementGroups($this->httpClient);
296+
}
297+
289298
/**
290299
* @return Certificates
291300
*/

src/Models/Actions/Action.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function __construct(
6767
int $progress,
6868
string $status,
6969
string $started,
70-
string $finished = null,
70+
?string $finished = null,
7171
$resources = null,
7272
$error = null
7373
) {
@@ -148,6 +148,6 @@ public static function parse($input)
148148
return;
149149
}
150150

151-
return new self($input->id, $input->command, $input->progress, $input->status, $input->started, $input->finished, $input->resources, $input->error);
151+
return new self($input->id, $input->command, $input->progress, $input->status, $input->started, $input->finished, $input->resources, $input->error ?? null);
152152
}
153153
}

src/Models/Actions/ActionRequestOpts.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Created by PhpStorm.
45
* User: lukaskammerling
@@ -30,7 +31,7 @@ class ActionRequestOpts extends RequestOpts
3031
* @param $page
3132
* @param $labelSelector
3233
*/
33-
public function __construct(string $status = null, string $sort = null, int $perPage = null, int $page = null, string $labelSelector = null)
34+
public function __construct(?string $status = null, ?string $sort = null, ?int $perPage = null, ?int $page = null, ?string $labelSelector = null)
3435
{
3536
parent::__construct($perPage, $page, $labelSelector);
3637
$this->status = $status;

src/Models/Actions/Actions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Actions extends Model implements Resources
2020
*/
2121
protected $actions;
2222

23-
public function all(RequestOpts $requestOpts = null): array
23+
public function all(?RequestOpts $requestOpts = null): array
2424
{
2525
if ($requestOpts == null) {
2626
$requestOpts = new RequestOpts();
@@ -35,7 +35,7 @@ public function all(RequestOpts $requestOpts = null): array
3535
*
3636
* @throws \LKDev\HetznerCloud\APIException
3737
*/
38-
public function list(RequestOpts $requestOpts = null): ?APIResponse
38+
public function list(?RequestOpts $requestOpts = null): ?APIResponse
3939
{
4040
if ($requestOpts == null) {
4141
$requestOpts = new RequestOpts();

0 commit comments

Comments
 (0)