From 06ea1d8f051e9fddb078e82f450e19107302dada Mon Sep 17 00:00:00 2001 From: Guido Schmechel Date: Sat, 9 Oct 2021 17:01:45 +0200 Subject: [PATCH 1/2] [FEATURE] Add firewalls parameter for server Related #70 --- src/Models/Servers/Servers.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Models/Servers/Servers.php b/src/Models/Servers/Servers.php index 516ab2b..a31621c 100644 --- a/src/Models/Servers/Servers.php +++ b/src/Models/Servers/Servers.php @@ -121,6 +121,7 @@ public function getById(int $serverId): ?Server * @param bool $automount * @param array $networks * @param array $labels + * @param array $firewalls * @return APIResponse|null * @throws \LKDev\HetznerCloud\APIException */ @@ -135,7 +136,8 @@ public function createInDatacenter( $volumes = [], $automount = false, $networks = [], - array $labels = [] + array $labels = [], + array $firewalls = [] ): ?APIResponse { $parameters = [ 'name' => $name, @@ -152,6 +154,9 @@ public function createInDatacenter( if (! empty($labels)) { $parameters['labels'] = $labels; } + if (! empty($firewalls)) { + $parameters['firewalls'] = json_encode($firewalls); + } $response = $this->httpClient->post('servers', [ 'json' => $parameters, ]); @@ -187,6 +192,7 @@ public function createInDatacenter( * @param bool $automount * @param array $networks * @param array $labels + * @param array $firewalls * @return APIResponse|null * @throws \LKDev\HetznerCloud\APIException */ @@ -200,7 +206,8 @@ public function createInLocation(string $name, array $volumes = [], bool $automount = false, array $networks = [], - array $labels = [] + array $labels = [], + array $firewalls =[] ): ?APIResponse { $parameters = [ 'name' => $name, @@ -217,6 +224,9 @@ public function createInLocation(string $name, if (! empty($labels)) { $parameters['labels'] = $labels; } + if (! empty($firewalls)) { + $parameters['firewalls'] = json_encode($firewalls); + } $response = $this->httpClient->post('servers', [ 'json' => $parameters, ]); From 58a6cd99101074e2369ca1d3c1170230b3fd6291 Mon Sep 17 00:00:00 2001 From: Guido Schmechel Date: Sat, 9 Oct 2021 17:02:24 +0200 Subject: [PATCH 2/2] [BUGFIX] Add missing space --- src/Models/Servers/Servers.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Models/Servers/Servers.php b/src/Models/Servers/Servers.php index a31621c..0449418 100644 --- a/src/Models/Servers/Servers.php +++ b/src/Models/Servers/Servers.php @@ -207,7 +207,7 @@ public function createInLocation(string $name, bool $automount = false, array $networks = [], array $labels = [], - array $firewalls =[] + array $firewalls = [] ): ?APIResponse { $parameters = [ 'name' => $name,