From 48404cd0ac5819b4b0f51a54768d02ccea37e5cf Mon Sep 17 00:00:00 2001 From: Vitaliy Dotsenko Date: Thu, 27 Jun 2019 18:20:34 +0300 Subject: [PATCH] Added update to Firewall rules --- src/Endpoints/Firewall.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/Endpoints/Firewall.php b/src/Endpoints/Firewall.php index 9c025da..49f68e9 100644 --- a/src/Endpoints/Firewall.php +++ b/src/Endpoints/Firewall.php @@ -81,4 +81,39 @@ class Firewall implements API return false; } + + public function updateFirewallRule( + string $zoneID, + string $ruleID, + string $filterID, + string $expression, + string $action, + string $description = null, + bool $paused = true, + int $priority = null + ): \stdClass { + $rule = [ + 'id' => $ruleID, + 'filter' => [ + 'id' => $filterID, + 'expression' => $expression, + 'paused' => false + ], + 'action' => $action, + 'paused' => $paused + ]; + + if ($description !== null) { + $rule['description'] = $description; + } + + if ($priority !== null) { + $rule['priority'] = $priority; + } + + $rule = $this->adapter->put('zones/' . $zoneID . '/firewall/rules/' . $ruleID, $rule); + $body = json_decode($rule->getBody()); + + return $body->result; + } }