Skip to content

Add Shield API #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
548 changes: 548 additions & 0 deletions docs/shield-api.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions phpmd.baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
<violation rule="PHPMD\Rule\Design\LongMethod" file="src/Model/API/Base/PullZone/AddPullZone.php" method="getBody"/>
<violation rule="PHPMD\Rule\Design\LongMethod" file="src/Model/API/Base/PullZone/UpdatePullZone.php" method="getBody"/>
<violation rule="PHPMD\Rule\CleanCode\BooleanArgumentFlag" file="src/Model/AbstractParameter.php"/>
<violation rule="PHPMD\Rule\Design\TooManyPublicMethods" file="src/ShieldAPI.php"/>
<violation rule="PHPMD\Rule\Design\CouplingBetweenObjects" file="src/ShieldAPI.php"/>
<violation rule="PHPMD\Rule\Design\TooManyPublicMethods" file="src/StreamAPI.php"/>
<violation rule="PHPMD\Rule\Design\CouplingBetweenObjects" file="src/StreamAPI.php"/>
<violation rule="PHPMD\Rule\Design\LongParameterList" file="src/TokenAuthentication.php" method="sign"/>
Expand Down
2 changes: 2 additions & 0 deletions src/Enum/Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ enum Method: string

case PUT = 'PUT';

case PATCH = 'PATCH';

case DELETE = 'DELETE';
}
29 changes: 29 additions & 0 deletions src/Model/API/Shield/DDoS/ListDDoSEnums.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace ToshY\BunnyNet\Model\API\Shield\DDoS;

use ToshY\BunnyNet\Enum\Header;
use ToshY\BunnyNet\Enum\Method;
use ToshY\BunnyNet\Model\EndpointInterface;

class ListDDoSEnums implements EndpointInterface
{
public function getMethod(): Method
{
return Method::GET;
}

public function getPath(): string
{
return 'shield/ddos/enums';
}

public function getHeaders(): array
{
return [
Header::ACCEPT_JSON,
];
}
}
29 changes: 29 additions & 0 deletions src/Model/API/Shield/EventLogs/ListEventLogs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace ToshY\BunnyNet\Model\API\Shield\EventLogs;

use ToshY\BunnyNet\Enum\Header;
use ToshY\BunnyNet\Enum\Method;
use ToshY\BunnyNet\Model\EndpointInterface;

class ListEventLogs implements EndpointInterface
{
public function getMethod(): Method
{
return Method::GET;
}

public function getPath(): string
{
return 'shield/event-logs/%d/%s/%s';
}

public function getHeaders(): array
{
return [
Header::ACCEPT_JSON,
];
}
}
29 changes: 29 additions & 0 deletions src/Model/API/Shield/Metrics/GetOverviewMetrics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace ToshY\BunnyNet\Model\API\Shield\Metrics;

use ToshY\BunnyNet\Enum\Header;
use ToshY\BunnyNet\Enum\Method;
use ToshY\BunnyNet\Model\EndpointInterface;

class GetOverviewMetrics implements EndpointInterface
{
public function getMethod(): Method
{
return Method::GET;
}

public function getPath(): string
{
return 'shield/metrics/overview/%d';
}

public function getHeaders(): array
{
return [
Header::ACCEPT_JSON,
];
}
}
29 changes: 29 additions & 0 deletions src/Model/API/Shield/Metrics/GetRateLimitMetrics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace ToshY\BunnyNet\Model\API\Shield\Metrics;

use ToshY\BunnyNet\Enum\Header;
use ToshY\BunnyNet\Enum\Method;
use ToshY\BunnyNet\Model\EndpointInterface;

class GetRateLimitMetrics implements EndpointInterface
{
public function getMethod(): Method
{
return Method::GET;
}

public function getPath(): string
{
return 'shield/metrics/rate-limit/%d';
}

public function getHeaders(): array
{
return [
Header::ACCEPT_JSON,
];
}
}
29 changes: 29 additions & 0 deletions src/Model/API/Shield/Metrics/GetWAFRuleMetrics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace ToshY\BunnyNet\Model\API\Shield\Metrics;

