Shield 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
require 'vendor/autoload.php';
use ToshY\BunnyNet\BunnyHttpClient;
use ToshY\BunnyNet\Enum\Endpoint;
$bunnyHttpClient = new BunnyHttpClient(
client: new \Symfony\Component\HttpClient\Psr18Client(),
// Provide the account API key.
apiKey: '2cebf4f8-4bff-429f-86f6-bce2c2163d7e89fb0a86-a1b2-463c-a142-11eba8811989',
baseUrl: Endpoint::SHIELD
);
Usage
Shield Zone
List Shield Zones
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Zone\ListShieldZones(
query: [
'page' => 1,
'perPage' => 1000,
],
)
);
Get Shield Zone
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Zone\GetShieldZone(
shieldZoneId: 1,
)
);
Get Shield Zone (by PullZoneId)
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Zone\GetShieldZoneByPullZoneId(
pullZoneId: 1,
)
);
Create Shield Zone
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Zone\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
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Zone\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
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Waf\ListCustomWafRules()
);
Review Triggered Rules
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Waf\ReviewTriggeredRules(
shieldZoneId: 1,
)
);
Review Triggered Rule
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Waf\ReviewTriggeredRule(
shieldZoneId: 1,
body: [
'ruleId' => '46d1703e-7d63-4138-83b1-78695bee5a07',
'action' => 2,
],
)
);
Review Triggered Rule AI Recommendation
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Waf\ReviewTriggeredRuleAiRecommendation(
shieldZoneId: 1,
ruleId: '46d1703e-7d63-4138-83b1-78695bee5a07',
)
);
List Custom WAF Rules
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Waf\ListCustomWafRules(
shieldZoneId: 1,
query: [
'page' => 1,
'perPage' => 1000,
],
)
);
Get Custom WAF Rule
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Waf\GetCustomWafRule(
id: 1,
)
);
Update Custom WAF Rule
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Waf\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)
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Waf\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
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Waf\DeleteCustomWafRule(
id: 1,
)
);
Create Custom WAF Rule
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Waf\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
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Waf\ListWafProfiles()
);
List WAF Enums
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Waf\ListWafEnums()
);
List WAF Engine Configuration
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Waf\ListWafEngineConfiguration()
);
DDoS
List DDoS Enums
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Ddos\ListDdosEnums()
);
Rate Limiting
List Rate Limits
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\RateLimiting\ListRateLimits(
shieldZoneId: 1,
query: [
'page' => 1,
'perPage' => 1000,
],
)
);
Get Rate Limit
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\RateLimiting\GetRateLimit(
id: 1,
)
);
Update Rate Limit
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\RateLimiting\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
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\RateLimiting\DeleteRateLimit(
id: 1,
)
);
Create Rate Limit
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\RateLimiting\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
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Metrics\GetOverviewMetrics(
shieldZoneId: 1,
)
);
List Rate Limit Metrics
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Metrics\ListRateLimitMetrics(
shieldZoneId: 1,
)
);
Get Rate Limit Metrics
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Metrics\GetRateLimitMetrics(
id: 1,
)
);
Get WAF Rule Metrics
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\Metrics\GetWafRuleMetrics(
shieldZoneId: 1,
ruleId: '68332416-124a-4a55-b3fd-4f6c995a3bdf',
)
);
Event Logs
List Event Logs
$bunnyHttpClient->request(
new \ToshY\BunnyNet\Model\Api\Shield\EventLogs\ListEventLogs(
shieldZoneId: 1,
date: 'Y-m-d\TH:i:s',
continuationToken: 'string',
)
);