├── LICENSE ├── README.md ├── composer.json └── src ├── BaseAPI.php ├── Client └── BunnyClient.php ├── EdgeScriptingAPI.php ├── EdgeStorageAPI.php ├── Enum ├── Header.php ├── Host.php ├── Method.php ├── MimeType.php ├── Region.php └── Type.php ├── Exception ├── BunnyClientResponseException.php ├── InvalidTypeForKeyValueException.php ├── InvalidTypeForListValueException.php ├── JSONException.php ├── ParameterIsRequiredException.php └── UnexpectedParameterForObjectException.php ├── Helper ├── BodyContentHelper.php └── BunnyClientHelper.php ├── ImageProcessor.php ├── LoggingAPI.php ├── Model ├── API │ ├── Base │ │ ├── APIKeys │ │ │ └── ListAPIKeys.php │ │ ├── AbuseCase │ │ │ ├── CheckAbuseCase.php │ │ │ ├── GetAbuseCase.php │ │ │ ├── GetDMCACase.php │ │ │ ├── ListAbuseCases.php │ │ │ ├── ResolveAbuseCase.php │ │ │ └── ResolveDMCACase.php │ │ ├── Auth │ │ │ ├── AuthJwt2fa.php │ │ │ └── RefreshJwt.php │ │ ├── Billing │ │ │ ├── ApplyPromoCode.php │ │ │ ├── ClaimAffiliateCredits.php │ │ │ ├── ConfigureAutoRecharge.php │ │ │ ├── CreateCoinifyPayment.php │ │ │ ├── CreatePaymentCheckout.php │ │ │ ├── GetAffiliateDetails.php │ │ │ ├── GetBillingDetails.php │ │ │ ├── GetBillingSummary.php │ │ │ ├── GetBillingSummaryPDF.php │ │ │ ├── GetCoinifyBitcoinExchangeRate.php │ │ │ └── PreparePaymentAuthorization.php │ │ ├── Countries │ │ │ └── ListCountries.php │ │ ├── DNSZone │ │ │ ├── AddDNSRecord.php │ │ │ ├── AddDNSZone.php │ │ │ ├── CheckDNSZoneAvailability.php │ │ │ ├── DeleteDNSRecord.php │ │ │ ├── DeleteDNSZone.php │ │ │ ├── DisableDNSSECOnDNSZone.php │ │ │ ├── DismissDNSConfigurationNotice.php │ │ │ ├── EnableDNSSECOnDNSZone.php │ │ │ ├── ExportDNSRecords.php │ │ │ ├── GetDNSZone.php │ │ │ ├── GetDNSZoneQueryStatistics.php │ │ │ ├── ImportDNSRecords.php │ │ │ ├── ListDNSZones.php │ │ │ ├── RecheckDNSConfiguration.php │ │ │ ├── UpdateDNSRecord.php │ │ │ └── UpdateDNSZone.php │ │ ├── DRMCertificate │ │ │ └── ListDRMCertificates.php │ │ ├── Integration │ │ │ └── GetGitHubIntegration.php │ │ ├── PullZone │ │ │ ├── AddAllowedReferer.php │ │ │ ├── AddBlockedIP.php │ │ │ ├── AddBlockedReferer.php │ │ │ ├── AddCustomCertificate.php │ │ │ ├── AddCustomHostname.php │ │ │ ├── AddOrUpdateEdgeRule.php │ │ │ ├── AddPullZone.php │ │ │ ├── CheckPullZoneAvailability.php │ │ │ ├── DeleteAllowedReferer.php │ │ │ ├── DeleteBlockedIP.php │ │ │ ├── DeleteBlockedReferer.php │ │ │ ├── DeleteCertificate.php │ │ │ ├── DeleteCustomHostname.php │ │ │ ├── DeleteEdgeRule.php │ │ │ ├── DeletePullZone.php │ │ │ ├── GetOptimizerStatistics.php │ │ │ ├── GetOriginShieldQueueStatistics.php │ │ │ ├── GetPullZone.php │ │ │ ├── GetSafeHopStatistics.php │ │ │ ├── GetWAFStatistics.php │ │ │ ├── ListPullZones.php │ │ │ ├── LoadFreeCertificate.php │ │ │ ├── PurgeCache.php │ │ │ ├── ResetTokenKey.php │ │ │ ├── SetEdgeRuleEnabled.php │ │ │ ├── SetForceSSL.php │ │ │ ├── SetZoneSecurityEnabled.php │ │ │ ├── SetZoneSecurityIncludeHashRemoteIPEnabled.php │ │ │ └── UpdatePullZone.php │ │ ├── Purge │ │ │ ├── PurgeURL.php │ │ │ └── PurgeURLByHeader.php │ │ ├── Region │ │ │ └── ListRegions.php │ │ ├── Search │ │ │ └── GlobalSearch.php │ │ ├── Statistics │ │ │ └── GetStatistics.php │ │ ├── StorageZone │ │ │ ├── AddStorageZone.php │ │ │ ├── CheckStorageZoneAvailability.php │ │ │ ├── DeleteStorageZone.php │ │ │ ├── GetStorageZone.php │ │ │ ├── GetStorageZoneConnections.php │ │ │ ├── GetStorageZoneStatistics.php │ │ │ ├── ListStorageZones.php │ │ │ ├── ResetPassword.php │ │ │ ├── ResetReadOnlyPassword.php │ │ │ └── UpdateStorageZone.php │ │ ├── StreamVideoLibrary │ │ │ ├── AddAllowedReferer.php │ │ │ ├── AddBlockedReferer.php │ │ │ ├── AddVideoLibrary.php │ │ │ ├── AddWatermark.php │ │ │ ├── DeleteAllowedReferer.php │ │ │ ├── DeleteBlockedReferer.php │ │ │ ├── DeleteVideoLibrary.php │ │ │ ├── DeleteWatermark.php │ │ │ ├── GetLanguages.php │ │ │ ├── GetVideoLibrary.php │ │ │ ├── ListVideoLibraries.php │ │ │ ├── ResetPassword.php │ │ │ ├── ResetPasswordByPathParameter.php │ │ │ └── UpdateVideoLibrary.php │ │ ├── Support │ │ │ ├── CloseTicket.php │ │ │ ├── CreateTicket.php │ │ │ ├── GetTicketDetails.php │ │ │ ├── ListTickets.php │ │ │ └── ReplyTicket.php │ │ └── User │ │ │ ├── AcceptDPA.php │ │ │ ├── CloseAccount.php │ │ │ ├── DisableTwoFactorAuthentication.php │ │ │ ├── EnableTwoFactorAuthentication.php │ │ │ ├── GenerateTwoFactorAuthenticationVerification.php │ │ │ ├── GetDPADetails.php │ │ │ ├── GetDPADetailsHTML.php │ │ │ ├── GetHomeFeed.php │ │ │ ├── GetMarketingDetails.php │ │ │ ├── GetUserDetails.php │ │ │ ├── GetWhatsNewItems.php │ │ │ ├── ListCloseAccountReasons.php │ │ │ ├── ListNotifications.php │ │ │ ├── ResendEmailConfirmation.php │ │ │ ├── ResetAPIKey.php │ │ │ ├── ResetWhatsNew.php │ │ │ ├── SetNotificationsOpened.php │ │ │ ├── UpdateUserDetails.php │ │ │ └── VerifyTwoFactorAuthenticationCode.php │ ├── EdgeScripting │ │ ├── Code │ │ │ ├── GetCode.php │ │ │ └── SetCode.php │ │ ├── EdgeScript │ │ │ ├── AddEdgeScript.php │ │ │ ├── DeleteEdgeScript.php │ │ │ ├── GetEdgeScript.php │ │ │ ├── GetEdgeScriptStatistics.php │ │ │ ├── ListEdgeScripts.php │ │ │ ├── RotateDeploymentKey.php │ │ │ └── UpdateEdgeScript.php │ │ ├── Release │ │ │ ├── GetActiveReleases.php │ │ │ ├── GetReleases.php │ │ │ ├── PublishRelease.php │ │ │ └── PublishReleaseByPathParameter.php │ │ ├── Secret │ │ │ ├── AddSecret.php │ │ │ ├── DeleteSecret.php │ │ │ ├── ListSecrets.php │ │ │ ├── UpdateSecret.php │ │ │ └── UpsertSecret.php │ │ └── Variable │ │ │ ├── AddVariable.php │ │ │ ├── DeleteVariable.php │ │ │ ├── GetVariable.php │ │ │ ├── UpdateVariable.php │ │ │ └── UpsertVariable.php │ ├── EdgeStorage │ │ ├── BrowseFiles │ │ │ └── ListFiles.php │ │ └── ManageFiles │ │ │ ├── DeleteFile.php │ │ │ ├── DownloadFile.php │ │ │ ├── DownloadZip.php │ │ │ └── UploadFile.php │ ├── Logging │ │ └── GetLog.php │ ├── Shield │ │ ├── DDoS │ │ │ └── ListDDoSEnums.php │ │ ├── EventLogs │ │ │ └── ListEventLogs.php │ │ ├── Metrics │ │ │ ├── GetOverviewMetrics.php │ │ │ ├── GetRateLimitMetrics.php │ │ │ ├── GetWAFRuleMetrics.php │ │ │ └── ListRateLimitMetrics.php │ │ ├── RateLimiting │ │ │ ├── CreateRateLimit.php │ │ │ ├── DeleteRateLimit.php │ │ │ ├── GetRateLimit.php │ │ │ ├── ListRateLimits.php │ │ │ └── UpdateRateLimit.php │ │ ├── WAF │ │ │ ├── CreateCustomWAFRule.php │ │ │ ├── DeleteCustomWAFRule.php │ │ │ ├── GetCustomWAFRule.php │ │ │ ├── ListCustomWAFRules.php │ │ │ ├── ListWAFEngineConfiguration.php │ │ │ ├── ListWAFEnums.php │ │ │ ├── ListWAFProfiles.php │ │ │ ├── ListWAFRules.php │ │ │ ├── ReviewTriggeredRule.php │ │ │ ├── ReviewTriggeredRuleAIRecommendation.php │ │ │ ├── ReviewTriggeredRules.php │ │ │ ├── UpdateCustomWAFRule.php │ │ │ └── UpdateCustomWAFRuleByPatch.php │ │ └── Zone │ │ │ ├── CreateShieldZone.php │ │ │ ├── GetShieldZone.php │ │ │ ├── GetShieldZoneByPullZoneId.php │ │ │ ├── ListShieldZones.php │ │ │ └── UpdateShieldZone.php │ └── Stream │ │ ├── ManageCollections │ │ ├── CreateCollection.php │ │ ├── DeleteCollection.php │ │ ├── GetCollection.php │ │ ├── ListCollections.php │ │ └── UpdateCollection.php │ │ ├── ManageVideos │ │ ├── AddCaption.php │ │ ├── AddOutputCodecToVideo.php │ │ ├── CreateVideo.php │ │ ├── DeleteCaption.php │ │ ├── DeleteUnconfiguredResolutions.php │ │ ├── DeleteVideo.php │ │ ├── FetchVideo.php │ │ ├── GetVideo.php │ │ ├── GetVideoHeatmap.php │ │ ├── GetVideoPlayData.php │ │ ├── GetVideoResolutionsInfo.php │ │ ├── ListVideoStatistics.php │ │ ├── ListVideos.php │ │ ├── ReEncodeVideo.php │ │ ├── RepackageVideo.php │ │ ├── SetThumbnail.php │ │ ├── TranscribeVideo.php │ │ ├── UpdateVideo.php │ │ └── UploadVideo.php │ │ └── OEmbed │ │ └── GetOEmbed.php ├── AbstractParameter.php ├── Client │ ├── BunnyClientResponse.php │ └── Interface │ │ └── BunnyClientResponseInterface.php ├── EndpointBodyInterface.php ├── EndpointInterface.php ├── EndpointQueryInterface.php └── ParameterInterface.php ├── ShieldAPI.php ├── StreamAPI.php ├── TokenAuthentication.php └── Validator └── ParameterValidator.php /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 ToshY 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "toshy/bunnynet-php", 3 | "description": "BunnyNet API client for PHP", 4 | "keywords": [ 5 | "Bunny.net", 6 | "BunnyCDN", 7 | "BunnyWay", 8 | "BunnyNet-PHP", 9 | "BunnyWay-PHP", 10 | "Bunny PHP", 11 | "Bunny CDN PHP", 12 | "BunnyNet PHP client", 13 | "ToshY" 14 | ], 15 | "type": "library", 16 | "license": "MIT", 17 | "minimum-stability": "stable", 18 | "authors": [ 19 | { 20 | "name": "ToshY", 21 | "homepage": "https://github.com/ToshY" 22 | } 23 | ], 24 | "autoload": { 25 | "psr-4": { 26 | "ToshY\\BunnyNet\\": "src/" 27 | } 28 | }, 29 | "autoload-dev": { 30 | "psr-4": { 31 | "ToshY\\BunnyNet\\Tests\\": "tests/", 32 | "ToshY\\BunnyNet\\Generator\\": "generator/" 33 | } 34 | }, 35 | "require": { 36 | "php": "^8.1", 37 | "ext-json": "*", 38 | "psr/http-client": "^1.0", 39 | "nyholm/psr7": "^1.6.1" 40 | }, 41 | "require-dev": { 42 | "rector/rector": "^2.0", 43 | "phpmd/phpmd": "^2.15", 44 | "friendsofphp/php-cs-fixer": "^3.75", 45 | "phpstan/phpstan": "^2.1", 46 | "phpunit/phpunit": "^10.0", 47 | "nette/php-generator": "^4.1", 48 | "cebe/php-openapi": "^1.8" 49 | }, 50 | "config": { 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/Enum/Header.php: -------------------------------------------------------------------------------- 1 | MimeType::JSON, 11 | ]; 12 | 13 | public const ACCEPT_ALL = [ 14 | 'Accept' => MimeType::ALL, 15 | ]; 16 | 17 | public const CONTENT_TYPE_JSON = [ 18 | 'Content-Type' => MimeType::JSON, 19 | ]; 20 | 21 | public const CONTENT_TYPE_JSON_ALL = [ 22 | 'Content-Type' => MimeType::JSON_ALL, 23 | ]; 24 | 25 | public const CONTENT_TYPE_OCTET_STREAM = [ 26 | 'Content-Type' => MimeType::OCTET_STREAM, 27 | ]; 28 | } 29 | -------------------------------------------------------------------------------- /src/Enum/Host.php: -------------------------------------------------------------------------------- 1 | Host::STORAGE_ENDPOINT, 59 | default => sprintf('%s.%s', strtolower($this->value), Host::STORAGE_ENDPOINT), 60 | }; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Enum/Type.php: -------------------------------------------------------------------------------- 1 | value, 24 | gettype($actualValue), 25 | is_array($actualValue) === true ? json_encode($actualValue) : $actualValue, 26 | ), 27 | ); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Exception/InvalidTypeForListValueException.php: -------------------------------------------------------------------------------- 1 | value, 24 | gettype($actualValue), 25 | is_array($actualValue) === true ? json_encode($actualValue) : $actualValue, 26 | ), 27 | ); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Exception/JSONException.php: -------------------------------------------------------------------------------- 1 | getMessage(), 33 | ); 34 | } 35 | 36 | return $jsonBody; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/ImageProcessor.php: -------------------------------------------------------------------------------- 1 | $optimization 12 | * @return string 13 | */ 14 | public function generate( 15 | string $url, 16 | array $optimization = [], 17 | ): string { 18 | if (true === empty($optimization)) { 19 | return $url; 20 | } 21 | 22 | foreach ($optimization as $key => $value) { 23 | if (false === is_bool($value)) { 24 | continue; 25 | } 26 | 27 | $optimization[$key] = $value ? 'true' : 'false'; 28 | } 29 | 30 | $query = http_build_query( 31 | data: $optimization, 32 | arg_separator: '&', 33 | encoding_type: PHP_QUERY_RFC3986, 34 | ); 35 | 36 | return sprintf('%s?%s', $url, $query); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/LoggingAPI.php: -------------------------------------------------------------------------------- 1 | client 26 | ->setApiKey($this->apiKey) 27 | ->setBaseUrl(Host::LOGGING_ENDPOINT); 28 | } 29 | 30 | /** 31 | * @throws ClientExceptionInterface 32 | * @throws Exception\BunnyClientResponseException 33 | * @throws Exception\JSONException 34 | * @throws Exception\InvalidTypeForKeyValueException 35 | * @throws Exception\InvalidTypeForListValueException 36 | * @throws Exception\ParameterIsRequiredException 37 | * @param int $pullZoneId 38 | * @param DateTimeInterface $dateTime 39 | * @param array $query 40 | * @return BunnyClientResponseInterface 41 | */ 42 | public function getLog( 43 | int $pullZoneId, 44 | DateTimeInterface $dateTime, 45 | array $query = [], 46 | ): BunnyClientResponseInterface { 47 | $endpoint = new GetLog(); 48 | $dateTimeFormat = $dateTime->format('m-d-y'); 49 | 50 | ParameterValidator::validate($query, $endpoint->getQuery()); 51 | 52 | return $this->client->request( 53 | endpoint: $endpoint, 54 | parameters: [$dateTimeFormat, $pullZoneId], 55 | query: $query, 56 | ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/Model/API/Base/APIKeys/ListAPIKeys.php: -------------------------------------------------------------------------------- 1 | |null $children 16 | */ 17 | public function __construct( 18 | private readonly string|null $name, 19 | private readonly Type $type, 20 | private readonly bool $required = false, 21 | private readonly array|null $children = null, 22 | ) { 23 | } 24 | 25 | public function getName(): string|null 26 | { 27 | return $this->name; 28 | } 29 | 30 | public function getType(): Type 31 | { 32 | return $this->type; 33 | } 34 | 35 | public function isRequired(): bool 36 | { 37 | return $this->required; 38 | } 39 | 40 | /** 41 | * @return array|null 42 | */ 43 | public function getChildren(): array|null 44 | { 45 | return $this->children; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Model/Client/BunnyClientResponse.php: -------------------------------------------------------------------------------- 1 | response; 29 | } 30 | 31 | /** 32 | * @return mixed 33 | */ 34 | public function getContents(): mixed 35 | { 36 | return $this->contents; 37 | } 38 | 39 | /** 40 | * @return StreamInterface 41 | */ 42 | public function getBody(): StreamInterface 43 | { 44 | return $this->response->getBody(); 45 | } 46 | 47 | /** 48 | * @return array> 49 | */ 50 | public function getHeaders(): array 51 | { 52 | return $this->response->getHeaders(); 53 | } 54 | 55 | /** 56 | * @return int 57 | */ 58 | public function getStatusCode(): int 59 | { 60 | return $this->response->getStatusCode(); 61 | } 62 | 63 | /** 64 | * @return string 65 | */ 66 | public function getReasonPhrase(): string 67 | { 68 | return $this->response->getReasonPhrase(); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/Model/Client/Interface/BunnyClientResponseInterface.php: -------------------------------------------------------------------------------- 1 | > 29 | */ 30 | public function getHeaders(): array; 31 | 32 | /** 33 | * @return int 34 | */ 35 | public function getStatusCode(): int; 36 | 37 | /** 38 | * @return string 39 | */ 40 | public function getReasonPhrase(): string; 41 | } 42 | -------------------------------------------------------------------------------- /src/Model/EndpointBodyInterface.php: -------------------------------------------------------------------------------- 1 | 11 | */ 12 | public function getBody(): array; 13 | } 14 | -------------------------------------------------------------------------------- /src/Model/EndpointInterface.php: -------------------------------------------------------------------------------- 1 | > 23 | */ 24 | public function getHeaders(): array; 25 | } 26 | -------------------------------------------------------------------------------- /src/Model/EndpointQueryInterface.php: -------------------------------------------------------------------------------- 1 | 11 | */ 12 | public function getQuery(): array; 13 | } 14 | -------------------------------------------------------------------------------- /src/Model/ParameterInterface.php: -------------------------------------------------------------------------------- 1 |