use ToshY\BunnyNet\Enum\Header;
use ToshY\BunnyNet\Enum\Method;
use ToshY\BunnyNet\Model\EndpointInterface;

class GetWAFRuleMetrics implements EndpointInterface
{
public function getMethod(): Method
{
return Method::GET;
}

public function getPath(): string
{
return 'shield/metrics/shield-zone/%d/waf-rule/%s';
}

public function getHeaders(): array
{
return [
Header::ACCEPT_JSON,
];
}
}
29 changes: 29 additions & 0 deletions src/Model/API/Shield/Metrics/ListRateLimitMetrics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace ToshY\BunnyNet\Model\API\Shield\Metrics;

use ToshY\BunnyNet\Enum\Header;
use ToshY\BunnyNet\Enum\Method;
use ToshY\BunnyNet\Model\EndpointInterface;

class ListRateLimitMetrics implements EndpointInterface
{
public function getMethod(): Method
{
return Method::GET;
}

public function getPath(): string
{
return 'shield/metrics/rate-limits/%d';
}

public function getHeaders(): array
{
return [
Header::ACCEPT_JSON,
];
}
}
81 changes: 81 additions & 0 deletions src/Model/API/Shield/RateLimiting/CreateRateLimit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

declare(strict_types=1);

namespace ToshY\BunnyNet\Model\API\Shield\RateLimiting;

use ToshY\BunnyNet\Enum\Header;
use ToshY\BunnyNet\Enum\Method;
use ToshY\BunnyNet\Enum\Type;
use ToshY\BunnyNet\Model\AbstractParameter;
use ToshY\BunnyNet\Model\EndpointBodyInterface;
use ToshY\BunnyNet\Model\EndpointInterface;

class CreateRateLimit implements EndpointInterface, EndpointBodyInterface
{
public function getMethod(): Method
{
return Method::POST;
}

public function getPath(): string
{
return 'shield/rate-limit';
}

public function getHeaders(): array
{
return [
Header::ACCEPT_JSON,
Header::CONTENT_TYPE_JSON_ALL,
];
}

public function getBody(): array
{
return [
new AbstractParameter(name: 'shieldZoneId', type: Type::INT_TYPE),
new AbstractParameter(name: 'ruleName', type: Type::STRING_TYPE),
new AbstractParameter(name: 'ruleDescription', type: Type::STRING_TYPE),
new AbstractParameter(name: 'ruleConfiguration', type: Type::ARRAY_TYPE, children: [
new AbstractParameter(name: 'actionType', type: Type::INT_TYPE),
new AbstractParameter(name: 'variableTypes', type: Type::ARRAY_TYPE, children: [
new AbstractParameter(name: 'REQUEST_URI', type: Type::STRING_TYPE),
new AbstractParameter(name: 'REQUEST_URI_RAW', type: Type::STRING_TYPE),
new AbstractParameter(name: 'ARGS', type: Type::STRING_TYPE),
new AbstractParameter(name: 'ARGS_COMBINED_SIZE', type: Type::STRING_TYPE),
new AbstractParameter(name: 'ARGS_GET', type: Type::STRING_TYPE),
new AbstractParameter(name: 'ARGS_GET_NAMES', type: Type::STRING_TYPE),
new AbstractParameter(name: 'ARGS_POST', type: Type::STRING_TYPE),
new AbstractParameter(name: 'ARGS_POST_NAMES', type: Type::STRING_TYPE),
new AbstractParameter(name: 'FILES_NAMES', type: Type::STRING_TYPE),
new AbstractParameter(name: 'GEO', type: Type::STRING_TYPE),
new AbstractParameter(name: 'REMOTE_ADDR', type: Type::STRING_TYPE),
new AbstractParameter(name: 'QUERY_STRING', type: Type::STRING_TYPE),
new AbstractParameter(name: 'REQUEST_BASENAME', type: Type::STRING_TYPE),
new AbstractParameter(name: 'REQUEST_BODY', type: Type::STRING_TYPE),
new AbstractParameter(name: 'REQUEST_COOKIES_NAMES', type: Type::STRING_TYPE),
new AbstractParameter(name: 'REQUEST_COOKIES', type: Type::STRING_TYPE),
new AbstractParameter(name: 'REQUEST_FILENAME', type: Type::STRING_TYPE),
new AbstractParameter(name: 'REQUEST_HEADERS_NAMES', type: Type::STRING_TYPE),
new AbstractParameter(name: 'REQUEST_HEADERS', type: Type::STRING_TYPE),
new AbstractParameter(name: 'REQUEST_LINE', type: Type::STRING_TYPE),
new AbstractParameter(name: 'REQUEST_METHOD', type: Type::STRING_TYPE),
new AbstractParameter(name: 'REQUEST_PROTOCOL', type: Type::STRING_TYPE),
new AbstractParameter(name: 'RESPONSE_BODY', type: Type::STRING_TYPE),
new AbstractParameter(name: 'RESPONSE_HEADERS', type: Type::STRING_TYPE),
new AbstractParameter(name: 'RESPONSE_STATUS', type: Type::STRING_TYPE),
]),
new AbstractParameter(name: 'operatorType', type: Type::INT_TYPE),
new AbstractParameter(name: 'severityType', type: Type::INT_TYPE),
new AbstractParameter(name: 'transformationTypes', type: Type::ARRAY_TYPE, children: [
new AbstractParameter(name: null, type: Type::INT_TYPE),
]),
new AbstractParameter(name: 'value', type: Type::STRING_TYPE),
new AbstractParameter(name: 'requestCount', type: Type::INT_TYPE),
new AbstractParameter(name: 'timeframe', type: Type::INT_TYPE),
new AbstractParameter(name: 'blockTime', type: Type::INT_TYPE),
]),
];
}
}
29 changes: 29 additions & 0 deletions src/Model/API/Shield/RateLimiting/DeleteRateLimit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace ToshY\BunnyNet\Model\API\Shield\RateLimiting;

