diff --git a/docs/shield-api.md b/docs/shield-api.md new file mode 100644 index 0000000..949cf0e --- /dev/null +++ b/docs/shield-api.md @@ -0,0 +1,548 @@ +# Base API + +Bunny Shield: a powerful, next-generation web security suite—built to democratize access to serious, scalable protection that supports you from the moment you go live. + +## Setup + +```php +listShieldZones( + query: [ + 'page' => 1, + 'perPage' => 1000, + ], +); +``` + +#### [Get Shield Zone](https://docs.bunny.net/reference/get_shield-shield-zone-shieldzoneid) + +```php +$shieldApi->getShieldZone( + shieldZoneId: 1, +); +``` + +#### [Get Shield Zone (by PullZoneId)](https://docs.bunny.net/reference/get_shield-shield-zone-get-by-pullzone-pullzoneid) + +```php +$shieldApi->getShieldZoneByPullZoneId( + pullZoneId: 1, +); +``` + +#### [Create Shield Zone](https://docs.bunny.net/reference/post_shield-shield-zone) + +```php +$shieldApi->createShieldZone( + body: [ + 'pullZoneId' => 1, + 'shieldZone' => [ + 'shieldZoneId' => 2, + 'premiumPlan' => false, + 'learningMode' => true, + 'learningModeUntil' => 'Y-m-d\TH:i:s', + 'wafEnabled' => true, + 'wafExecutionMode' => 1, + 'wafDisabledRules' => [], + 'wafLogOnlyRules' => [], + 'wafRequestHeaderLoggingEnabled' => true, + 'wafRequestIgnoredHeaders' => [], + 'wafRealtimeThreatIntelligenceEnabled' => false, + 'wafProfileId' => 1, + 'wafEngineConfig' => [], + 'dDoSShieldSensitivity' => 1, + 'dDoSExecutionMode' => 1, + 'dDoSChallengeWindow' => 1, + 'blockVpn' => false, + 'blockTor' => false, + 'blockDatacentre' => false, + 'whitelabelResponsePages' => false, + ], + ], +); +``` + +!!! note + + - The key `shieldZoneId` is not needed or required when creating a shield zone. + +#### [Update Shield Zone](https://docs.bunny.net/reference/patch_shield-shield-zone2) + +```php +$shieldApi->updateShieldZone( +body: [ + 'shieldZoneId' => 2, + 'shieldZone' => [ + 'shieldZoneId' => 2, + 'premiumPlan' => false, + 'learningMode' => true, + 'learningModeUntil' => 'Y-m-d\TH:i:s', + 'wafEnabled' => true, + 'wafExecutionMode' => 1, + 'wafDisabledRules' => [], + 'wafLogOnlyRules' => [], + 'wafRequestHeaderLoggingEnabled' => true, + 'wafRequestIgnoredHeaders' => [], + 'wafRealtimeThreatIntelligenceEnabled' => false, + 'wafProfileId' => 1, + 'wafEngineConfig' => [], + 'dDoSShieldSensitivity' => 1, + 'dDoSExecutionMode' => 1, + 'dDoSChallengeWindow' => 1, + 'blockVpn' => false, + 'blockTor' => false, + 'blockDatacentre' => false, + 'whitelabelResponsePages' => false, + ], + ], +); +``` + +### WAF + +#### [List WAF Rules](https://docs.bunny.net/reference/get_shield-waf-rules) + +```php +$shieldApi->listWafRules(); +``` + +#### [Review Triggered Rules](https://docs.bunny.net/reference/get_shield-waf-rules-review-triggered-shieldzoneid) + +```php +$shieldApi->reviewTriggeredRules( + shieldZoneId: 1, +); +``` + +#### [Review Triggered Rule](https://docs.bunny.net/reference/post_shield-waf-rules-review-triggered-shieldzoneid) + +```php +$shieldApi->reviewTriggeredRule( + shieldZoneId: 1, + body: [ + 'ruleId' => '46d1703e-7d63-4138-83b1-78695bee5a07', + 'action' => 2, + ], +); +``` + +#### [Shield AI Triggered Rule Recommendation](https://docs.bunny.net/reference/get_shield-waf-rules-review-triggered-ai-recommendation-shieldzoneid-ruleid) + +```php +$shieldApi->reviewTriggeredRuleAiRecommendation( + shieldZoneId: 1, + ruleId: '46d1703e-7d63-4138-83b1-78695bee5a07', +); +``` + +#### [List Custom WAF Rules](https://docs.bunny.net/reference/get_shield-waf-custom-rules-shieldzoneid) + +```php +$shieldApi->listCustomWafRules( + shieldZoneId: 1, + query: [ + 'page' => 1, + 'perPage' => 1000, + ], +); +``` + +#### [Get Custom WAF Rule](https://docs.bunny.net/reference/get_shield-waf-custom-rule-id) + +```php +$shieldApi->getCustomWafRule( + id: 1, +); +``` + +#### [Update Custom WAF Rule](https://docs.bunny.net/reference/put_shield-waf-custom-rule-id) + +```php +$shieldApi->updateCustomWafRule( + id: 1, + body: [ + 'ruleName' => 'string', + 'ruleDescription' => 'string', + 'ruleConfiguration' => [ + 'actionType' => 1, + 'variableTypes' => [ + 'REQUEST_URI' => 'string', + 'REQUEST_URI_RAW' => 'string', + 'ARGS' => 'string', + 'ARGS_COMBINED_SIZE' => 'string', + 'ARGS_GET' => 'string', + 'ARGS_GET_NAMES' => 'string', + 'ARGS_POST' => 'string', + 'ARGS_POST_NAMES' => 'string', + 'FILES_NAMES' => 'string', + 'GEO' => 'string', + 'REMOTE_ADDR' => 'string', + 'QUERY_STRING' => 'string', + 'REQUEST_BASENAME' => 'string', + 'REQUEST_BODY' => 'string', + 'REQUEST_COOKIES_NAMES' => 'string', + 'REQUEST_COOKIES' => 'string', + 'REQUEST_FILENAME' => 'string', + 'REQUEST_HEADERS_NAMES' => 'string', + 'REQUEST_HEADERS' => 'string', + 'REQUEST_LINE' => 'string', + 'REQUEST_METHOD' => 'string', + 'REQUEST_PROTOCOL' => 'string', + 'RESPONSE_BODY' => 'string', + 'RESPONSE_HEADERS' => 'string', + 'RESPONSE_STATUS' => 'string', + ], + 'operatorType' => 0, + 'severityType' => 0, + 'transformationTypes' => [1], + 'value' => 'string', + 'requestCount' => 0, + 'timeframe' => 1, + 'blockTime' => 30, + ], + ] +); +``` + +#### [Update Custom WAF Rule (PATCH)](https://docs.bunny.net/reference/patch_shield-waf-custom-rule-id) + +```php +$shieldApi->updateCustomWafRuleByPatch( + id: 1, + body: [ + 'ruleName' => 'string', + 'ruleDescription' => 'string', + 'ruleConfiguration' => [ + 'actionType' => 1, + 'variableTypes' => [ + 'REQUEST_URI' => 'string', + 'REQUEST_URI_RAW' => 'string', + 'ARGS' => 'string', + 'ARGS_COMBINED_SIZE' => 'string', + 'ARGS_GET' => 'string', + 'ARGS_GET_NAMES' => 'string', + 'ARGS_POST' => 'string', + 'ARGS_POST_NAMES' => 'string', + 'FILES_NAMES' => 'string', + 'GEO' => 'string', + 'REMOTE_ADDR' => 'string', + 'QUERY_STRING' => 'string', + 'REQUEST_BASENAME' => 'string', + 'REQUEST_BODY' => 'string', + 'REQUEST_COOKIES_NAMES' => 'string', + 'REQUEST_COOKIES' => 'string', + 'REQUEST_FILENAME' => 'string', + 'REQUEST_HEADERS_NAMES' => 'string', + 'REQUEST_HEADERS' => 'string', + 'REQUEST_LINE' => 'string', + 'REQUEST_METHOD' => 'string', + 'REQUEST_PROTOCOL' => 'string', + 'RESPONSE_BODY' => 'string', + 'RESPONSE_HEADERS' => 'string', + 'RESPONSE_STATUS' => 'string', + ], + 'operatorType' => 0, + 'severityType' => 0, + 'transformationTypes' => [1], + 'value' => 'string', + 'requestCount' => 0, + 'timeframe' => 1, + 'blockTime' => 30, + ], + ] +); +``` + +#### [Delete Custom WAF Rule](https://docs.bunny.net/reference/delete_shield-waf-custom-rule-id) + +```php +$shieldApi->deleteCustomWafRule( + id: 1, +); +``` + + +#### [Create Custom WAF Rule](https://docs.bunny.net/reference/post_shield-waf-custom-rule) + +```php +$shieldApi->createCustomWafRule( + body: [ + 'shieldZoneId' => 1, + 'ruleName' => 'string', + 'ruleDescription' => 'string', + 'ruleConfiguration' => [ + 'actionType' => 1, + 'variableTypes' => [ + 'REQUEST_URI' => 'string', + 'REQUEST_URI_RAW' => 'string', + 'ARGS' => 'string', + 'ARGS_COMBINED_SIZE' => 'string', + 'ARGS_GET' => 'string', + 'ARGS_GET_NAMES' => 'string', + 'ARGS_POST' => 'string', + 'ARGS_POST_NAMES' => 'string', + 'FILES_NAMES' => 'string', + 'GEO' => 'string', + 'REMOTE_ADDR' => 'string', + 'QUERY_STRING' => 'string', + 'REQUEST_BASENAME' => 'string', + 'REQUEST_BODY' => 'string', + 'REQUEST_COOKIES_NAMES' => 'string', + 'REQUEST_COOKIES' => 'string', + 'REQUEST_FILENAME' => 'string', + 'REQUEST_HEADERS_NAMES' => 'string', + 'REQUEST_HEADERS' => 'string', + 'REQUEST_LINE' => 'string', + 'REQUEST_METHOD' => 'string', + 'REQUEST_PROTOCOL' => 'string', + 'RESPONSE_BODY' => 'string', + 'RESPONSE_HEADERS' => 'string', + 'RESPONSE_STATUS' => 'string', + ], + 'operatorType' => 0, + 'severityType' => 0, + 'transformationTypes' => [1], + 'value' => 'string', + 'requestCount' => 0, + 'timeframe' => 1, + 'blockTime' => 30, + ], + ] +); +``` + +!!! warning + + - If this endpoint is requested for a shield zone on a free tier, it returns a `202` status code with the error message: `We do not support Custom WAF Rule creation on our Free Tier of Bunny Shield, please upgrade to Advanced.` + +#### [List WAF Profiles](https://docs.bunny.net/reference/get_shield-waf-profiles) + +```php +$shieldApi->listWafProfiles(); +``` + +#### [List WAF Enums](https://docs.bunny.net/reference/get_shield-waf-enums) + +```php +$shieldApi->listWafEnums(); +``` + +#### [List WAF Engine Configuration](https://docs.bunny.net/reference/get_shield-waf-engine-config) + +```php +$shieldApi->listWafEngineConfiguration(); +``` + +### DDoS + +#### [List DDoS Enums](https://docs.bunny.net/reference/get_shield-ddos-enums) + +```php +$shieldApi->listDdosEnums(); +``` + +### Rate Limiting + +#### [List Rate Limits](https://docs.bunny.net/reference/get_shield-rate-limits-shieldzoneid) + +```php +$shieldApi->listRateLimits( + shieldZoneId: 1, + query: [ + 'page' => 1, + 'perPage' => 1000, + ], +); +``` + +#### [Get Rate Limit](https://docs.bunny.net/reference/get_shield-rate-limit-id) + +```php +$shieldApi->getRateLimit( + id: 1, +); +``` + +#### [Update Rate Limit](https://docs.bunny.net/reference/patch_shield-rate-limit-id) + +```php +$shieldApi->updateRateLimit( + id: 1, + body: [ + 'ruleName' => 'string', + 'ruleDescription' => 'string', + 'ruleConfiguration' => [ + 'actionType' => 1, + 'variableTypes' => [ + 'REQUEST_URI' => 'string', + 'REQUEST_URI_RAW' => 'string', + 'ARGS' => 'string', + 'ARGS_COMBINED_SIZE' => 'string', + 'ARGS_GET' => 'string', + 'ARGS_GET_NAMES' => 'string', + 'ARGS_POST' => 'string', + 'ARGS_POST_NAMES' => 'string', + 'FILES_NAMES' => 'string', + 'GEO' => 'string', + 'REMOTE_ADDR' => 'string', + 'QUERY_STRING' => 'string', + 'REQUEST_BASENAME' => 'string', + 'REQUEST_BODY' => 'string', + 'REQUEST_COOKIES_NAMES' => 'string', + 'REQUEST_COOKIES' => 'string', + 'REQUEST_FILENAME' => 'string', + 'REQUEST_HEADERS_NAMES' => 'string', + 'REQUEST_HEADERS' => 'string', + 'REQUEST_LINE' => 'string', + 'REQUEST_METHOD' => 'string', + 'REQUEST_PROTOCOL' => 'string', + 'RESPONSE_BODY' => 'string', + 'RESPONSE_HEADERS' => 'string', + 'RESPONSE_STATUS' => 'string', + ], + 'operatorType' => 0, + 'severityType' => 0, + 'transformationTypes' => [1], + 'value' => 'string', + 'requestCount' => 0, + 'timeframe' => 1, + 'blockTime' => 30, + ], + ], +); +``` + + +#### [Delete Rate Limit](https://docs.bunny.net/reference/delete_shield-rate-limit-id) + +```php +$shieldApi->deleteRateLimit( + id: 1, +); +``` + +#### [Create Rate Limit](https://docs.bunny.net/reference/post_shield-rate-limit) + +```php +$shieldApi->createRateLimit( + id: 1, + body: [ + 'shieldZoneId' => 1, + 'ruleName' => 'string', + 'ruleDescription' => 'string', + 'ruleConfiguration' => [ + 'actionType' => 1, + 'variableTypes' => [ + 'REQUEST_URI' => 'string', + 'REQUEST_URI_RAW' => 'string', + 'ARGS' => 'string', + 'ARGS_COMBINED_SIZE' => 'string', + 'ARGS_GET' => 'string', + 'ARGS_GET_NAMES' => 'string', + 'ARGS_POST' => 'string', + 'ARGS_POST_NAMES' => 'string', + 'FILES_NAMES' => 'string', + 'GEO' => 'string', + 'REMOTE_ADDR' => 'string', + 'QUERY_STRING' => 'string', + 'REQUEST_BASENAME' => 'string', + 'REQUEST_BODY' => 'string', + 'REQUEST_COOKIES_NAMES' => 'string', + 'REQUEST_COOKIES' => 'string', + 'REQUEST_FILENAME' => 'string', + 'REQUEST_HEADERS_NAMES' => 'string', + 'REQUEST_HEADERS' => 'string', + 'REQUEST_LINE' => 'string', + 'REQUEST_METHOD' => 'string', + 'REQUEST_PROTOCOL' => 'string', + 'RESPONSE_BODY' => 'string', + 'RESPONSE_HEADERS' => 'string', + 'RESPONSE_STATUS' => 'string', + ], + 'operatorType' => 0, + 'severityType' => 0, + 'transformationTypes' => [1], + 'value' => 'string', + 'requestCount' => 0, + 'timeframe' => 1, + 'blockTime' => 30, + ], + ], +); +``` + +### Metrics + +#### [Get Overview Metrics](https://docs.bunny.net/reference/get_shield-metrics-overview-shieldzoneid) + +```php +$shieldApi->getOverviewMetrics( + shieldZoneId: 1, +); +``` + +#### [List Rate Limit Metrics](https://docs.bunny.net/reference/get_shield-metrics-rate-limits-shieldzoneid) + +```php +$shieldApi->listRateLimitMetrics( + shieldZoneId: 1, +); +``` + +#### [Get Rate Limit Metrics](https://docs.bunny.net/reference/get_shield-metrics-rate-limit-id) + +```php +$shieldApi->getRateLimitMetrics( + id: 1, +); +``` + +#### [Get WAF Rule Metrics](https://docs.bunny.net/reference/get_shield-metrics-shield-zone-shieldzoneid-waf-rule-ruleid) + +```php +$shieldApi->getWafRuleMetrics( + shieldZoneId: 1, + ruleId: '68332416-124a-4a55-b3fd-4f6c995a3bdf', +); +``` + +### Event Logs + +#### [List Event Logs](https://docs.bunny.net/reference/get_shield-event-logs-shieldzoneid-date-continuationtoken) + +```php +$shieldApi->listEventLogs( + shieldZoneId: 1, + date: 'Y-m-d\TH:i:s', + continuationToken: 'string', +); +``` + +## Reference + +* [Shield API](https://docs.bunny.net/reference/get_shield-shield-zones) +* [Shield API (Swagger)](https://api.bunny.net/shield/docs/index.html) diff --git a/mkdocs.yml b/mkdocs.yml index 5103ac0..994422d 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -60,6 +60,7 @@ nav: - Edge Storage: edge-storage-api.md - Stream: stream-api.md - Edge Scripting: edge-scripting-api.md + - Shield: shield-api.md - Logging: logging-api.md - Other: - Image Processing: image-processing.md diff --git a/phpmd.baseline.xml b/phpmd.baseline.xml index 5956290..8c11cbc 100644 --- a/phpmd.baseline.xml +++ b/phpmd.baseline.xml @@ -12,6 +12,8 @@ + + diff --git a/src/Enum/Method.php b/src/Enum/Method.php index bc983a8..cd32f83 100644 --- a/src/Enum/Method.php +++ b/src/Enum/Method.php @@ -12,5 +12,7 @@ enum Method: string case PUT = 'PUT'; + case PATCH = 'PATCH'; + case DELETE = 'DELETE'; } diff --git a/src/Model/API/Shield/DDoS/ListDDoSEnums.php b/src/Model/API/Shield/DDoS/ListDDoSEnums.php new file mode 100644 index 0000000..d15b88f --- /dev/null +++ b/src/Model/API/Shield/DDoS/ListDDoSEnums.php @@ -0,0 +1,29 @@ +client + ->setApiKey($this->apiKey) + ->setBaseUrl(Host::API_ENDPOINT); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\InvalidTypeForKeyValueException + * @throws Exception\InvalidTypeForListValueException + * @throws Exception\JSONException + * @throws Exception\ParameterIsRequiredException + * @param array $query + * @return BunnyClientResponseInterface + */ + public function listShieldZones(array $query = []): BunnyClientResponseInterface + { + $endpoint = new ListShieldZones(); + + ParameterValidator::validate($query, $endpoint->getQuery()); + + return $this->client->request( + endpoint: $endpoint, + query: $query, + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @return BunnyClientResponseInterface + * @param int $shieldZoneId + */ + public function getShieldZone(int $shieldZoneId): BunnyClientResponseInterface + { + $endpoint = new GetShieldZone(); + + return $this->client->request( + endpoint: $endpoint, + parameters: [$shieldZoneId], + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @return BunnyClientResponseInterface + * @param int $pullZoneId + */ + public function getShieldZoneByPullZoneId(int $pullZoneId): BunnyClientResponseInterface + { + $endpoint = new GetShieldZoneByPullZoneId(); + + return $this->client->request( + endpoint: $endpoint, + parameters: [$pullZoneId], + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @throws Exception\InvalidTypeForKeyValueException + * @throws Exception\InvalidTypeForListValueException + * @throws Exception\ParameterIsRequiredException + * @return BunnyClientResponseInterface + * @param array $body + */ + public function createShieldZone(array $body): BunnyClientResponseInterface + { + $endpoint = new CreateShieldZone(); + + ParameterValidator::validate($body, $endpoint->getBody()); + + return $this->client->request( + endpoint: $endpoint, + body: BodyContentHelper::getBody($body), + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @throws Exception\InvalidTypeForKeyValueException + * @throws Exception\InvalidTypeForListValueException + * @throws Exception\ParameterIsRequiredException + * @return BunnyClientResponseInterface + * @param array $body + */ + public function updateShieldZone(array $body): BunnyClientResponseInterface + { + $endpoint = new UpdateShieldZone(); + + ParameterValidator::validate($body, $endpoint->getBody()); + + return $this->client->request( + endpoint: $endpoint, + body: BodyContentHelper::getBody($body), + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @return BunnyClientResponseInterface + */ + public function listWafRules(): BunnyClientResponseInterface + { + $endpoint = new ListWAFRules(); + + return $this->client->request( + endpoint: $endpoint, + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @return BunnyClientResponseInterface + * @param int $shieldZoneId + */ + public function reviewTriggeredRules(int $shieldZoneId): BunnyClientResponseInterface + { + $endpoint = new ReviewTriggeredRules(); + + return $this->client->request( + endpoint: $endpoint, + parameters: [$shieldZoneId], + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @throws Exception\InvalidTypeForKeyValueException + * @throws Exception\InvalidTypeForListValueException + * @throws Exception\ParameterIsRequiredException + * @return BunnyClientResponseInterface + * @param int $shieldZoneId + * @param array $body + */ + public function reviewTriggeredRule( + int $shieldZoneId, + array $body, + ): BunnyClientResponseInterface { + $endpoint = new ReviewTriggeredRule(); + + ParameterValidator::validate($body, $endpoint->getBody()); + + return $this->client->request( + endpoint: $endpoint, + parameters: [$shieldZoneId], + body: BodyContentHelper::getBody($body), + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @return BunnyClientResponseInterface + * @param int $shieldZoneId + * @param string $ruleId + */ + public function reviewTriggeredRuleAiRecommendation( + int $shieldZoneId, + string $ruleId, + ): BunnyClientResponseInterface { + $endpoint = new ReviewTriggeredRuleAIRecommendation(); + + return $this->client->request( + endpoint: $endpoint, + parameters: [$shieldZoneId, $ruleId], + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @throws Exception\InvalidTypeForKeyValueException + * @throws Exception\InvalidTypeForListValueException + * @throws Exception\ParameterIsRequiredException + * @param int $shieldZoneId + * @param array $query + * @return BunnyClientResponseInterface + */ + public function listCustomWafRules( + int $shieldZoneId, + array $query = [], + ): BunnyClientResponseInterface { + $endpoint = new ListCustomWAFRules(); + + ParameterValidator::validate($query, $endpoint->getQuery()); + + return $this->client->request( + endpoint: $endpoint, + parameters: [$shieldZoneId], + query: $query, + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @return BunnyClientResponseInterface + * @param int $id + */ + public function getCustomWafRule(int $id): BunnyClientResponseInterface + { + $endpoint = new GetCustomWAFRule(); + + return $this->client->request( + endpoint: $endpoint, + parameters: [$id], + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @throws Exception\InvalidTypeForKeyValueException + * @throws Exception\InvalidTypeForListValueException + * @throws Exception\ParameterIsRequiredException + * @return BunnyClientResponseInterface + * @param int $id + * @param array $body + */ + public function updateCustomWafRule( + int $id, + array $body, + ): BunnyClientResponseInterface { + $endpoint = new UpdateCustomWAFRule(); + + ParameterValidator::validate($body, $endpoint->getBody()); + + return $this->client->request( + endpoint: $endpoint, + parameters: [$id], + body: BodyContentHelper::getBody($body), + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @throws Exception\InvalidTypeForKeyValueException + * @throws Exception\InvalidTypeForListValueException + * @throws Exception\ParameterIsRequiredException + * @return BunnyClientResponseInterface + * @param int $id + * @param array $body + */ + public function updateCustomWafRuleByPatch( + int $id, + array $body, + ): BunnyClientResponseInterface { + $endpoint = new UpdateCustomWAFRuleByPatch(); + + ParameterValidator::validate($body, $endpoint->getBody()); + + return $this->client->request( + endpoint: $endpoint, + parameters: [$id], + body: BodyContentHelper::getBody($body), + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @return BunnyClientResponseInterface + * @param int $id + */ + public function deleteCustomWafRule(int $id): BunnyClientResponseInterface + { + $endpoint = new DeleteCustomWAFRule(); + + return $this->client->request( + endpoint: $endpoint, + parameters: [$id], + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @throws Exception\InvalidTypeForKeyValueException + * @throws Exception\InvalidTypeForListValueException + * @throws Exception\ParameterIsRequiredException + * @return BunnyClientResponseInterface + * @param array $body + */ + public function createCustomWafRule( + array $body, + ): BunnyClientResponseInterface { + $endpoint = new CreateCustomWAFRule(); + + ParameterValidator::validate($body, $endpoint->getBody()); + + return $this->client->request( + endpoint: $endpoint, + body: BodyContentHelper::getBody($body), + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @return BunnyClientResponseInterface + */ + public function listWafProfiles(): BunnyClientResponseInterface + { + $endpoint = new ListWafProfiles(); + + return $this->client->request( + endpoint: $endpoint, + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @return BunnyClientResponseInterface + */ + public function listWafEnums(): BunnyClientResponseInterface + { + $endpoint = new ListWAFEnums(); + + return $this->client->request( + endpoint: $endpoint, + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @return BunnyClientResponseInterface + */ + public function listWafEngineConfiguration(): BunnyClientResponseInterface + { + $endpoint = new ListWAFEngineConfiguration(); + + return $this->client->request( + endpoint: $endpoint, + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @return BunnyClientResponseInterface + */ + public function listDdosEnums(): BunnyClientResponseInterface + { + $endpoint = new ListDDoSEnums(); + + return $this->client->request( + endpoint: $endpoint, + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @throws Exception\InvalidTypeForKeyValueException + * @throws Exception\InvalidTypeForListValueException + * @throws Exception\ParameterIsRequiredException + * @param int $shieldZoneId + * @param array $query + * @return BunnyClientResponseInterface + */ + public function listRateLimits( + int $shieldZoneId, + array $query = [], + ): BunnyClientResponseInterface { + $endpoint = new ListRateLimits(); + + ParameterValidator::validate($query, $endpoint->getQuery()); + + return $this->client->request( + endpoint: $endpoint, + parameters: [$shieldZoneId], + query: $query, + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @return BunnyClientResponseInterface + * @param int $id + */ + public function getRateLimit(int $id): BunnyClientResponseInterface + { + $endpoint = new GetRateLimit(); + + return $this->client->request( + endpoint: $endpoint, + parameters: [$id], + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @throws Exception\InvalidTypeForKeyValueException + * @throws Exception\InvalidTypeForListValueException + * @throws Exception\ParameterIsRequiredException + * @return BunnyClientResponseInterface + * @param int $id + * @param array $body + */ + public function updateRateLimit( + int $id, + array $body, + ): BunnyClientResponseInterface { + $endpoint = new UpdateRateLimit(); + + ParameterValidator::validate($body, $endpoint->getBody()); + + return $this->client->request( + endpoint: $endpoint, + parameters: [$id], + body: BodyContentHelper::getBody($body), + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @return BunnyClientResponseInterface + * @param int $id + */ + public function deleteRateLimit(int $id): BunnyClientResponseInterface + { + $endpoint = new DeleteRateLimit(); + + return $this->client->request( + endpoint: $endpoint, + parameters: [$id], + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @throws Exception\InvalidTypeForKeyValueException + * @throws Exception\InvalidTypeForListValueException + * @throws Exception\ParameterIsRequiredException + * @return BunnyClientResponseInterface + * @param array $body + */ + public function createRateLimit( + array $body, + ): BunnyClientResponseInterface { + $endpoint = new CreateRateLimit(); + + ParameterValidator::validate($body, $endpoint->getBody()); + + return $this->client->request( + endpoint: $endpoint, + body: BodyContentHelper::getBody($body), + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @return BunnyClientResponseInterface + * @param int $shieldZoneId + */ + public function getOverviewMetrics( + int $shieldZoneId, + ): BunnyClientResponseInterface { + $endpoint = new GetOverviewMetrics(); + + return $this->client->request( + endpoint: $endpoint, + parameters: [$shieldZoneId], + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @return BunnyClientResponseInterface + * @param int $shieldZoneId + */ + public function listRateLimitMetrics( + int $shieldZoneId, + ): BunnyClientResponseInterface { + $endpoint = new ListRateLimitMetrics(); + + return $this->client->request( + endpoint: $endpoint, + parameters: [$shieldZoneId], + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @return BunnyClientResponseInterface + * @param int $id + */ + public function getRateLimitMetrics( + int $id, + ): BunnyClientResponseInterface { + $endpoint = new GetRateLimitMetrics(); + + return $this->client->request( + endpoint: $endpoint, + parameters: [$id], + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @return BunnyClientResponseInterface + * @param int $shieldZoneId + * @param string $ruleId + */ + public function getWafRuleMetrics( + int $shieldZoneId, + string $ruleId, + ): BunnyClientResponseInterface { + $endpoint = new GetWafRuleMetrics(); + + return $this->client->request( + endpoint: $endpoint, + parameters: [$shieldZoneId, $ruleId], + ); + } + + /** + * @throws ClientExceptionInterface + * @throws Exception\BunnyClientResponseException + * @throws Exception\JSONException + * @return BunnyClientResponseInterface + * @param int $shieldZoneId + * @param string $date + * @param string $continuationToken + */ + public function listEventLogs( + int $shieldZoneId, + string $date, + string $continuationToken, + ): BunnyClientResponseInterface { + $endpoint = new GetWafRuleMetrics(); + + return $this->client->request( + endpoint: $endpoint, + parameters: [$shieldZoneId, $date, $continuationToken], + ); + } +}