use ToshY\BunnyNet\Enum\Header;
use ToshY\BunnyNet\Enum\Method;
use ToshY\BunnyNet\Model\EndpointInterface;

class DeleteRateLimit implements EndpointInterface
{
public function getMethod(): Method
{
return Method::DELETE;
}

public function getPath(): string
{
return 'shield/rate-limit/%d';
}

public function getHeaders(): array
{
return [
Header::ACCEPT_JSON,
];
}
}
29 changes: 29 additions & 0 deletions src/Model/API/Shield/RateLimiting/GetRateLimit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);

namespace ToshY\BunnyNet\Model\API\Shield\RateLimiting;

use ToshY\BunnyNet\Enum\Header;
use ToshY\BunnyNet\Enum\Method;
use ToshY\BunnyNet\Model\EndpointInterface;

class GetRateLimit implements EndpointInterface
{
public function getMethod(): Method
{
return Method::GET;
}

public function getPath(): string
{
return 'shield/rate-limit/%d';
}

public function getHeaders(): array
{
return [
Header::ACCEPT_JSON,
];
}
}
40 changes: 40 additions & 0 deletions src/Model/API/Shield/RateLimiting/ListRateLimits.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

declare(strict_types=1);

namespace ToshY\BunnyNet\Model\API\Shield\RateLimiting;

use ToshY\BunnyNet\Enum\Header;
use ToshY\BunnyNet\Enum\Method;
use ToshY\BunnyNet\Enum\Type;
use ToshY\BunnyNet\Model\AbstractParameter;
use ToshY\BunnyNet\Model\EndpointInterface;
use ToshY\BunnyNet\Model\EndpointQueryInterface;

class ListRateLimits implements EndpointInterface, EndpointQueryInterface
{
public function getMethod(): Method
{
return Method::GET;
}

public function getPath(): string
{
return 'shield/rate-limits/%d';
}

public function getHeaders(): array
{
return [
Header::ACCEPT_JSON,
];
}

public function getQuery(): array
{
return [
new AbstractParameter(name: 'page', type: Type::INT_TYPE),
new AbstractParameter(name: 'perPage', type: Type::INT_TYPE),
];
}
}
Loading