From 60214daaef37c84c4e656559507ecb73feed9a79 Mon Sep 17 00:00:00 2001 From: SergkeiM Date: Tue, 28 Jul 2026 16:40:04 +0300 Subject: [PATCH] feat: Standardize API client endpoint structure and method naming This commit introduces a significant refactoring of the API client to enhance consistency and improve developer experience. Key changes include: * **Flattened Endpoint Hierarchy**: Many endpoints previously nested under `accounts()` or `zones()` (e.g., `pageRules`, `firewallRules`, `R2` related services, `loadBalancers`, `dns`, `dnssec`) are now accessible directly from the `Client` object, simplifying access and discovery. * **Consistent Method Naming**: * `details()` methods are renamed to `get()`. * `update()` methods for partial resource updates are renamed to `edit()`. * `overwrite()` methods for full resource replacements are renamed to `update()`. * `get()` methods used for listing collections are renamed to `list()`. * **Helper Methods**: Added `scopePath()` to `AbstractEndpoint` for consistent handling of account- or zone-scoped resources, and `jurisdictionHeader()` for R2-specific requests. * Updated documentation, examples, and tests to reflect the new structure and method names. This refactoring aims to make the Cloudflare SDK more intuitive and aligned with common RESTful API client conventions. --- docs/content/1.getting-started/4.laravel.md | 4 +- docs/content/2.api/0.accounts/0.accounts.md | 4 +- docs/content/2.api/0.accounts/1.roles.md | 2 +- .../content/2.api/0.accounts/10.r2-buckets.md | 73 ----- docs/content/2.api/0.accounts/11.r2-cors.md | 45 --- .../2.api/0.accounts/12.r2-lifecycle.md | 38 --- docs/content/2.api/0.accounts/13.r2-lock.md | 39 --- .../2.api/0.accounts/14.r2-custom-domains.md | 62 ---- .../2.api/0.accounts/15.r2-managed-domain.md | 28 -- docs/content/2.api/0.accounts/16.r2-sippy.md | 46 --- .../0.accounts/17.r2-event-notifications.md | 52 --- docs/content/2.api/0.accounts/2.members.md | 2 +- .../2.api/0.accounts/6.load-balancers.md | 100 ------ .../0.accounts/7.load-balancer-monitors.md | 93 ------ .../2.api/0.accounts/8.load-balancer-pools.md | 121 ------- docs/content/2.api/1.zones/0.index.md | 16 +- docs/content/2.api/1.zones/1.dns.md | 101 ------ docs/content/2.api/1.zones/10.filters.md | 63 ---- .../2.api/1.zones/11.firewall-rules.md | 76 ----- docs/content/2.api/1.zones/12.access-rules.md | 56 ---- docs/content/2.api/1.zones/13.rate-limits.md | 78 ----- .../2.api/1.zones/15.load-balancers.md | 74 ----- docs/content/2.api/1.zones/2.dnssec.md | 36 -- docs/content/2.api/1.zones/2.page-rules.md | 95 ------ .../2.api/1.zones/4.cloud-conenctor-rules.md | 29 -- docs/content/2.api/1.zones/5.holds.md | 2 +- docs/content/2.api/1.zones/6.lockdown.md | 52 --- docs/content/2.api/1.zones/7.rulesets.md | 61 ---- docs/content/2.api/1.zones/8.ssl.md | 46 --- .../2.api/1.zones/9.origin-ca-certificates.md | 46 --- docs/content/2.api/10.page-rules.md | 70 ++++ docs/content/2.api/11.lockdown.md | 42 +++ docs/content/2.api/12.ssl.md | 40 +++ .../2.api/13.origin-ca-certificates.md | 36 ++ docs/content/2.api/14.filters.md | 46 +++ docs/content/2.api/15.firewall-rules.md | 53 +++ docs/content/2.api/16.access-rules.md | 41 +++ docs/content/2.api/17.rate-limits.md | 52 +++ ...bot-management.md => 18.bot-management.md} | 14 +- docs/content/2.api/19.cloud-connector.md | 29 ++ docs/content/2.api/2.workers/10.logs.md | 2 +- docs/content/2.api/2.workers/11.routes.md | 4 +- docs/content/2.api/2.workers/3.deployments.md | 2 +- docs/content/2.api/2.workers/4.domains.md | 4 +- docs/content/2.api/2.workers/6.scripts.md | 4 +- docs/content/2.api/2.workers/8.versions.md | 2 +- docs/content/2.api/20.r2/0.index.md | 24 ++ docs/content/2.api/20.r2/1.buckets.md | 61 ++++ docs/content/2.api/20.r2/2.cors.md | 32 ++ docs/content/2.api/20.r2/3.lifecycle.md | 26 ++ docs/content/2.api/20.r2/4.lock.md | 26 ++ docs/content/2.api/20.r2/5.custom-domains.md | 48 +++ docs/content/2.api/20.r2/6.managed-domain.md | 24 ++ docs/content/2.api/20.r2/7.sippy.md | 37 +++ .../2.api/20.r2/8.event-notifications.md | 42 +++ .../18.r2-metrics.md => 20.r2/9.metrics.md} | 6 +- docs/content/2.api/3.d1/index.md | 2 +- docs/content/2.api/4.tunnel/1.routes.md | 4 +- .../2.api/4.tunnel/2.virtual-networks.md | 4 +- .../content/2.api/6.load-balancers/0.index.md | 93 ++++++ .../content/2.api/6.load-balancers/1.pools.md | 105 ++++++ .../2.api/6.load-balancers/2.monitors.md | 79 +++++ .../3.monitor-groups.md} | 34 +- .../4.regions.md} | 14 +- .../2.api/6.load-balancers/5.searches.md | 20 ++ .../2.api/6.load-balancers/6.previews.md | 18 + .../5.rulesets.md => 7.rulesets/0.index.md} | 32 +- docs/content/2.api/7.rulesets/1.rules.md | 22 ++ docs/content/2.api/8.dns.md | 88 +++++ docs/content/2.api/9.dnssec.md | 32 ++ docs/content/4.coverage.md | 308 +++++++++--------- docs/package-lock.json | 19 ++ src/Client.php | 30 ++ src/Endpoints/AbstractEndpoint.php | 32 ++ src/Endpoints/{Zones => }/AccessRules.php | 9 +- src/Endpoints/Accounts.php | 169 +--------- src/Endpoints/Accounts/LoadBalancers.php | 148 --------- src/Endpoints/Accounts/Members.php | 2 +- src/Endpoints/Accounts/Roles.php | 2 +- src/Endpoints/Accounts/Rulesets.php | 76 ----- src/Endpoints/{Zones => }/BotManagement.php | 5 +- src/Endpoints/{Zones => }/CloudConnector.php | 3 +- src/Endpoints/D1.php | 2 +- src/Endpoints/{Zones => }/DNS.php | 17 +- src/Endpoints/{Zones => }/DNSSEC.php | 9 +- src/Endpoints/{Zones => }/Filters.php | 5 +- src/Endpoints/{Zones => }/FirewallRules.php | 5 +- src/Endpoints/LoadBalancers.php | 194 +++++++++++ .../MonitorGroups.php} | 10 +- .../Monitors.php} | 40 +-- .../Pools.php} | 66 ++-- src/Endpoints/LoadBalancers/Previews.php | 24 ++ .../Regions.php} | 6 +- src/Endpoints/LoadBalancers/Searches.php | 24 ++ src/Endpoints/{Zones => }/Lockdown.php | 5 +- .../{Zones => }/OriginCACertificates.php | 5 +- src/Endpoints/{Zones => }/PageRules.php | 11 +- src/Endpoints/R2.php | 106 ++++++ .../R2Buckets.php => R2/Buckets.php} | 24 +- .../{Accounts/R2Cors.php => R2/Cors.php} | 18 +- .../CustomDomains.php} | 18 +- .../EventNotifications.php} | 18 +- .../R2Lifecycle.php => R2/Lifecycle.php} | 18 +- .../{Accounts/R2Lock.php => R2/Lock.php} | 18 +- .../ManagedDomain.php} | 18 +- .../R2Metrics.php => R2/Metrics.php} | 4 +- .../{Accounts/R2Sippy.php => R2/Sippy.php} | 18 +- src/Endpoints/{Zones => }/RateLimits.php | 5 +- src/Endpoints/Rulesets.php | 95 ++++++ src/Endpoints/Rulesets/Rules.php | 33 ++ src/Endpoints/{Zones => }/Ssl.php | 5 +- src/Endpoints/Tunnel/Routes.php | 4 +- src/Endpoints/Tunnel/VirtualNetworks.php | 4 +- src/Endpoints/Workers/Deployments.php | 2 +- src/Endpoints/Workers/Domains.php | 4 +- src/Endpoints/Workers/KV.php | 2 +- src/Endpoints/Workers/Logs.php | 2 +- src/Endpoints/Workers/Routes.php | 4 +- src/Endpoints/Workers/Scripts.php | 2 +- src/Endpoints/Workers/Versions.php | 2 +- src/Endpoints/Zones.php | 187 +---------- src/Endpoints/Zones/Cache.php | 9 - src/Endpoints/Zones/{Hold.php => Holds.php} | 4 +- src/Endpoints/Zones/LoadBalancers.php | 104 ------ src/Endpoints/Zones/Rules.php | 21 -- src/Endpoints/Zones/Rulesets.php | 76 ----- test/Tests/D1Test.php | 2 +- test/Tests/Endpoints/AccessRulesTest.php | 72 ++++ test/Tests/Endpoints/Accounts/MembersTest.php | 2 +- test/Tests/Endpoints/Accounts/RolesTest.php | 2 +- test/Tests/Endpoints/AccountsTest.php | 2 +- test/Tests/Endpoints/BotManagementTest.php | 41 +++ .../{Zones => }/CloudConnectorTest.php | 15 +- .../Endpoints/{Zones => }/DNSSECTest.php | 20 +- test/Tests/Endpoints/{Zones => }/DNSTest.php | 53 ++- test/Tests/Endpoints/FiltersTest.php | 83 +++++ test/Tests/Endpoints/FirewallRulesTest.php | 102 ++++++ .../MonitorGroupsTest.php} | 20 +- .../MonitorsTest.php} | 52 +-- .../PoolsTest.php} | 82 ++--- .../Endpoints/LoadBalancers/PreviewsTest.php | 34 ++ .../RegionsTest.php} | 8 +- .../Endpoints/LoadBalancers/SearchesTest.php | 36 ++ .../{Accounts => }/LoadBalancersTest.php | 117 ++++--- .../Endpoints/{Zones => }/LockdownTest.php | 33 +- .../Endpoints/OriginCACertificatesTest.php | 69 ++++ .../Endpoints/{Zones => }/PageRulesTest.php | 82 +---- .../R2BucketsTest.php => R2/BucketsTest.php} | 20 +- .../R2CorsTest.php => R2/CorsTest.php} | 10 +- .../CustomDomainsTest.php} | 14 +- .../EventNotificationsTest.php} | 12 +- .../LifecycleTest.php} | 8 +- .../R2LockTest.php => R2/LockTest.php} | 8 +- .../ManagedDomainTest.php} | 8 +- .../R2MetricsTest.php => R2/MetricsTest.php} | 6 +- .../R2SippyTest.php => R2/SippyTest.php} | 10 +- test/Tests/Endpoints/RateLimitsTest.php | 93 ++++++ .../{Zones => Rulesets}/RulesTest.php | 7 +- .../Endpoints/{Accounts => }/RulesetsTest.php | 53 ++- test/Tests/Endpoints/SslTest.php | 69 ++++ test/Tests/Endpoints/Tunnel/RoutesTest.php | 4 +- .../Endpoints/Tunnel/VirtualNetworksTest.php | 4 +- .../Endpoints/Workers/DeploymentsTest.php | 2 +- test/Tests/Endpoints/Workers/DomainsTest.php | 4 +- test/Tests/Endpoints/Workers/KVTest.php | 2 +- test/Tests/Endpoints/Workers/LogsTest.php | 2 +- test/Tests/Endpoints/Workers/RoutesTest.php | 4 +- test/Tests/Endpoints/Workers/ScriptsTest.php | 2 +- test/Tests/Endpoints/Workers/VersionsTest.php | 2 +- .../Tests/Endpoints/Zones/AccessRulesTest.php | 105 ------ .../Endpoints/Zones/BotManagementTest.php | 58 ---- test/Tests/Endpoints/Zones/FiltersTest.php | 126 ------- .../Endpoints/Zones/FirewallRulesTest.php | 149 --------- .../Zones/{HoldTest.php => HoldsTest.php} | 4 +- .../Endpoints/Zones/LoadBalancersTest.php | 151 --------- .../Zones/OriginCACertificatesTest.php | 104 ------ test/Tests/Endpoints/Zones/RateLimitsTest.php | 132 -------- test/Tests/Endpoints/Zones/RulesetsTest.php | 126 ------- test/Tests/Endpoints/Zones/SslTest.php | 103 ------ test/Tests/Endpoints/ZonesTest.php | 19 +- test/Tests/HttpClient/HttpClientTest.php | 4 +- 181 files changed, 3021 insertions(+), 4236 deletions(-) delete mode 100644 docs/content/2.api/0.accounts/10.r2-buckets.md delete mode 100644 docs/content/2.api/0.accounts/11.r2-cors.md delete mode 100644 docs/content/2.api/0.accounts/12.r2-lifecycle.md delete mode 100644 docs/content/2.api/0.accounts/13.r2-lock.md delete mode 100644 docs/content/2.api/0.accounts/14.r2-custom-domains.md delete mode 100644 docs/content/2.api/0.accounts/15.r2-managed-domain.md delete mode 100644 docs/content/2.api/0.accounts/16.r2-sippy.md delete mode 100644 docs/content/2.api/0.accounts/17.r2-event-notifications.md delete mode 100644 docs/content/2.api/0.accounts/6.load-balancers.md delete mode 100644 docs/content/2.api/0.accounts/7.load-balancer-monitors.md delete mode 100644 docs/content/2.api/0.accounts/8.load-balancer-pools.md delete mode 100644 docs/content/2.api/1.zones/1.dns.md delete mode 100644 docs/content/2.api/1.zones/10.filters.md delete mode 100644 docs/content/2.api/1.zones/11.firewall-rules.md delete mode 100644 docs/content/2.api/1.zones/12.access-rules.md delete mode 100644 docs/content/2.api/1.zones/13.rate-limits.md delete mode 100644 docs/content/2.api/1.zones/15.load-balancers.md delete mode 100644 docs/content/2.api/1.zones/2.dnssec.md delete mode 100644 docs/content/2.api/1.zones/2.page-rules.md delete mode 100644 docs/content/2.api/1.zones/4.cloud-conenctor-rules.md delete mode 100644 docs/content/2.api/1.zones/6.lockdown.md delete mode 100644 docs/content/2.api/1.zones/7.rulesets.md delete mode 100644 docs/content/2.api/1.zones/8.ssl.md delete mode 100644 docs/content/2.api/1.zones/9.origin-ca-certificates.md create mode 100644 docs/content/2.api/10.page-rules.md create mode 100644 docs/content/2.api/11.lockdown.md create mode 100644 docs/content/2.api/12.ssl.md create mode 100644 docs/content/2.api/13.origin-ca-certificates.md create mode 100644 docs/content/2.api/14.filters.md create mode 100644 docs/content/2.api/15.firewall-rules.md create mode 100644 docs/content/2.api/16.access-rules.md create mode 100644 docs/content/2.api/17.rate-limits.md rename docs/content/2.api/{1.zones/14.bot-management.md => 18.bot-management.md} (61%) create mode 100644 docs/content/2.api/19.cloud-connector.md create mode 100644 docs/content/2.api/20.r2/0.index.md create mode 100644 docs/content/2.api/20.r2/1.buckets.md create mode 100644 docs/content/2.api/20.r2/2.cors.md create mode 100644 docs/content/2.api/20.r2/3.lifecycle.md create mode 100644 docs/content/2.api/20.r2/4.lock.md create mode 100644 docs/content/2.api/20.r2/5.custom-domains.md create mode 100644 docs/content/2.api/20.r2/6.managed-domain.md create mode 100644 docs/content/2.api/20.r2/7.sippy.md create mode 100644 docs/content/2.api/20.r2/8.event-notifications.md rename docs/content/2.api/{0.accounts/18.r2-metrics.md => 20.r2/9.metrics.md} (71%) create mode 100644 docs/content/2.api/6.load-balancers/0.index.md create mode 100644 docs/content/2.api/6.load-balancers/1.pools.md create mode 100644 docs/content/2.api/6.load-balancers/2.monitors.md rename docs/content/2.api/{0.accounts/19.load-balancer-monitor-groups.md => 6.load-balancers/3.monitor-groups.md} (51%) rename docs/content/2.api/{0.accounts/9.load-balancer-regions.md => 6.load-balancers/4.regions.md} (56%) create mode 100644 docs/content/2.api/6.load-balancers/5.searches.md create mode 100644 docs/content/2.api/6.load-balancers/6.previews.md rename docs/content/2.api/{0.accounts/5.rulesets.md => 7.rulesets/0.index.md} (58%) create mode 100644 docs/content/2.api/7.rulesets/1.rules.md create mode 100644 docs/content/2.api/8.dns.md create mode 100644 docs/content/2.api/9.dnssec.md rename src/Endpoints/{Zones => }/AccessRules.php (89%) delete mode 100644 src/Endpoints/Accounts/LoadBalancers.php delete mode 100644 src/Endpoints/Accounts/Rulesets.php rename src/Endpoints/{Zones => }/BotManagement.php (88%) rename src/Endpoints/{Zones => }/CloudConnector.php (92%) rename src/Endpoints/{Zones => }/DNS.php (93%) rename src/Endpoints/{Zones => }/DNSSEC.php (86%) rename src/Endpoints/{Zones => }/Filters.php (94%) rename src/Endpoints/{Zones => }/FirewallRules.php (95%) create mode 100644 src/Endpoints/LoadBalancers.php rename src/Endpoints/{Accounts/LoadBalancerMonitorGroups.php => LoadBalancers/MonitorGroups.php} (93%) rename src/Endpoints/{Accounts/LoadBalancerMonitors.php => LoadBalancers/Monitors.php} (92%) rename src/Endpoints/{Accounts/LoadBalancerPools.php => LoadBalancers/Pools.php} (93%) create mode 100644 src/Endpoints/LoadBalancers/Previews.php rename src/Endpoints/{Accounts/LoadBalancerRegions.php => LoadBalancers/Regions.php} (85%) create mode 100644 src/Endpoints/LoadBalancers/Searches.php rename src/Endpoints/{Zones => }/Lockdown.php (96%) rename src/Endpoints/{Zones => }/OriginCACertificates.php (94%) rename src/Endpoints/{Zones => }/PageRules.php (90%) create mode 100644 src/Endpoints/R2.php rename src/Endpoints/{Accounts/R2Buckets.php => R2/Buckets.php} (84%) rename src/Endpoints/{Accounts/R2Cors.php => R2/Cors.php} (81%) rename src/Endpoints/{Accounts/R2CustomDomains.php => R2/CustomDomains.php} (88%) rename src/Endpoints/{Accounts/R2EventNotifications.php => R2/EventNotifications.php} (86%) rename src/Endpoints/{Accounts/R2Lifecycle.php => R2/Lifecycle.php} (75%) rename src/Endpoints/{Accounts/R2Lock.php => R2/Lock.php} (75%) rename src/Endpoints/{Accounts/R2ManagedDomain.php => R2/ManagedDomain.php} (75%) rename src/Endpoints/{Accounts/R2Metrics.php => R2/Metrics.php} (88%) rename src/Endpoints/{Accounts/R2Sippy.php => R2/Sippy.php} (81%) rename src/Endpoints/{Zones => }/RateLimits.php (94%) create mode 100644 src/Endpoints/Rulesets.php create mode 100644 src/Endpoints/Rulesets/Rules.php rename src/Endpoints/{Zones => }/Ssl.php (93%) delete mode 100644 src/Endpoints/Zones/Cache.php rename src/Endpoints/Zones/{Hold.php => Holds.php} (96%) delete mode 100644 src/Endpoints/Zones/LoadBalancers.php delete mode 100644 src/Endpoints/Zones/Rules.php delete mode 100644 src/Endpoints/Zones/Rulesets.php create mode 100644 test/Tests/Endpoints/AccessRulesTest.php create mode 100644 test/Tests/Endpoints/BotManagementTest.php rename test/Tests/Endpoints/{Zones => }/CloudConnectorTest.php (75%) rename test/Tests/Endpoints/{Zones => }/DNSSECTest.php (70%) rename test/Tests/Endpoints/{Zones => }/DNSTest.php (77%) create mode 100644 test/Tests/Endpoints/FiltersTest.php create mode 100644 test/Tests/Endpoints/FirewallRulesTest.php rename test/Tests/Endpoints/{Accounts/LoadBalancerMonitorGroupsTest.php => LoadBalancers/MonitorGroupsTest.php} (86%) rename test/Tests/Endpoints/{Accounts/LoadBalancerMonitorsTest.php => LoadBalancers/MonitorsTest.php} (86%) rename test/Tests/Endpoints/{Accounts/LoadBalancerPoolsTest.php => LoadBalancers/PoolsTest.php} (86%) create mode 100644 test/Tests/Endpoints/LoadBalancers/PreviewsTest.php rename test/Tests/Endpoints/{Accounts/LoadBalancerRegionsTest.php => LoadBalancers/RegionsTest.php} (84%) create mode 100644 test/Tests/Endpoints/LoadBalancers/SearchesTest.php rename test/Tests/Endpoints/{Accounts => }/LoadBalancersTest.php (66%) rename test/Tests/Endpoints/{Zones => }/LockdownTest.php (66%) create mode 100644 test/Tests/Endpoints/OriginCACertificatesTest.php rename test/Tests/Endpoints/{Zones => }/PageRulesTest.php (56%) rename test/Tests/Endpoints/{Accounts/R2BucketsTest.php => R2/BucketsTest.php} (86%) rename test/Tests/Endpoints/{Accounts/R2CorsTest.php => R2/CorsTest.php} (87%) rename test/Tests/Endpoints/{Accounts/R2CustomDomainsTest.php => R2/CustomDomainsTest.php} (85%) rename test/Tests/Endpoints/{Accounts/R2EventNotificationsTest.php => R2/EventNotificationsTest.php} (84%) rename test/Tests/Endpoints/{Accounts/R2LifecycleTest.php => R2/LifecycleTest.php} (86%) rename test/Tests/Endpoints/{Accounts/R2LockTest.php => R2/LockTest.php} (87%) rename test/Tests/Endpoints/{Accounts/R2ManagedDomainTest.php => R2/ManagedDomainTest.php} (84%) rename test/Tests/Endpoints/{Accounts/R2MetricsTest.php => R2/MetricsTest.php} (83%) rename test/Tests/Endpoints/{Accounts/R2SippyTest.php => R2/SippyTest.php} (85%) create mode 100644 test/Tests/Endpoints/RateLimitsTest.php rename test/Tests/Endpoints/{Zones => Rulesets}/RulesTest.php (77%) rename test/Tests/Endpoints/{Accounts => }/RulesetsTest.php (65%) create mode 100644 test/Tests/Endpoints/SslTest.php delete mode 100644 test/Tests/Endpoints/Zones/AccessRulesTest.php delete mode 100644 test/Tests/Endpoints/Zones/BotManagementTest.php delete mode 100644 test/Tests/Endpoints/Zones/FiltersTest.php delete mode 100644 test/Tests/Endpoints/Zones/FirewallRulesTest.php rename test/Tests/Endpoints/Zones/{HoldTest.php => HoldsTest.php} (96%) delete mode 100644 test/Tests/Endpoints/Zones/LoadBalancersTest.php delete mode 100644 test/Tests/Endpoints/Zones/OriginCACertificatesTest.php delete mode 100644 test/Tests/Endpoints/Zones/RateLimitsTest.php delete mode 100644 test/Tests/Endpoints/Zones/RulesetsTest.php delete mode 100644 test/Tests/Endpoints/Zones/SslTest.php diff --git a/docs/content/1.getting-started/4.laravel.md b/docs/content/1.getting-started/4.laravel.md index c7b5c8b..8f7c35d 100644 --- a/docs/content/1.getting-started/4.laravel.md +++ b/docs/content/1.getting-started/4.laravel.md @@ -48,7 +48,7 @@ Cloudflare::accounts()->list(); // or -Cloudflare::accounts()->details('ACCOUNT_ID'); +Cloudflare::accounts()->get('ACCOUNT_ID'); ``` If you prefer to use dependency injection over facades, then you can easily inject the manager like so: @@ -67,7 +67,7 @@ class Foo public function bar() { - $this->cloudflare->accounts()->details('ACCOUNT_ID'); + $this->cloudflare->accounts()->get('ACCOUNT_ID'); } } diff --git a/docs/content/2.api/0.accounts/0.accounts.md b/docs/content/2.api/0.accounts/0.accounts.md index 64e4107..3b9b18b 100644 --- a/docs/content/2.api/0.accounts/0.accounts.md +++ b/docs/content/2.api/0.accounts/0.accounts.md @@ -25,12 +25,12 @@ Create an account. $response = $client->accounts()->create('Name', 'standard', 'f267e341f3dd4697bd3b9f71dd96247f'); ``` -## Details +## Get Get information about a specific account that you are a member of. ```php [php] -$response = $client->accounts()->details('ACCOUNT_ID'); +$response = $client->accounts()->get('ACCOUNT_ID'); ``` ## Update diff --git a/docs/content/2.api/0.accounts/1.roles.md b/docs/content/2.api/0.accounts/1.roles.md index 4001965..ba20c7f 100644 --- a/docs/content/2.api/0.accounts/1.roles.md +++ b/docs/content/2.api/0.accounts/1.roles.md @@ -22,5 +22,5 @@ $response = $client->accounts()->roles()->list('ACCOUNT_ID'); Get information about a specific role for an account. ```php [php] -$response = $client->accounts()->roles()->details('ACCOUNT_ID', 'ROLE_ID'); +$response = $client->accounts()->roles()->get('ACCOUNT_ID', 'ROLE_ID'); ``` \ No newline at end of file diff --git a/docs/content/2.api/0.accounts/10.r2-buckets.md b/docs/content/2.api/0.accounts/10.r2-buckets.md deleted file mode 100644 index 799d1b0..0000000 --- a/docs/content/2.api/0.accounts/10.r2-buckets.md +++ /dev/null @@ -1,73 +0,0 @@ ---- -title: R2 Buckets -description: Manage R2 storage buckets for an account. -navigation: - title: R2 Buckets ---- - -# R2 Buckets - -Manage R2 storage buckets for an account. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/r2-list-buckets" blank} - -## List - -Returns a list of buckets for an account. - -```php [php] -$response = $client->accounts()->r2Buckets()->list('account_id'); -``` - -## Create - -Creates a new bucket for an account. - -```php [php] -$values = [ - 'name' => 'my-bucket', -]; - -$response = $client->accounts()->r2Buckets()->create('account_id', $values); -``` - -## Details - -Get a bucket's details. - -```php [php] -$response = $client->accounts()->r2Buckets()->details('account_id', 'my-bucket'); -``` - -## Update - -Update the storage class of an existing bucket. - -```php [php] -$response = $client->accounts()->r2Buckets()->update('account_id', 'my-bucket', 'InfrequentAccess'); -``` - -## Delete - -Deletes an existing bucket. - -```php [php] -$response = $client->accounts()->r2Buckets()->delete('account_id', 'my-bucket'); -``` - -## Create Temporary Access Credentials - -Creates temporary access credentials scoped to a specific bucket. - -```php [php] -$values = [ - 'bucket' => 'my-bucket', - 'permission' => 'object-read-only', - 'ttlSeconds' => 3600, - 'parentAccessKeyId' => 'parent_access_key_id', -]; - -$response = $client->accounts()->r2Buckets()->createTemporaryCredentials('account_id', $values); -``` - -All bucket-scoped methods accept an optional trailing `$jurisdiction` argument (e.g. `'eu'`) which is sent as the `cf-r2-jurisdiction` header. diff --git a/docs/content/2.api/0.accounts/11.r2-cors.md b/docs/content/2.api/0.accounts/11.r2-cors.md deleted file mode 100644 index 8debee0..0000000 --- a/docs/content/2.api/0.accounts/11.r2-cors.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -title: R2 Bucket CORS -description: Manage the CORS (Cross-Origin Resource Sharing) configuration for an R2 bucket. -navigation: - title: R2 Bucket CORS ---- - -# R2 Bucket CORS - -Manage the CORS (Cross-Origin Resource Sharing) configuration for an R2 bucket. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/r2-get-bucket-cors-policy" blank} - -## Details - -Get the CORS configuration for a bucket. - -```php [php] -$response = $client->accounts()->r2Cors()->details('account_id', 'my-bucket'); -``` - -## Update - -Set the CORS configuration for a bucket. - -```php [php] -$rules = [ - [ - 'allowed' => [ - 'methods' => ['GET'], - 'origins' => ['*'], - ], - ], -]; - -$response = $client->accounts()->r2Cors()->update('account_id', 'my-bucket', $rules); -``` - -## Delete - -Delete the CORS configuration for a bucket. - -```php [php] -$response = $client->accounts()->r2Cors()->delete('account_id', 'my-bucket'); -``` diff --git a/docs/content/2.api/0.accounts/12.r2-lifecycle.md b/docs/content/2.api/0.accounts/12.r2-lifecycle.md deleted file mode 100644 index 2cb70e0..0000000 --- a/docs/content/2.api/0.accounts/12.r2-lifecycle.md +++ /dev/null @@ -1,38 +0,0 @@ ---- -title: R2 Bucket Lifecycle -description: Manage lifecycle rules that automatically transition or expire objects in an R2 bucket. -navigation: - title: R2 Bucket Lifecycle ---- - -# R2 Bucket Lifecycle - -Manage lifecycle rules that automatically transition or expire objects in an R2 bucket. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/r2-get-bucket-lifecycle-configuration" blank} - -## Details - -Get the lifecycle configuration for a bucket. - -```php [php] -$response = $client->accounts()->r2Lifecycle()->details('account_id', 'my-bucket'); -``` - -## Update - -Set the lifecycle configuration for a bucket. - -```php [php] -$rules = [ - [ - 'id' => 'expire-old-objects', - 'conditions' => [ - 'maxAge' => 86400, - ], - 'enabled' => true, - ], -]; - -$response = $client->accounts()->r2Lifecycle()->update('account_id', 'my-bucket', $rules); -``` diff --git a/docs/content/2.api/0.accounts/13.r2-lock.md b/docs/content/2.api/0.accounts/13.r2-lock.md deleted file mode 100644 index 681de4a..0000000 --- a/docs/content/2.api/0.accounts/13.r2-lock.md +++ /dev/null @@ -1,39 +0,0 @@ ---- -title: R2 Bucket Object Lock -description: Manage object lock (retention) rules for an R2 bucket. -navigation: - title: R2 Bucket Object Lock ---- - -# R2 Bucket Object Lock - -Manage object lock (retention) rules for an R2 bucket. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/r2-get-bucket-lock-configuration" blank} - -## Details - -Get the object lock configuration for a bucket. - -```php [php] -$response = $client->accounts()->r2Lock()->details('account_id', 'my-bucket'); -``` - -## Update - -Set the object lock configuration for a bucket. - -```php [php] -$rules = [ - [ - 'id' => 'retain-30-days', - 'condition' => [ - 'type' => 'Age', - 'maxAgeSeconds' => 2592000, - ], - 'enabled' => true, - ], -]; - -$response = $client->accounts()->r2Lock()->update('account_id', 'my-bucket', $rules); -``` diff --git a/docs/content/2.api/0.accounts/14.r2-custom-domains.md b/docs/content/2.api/0.accounts/14.r2-custom-domains.md deleted file mode 100644 index 7aaff0d..0000000 --- a/docs/content/2.api/0.accounts/14.r2-custom-domains.md +++ /dev/null @@ -1,62 +0,0 @@ ---- -title: R2 Bucket Custom Domains -description: Manage custom domains connected to an R2 bucket. -navigation: - title: R2 Bucket Custom Domains ---- - -# R2 Bucket Custom Domains - -Manage custom domains connected to an R2 bucket. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/r2-list-bucket-domains" blank} - -## List - -List custom domains for a bucket. - -```php [php] -$response = $client->accounts()->r2CustomDomains()->list('account_id', 'my-bucket'); -``` - -## Create - -Add a custom domain to a bucket. - -```php [php] -$values = [ - 'domain' => 'assets.example.com', - 'zoneId' => 'zone_id', - 'enabled' => true, -]; - -$response = $client->accounts()->r2CustomDomains()->create('account_id', 'my-bucket', $values); -``` - -## Details - -Get an existing custom domain for a bucket. - -```php [php] -$response = $client->accounts()->r2CustomDomains()->details('account_id', 'my-bucket', 'assets.example.com'); -``` - -## Update - -Update an existing custom domain for a bucket. - -```php [php] -$values = [ - 'enabled' => false, -]; - -$response = $client->accounts()->r2CustomDomains()->update('account_id', 'my-bucket', 'assets.example.com', $values); -``` - -## Delete - -Remove a custom domain from a bucket. - -```php [php] -$response = $client->accounts()->r2CustomDomains()->delete('account_id', 'my-bucket', 'assets.example.com'); -``` diff --git a/docs/content/2.api/0.accounts/15.r2-managed-domain.md b/docs/content/2.api/0.accounts/15.r2-managed-domain.md deleted file mode 100644 index d48a707..0000000 --- a/docs/content/2.api/0.accounts/15.r2-managed-domain.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: R2 Bucket Managed Domain -description: Manage the Cloudflare-provided (r2.dev) managed domain for an R2 bucket. -navigation: - title: R2 Bucket Managed Domain ---- - -# R2 Bucket Managed Domain - -Manage the Cloudflare-provided (`r2.dev`) managed domain for an R2 bucket. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/r2-get-bucket-managed-domain" blank} - -## Details - -Get the managed domain configuration for a bucket. - -```php [php] -$response = $client->accounts()->r2ManagedDomain()->details('account_id', 'my-bucket'); -``` - -## Update - -Enable or disable the managed domain for a bucket. - -```php [php] -$response = $client->accounts()->r2ManagedDomain()->update('account_id', 'my-bucket', true); -``` diff --git a/docs/content/2.api/0.accounts/16.r2-sippy.md b/docs/content/2.api/0.accounts/16.r2-sippy.md deleted file mode 100644 index 8ca19f6..0000000 --- a/docs/content/2.api/0.accounts/16.r2-sippy.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: R2 Bucket Sippy -description: Manage Sippy, incremental migration of objects from another cloud provider into an R2 bucket on read. -navigation: - title: R2 Bucket Sippy ---- - -# R2 Bucket Sippy - -Manage Sippy, incremental migration of objects from another cloud provider into an R2 bucket on read. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/r2-get-bucket-sippy-configuration" blank} - -## Details - -Get the Sippy configuration for a bucket. - -```php [php] -$response = $client->accounts()->r2Sippy()->details('account_id', 'my-bucket'); -``` - -## Update (Enable) - -Enable Sippy for a bucket. - -```php [php] -$values = [ - 'source' => [ - 'provider' => 'aws', - 'bucket' => 'source-bucket', - ], - 'destination' => [ - 'provider' => 'r2', - ], -]; - -$response = $client->accounts()->r2Sippy()->update('account_id', 'my-bucket', $values); -``` - -## Delete (Disable) - -Disable Sippy for a bucket. - -```php [php] -$response = $client->accounts()->r2Sippy()->delete('account_id', 'my-bucket'); -``` diff --git a/docs/content/2.api/0.accounts/17.r2-event-notifications.md b/docs/content/2.api/0.accounts/17.r2-event-notifications.md deleted file mode 100644 index 068987a..0000000 --- a/docs/content/2.api/0.accounts/17.r2-event-notifications.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -title: R2 Event Notifications -description: Manage event notification configurations that publish R2 bucket events to a queue. -navigation: - title: R2 Event Notifications ---- - -# R2 Event Notifications - -Manage event notification configurations that publish R2 bucket events to a queue. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/r2-event-notifications-get-configuration" blank} - -## Read Configuration - -Read the event notification configuration for a bucket, listing rules for all configured queues. - -```php [php] -$response = $client->accounts()->r2EventNotifications()->list('account_id', 'my-bucket'); -``` - -## Get Queue Configuration - -Get the event notification configuration for a bucket and a specific queue. - -```php [php] -$response = $client->accounts()->r2EventNotifications()->details('account_id', 'my-bucket', 'queue_id'); -``` - -## Create/Update Configuration - -Create or update the event notification configuration for a bucket and a specific queue. - -```php [php] -$values = [ - 'rules' => [ - [ - 'actions' => ['PutObject', 'DeleteObject'], - ], - ], -]; - -$response = $client->accounts()->r2EventNotifications()->update('account_id', 'my-bucket', 'queue_id', $values); -``` - -## Delete Configuration - -Delete the event notification configuration for a bucket and a specific queue. - -```php [php] -$response = $client->accounts()->r2EventNotifications()->delete('account_id', 'my-bucket', 'queue_id'); -``` diff --git a/docs/content/2.api/0.accounts/2.members.md b/docs/content/2.api/0.accounts/2.members.md index 98b67c6..c5d93c1 100644 --- a/docs/content/2.api/0.accounts/2.members.md +++ b/docs/content/2.api/0.accounts/2.members.md @@ -35,7 +35,7 @@ $response = $client->accounts()->members()->add('ACCOUNT_ID', $values); Get informationabout a specific member of an account. ```php [php] -$response = $client->accounts()->members()->details('ACCOUNT_ID', 'MEMBER_ID'); +$response = $client->accounts()->members()->get('ACCOUNT_ID', 'MEMBER_ID'); ``` ## Update diff --git a/docs/content/2.api/0.accounts/6.load-balancers.md b/docs/content/2.api/0.accounts/6.load-balancers.md deleted file mode 100644 index c6c5d1c..0000000 --- a/docs/content/2.api/0.accounts/6.load-balancers.md +++ /dev/null @@ -1,100 +0,0 @@ ---- -title: Load Balancers -description: Manage load balancers configured for an account. -navigation: - title: Load Balancers ---- - -# Load Balancers - -Manage load balancers configured for an account. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/account-level-load-balancers-list-load-balancers" blank} - -## List - -List configured load balancers for an account. - -```php [php] -$response = $client->accounts()->loadBalancers()->list('account_id'); -``` - -## Create - -Create a new load balancer for an account. - -```php [php] -$values = [ - 'name' => 'www.example.com', - 'default_pools' => ['pool_id'], - 'fallback_pool' => 'pool_id', -]; - -$response = $client->accounts()->loadBalancers()->create('account_id', $values); -``` - -## Details - -Get a single configured load balancer for an account. - -```php [php] -$response = $client->accounts()->loadBalancers()->details('account_id', 'load_balancer_id'); -``` - -## Update - -Update an existing load balancer for an account. - -```php [php] -$values = [ - 'name' => 'www.example.com', - 'default_pools' => ['pool_id'], - 'fallback_pool' => 'pool_id', -]; - -$response = $client->accounts()->loadBalancers()->update('account_id', 'load_balancer_id', $values); -``` - -## Delete - -Delete a load balancer for an account. - -```php [php] -$response = $client->accounts()->loadBalancers()->delete('account_id', 'load_balancer_id'); -``` - -## Patch - -Apply changes to an existing load balancer, overwriting only the supplied properties. - -```php [php] -$response = $client->accounts()->loadBalancers()->patch('account_id', 'load_balancer_id', [ - 'enabled' => false, -]); -``` - -## Usage - -Fetch the current load balancer usage for an account. - -```php [php] -$response = $client->accounts()->loadBalancers()->usage('account_id'); -``` - -## Search - -Search load balancing resources (Load Balancers, Pools, Monitors) by name. - -```php [php] -$response = $client->accounts()->loadBalancers()->search('account_id', [ - 'query' => 'www.example.com', -]); -``` - -## Preview Result - -Get the result of a previously requested monitor or pool preview. - -```php [php] -$response = $client->accounts()->loadBalancers()->previewResult('account_id', 'preview_id'); -``` diff --git a/docs/content/2.api/0.accounts/7.load-balancer-monitors.md b/docs/content/2.api/0.accounts/7.load-balancer-monitors.md deleted file mode 100644 index 95d2751..0000000 --- a/docs/content/2.api/0.accounts/7.load-balancer-monitors.md +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: Load Balancer Monitors -description: Manage health check monitors used to determine the health of load balancer pool origins. -navigation: - title: Load Balancer Monitors ---- - -# Load Balancer Monitors - -Manage health check monitors used to determine the health of load balancer pool origins. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/load-balancer-monitors-list-monitors" blank} - -## List - -List configured load balancer monitors for an account. - -```php [php] -$response = $client->accounts()->loadBalancerMonitors()->list('account_id'); -``` - -## Create - -Create a new load balancer monitor for an account. - -```php [php] -$values = [ - 'type' => 'http', - 'method' => 'GET', - 'path' => '/health', -]; - -$response = $client->accounts()->loadBalancerMonitors()->create('account_id', $values); -``` - -## Details - -Get a single configured load balancer monitor for an account. - -```php [php] -$response = $client->accounts()->loadBalancerMonitors()->details('account_id', 'monitor_id'); -``` - -## Update - -Update an existing load balancer monitor for an account. - -```php [php] -$values = [ - 'type' => 'http', - 'method' => 'POST', -]; - -$response = $client->accounts()->loadBalancerMonitors()->update('account_id', 'monitor_id', $values); -``` - -## Delete - -Delete a load balancer monitor for an account. - -```php [php] -$response = $client->accounts()->loadBalancerMonitors()->delete('account_id', 'monitor_id'); -``` - -## Preview - -Preview pools associated with a given monitor and show the effective response. - -```php [php] -$values = [ - 'pools' => ['pool_id'], -]; - -$response = $client->accounts()->loadBalancerMonitors()->preview('account_id', 'monitor_id', $values); -``` - -## Patch - -Apply changes to an existing monitor, overwriting only the supplied properties. - -```php [php] -$response = $client->accounts()->loadBalancerMonitors()->patch('account_id', 'monitor_id', [ - 'method' => 'POST', -]); -``` - -## References - -List the load balancers and pools that reference a given monitor. - -```php [php] -$response = $client->accounts()->loadBalancerMonitors()->references('account_id', 'monitor_id'); -``` diff --git a/docs/content/2.api/0.accounts/8.load-balancer-pools.md b/docs/content/2.api/0.accounts/8.load-balancer-pools.md deleted file mode 100644 index e5901c2..0000000 --- a/docs/content/2.api/0.accounts/8.load-balancer-pools.md +++ /dev/null @@ -1,121 +0,0 @@ ---- -title: Load Balancer Pools -description: Manage groups of origins that load balancers distribute traffic across. -navigation: - title: Load Balancer Pools ---- - -# Load Balancer Pools - -Manage groups of origins that load balancers distribute traffic across. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/load-balancer-pools-list-pools" blank} - -## List - -List configured load balancer pools for an account. - -```php [php] -$response = $client->accounts()->loadBalancerPools()->list('account_id'); -``` - -## Create - -Create a new load balancer pool for an account. - -```php [php] -$values = [ - 'name' => 'primary-pool', - 'origins' => [ - [ - 'name' => 'origin-1', - 'address' => '192.0.2.1', - ], - ], -]; - -$response = $client->accounts()->loadBalancerPools()->create('account_id', $values); -``` - -## Details - -Get a single configured load balancer pool for an account. - -```php [php] -$response = $client->accounts()->loadBalancerPools()->details('account_id', 'pool_id'); -``` - -## Update - -Update an existing load balancer pool for an account. - -```php [php] -$values = [ - 'name' => 'primary-pool', - 'origins' => [ - [ - 'name' => 'origin-1', - 'address' => '192.0.2.1', - ], - ], - 'enabled' => false, -]; - -$response = $client->accounts()->loadBalancerPools()->update('account_id', 'pool_id', $values); -``` - -## Delete - -Delete a load balancer pool for an account. - -```php [php] -$response = $client->accounts()->loadBalancerPools()->delete('account_id', 'pool_id'); -``` - -## Health - -Fetch the latest pool health status for a single pool. - -```php [php] -$response = $client->accounts()->loadBalancerPools()->health('account_id', 'pool_id'); -``` - -## Preview - -Preview pool health using the specified monitor and show the effective response. - -```php [php] -$values = [ - 'monitor' => 'monitor_id', -]; - -$response = $client->accounts()->loadBalancerPools()->preview('account_id', 'pool_id', $values); -``` - -## Patch - -Apply changes to an existing pool, overwriting only the supplied properties. - -```php [php] -$response = $client->accounts()->loadBalancerPools()->patch('account_id', 'pool_id', [ - 'enabled' => false, -]); -``` - -## Patch Multiple Pools - -Apply changes to a number of existing pools, overwriting the supplied properties. Returns the list of affected pools. - -```php [php] -$response = $client->accounts()->loadBalancerPools()->patchMultiplePools('account_id', [ - ['id' => 'pool_id', 'enabled' => false], -]); -``` - -## References - -List the load balancers that reference a given pool. - -```php [php] -$response = $client->accounts()->loadBalancerPools()->references('account_id', 'pool_id'); -``` diff --git a/docs/content/2.api/1.zones/0.index.md b/docs/content/2.api/1.zones/0.index.md index cec670b..3ef0783 100644 --- a/docs/content/2.api/1.zones/0.index.md +++ b/docs/content/2.api/1.zones/0.index.md @@ -29,12 +29,12 @@ $values = [ $response = $client->zones()->create('ACCOUNT_ID', $values); ``` -## Details +## Get Get Zone Details. ```php [php] -$response = $client->zones()->details('ZONE_ID'); +$response = $client->zones()->get('ZONE_ID'); ``` ## Edit @@ -42,11 +42,7 @@ $response = $client->zones()->details('ZONE_ID'); Edit Zone. ```php [php] -$values = [ - 'plan' => 'free' -]; - -$response = $client->zones()->update('ZONE_ID'); +$response = $client->zones()->edit('ZONE_ID', 'full'); ``` ## Activation Check @@ -92,4 +88,8 @@ Delete Zone. ```php [php] $response = $client->zones()->delete('ZONE_ID'); -``` \ No newline at end of file +``` + +## Sub-resources + +- [Holds](/api/zones/holds) \ No newline at end of file diff --git a/docs/content/2.api/1.zones/1.dns.md b/docs/content/2.api/1.zones/1.dns.md deleted file mode 100644 index f7f3e05..0000000 --- a/docs/content/2.api/1.zones/1.dns.md +++ /dev/null @@ -1,101 +0,0 @@ ---- -title: DNS Records -description: View, create, update your zones DNS Records on Cloudflare. ---- - -# DNS Records - -View, create, update your zones DNS Records on Cloudflare. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/dns-records-for-a-zone-list-dns-records" blank} - -## Scan - -Scan DNS record. Scan for common DNS records on your domain and automatically add them to your zone. Useful if you haven't updated your nameservers yet. - -```php [php] -$response = $client->zones()->dns()->scan('zone_id'); -``` - -## List - -List, search, sort, and filter a zones' DNS record. - -```php [php] -$response = $client->zones()->dns()->list('zone_id'); -``` - -## Create - -Create a new DNS record for a zone. - -```php [php] -$response = $client->zones()->dns()->create('zone_id', [ - 'name' => '@' - 'content' => '127.0.0.1', - 'proxied' => true, - 'type' => 'A' -]); -``` - -## Export - -Export DNS record as [BIND config](https://en.wikipedia.org/wiki/Zone_file). - -```php [php] -$response = $client->zones()->dns()->export('zone_id'); - -file_put_contents('./test.txt', $response->body()); -``` - -## Import - -Import DNS record as [BIND config](https://en.wikipedia.org/wiki/Zone_file). - -```php [php] -$contents = file_put_contents('./test.txt'); - -$response = $client->zones()->dns()->import('zone_id', $contents); -``` - -## Details - -DNS record Details. - -```php [php] -$response = $client->zones()->dns()->details('zone_id', 'dns_record_id'); -``` - -## Update - -Update an existing DNS record. - -```php [php] -$response = $client->zones()->dns()->update('zone_id', 'dns_record_id', [ - 'name' => '@' - 'content' => '127.0.0.1', - 'proxied' => true, - 'type' => 'A' -]); -``` - -## Overwrite - -Overwrite an existing DNS record. - -```php [php] -$response = $client->zones()->dns()->overwrite('zone_id', 'dns_record_id', [ - 'name' => '@' - 'content' => '127.0.0.1', - 'proxied' => true, - 'type' => 'A' -]); -``` - -## Delete - -Delete DNS record. - -```php [php] -$response = $client->zones()->dns()->delete('zone_id', 'dns_record_id'); -``` \ No newline at end of file diff --git a/docs/content/2.api/1.zones/10.filters.md b/docs/content/2.api/1.zones/10.filters.md deleted file mode 100644 index 870697d..0000000 --- a/docs/content/2.api/1.zones/10.filters.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -title: Filters -description: Filters are reusable rule-matching expressions used by Firewall Rules, Rate Limiting, and other zone security products. -navigation: - title: Filters ---- - -# Filters - -Filters are reusable rule-matching expressions used by Firewall Rules, Rate Limiting, and other zone security products. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/filters-list-filters" blank} - -## List - -List all filters for a zone. - -```php [php] -$response = $client->zones()->filters()->list('zone_id'); -``` - -## Details - -Get a single filter. - -```php [php] -$response = $client->zones()->filters()->details('zone_id', 'filter_id'); -``` - -## Create - -Create one or more filters for a zone. - -```php [php] -$values = [ - [ - 'expression' => 'ip.src eq 127.0.0.1', - ], -]; - -$response = $client->zones()->filters()->create('zone_id', $values); -``` - -## Update - -Update an existing filter for a zone. - -```php [php] -$values = [ - 'expression' => 'ip.src eq 127.0.0.1', - 'paused' => true, -]; - -$response = $client->zones()->filters()->update('zone_id', 'filter_id', $values); -``` - -## Delete - -Delete a filter for a zone. - -```php [php] -$response = $client->zones()->filters()->delete('zone_id', 'filter_id'); -``` diff --git a/docs/content/2.api/1.zones/11.firewall-rules.md b/docs/content/2.api/1.zones/11.firewall-rules.md deleted file mode 100644 index 14d547b..0000000 --- a/docs/content/2.api/1.zones/11.firewall-rules.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -title: Firewall Rules -description: Firewall Rules pair a Filter expression with an action, allowing you to control how traffic is handled on your zone. -navigation: - title: Firewall Rules ---- - -# Firewall Rules - -Firewall Rules pair a Filter expression with an action, allowing you to control how traffic is handled on your zone. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/firewall-rules-list-firewall-rules" blank} - -## List - -List all firewall rules for a zone. - -```php [php] -$response = $client->zones()->firewallRules()->list('zone_id'); -``` - -## Details - -Get a single firewall rule. - -```php [php] -$response = $client->zones()->firewallRules()->details('zone_id', 'rule_id'); -``` - -## Create - -Create one or more firewall rules for a zone. - -```php [php] -$values = [ - [ - 'action' => 'block', - 'filter' => [ - 'id' => 'filter_id', - ], - ], -]; - -$response = $client->zones()->firewallRules()->create('zone_id', $values); -``` - -## Update - -Update an existing firewall rule for a zone. - -```php [php] -$values = [ - 'action' => 'challenge', - 'filter' => [ - 'id' => 'filter_id', - ], -]; - -$response = $client->zones()->firewallRules()->update('zone_id', 'rule_id', $values); -``` - -## Update Priority - -Update the priority of an existing firewall rule for a zone. - -```php [php] -$response = $client->zones()->firewallRules()->updatePriority('zone_id', 'rule_id', 5); -``` - -## Delete - -Delete a firewall rule for a zone. - -```php [php] -$response = $client->zones()->firewallRules()->delete('zone_id', 'rule_id'); -``` diff --git a/docs/content/2.api/1.zones/12.access-rules.md b/docs/content/2.api/1.zones/12.access-rules.md deleted file mode 100644 index bbbf377..0000000 --- a/docs/content/2.api/1.zones/12.access-rules.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -title: IP Access Rules -description: IP Access rules allow you to allowlist, block, or challenge requests for a zone based on IP address, IP range, ASN, or country. -navigation: - title: IP Access Rules ---- - -# IP Access Rules - -IP Access rules allow you to allowlist, block, or challenge requests for a zone based on IP address, IP range, ASN, or country. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/ip-access-rules-for-a-zone-list-ip-access-rules" blank} - -## List - -List all IP Access rules for a zone. - -```php [php] -$response = $client->zones()->accessRules()->list('zone_id'); -``` - -## Create - -Create a new IP Access rule for a zone. - -```php [php] -$values = [ - 'mode' => 'block', - 'configuration' => [ - 'target' => 'ip', - 'value' => '127.0.0.1', - ], -]; - -$response = $client->zones()->accessRules()->create('zone_id', $values); -``` - -## Update - -Update an existing IP Access rule for a zone. - -```php [php] -$values = [ - 'mode' => 'challenge', -]; - -$response = $client->zones()->accessRules()->update('zone_id', 'rule_id', $values); -``` - -## Delete - -Delete an IP Access rule for a zone. - -```php [php] -$response = $client->zones()->accessRules()->delete('zone_id', 'rule_id'); -``` diff --git a/docs/content/2.api/1.zones/13.rate-limits.md b/docs/content/2.api/1.zones/13.rate-limits.md deleted file mode 100644 index afcf513..0000000 --- a/docs/content/2.api/1.zones/13.rate-limits.md +++ /dev/null @@ -1,78 +0,0 @@ ---- -title: Rate Limits -description: Rate Limiting rules protect a zone against traffic surges that do not conform to a defined rate expectation. -navigation: - title: Rate Limits ---- - -# Rate Limits - -Rate Limiting rules protect a zone against traffic surges that do not conform to a defined rate expectation. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/rate-limits-for-a-zone-list-rate-limits" blank} - -## List - -List all rate limits for a zone. - -```php [php] -$response = $client->zones()->rateLimits()->list('zone_id'); -``` - -## Details - -Get a single rate limit. - -```php [php] -$response = $client->zones()->rateLimits()->details('zone_id', 'rate_limit_id'); -``` - -## Create - -Create a new rate limit for a zone. - -```php [php] -$values = [ - 'threshold' => 100, - 'period' => 60, - 'match' => [ - 'request' => [ - 'url' => '*.example.com/*', - ], - ], - 'action' => [ - 'mode' => 'simulate', - ], -]; - -$response = $client->zones()->rateLimits()->create('zone_id', $values); -``` - -## Update - -Update an existing rate limit for a zone. - -```php [php] -$values = [ - 'threshold' => 200, - 'period' => 60, - 'match' => [ - 'request' => [ - 'url' => '*.example.com/*', - ], - ], - 'action' => [ - 'mode' => 'simulate', - ], -]; - -$response = $client->zones()->rateLimits()->update('zone_id', 'rate_limit_id', $values); -``` - -## Delete - -Delete a rate limit for a zone. - -```php [php] -$response = $client->zones()->rateLimits()->delete('zone_id', 'rate_limit_id'); -``` diff --git a/docs/content/2.api/1.zones/15.load-balancers.md b/docs/content/2.api/1.zones/15.load-balancers.md deleted file mode 100644 index 1b9d35e..0000000 --- a/docs/content/2.api/1.zones/15.load-balancers.md +++ /dev/null @@ -1,74 +0,0 @@ ---- -title: Load Balancers -description: Manage load balancers configured for a zone. -navigation: - title: Load Balancers ---- - -# Load Balancers - -Manage load balancers configured for a zone. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/zone-level-load-balancers-list-load-balancers" blank} - -## List - -List configured load balancers for a zone. - -```php [php] -$response = $client->zones()->loadBalancers()->list('zone_id'); -``` - -## Create - -Create a new load balancer for a zone. - -```php [php] -$values = [ - 'name' => 'www.example.com', - 'default_pools' => ['pool_id'], - 'fallback_pool' => 'pool_id', -]; - -$response = $client->zones()->loadBalancers()->create('zone_id', $values); -``` - -## Details - -Get a single configured load balancer for a zone. - -```php [php] -$response = $client->zones()->loadBalancers()->details('zone_id', 'load_balancer_id'); -``` - -## Update - -Update an existing load balancer for a zone. - -```php [php] -$values = [ - 'name' => 'www.example.com', - 'default_pools' => ['pool_id'], - 'fallback_pool' => 'pool_id', -]; - -$response = $client->zones()->loadBalancers()->update('zone_id', 'load_balancer_id', $values); -``` - -## Delete - -Delete a load balancer for a zone. - -```php [php] -$response = $client->zones()->loadBalancers()->delete('zone_id', 'load_balancer_id'); -``` - -## Patch - -Apply changes to an existing load balancer, overwriting only the supplied properties. - -```php [php] -$response = $client->zones()->loadBalancers()->patch('zone_id', 'load_balancer_id', [ - 'enabled' => false, -]); -``` diff --git a/docs/content/2.api/1.zones/2.dnssec.md b/docs/content/2.api/1.zones/2.dnssec.md deleted file mode 100644 index 0f84aaf..0000000 --- a/docs/content/2.api/1.zones/2.dnssec.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -title: DNSSEC -description: DNS Security Extensions (DNSSEC) adds an extra layer of authentication to DNS. ---- - -# DNSSEC - -DNS Security Extensions (DNSSEC) adds an extra layer of authentication to DNS, ensuring requests are not routed to a spoofed domain. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/dnssec-dnssec-details" blank} - -## Details - -Details about DNSSEC status and configuration. - -```php [php] -$response = $client->zones()->dnssec()->details('zone_id'); -``` - -## Update - -Enable or disable DNSSEC. - -```php [php] -$response = $client->zones() - ->dnssec() - ->update('zone_id', status: 'active', multiSigner: false, presigned: false); -``` - -## Delete - -Delete DNSSEC records - -```php [php] -$response = $client->zones()->dnssec()->delete('zone_id'); -``` \ No newline at end of file diff --git a/docs/content/2.api/1.zones/2.page-rules.md b/docs/content/2.api/1.zones/2.page-rules.md deleted file mode 100644 index 8796c27..0000000 --- a/docs/content/2.api/1.zones/2.page-rules.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -title: Page Rules -description: Cloudflare Page Rules allow you to make adjustments to requests, configure Cloudflare settings, and trigger specific actions for matching requests. ---- - -# Page Rules - -Cloudflare Page Rules allow you to make adjustments to requests, configure Cloudflare settings, and trigger specific actions for matching requests. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/page-rules-list-page-rules" blank} - -## Settings - -Returns a list of settings (and their details) that Page Rules can apply to matching requests. - -```php [php] -$response = $client->zones()->pageRules()->settings('zone_id'); -``` - -## List - -List, search, sort, and filter a zones Page Rules. - -```php [php] -$response = $client->zones()->pageRules()->list('zone_id'); -``` - -## Create - -Creates a new Page Rule for a zone. - -```php [php] -$response = $client->zones()->pageRules()->create('zone_id', [ - 'actions' => [], - 'targets' => [], - 'status' => 'active' -]); -``` - -Using `PageRule Configuration` helper. - -```php [php] -use Cloudflare\Configurations\PageRule; - -$target = "example.com/*"; - -$config = (new PageRule($target)) - ->setStatus(true) - ->setPriority(100) - ->cacheLevel('simplified') - ->disableZaraz(true) - ->edgeCacheTTL(600); - -$response = $client->zones()->pageRules()->create('zone_id', $config); -``` - -## Details - -Fetches the details of a Page Rule. - -```php [php] -$response = $client->zones()->pageRules()->details('zone_id', 'pageRuleId'); -``` - -## Update - -Updates one or more fields of an existing Page Rule. - -```php [php] -$response = $client->zones()->pageRules()->update('zone_id', 'pageRuleId', [ - 'actions' => [], - 'targets' => [], - 'status' => 'active' -]); -``` - -## Overwrite - -Replaces the configuration of an existing Page Rule. The configuration of the updated Page Rule will exactly match the data passed in the API request. - -```php [php] -$response = $client->zones()->pageRules()->overwrite('zone_id', 'pageRuleId', [ - 'actions' => [], - 'targets' => [], - 'status' => 'active' -]); -``` - -## Delete - -Delete a Page Rule. - -```php [php] -$response = $client->zones()->pageRules()->delete('zone_id', 'pageRuleId'); -``` \ No newline at end of file diff --git a/docs/content/2.api/1.zones/4.cloud-conenctor-rules.md b/docs/content/2.api/1.zones/4.cloud-conenctor-rules.md deleted file mode 100644 index 20a2868..0000000 --- a/docs/content/2.api/1.zones/4.cloud-conenctor-rules.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -title: Cloud Connector Rules -description: Cloud Connector allows you to route matching incoming traffic from your website to a public cloud provider that you define such as AWS, Google Cloud, and Azure. ---- - -# Cloud Connector Rules - -Cloud Connector allows you to route matching incoming traffic from your website to a public cloud provider that you define such as AWS, Google Cloud, and Azure. With Cloud Connector you can make Cloudflare the control center for your web traffic, including traffic served from public cloud providers, without having to configure additional rules. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/zone-cloud-connector-rules" blank} - -## Get - -Get Rules. - -```php [php] -$response = $client->zones()->cloudConnector()->get('account_id'); -``` - -## Update - -Update Rules. - -```php [php] -$response = $client->zones()->cloudConnector()->update('account_id', [ - 'enabled' => true, - 'provider' => 'aws_s3' -]); -``` \ No newline at end of file diff --git a/docs/content/2.api/1.zones/5.holds.md b/docs/content/2.api/1.zones/5.holds.md index 719c1ee..41f0509 100644 --- a/docs/content/2.api/1.zones/5.holds.md +++ b/docs/content/2.api/1.zones/5.holds.md @@ -16,7 +16,7 @@ Zone holds prevent other teams in your organization from adding zones that are a Retrieve whether the zone is subject to a zone hold, and metadata about the hold. ```php [php] -$response = $client->zones()->holds()->details('zone_id'); +$response = $client->zones()->holds()->get('zone_id'); ``` ## Create diff --git a/docs/content/2.api/1.zones/6.lockdown.md b/docs/content/2.api/1.zones/6.lockdown.md deleted file mode 100644 index 5c4d0d9..0000000 --- a/docs/content/2.api/1.zones/6.lockdown.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -title: Zone Lockdown -description: Zone Lockdown specifies a list of one or more IP addresses, CIDR ranges, or networks that are the only IPs allowed to access a domain, subdomain, or URL.. -navigation: - title: Lockdown ---- - -# Zone Lockdown - -Zone Lockdown specifies a list of one or more IP addresses, CIDR ranges, or networks that are the only IPs allowed to access a domain, subdomain, or URL. You can configure multiple destinations, including IPv4/IPv6 addresses, in a single Zone Lockdown rule. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/zone-lockdown-list-zone-lockdown-rules" blank} - -## List - -Fetches Zone Lockdown rules. You can filter the results using several optional parameters. - -```php [php] -$response = $client->zones()->lockdowns()->list('zone_id'); -``` - -## Create - -Creates a new Zone Lockdown rule. - -```php [php] -$response = $client->zones()->lockdowns()->create('zone_id', '198.51.100.4'); -``` - -## Details - -Fetches the details of a Zone Lockdown rule. - -```php [php] -$response = $client->zones()->lockdowns()->details('zone_id', 'lockdown_id'); -``` - -## Update - -Updates an existing Zone Lockdown rule. - -```php [php] -$response = $client->zones()->lockdowns()->update('zone_id', 'lockdown_id', '198.51.100.4'); -``` - -## Delete - -Deletes an existing Zone Lockdown rule. - -```php [php] -$response = $client->zones()->lockdowns()->delete('zone_id', 'lockdown_id'); -``` \ No newline at end of file diff --git a/docs/content/2.api/1.zones/7.rulesets.md b/docs/content/2.api/1.zones/7.rulesets.md deleted file mode 100644 index 608a4bb..0000000 --- a/docs/content/2.api/1.zones/7.rulesets.md +++ /dev/null @@ -1,61 +0,0 @@ ---- -title: Rulesets -description: Account Rulesets ---- - -# Rulesets - -The Cloudflare Ruleset Engine allows you to create and deploy rules and rulesets in different Cloudflare products using the same basic syntax. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/listZoneRulesets" blank} - -## List - -Fetches all rulesets at the zone level. - -```php [php] -$response = $client->zones()->rulesets()->get('ZONE_ID'); -``` - -## Create - -Creates a ruleset at the zone level. - -```php [php] -use Cloudflare\Configurations\Rules\BlockRule; -use Cloudflare\Configurations\Ruleset; - -$ruleset = (new Ruleset('The human-readable name of the ruleset.')) - ->managed() //Set Ruleset kind to 'managed' - ->configSettings() //Set Ruleset phase to 'http_config_settings' - ->setDescription('An informative description of the ruleset.'); - -//Create a BlockRule -$blockRule = new BlockRule(['title' => 'My Response Title', 'text' => 'My response text'], 'application/json', 400); - -$blockRule->setExpression(function(ExpressionBuilder $builder){ - return $builder->field('ip.src')->eq('192.168.1.2')->or()->group(function(ExpressionBuilder $bilder){ - $bilder->not()->field('ssl')->or()->field('udp')->contains(32); - })->or()->addExpression('ip.src', 'eq', '127.0.01'); -}); - -$ruleset->addRule($blockRule); - -$response = $client->zones()->rulesets()->create('ZONE_ID', $ruleset); -``` - -## Details - -Fetches the latest version of a zone ruleset. - -```php [php] -$response = $client->zones()->rulesets()->details('ZONE_ID', 'RULESET_ID'); -``` - -## Delete - -Deletes all versions of an existing zone ruleset. - -```php [php] -$response = $client->zones()->rulesets()->delete('ZONE_ID', 'RULESET_ID'); -``` \ No newline at end of file diff --git a/docs/content/2.api/1.zones/8.ssl.md b/docs/content/2.api/1.zones/8.ssl.md deleted file mode 100644 index 0d6cefa..0000000 --- a/docs/content/2.api/1.zones/8.ssl.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: SSL/TLS -description: Manage SSL/TLS verification and Universal SSL settings for a zone. -navigation: - title: SSL/TLS ---- - -# SSL/TLS - -Manage SSL/TLS certificate verification and Universal SSL settings for a zone. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/ssl-verification-details" blank} - -## Verification - -SSL Verification Details. - -```php [php] -$response = $client->zones()->ssl()->verification('zone_id'); -``` - -## Edit Verification - -Edit SSL Certificate Pack Validation Method. - -```php [php] -$response = $client->zones() - ->ssl() - ->editVerification('zone_id', 'cert_pack_uuid', 'txt'); -``` - -## Universal SSL Settings - -Universal SSL Settings Details. - -```php [php] -$response = $client->zones()->ssl()->universalSettings('zone_id'); -``` - -## Update Universal SSL Settings - -Edit Universal SSL Settings. - -```php [php] -$response = $client->zones()->ssl()->updateUniversalSettings('zone_id', true); -``` diff --git a/docs/content/2.api/1.zones/9.origin-ca-certificates.md b/docs/content/2.api/1.zones/9.origin-ca-certificates.md deleted file mode 100644 index f11632b..0000000 --- a/docs/content/2.api/1.zones/9.origin-ca-certificates.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: Origin CA Certificates -description: Issue and manage certificates issued by Cloudflare's Origin CA for securing connections between Cloudflare and your origin server. -navigation: - title: Origin CA Certificates ---- - -# Origin CA Certificates - -Issue and manage certificates issued by Cloudflare's Origin CA for securing connections between Cloudflare and your origin server. - -:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/origin-ca-certificates-list-certificates" blank} - -## List - -List all Origin CA certificates. - -```php [php] -$response = $client->zones()->originCACertificates()->list(['zone_id' => 'zone_id']); -``` - -## Create - -Create an Origin CA certificate. - -```php [php] -$response = $client->zones() - ->originCACertificates() - ->create('csr', ['example.com', '*.example.com']); -``` - -## Details - -Get an Origin CA certificate. - -```php [php] -$response = $client->zones()->originCACertificates()->details('certificate_id'); -``` - -## Revoke - -Revoke an Origin CA certificate. - -```php [php] -$response = $client->zones()->originCACertificates()->revoke('certificate_id'); -``` diff --git a/docs/content/2.api/10.page-rules.md b/docs/content/2.api/10.page-rules.md new file mode 100644 index 0000000..6c94ea5 --- /dev/null +++ b/docs/content/2.api/10.page-rules.md @@ -0,0 +1,70 @@ +--- +title: Page Rules +description: Manage Page Rules for a zone. +navigation: + title: Page Rules +--- + +# Page Rules + +Manage Page Rules for a zone. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/page-rules-list-page-rules" blank} + +## Settings + +Returns a list of settings (and their details) that Page Rules can apply to matching requests. + +```php [php] +$response = $client->pageRules()->settings('zone_id'); +``` + +## List + +```php [php] +$response = $client->pageRules()->list('zone_id'); +``` + +## Create + +```php [php] +use Cloudflare\Configurations\Zones\PageRule; + +$response = $client->pageRules()->create('zone_id', [ + 'targets' => [['target' => 'url', 'constraint' => ['operator' => 'matches', 'value' => '*example.com/*']]], + 'actions' => [['id' => 'always_use_https']], +]); +``` + +## Get + +```php [php] +$response = $client->pageRules()->get('zone_id', 'page_rule_id'); +``` + +## Edit + +Updates one or more fields of an existing Page Rule. + +```php [php] +$response = $client->pageRules()->edit('zone_id', 'page_rule_id', [ + 'actions' => [['id' => 'always_use_https']], +]); +``` + +## Update + +Replaces the configuration of an existing Page Rule. + +```php [php] +$response = $client->pageRules()->update('zone_id', 'page_rule_id', [ + 'targets' => [['target' => 'url', 'constraint' => ['operator' => 'matches', 'value' => '*example.com/*']]], + 'actions' => [['id' => 'always_use_https']], +]); +``` + +## Delete + +```php [php] +$response = $client->pageRules()->delete('zone_id', 'page_rule_id'); +``` diff --git a/docs/content/2.api/11.lockdown.md b/docs/content/2.api/11.lockdown.md new file mode 100644 index 0000000..24e9361 --- /dev/null +++ b/docs/content/2.api/11.lockdown.md @@ -0,0 +1,42 @@ +--- +title: Zone Lockdown +description: Restrict access to URLs in a zone to specific IP addresses or ranges. +navigation: + title: Lockdown +--- + +# Zone Lockdown + +Restrict access to URLs in a zone to specific IP addresses or ranges. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/zone-lockdown-list-zone-lockdown-rules" blank} + +## List + +```php [php] +$response = $client->lockdown()->list('zone_id'); +``` + +## Create + +```php [php] +$response = $client->lockdown()->create('zone_id', '192.0.2.1', ['example.com/*']); +``` + +## Get + +```php [php] +$response = $client->lockdown()->get('zone_id', 'lockdown_id'); +``` + +## Update + +```php [php] +$response = $client->lockdown()->update('zone_id', 'lockdown_id', '192.0.2.1', ['example.com/*']); +``` + +## Delete + +```php [php] +$response = $client->lockdown()->delete('zone_id', 'lockdown_id'); +``` diff --git a/docs/content/2.api/12.ssl.md b/docs/content/2.api/12.ssl.md new file mode 100644 index 0000000..9c9b235 --- /dev/null +++ b/docs/content/2.api/12.ssl.md @@ -0,0 +1,40 @@ +--- +title: SSL/TLS +description: Manage SSL certificate pack verification and Universal SSL settings for a zone. +navigation: + title: SSL +--- + +# SSL/TLS + +Manage SSL certificate pack verification and Universal SSL settings for a zone. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/ssl-verification-details" blank} + +## Verification + +SSL Verification Details. + +```php [php] +$response = $client->ssl()->verification('zone_id'); +``` + +## Edit Verification + +Edit SSL Certificate Pack Validation Method. + +```php [php] +$response = $client->ssl()->editVerification('zone_id', 'cert_pack_uuid', 'txt'); +``` + +## Universal Settings + +```php [php] +$response = $client->ssl()->universalSettings('zone_id'); +``` + +## Edit Universal Settings + +```php [php] +$response = $client->ssl()->editUniversalSettings('zone_id', false); +``` diff --git a/docs/content/2.api/13.origin-ca-certificates.md b/docs/content/2.api/13.origin-ca-certificates.md new file mode 100644 index 0000000..4c26fb9 --- /dev/null +++ b/docs/content/2.api/13.origin-ca-certificates.md @@ -0,0 +1,36 @@ +--- +title: Origin CA Certificates +description: Manage Origin CA certificates used to encrypt traffic between Cloudflare and your origin server. +navigation: + title: Origin CA Certificates +--- + +# Origin CA Certificates + +Manage Origin CA certificates used to encrypt traffic between Cloudflare and your origin server. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/origin-ca-certificates-list-certificates" blank} + +## List + +```php [php] +$response = $client->originCACertificates()->list(['zone_id' => 'zone_id']); +``` + +## Create + +```php [php] +$response = $client->originCACertificates()->create($csr, ['example.com', '*.example.com']); +``` + +## Get + +```php [php] +$response = $client->originCACertificates()->get('certificate_id'); +``` + +## Revoke + +```php [php] +$response = $client->originCACertificates()->revoke('certificate_id'); +``` diff --git a/docs/content/2.api/14.filters.md b/docs/content/2.api/14.filters.md new file mode 100644 index 0000000..58d2a46 --- /dev/null +++ b/docs/content/2.api/14.filters.md @@ -0,0 +1,46 @@ +--- +title: Filters +description: Manage reusable filter expressions referenced by firewall rules and rate limits. +navigation: + title: Filters +--- + +# Filters + +Manage reusable filter expressions referenced by firewall rules and rate limits. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/filters-list-filters" blank} + +## List + +```php [php] +$response = $client->filters()->list('zone_id'); +``` + +## Get + +```php [php] +$response = $client->filters()->get('zone_id', 'filter_id'); +``` + +## Create + +```php [php] +$response = $client->filters()->create('zone_id', [ + ['expression' => 'ip.src eq 127.0.0.1'], +]); +``` + +## Update + +```php [php] +$response = $client->filters()->update('zone_id', 'filter_id', [ + 'expression' => 'ip.src eq 127.0.0.1', +]); +``` + +## Delete + +```php [php] +$response = $client->filters()->delete('zone_id', 'filter_id'); +``` diff --git a/docs/content/2.api/15.firewall-rules.md b/docs/content/2.api/15.firewall-rules.md new file mode 100644 index 0000000..a728b71 --- /dev/null +++ b/docs/content/2.api/15.firewall-rules.md @@ -0,0 +1,53 @@ +--- +title: Firewall Rules +description: Manage a zone's firewall rules, which combine a filter expression with an action. +navigation: + title: Firewall Rules +--- + +# Firewall Rules + +Manage a zone's firewall rules, which combine a filter expression with an action. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/firewall-rules-list-firewall-rules" blank} + +## List + +```php [php] +$response = $client->firewallRules()->list('zone_id'); +``` + +## Get + +```php [php] +$response = $client->firewallRules()->get('zone_id', 'rule_id'); +``` + +## Create + +```php [php] +$response = $client->firewallRules()->create('zone_id', [ + ['action' => 'block', 'filter' => ['expression' => 'ip.src eq 127.0.0.1']], +]); +``` + +## Update + +```php [php] +$response = $client->firewallRules()->update('zone_id', 'rule_id', [ + 'action' => 'block', + 'filter' => ['id' => 'filter_id'], +]); +``` + +## Update Priority + +```php [php] +$response = $client->firewallRules()->updatePriority('zone_id', 'rule_id', 5); +``` + +## Delete + +```php [php] +$response = $client->firewallRules()->delete('zone_id', 'rule_id'); +``` diff --git a/docs/content/2.api/16.access-rules.md b/docs/content/2.api/16.access-rules.md new file mode 100644 index 0000000..b486e25 --- /dev/null +++ b/docs/content/2.api/16.access-rules.md @@ -0,0 +1,41 @@ +--- +title: IP Access Rules +description: Manage a zone's IP Access rules, which allow, challenge, or block traffic from specific IPs, ranges, or countries. +navigation: + title: Access Rules +--- + +# IP Access Rules + +Manage a zone's IP Access rules, which allow, challenge, or block traffic from specific IPs, ranges, or countries. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/ip-access-rules-for-a-zone-list-ip-access-rules" blank} + +## List + +```php [php] +$response = $client->accessRules()->list('zone_id'); +``` + +## Create + +```php [php] +$response = $client->accessRules()->create('zone_id', [ + 'mode' => 'block', + 'configuration' => ['target' => 'ip', 'value' => '192.0.2.1'], +]); +``` + +## Edit + +```php [php] +$response = $client->accessRules()->edit('zone_id', 'rule_id', [ + 'mode' => 'challenge', +]); +``` + +## Delete + +```php [php] +$response = $client->accessRules()->delete('zone_id', 'rule_id'); +``` diff --git a/docs/content/2.api/17.rate-limits.md b/docs/content/2.api/17.rate-limits.md new file mode 100644 index 0000000..b0ca1b8 --- /dev/null +++ b/docs/content/2.api/17.rate-limits.md @@ -0,0 +1,52 @@ +--- +title: Rate Limits +description: Manage a zone's rate limiting rules. +navigation: + title: Rate Limits +--- + +# Rate Limits + +Manage a zone's rate limiting rules. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/rate-limits-for-a-zone-list-rate-limits" blank} + +## List + +```php [php] +$response = $client->rateLimits()->list('zone_id'); +``` + +## Get + +```php [php] +$response = $client->rateLimits()->get('zone_id', 'rate_limit_id'); +``` + +## Create + +```php [php] +$response = $client->rateLimits()->create('zone_id', [ + 'threshold' => 1000, + 'period' => 60, + 'match' => ['request' => ['url' => '*example.com/*']], + 'action' => ['mode' => 'simulate', 'timeout' => 60], +]); +``` + +## Update + +```php [php] +$response = $client->rateLimits()->update('zone_id', 'rate_limit_id', [ + 'threshold' => 2000, + 'period' => 60, + 'match' => ['request' => ['url' => '*example.com/*']], + 'action' => ['mode' => 'simulate', 'timeout' => 60], +]); +``` + +## Delete + +```php [php] +$response = $client->rateLimits()->delete('zone_id', 'rate_limit_id'); +``` diff --git a/docs/content/2.api/1.zones/14.bot-management.md b/docs/content/2.api/18.bot-management.md similarity index 61% rename from docs/content/2.api/1.zones/14.bot-management.md rename to docs/content/2.api/18.bot-management.md index 57539f3..d4f3201 100644 --- a/docs/content/2.api/1.zones/14.bot-management.md +++ b/docs/content/2.api/18.bot-management.md @@ -11,22 +11,16 @@ Manage the Bot Management configuration for a zone. :button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/zone-bot-management-get-config" blank} -## Details - -Get the current Bot Management configuration for a zone. +## Get ```php [php] -$response = $client->zones()->botManagement()->details('zone_id'); +$response = $client->botManagement()->get('zone_id'); ``` ## Update -Update the Bot Management configuration for a zone. - ```php [php] -$values = [ +$response = $client->botManagement()->update('zone_id', [ 'fight_mode' => false, -]; - -$response = $client->zones()->botManagement()->update('zone_id', $values); +]); ``` diff --git a/docs/content/2.api/19.cloud-connector.md b/docs/content/2.api/19.cloud-connector.md new file mode 100644 index 0000000..59a4626 --- /dev/null +++ b/docs/content/2.api/19.cloud-connector.md @@ -0,0 +1,29 @@ +--- +title: Cloud Connector Rules +description: Manage a zone's Cloud Connector rules. +navigation: + title: Cloud Connector +--- + +# Cloud Connector Rules + +Manage a zone's Cloud Connector rules. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/zone-cloud-connector-rules" blank} + +## Get + +```php [php] +$response = $client->cloudConnector()->get('zone_id'); +``` + +## Update + +```php [php] +$response = $client->cloudConnector()->update('zone_id', [ + 'name' => 'my rule', + 'expression' => 'true', + 'provider' => 'aws_s3', + 'enabled' => true, +]); +``` diff --git a/docs/content/2.api/2.workers/10.logs.md b/docs/content/2.api/2.workers/10.logs.md index c28215e..76e9989 100644 --- a/docs/content/2.api/2.workers/10.logs.md +++ b/docs/content/2.api/2.workers/10.logs.md @@ -14,7 +14,7 @@ navigation: Get list of tails currently deployed on a Worker. ```php [php] -$response = $client->workers()->logs()->get('account_id', 'script_name'); +$response = $client->workers()->logs()->list('account_id', 'script_name'); ``` ## Start Tail diff --git a/docs/content/2.api/2.workers/11.routes.md b/docs/content/2.api/2.workers/11.routes.md index c5c9528..f0398f2 100644 --- a/docs/content/2.api/2.workers/11.routes.md +++ b/docs/content/2.api/2.workers/11.routes.md @@ -14,7 +14,7 @@ navigation: Returns routes for a zone. ```php [php] -$response = $client->workers()->routes()->get('zone_id'); +$response = $client->workers()->routes()->list('zone_id'); ``` ## Create @@ -33,7 +33,7 @@ $response = $client->workers()->routes()->create('zone_id', [ Returns information about a route, including URL pattern and Worker. ```php [php] -$response = $client->workers()->routes()->details('zone_id', 'route_id'); +$response = $client->workers()->routes()->get('zone_id', 'route_id'); ``` ## Update diff --git a/docs/content/2.api/2.workers/3.deployments.md b/docs/content/2.api/2.workers/3.deployments.md index d6ae02f..1056160 100644 --- a/docs/content/2.api/2.workers/3.deployments.md +++ b/docs/content/2.api/2.workers/3.deployments.md @@ -16,7 +16,7 @@ Deployments track the version(s) of your Worker that are actively serving traffi List of Worker Deployments. The first deployment in the list is the latest deployment actively serving traffic. ```php [php] -$response = $client->workers()->deployments()->get('account_id', 'script_name'); +$response = $client->workers()->deployments()->list('account_id', 'script_name'); ``` ## Create diff --git a/docs/content/2.api/2.workers/4.domains.md b/docs/content/2.api/2.workers/4.domains.md index 6b4ab0a..6f182d9 100644 --- a/docs/content/2.api/2.workers/4.domains.md +++ b/docs/content/2.api/2.workers/4.domains.md @@ -14,7 +14,7 @@ navigation: Lists all Worker Domains for an account. ```php [php] -$response = $client->workers()->domains()->get('account_id'); +$response = $client->workers()->domains()->list('account_id'); ``` ## Attach @@ -45,5 +45,5 @@ $response = $client->workers()->domains()->detach('account_id', 'domain_id'); Gets a Worker domain. ```php [php] -$response = $client->workers()->domains()->domain('account_id', 'domain_id'); +$response = $client->workers()->domains()->get('account_id', 'domain_id'); ``` \ No newline at end of file diff --git a/docs/content/2.api/2.workers/6.scripts.md b/docs/content/2.api/2.workers/6.scripts.md index d32df02..960b1e0 100644 --- a/docs/content/2.api/2.workers/6.scripts.md +++ b/docs/content/2.api/2.workers/6.scripts.md @@ -14,7 +14,7 @@ navigation: Fetch a list of uploaded workers. ```php [php] -$response = $client->workers()->scripts()->get('account_id'); +$response = $client->workers()->scripts()->list('account_id'); ``` ## Download Worker @@ -22,7 +22,7 @@ $response = $client->workers()->scripts()->get('account_id'); Fetch raw script content for your worker. Note this is the original script content, not JSON encoded. ```php [php] -$response = $client->workers()->scripts()->get('account_id', 'script_name'); +$response = $client->workers()->scripts()->download('account_id', 'script_name'); $content = $response->body(); ``` diff --git a/docs/content/2.api/2.workers/8.versions.md b/docs/content/2.api/2.workers/8.versions.md index 6b307ce..e826aa0 100644 --- a/docs/content/2.api/2.workers/8.versions.md +++ b/docs/content/2.api/2.workers/8.versions.md @@ -30,5 +30,5 @@ Upload a Worker Version without deploying to Cloudflare's network. You can find ## Get Version Details ```php [php] -$response = $client->workers()->details()->details('account_id', 'script_name', 'version_id'); +$response = $client->workers()->versions()->get('account_id', 'script_name', 'version_id'); ``` \ No newline at end of file diff --git a/docs/content/2.api/20.r2/0.index.md b/docs/content/2.api/20.r2/0.index.md new file mode 100644 index 0000000..758acc7 --- /dev/null +++ b/docs/content/2.api/20.r2/0.index.md @@ -0,0 +1,24 @@ +--- +title: R2 +description: Manage R2 object storage buckets and their configuration. +navigation: + title: R2 +--- + +# R2 + +Manage R2 object storage buckets and their configuration. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/r2-list-buckets" blank} + +## Sub-resources + +- [Buckets](/api/r2/buckets) +- [CORS](/api/r2/cors) +- [Lifecycle](/api/r2/lifecycle) +- [Object Lock](/api/r2/lock) +- [Custom Domains](/api/r2/custom-domains) +- [Managed Domain](/api/r2/managed-domain) +- [Sippy](/api/r2/sippy) +- [Event Notifications](/api/r2/event-notifications) +- [Metrics](/api/r2/metrics) diff --git a/docs/content/2.api/20.r2/1.buckets.md b/docs/content/2.api/20.r2/1.buckets.md new file mode 100644 index 0000000..88d2355 --- /dev/null +++ b/docs/content/2.api/20.r2/1.buckets.md @@ -0,0 +1,61 @@ +--- +title: R2 Buckets +description: Manage R2 buckets for an account. +navigation: + title: Buckets +--- + +# R2 Buckets + +Manage R2 buckets for an account. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/r2-list-buckets" blank} + +## List + +```php [php] +$response = $client->r2()->buckets()->list('account_id'); +``` + +## Create + +```php [php] +$response = $client->r2()->buckets()->create('account_id', [ + 'name' => 'my-bucket', +]); +``` + +## Get + +```php [php] +$response = $client->r2()->buckets()->get('account_id', 'my-bucket'); +``` + +## Edit + +Apply changes to the storage class of an existing bucket. + +```php [php] +$response = $client->r2()->buckets()->edit('account_id', 'my-bucket', 'InfrequentAccess'); +``` + +## Delete + +```php [php] +$response = $client->r2()->buckets()->delete('account_id', 'my-bucket'); +``` + +## Create Temporary Credentials + +Creates temporary access credentials scoped to a specific bucket. + +```php [php] +$response = $client->r2()->buckets()->createTemporaryCredentials('account_id', [ + 'bucket' => 'my-bucket', + 'permission' => 'object-read-only', + 'ttlSeconds' => 3600, + 'parentAccessKeyId' => 'parent_access_key_id', +]); +``` + +All methods accept an optional trailing `$jurisdiction` argument (e.g. `'eu'`) which sets the `cf-r2-jurisdiction` header. diff --git a/docs/content/2.api/20.r2/2.cors.md b/docs/content/2.api/20.r2/2.cors.md new file mode 100644 index 0000000..bf5aefe --- /dev/null +++ b/docs/content/2.api/20.r2/2.cors.md @@ -0,0 +1,32 @@ +--- +title: R2 Bucket CORS +description: Manage the CORS configuration for an R2 bucket. +navigation: + title: CORS +--- + +# R2 Bucket CORS + +Manage the CORS configuration for an R2 bucket. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/r2-get-bucket-cors-policy" blank} + +## Get + +```php [php] +$response = $client->r2()->cors()->get('account_id', 'my-bucket'); +``` + +## Update + +```php [php] +$response = $client->r2()->cors()->update('account_id', 'my-bucket', [ + ['id' => 'rule-1', 'allowed' => ['methods' => ['GET'], 'origins' => ['*']]], +]); +``` + +## Delete + +```php [php] +$response = $client->r2()->cors()->delete('account_id', 'my-bucket'); +``` diff --git a/docs/content/2.api/20.r2/3.lifecycle.md b/docs/content/2.api/20.r2/3.lifecycle.md new file mode 100644 index 0000000..d2ef8c3 --- /dev/null +++ b/docs/content/2.api/20.r2/3.lifecycle.md @@ -0,0 +1,26 @@ +--- +title: R2 Bucket Lifecycle +description: Manage the lifecycle configuration for an R2 bucket. +navigation: + title: Lifecycle +--- + +# R2 Bucket Lifecycle + +Manage the lifecycle configuration for an R2 bucket. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/r2-get-bucket-lifecycle-configuration" blank} + +## Get + +```php [php] +$response = $client->r2()->lifecycle()->get('account_id', 'my-bucket'); +``` + +## Update + +```php [php] +$response = $client->r2()->lifecycle()->update('account_id', 'my-bucket', [ + ['id' => 'rule-1', 'conditions' => ['maxAge' => 3600]], +]); +``` diff --git a/docs/content/2.api/20.r2/4.lock.md b/docs/content/2.api/20.r2/4.lock.md new file mode 100644 index 0000000..bfd41e3 --- /dev/null +++ b/docs/content/2.api/20.r2/4.lock.md @@ -0,0 +1,26 @@ +--- +title: R2 Bucket Object Lock +description: Manage the object lock (retention) configuration for an R2 bucket. +navigation: + title: Object Lock +--- + +# R2 Bucket Object Lock + +Manage the object lock (retention) configuration for an R2 bucket. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/r2-get-bucket-lock-configuration" blank} + +## Get + +```php [php] +$response = $client->r2()->lock()->get('account_id', 'my-bucket'); +``` + +## Update + +```php [php] +$response = $client->r2()->lock()->update('account_id', 'my-bucket', [ + ['id' => 'rule-1', 'condition' => ['type' => 'Age', 'maxAgeSeconds' => 86400]], +]); +``` diff --git a/docs/content/2.api/20.r2/5.custom-domains.md b/docs/content/2.api/20.r2/5.custom-domains.md new file mode 100644 index 0000000..66d0c20 --- /dev/null +++ b/docs/content/2.api/20.r2/5.custom-domains.md @@ -0,0 +1,48 @@ +--- +title: R2 Bucket Custom Domains +description: Manage custom domains attached to an R2 bucket. +navigation: + title: Custom Domains +--- + +# R2 Bucket Custom Domains + +Manage custom domains attached to an R2 bucket. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/r2-list-bucket-domains" blank} + +## List + +```php [php] +$response = $client->r2()->customDomains()->list('account_id', 'my-bucket'); +``` + +## Create + +```php [php] +$response = $client->r2()->customDomains()->create('account_id', 'my-bucket', [ + 'domain' => 'assets.example.com', + 'zoneId' => 'zone_id', + 'enabled' => true, +]); +``` + +## Get + +```php [php] +$response = $client->r2()->customDomains()->get('account_id', 'my-bucket', 'assets.example.com'); +``` + +## Update + +```php [php] +$response = $client->r2()->customDomains()->update('account_id', 'my-bucket', 'assets.example.com', [ + 'enabled' => false, +]); +``` + +## Delete + +```php [php] +$response = $client->r2()->customDomains()->delete('account_id', 'my-bucket', 'assets.example.com'); +``` diff --git a/docs/content/2.api/20.r2/6.managed-domain.md b/docs/content/2.api/20.r2/6.managed-domain.md new file mode 100644 index 0000000..504f96f --- /dev/null +++ b/docs/content/2.api/20.r2/6.managed-domain.md @@ -0,0 +1,24 @@ +--- +title: R2 Bucket Managed Domain +description: Manage the managed (r2.dev) domain for an R2 bucket. +navigation: + title: Managed Domain +--- + +# R2 Bucket Managed Domain + +Manage the managed (`r2.dev`) domain for an R2 bucket. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/r2-get-bucket-managed-domain" blank} + +## Get + +```php [php] +$response = $client->r2()->managedDomain()->get('account_id', 'my-bucket'); +``` + +## Update + +```php [php] +$response = $client->r2()->managedDomain()->update('account_id', 'my-bucket', false); +``` diff --git a/docs/content/2.api/20.r2/7.sippy.md b/docs/content/2.api/20.r2/7.sippy.md new file mode 100644 index 0000000..156e6f2 --- /dev/null +++ b/docs/content/2.api/20.r2/7.sippy.md @@ -0,0 +1,37 @@ +--- +title: R2 Bucket Sippy +description: Manage incremental migration (Sippy) for an R2 bucket. +navigation: + title: Sippy +--- + +# R2 Bucket Sippy + +Manage incremental migration (Sippy) for an R2 bucket. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/r2-get-bucket-sippy-configuration" blank} + +## Get + +```php [php] +$response = $client->r2()->sippy()->get('account_id', 'my-bucket'); +``` + +## Update + +Enable Sippy for a bucket. + +```php [php] +$response = $client->r2()->sippy()->update('account_id', 'my-bucket', [ + 'source' => ['provider' => 'aws', 'bucket' => 'source-bucket'], + 'destination' => ['provider' => 'r2'], +]); +``` + +## Delete + +Disable Sippy for a bucket. + +```php [php] +$response = $client->r2()->sippy()->delete('account_id', 'my-bucket'); +``` diff --git a/docs/content/2.api/20.r2/8.event-notifications.md b/docs/content/2.api/20.r2/8.event-notifications.md new file mode 100644 index 0000000..a559c9b --- /dev/null +++ b/docs/content/2.api/20.r2/8.event-notifications.md @@ -0,0 +1,42 @@ +--- +title: R2 Bucket Event Notifications +description: Manage event notification configuration for an R2 bucket. +navigation: + title: Event Notifications +--- + +# R2 Bucket Event Notifications + +Manage event notification configuration for an R2 bucket. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/r2-event-notifications-get-configuration" blank} + +## List + +Read the event notification configuration for a bucket, listing rules for all configured queues. + +```php [php] +$response = $client->r2()->eventNotifications()->list('account_id', 'my-bucket'); +``` + +## Get + +```php [php] +$response = $client->r2()->eventNotifications()->get('account_id', 'my-bucket', 'queue_id'); +``` + +## Update + +Create or update the event notification configuration for a bucket and a specific queue. + +```php [php] +$response = $client->r2()->eventNotifications()->update('account_id', 'my-bucket', 'queue_id', [ + 'rules' => [['actions' => ['PutObject']]], +]); +``` + +## Delete + +```php [php] +$response = $client->r2()->eventNotifications()->delete('account_id', 'my-bucket', 'queue_id'); +``` diff --git a/docs/content/2.api/0.accounts/18.r2-metrics.md b/docs/content/2.api/20.r2/9.metrics.md similarity index 71% rename from docs/content/2.api/0.accounts/18.r2-metrics.md rename to docs/content/2.api/20.r2/9.metrics.md index 65c5974..2e24e40 100644 --- a/docs/content/2.api/0.accounts/18.r2-metrics.md +++ b/docs/content/2.api/20.r2/9.metrics.md @@ -2,7 +2,7 @@ title: R2 Metrics description: Get storage metrics for an account's R2 buckets. navigation: - title: R2 Metrics + title: Metrics --- # R2 Metrics @@ -13,8 +13,6 @@ Get storage metrics for an account's R2 buckets. ## List -Get storage metrics for an account's R2 buckets. - ```php [php] -$response = $client->accounts()->r2Metrics()->list('account_id'); +$response = $client->r2()->metrics()->list('account_id'); ``` diff --git a/docs/content/2.api/3.d1/index.md b/docs/content/2.api/3.d1/index.md index 9a5cedf..3016cd2 100644 --- a/docs/content/2.api/3.d1/index.md +++ b/docs/content/2.api/3.d1/index.md @@ -33,7 +33,7 @@ $response = $client->d1()->create('ACCOUNT_ID', 'name', 'location'); Returns the specified D1 database. ```php [php] -$response = $client->d1()->details('ACCOUNT_ID', 'DATABASE_ID'); +$response = $client->d1()->get('ACCOUNT_ID', 'DATABASE_ID'); ``` ## Delete diff --git a/docs/content/2.api/4.tunnel/1.routes.md b/docs/content/2.api/4.tunnel/1.routes.md index 8121975..04ca065 100644 --- a/docs/content/2.api/4.tunnel/1.routes.md +++ b/docs/content/2.api/4.tunnel/1.routes.md @@ -38,7 +38,7 @@ $response = $client->tunnel()->routes()->create('ACCOUNT_ID', '172.16.0.0/16', ' Get a private network route in an account. ```php [php] -$response = $client->tunnel()->routes()->details('ACCOUNT_ID', 'ROUTE_ID'); +$response = $client->tunnel()->routes()->get('ACCOUNT_ID', 'ROUTE_ID'); ``` ## Update @@ -46,7 +46,7 @@ $response = $client->tunnel()->routes()->details('ACCOUNT_ID', 'ROUTE_ID'); Updates an existing private network route in an account. The fields that are meant to be updated should be provided in the body of the request. ```php [php] -$response = $client->tunnel()->routes()->update('ACCOUNT_ID', 'ROUTE_ID', [ +$response = $client->tunnel()->routes()->edit('ACCOUNT_ID', 'ROUTE_ID', [ 'network' => '172.16.0.0/16' ]); ``` diff --git a/docs/content/2.api/4.tunnel/2.virtual-networks.md b/docs/content/2.api/4.tunnel/2.virtual-networks.md index 4fa1a98..a8d8991 100644 --- a/docs/content/2.api/4.tunnel/2.virtual-networks.md +++ b/docs/content/2.api/4.tunnel/2.virtual-networks.md @@ -30,7 +30,7 @@ $response = $client->tunnel()->virtualNetworks()->create('ACCOUNT_ID', 'us-east- Get a virtual network. ```php [php] -$response = $client->tunnel()->virtualNetworks()->details('ACCOUNT_ID', 'VIRTUAL_NETWORK_ID'); +$response = $client->tunnel()->virtualNetworks()->get('ACCOUNT_ID', 'VIRTUAL_NETWORK_ID'); ``` ## Update @@ -38,7 +38,7 @@ $response = $client->tunnel()->virtualNetworks()->details('ACCOUNT_ID', 'VIRTUAL Updates an existing virtual network. ```php [php] -$response = $client->tunnel()->virtualNetworks()->update('ACCOUNT_ID', 'VIRTUAL_NETWORK_ID', [ +$response = $client->tunnel()->virtualNetworks()->edit('ACCOUNT_ID', 'VIRTUAL_NETWORK_ID', [ 'name' => 'us-east-1-vpc' ]); ``` diff --git a/docs/content/2.api/6.load-balancers/0.index.md b/docs/content/2.api/6.load-balancers/0.index.md new file mode 100644 index 0000000..21f4208 --- /dev/null +++ b/docs/content/2.api/6.load-balancers/0.index.md @@ -0,0 +1,93 @@ +--- +title: Load Balancers +description: Distribute traffic across your origin servers to reduce response time and increase availability. Scoped to either an account or a zone. +navigation: + title: Load Balancers +--- + +# Load Balancers + +Distribute traffic across your origin servers to reduce response time and increase availability. A load balancer is scoped to either an account or a zone: pass exactly one of `accountId` or `zoneId` (named arguments are the clearest way to do this). + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/account-level-load-balancers-list-load-balancers" blank} + +## List + +List configured load balancers. + +```php [php] +$response = $client->loadBalancers()->list(accountId: 'account_id'); +// or +$response = $client->loadBalancers()->list(zoneId: 'zone_id'); +``` + +## Create + +Create a new load balancer. + +```php [php] +$values = [ + 'name' => 'www.example.com', + 'default_pools' => ['pool_id'], + 'fallback_pool' => 'pool_id', +]; + +$response = $client->loadBalancers()->create(null, 'zone_id', $values); +``` + +## Get + +Get a single configured load balancer. + +```php [php] +$response = $client->loadBalancers()->get('account_id', null, 'load_balancer_id'); +``` + +## Update + +Update an existing load balancer, overwriting the full configuration. + +```php [php] +$values = [ + 'name' => 'www.example.com', + 'default_pools' => ['pool_id'], + 'fallback_pool' => 'pool_id', +]; + +$response = $client->loadBalancers()->update(null, 'zone_id', 'load_balancer_id', $values); +``` + +## Edit + +Apply changes to an existing load balancer, overwriting only the supplied properties. + +```php [php] +$response = $client->loadBalancers()->edit('account_id', null, 'load_balancer_id', [ + 'enabled' => false, +]); +``` + +## Delete + +Delete a load balancer. + +```php [php] +$response = $client->loadBalancers()->delete(null, 'zone_id', 'load_balancer_id'); +``` + +## Usage + +Fetch the current load balancer usage for an account. + +```php [php] +$response = $client->loadBalancers()->usage('account_id'); +``` + +## Sub-resources + +- [Pools](/api/load-balancers/pools) +- [Monitors](/api/load-balancers/monitors) +- [Monitor Groups](/api/load-balancers/monitor-groups) +- [Regions](/api/load-balancers/regions) +- [Searches](/api/load-balancers/searches) +- [Previews](/api/load-balancers/previews) diff --git a/docs/content/2.api/6.load-balancers/1.pools.md b/docs/content/2.api/6.load-balancers/1.pools.md new file mode 100644 index 0000000..f7a5da1 --- /dev/null +++ b/docs/content/2.api/6.load-balancers/1.pools.md @@ -0,0 +1,105 @@ +--- +title: Load Balancer Pools +description: Manage groups of origins that load balancers distribute traffic across. +navigation: + title: Pools +--- + +# Load Balancer Pools + +Manage groups of origins that load balancers distribute traffic across. Pools are account-scoped. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/load-balancer-pools-list-pools" blank} + +## List + +```php [php] +$response = $client->loadBalancers()->pools()->list('account_id'); +``` + +## Create + +```php [php] +$values = [ + 'name' => 'primary-pool', + 'origins' => [ + ['name' => 'origin-1', 'address' => '192.0.2.1'], + ], +]; + +$response = $client->loadBalancers()->pools()->create('account_id', $values); +``` + +## Get + +```php [php] +$response = $client->loadBalancers()->pools()->get('account_id', 'pool_id'); +``` + +## Update + +Overwrites the full pool configuration. + +```php [php] +$values = [ + 'name' => 'primary-pool', + 'origins' => [ + ['name' => 'origin-1', 'address' => '192.0.2.1'], + ], + 'enabled' => false, +]; + +$response = $client->loadBalancers()->pools()->update('account_id', 'pool_id', $values); +``` + +## Edit + +Apply changes, overwriting only the supplied properties. + +```php [php] +$response = $client->loadBalancers()->pools()->edit('account_id', 'pool_id', [ + 'enabled' => false, +]); +``` + +## Bulk Edit + +Apply changes to a number of existing pools at once, each identified by `id`. + +```php [php] +$response = $client->loadBalancers()->pools()->bulkEdit('account_id', [ + ['id' => 'pool_id', 'enabled' => false], +]); +``` + +## Delete + +```php [php] +$response = $client->loadBalancers()->pools()->delete('account_id', 'pool_id'); +``` + +## Health + +Fetch the latest pool health status for a single pool. + +```php [php] +$response = $client->loadBalancers()->pools()->health('account_id', 'pool_id'); +``` + +## Preview + +Preview pool health using the specified monitor and show the effective response. + +```php [php] +$response = $client->loadBalancers()->pools()->preview('account_id', 'pool_id', [ + 'monitor' => 'monitor_id', +]); +``` + +## References + +List the load balancers that reference a given pool. + +```php [php] +$response = $client->loadBalancers()->pools()->references('account_id', 'pool_id'); +``` diff --git a/docs/content/2.api/6.load-balancers/2.monitors.md b/docs/content/2.api/6.load-balancers/2.monitors.md new file mode 100644 index 0000000..d27b14d --- /dev/null +++ b/docs/content/2.api/6.load-balancers/2.monitors.md @@ -0,0 +1,79 @@ +--- +title: Load Balancer Monitors +description: Manage health check monitors used to determine the health of load balancer pool origins. +navigation: + title: Monitors +--- + +# Load Balancer Monitors + +Manage health check monitors used to determine the health of load balancer pool origins. Monitors are account-scoped. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/load-balancer-monitors-list-monitors" blank} + +## List + +```php [php] +$response = $client->loadBalancers()->monitors()->list('account_id'); +``` + +## Create + +```php [php] +$response = $client->loadBalancers()->monitors()->create('account_id', [ + 'type' => 'http', + 'method' => 'GET', + 'path' => '/health', +]); +``` + +## Get + +```php [php] +$response = $client->loadBalancers()->monitors()->get('account_id', 'monitor_id'); +``` + +## Update + +Overwrites the full monitor configuration. + +```php [php] +$response = $client->loadBalancers()->monitors()->update('account_id', 'monitor_id', [ + 'type' => 'http', + 'method' => 'POST', +]); +``` + +## Edit + +Apply changes, overwriting only the supplied properties. + +```php [php] +$response = $client->loadBalancers()->monitors()->edit('account_id', 'monitor_id', [ + 'method' => 'POST', +]); +``` + +## Delete + +```php [php] +$response = $client->loadBalancers()->monitors()->delete('account_id', 'monitor_id'); +``` + +## Preview + +Preview pools associated with a given monitor and show the effective response. + +```php [php] +$response = $client->loadBalancers()->monitors()->preview('account_id', 'monitor_id', [ + 'pools' => ['pool_id'], +]); +``` + +## References + +List the load balancers and pools that reference a given monitor. + +```php [php] +$response = $client->loadBalancers()->monitors()->references('account_id', 'monitor_id'); +``` diff --git a/docs/content/2.api/0.accounts/19.load-balancer-monitor-groups.md b/docs/content/2.api/6.load-balancers/3.monitor-groups.md similarity index 51% rename from docs/content/2.api/0.accounts/19.load-balancer-monitor-groups.md rename to docs/content/2.api/6.load-balancers/3.monitor-groups.md index 117fabd..70abb4d 100644 --- a/docs/content/2.api/0.accounts/19.load-balancer-monitor-groups.md +++ b/docs/content/2.api/6.load-balancers/3.monitor-groups.md @@ -2,27 +2,23 @@ title: Load Balancer Monitor Groups description: Manage groups of monitors that can be applied together to load balancer pools. navigation: - title: Load Balancer Monitor Groups + title: Monitor Groups --- # Load Balancer Monitor Groups -Manage groups of monitors that can be applied together to load balancer pools. +Manage groups of monitors that can be applied together to load balancer pools. Monitor groups are account-scoped. :button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/account-load-balancer-monitor-groups-list-monitor-groups" blank} ## List -List configured load balancer monitor groups for an account. - ```php [php] -$response = $client->accounts()->loadBalancerMonitorGroups()->list('account_id'); +$response = $client->loadBalancers()->monitorGroups()->list('account_id'); ``` ## Create -Create a new load balancer monitor group for an account. - ```php [php] $values = [ 'description' => 'Primary datacenter monitors', @@ -36,30 +32,28 @@ $values = [ ], ]; -$response = $client->accounts()->loadBalancerMonitorGroups()->create('account_id', $values); +$response = $client->loadBalancers()->monitorGroups()->create('account_id', $values); ``` -## Details - -Get a single configured load balancer monitor group for an account. +## Get ```php [php] -$response = $client->accounts()->loadBalancerMonitorGroups()->details('account_id', 'monitor_group_id'); +$response = $client->loadBalancers()->monitorGroups()->get('account_id', 'monitor_group_id'); ``` -## Patch +## Edit -Apply changes to an existing monitor group, overwriting only the supplied properties. +Apply changes, overwriting only the supplied properties. ```php [php] -$response = $client->accounts()->loadBalancerMonitorGroups()->patch('account_id', 'monitor_group_id', [ +$response = $client->loadBalancers()->monitorGroups()->edit('account_id', 'monitor_group_id', [ 'description' => 'Secondary datacenter monitors', ]); ``` ## Update -Update an existing load balancer monitor group for an account. +Overwrites the full monitor group configuration. ```php [php] $values = [ @@ -74,15 +68,13 @@ $values = [ ], ]; -$response = $client->accounts()->loadBalancerMonitorGroups()->update('account_id', 'monitor_group_id', $values); +$response = $client->loadBalancers()->monitorGroups()->update('account_id', 'monitor_group_id', $values); ``` ## Delete -Delete a load balancer monitor group for an account. - ```php [php] -$response = $client->accounts()->loadBalancerMonitorGroups()->delete('account_id', 'monitor_group_id'); +$response = $client->loadBalancers()->monitorGroups()->delete('account_id', 'monitor_group_id'); ``` ## References @@ -90,5 +82,5 @@ $response = $client->accounts()->loadBalancerMonitorGroups()->delete('account_id List the pools that reference a given monitor group. ```php [php] -$response = $client->accounts()->loadBalancerMonitorGroups()->references('account_id', 'monitor_group_id'); +$response = $client->loadBalancers()->monitorGroups()->references('account_id', 'monitor_group_id'); ``` diff --git a/docs/content/2.api/0.accounts/9.load-balancer-regions.md b/docs/content/2.api/6.load-balancers/4.regions.md similarity index 56% rename from docs/content/2.api/0.accounts/9.load-balancer-regions.md rename to docs/content/2.api/6.load-balancers/4.regions.md index 8f379ea..c37360c 100644 --- a/docs/content/2.api/0.accounts/9.load-balancer-regions.md +++ b/docs/content/2.api/6.load-balancers/4.regions.md @@ -2,27 +2,23 @@ title: Load Balancer Regions description: List the mapping of Cloudflare regions to countries and geographic regions, used to configure load balancer region pools. navigation: - title: Load Balancer Regions + title: Regions --- # Load Balancer Regions -List the mapping of Cloudflare regions to countries and geographic regions, used to configure load balancer region pools. +List the mapping of Cloudflare regions to countries and geographic regions, used to configure load balancer region pools. Regions are account-scoped. :button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/load-balancer-regions-list-regions" blank} ## List -List Load Balancer region mappings for an account. - ```php [php] -$response = $client->accounts()->loadBalancerRegions()->list('account_id'); +$response = $client->loadBalancers()->regions()->list('account_id'); ``` -## Details - -Get a single Load Balancer region mapping for an account. +## Get ```php [php] -$response = $client->accounts()->loadBalancerRegions()->details('account_id', 'WNAM'); +$response = $client->loadBalancers()->regions()->get('account_id', 'WNAM'); ``` diff --git a/docs/content/2.api/6.load-balancers/5.searches.md b/docs/content/2.api/6.load-balancers/5.searches.md new file mode 100644 index 0000000..a0e91b4 --- /dev/null +++ b/docs/content/2.api/6.load-balancers/5.searches.md @@ -0,0 +1,20 @@ +--- +title: Load Balancer Resource Search +description: Search load balancing resources (Load Balancers, Pools, Monitors) by name. +navigation: + title: Searches +--- + +# Load Balancer Resource Search + +Search load balancing resources (Load Balancers, Pools, Monitors) by name. Search is account-scoped. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/account-load-balancer-search-search-resources" blank} + +## List + +```php [php] +$response = $client->loadBalancers()->searches()->list('account_id', [ + 'query' => 'www.example.com', +]); +``` diff --git a/docs/content/2.api/6.load-balancers/6.previews.md b/docs/content/2.api/6.load-balancers/6.previews.md new file mode 100644 index 0000000..0419613 --- /dev/null +++ b/docs/content/2.api/6.load-balancers/6.previews.md @@ -0,0 +1,18 @@ +--- +title: Load Balancer Preview Results +description: Fetch the result of a previously requested monitor or pool preview. +navigation: + title: Previews +--- + +# Load Balancer Preview Results + +Fetch the result of a previously requested monitor or pool preview. Previews are account-scoped. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/account-load-balancer-monitors-preview-result" blank} + +## Get + +```php [php] +$response = $client->loadBalancers()->previews()->get('account_id', 'preview_id'); +``` diff --git a/docs/content/2.api/0.accounts/5.rulesets.md b/docs/content/2.api/7.rulesets/0.index.md similarity index 58% rename from docs/content/2.api/0.accounts/5.rulesets.md rename to docs/content/2.api/7.rulesets/0.index.md index 7555d62..1a190de 100644 --- a/docs/content/2.api/0.accounts/5.rulesets.md +++ b/docs/content/2.api/7.rulesets/0.index.md @@ -1,25 +1,29 @@ --- title: Rulesets -description: Account Rulesets +description: Create and deploy rules and rulesets in different Cloudflare products using the same basic syntax. Scoped to either an account or a zone. +navigation: + title: Rulesets --- # Rulesets -The Cloudflare Ruleset Engine allows you to create and deploy rules and rulesets in different Cloudflare products using the same basic syntax. +The Cloudflare Ruleset Engine allows you to create and deploy rules and rulesets in different Cloudflare products using the same basic syntax. A ruleset is scoped to either an account or a zone: pass exactly one of `accountId` or `zoneId` (named arguments are the clearest way to do this). :button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/listAccountRulesets" blank} ## List -Fetches all rulesets at the account level. +Fetches all rulesets. ```php [php] -$response = $client->accounts()->rulesets()->get('ACCOUNT_ID'); +$response = $client->rulesets()->list(accountId: 'account_id'); +// or +$response = $client->rulesets()->list(zoneId: 'zone_id'); ``` ## Create -Creates a ruleset at the account level. +Creates a ruleset. ```php [php] use Cloudflare\Configurations\Rules\BlockRule; @@ -41,21 +45,25 @@ $blockRule->setExpression(function(ExpressionBuilder $builder){ $ruleset->addRule($blockRule); -$response = $client->accounts()->rulesets()->create('ACCOUNT_ID', $ruleset); +$response = $client->rulesets()->create(null, 'zone_id', $ruleset); ``` -## Details +## Get -Fetches the latest version of an account ruleset. +Fetches the latest version of a ruleset. ```php [php] -$response = $client->accounts()->rulesets()->details('ACCOUNT_ID', 'RULESET_ID'); +$response = $client->rulesets()->get('account_id', null, 'ruleset_id'); ``` ## Delete -Deletes all versions of an existing account ruleset. +Deletes all versions of an existing ruleset. ```php [php] -$response = $client->accounts()->rulesets()->delete('ACCOUNT_ID', 'RULESET_ID'); -``` \ No newline at end of file +$response = $client->rulesets()->delete(null, 'zone_id', 'ruleset_id'); +``` + +## Sub-resources + +- [Rules](/api/rulesets/rules) diff --git a/docs/content/2.api/7.rulesets/1.rules.md b/docs/content/2.api/7.rulesets/1.rules.md new file mode 100644 index 0000000..3356818 --- /dev/null +++ b/docs/content/2.api/7.rulesets/1.rules.md @@ -0,0 +1,22 @@ +--- +title: Ruleset Rules +description: Add a rule to a ruleset. +navigation: + title: Rules +--- + +# Ruleset Rules + +Add a rule to an existing ruleset. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/updateZoneRuleset" blank} + +## Create + +```php [php] +use Cloudflare\Configurations\Rules\BlockRule; + +$rule = (new BlockRule(['error' => 'blocked']))->enable()->setExpression('true'); + +$response = $client->rulesets()->rules()->create(null, 'zone_id', 'ruleset_id', $rule); +``` diff --git a/docs/content/2.api/8.dns.md b/docs/content/2.api/8.dns.md new file mode 100644 index 0000000..e7bfe8c --- /dev/null +++ b/docs/content/2.api/8.dns.md @@ -0,0 +1,88 @@ +--- +title: DNS +description: List, search, sort, filter, and manage a zone's DNS records. +navigation: + title: DNS +--- + +# DNS + +List, search, sort, filter, and manage a zone's DNS records. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/dns-records-for-a-zone-list-dns-records" blank} + +## Scan + +Scan for common DNS records on your domain and automatically add them to your zone. Useful if you haven't updated your nameservers yet. + +```php [php] +$response = $client->dns()->scan('zone_id'); +``` + +## List + +```php [php] +$response = $client->dns()->list('zone_id'); +``` + +## Create + +```php [php] +$response = $client->dns()->create('zone_id', [ + 'content' => '192.0.2.1', + 'name' => 'example.com', + 'type' => 'A', +]); +``` + +## Export + +Export BIND config. + +```php [php] +$response = $client->dns()->export('zone_id'); +``` + +## Import + +Import BIND config. + +```php [php] +$response = $client->dns()->import('zone_id', $bindFileContents); +``` + +## Get + +```php [php] +$response = $client->dns()->get('zone_id', 'dns_record_id'); +``` + +## Edit + +Apply changes to an existing DNS record, overwriting only the supplied properties. + +```php [php] +$response = $client->dns()->edit('zone_id', 'dns_record_id', [ + 'content' => '192.0.2.2', + 'name' => 'example.com', + 'type' => 'A', +]); +``` + +## Update + +Update an existing DNS record, overwriting the full configuration. + +```php [php] +$response = $client->dns()->update('zone_id', 'dns_record_id', [ + 'content' => '192.0.2.2', + 'name' => 'example.com', + 'type' => 'A', +]); +``` + +## Delete + +```php [php] +$response = $client->dns()->delete('zone_id', 'dns_record_id'); +``` diff --git a/docs/content/2.api/9.dnssec.md b/docs/content/2.api/9.dnssec.md new file mode 100644 index 0000000..aab2eb8 --- /dev/null +++ b/docs/content/2.api/9.dnssec.md @@ -0,0 +1,32 @@ +--- +title: DNSSEC +description: Manage DNSSEC status and configuration for a zone. +navigation: + title: DNSSEC +--- + +# DNSSEC + +Manage DNSSEC status and configuration for a zone. + +:button-link[Cloudflare API docs]{icon="heroicons-outline:external-link" href="https://developers.cloudflare.com/api/operations/dnssec-dnssec-details" blank} + +## Get + +```php [php] +$response = $client->dnssec()->get('zone_id'); +``` + +## Edit + +Enable or disable DNSSEC. + +```php [php] +$response = $client->dnssec()->edit('zone_id', 'active'); +``` + +## Delete + +```php [php] +$response = $client->dnssec()->delete('zone_id'); +``` diff --git a/docs/content/4.coverage.md b/docs/content/4.coverage.md index 3181061..3d366d6 100644 --- a/docs/content/4.coverage.md +++ b/docs/content/4.coverage.md @@ -141,54 +141,54 @@ Please find below implemented endpoints. - [ ] Billing Profile Details ## Account Load Balancer Monitor Groups - - [x] [List Monitor Groups](/api/accounts/load-balancer-monitor-groups#list) - - [x] [Create Monitor Group](/api/accounts/load-balancer-monitor-groups#create) - - [x] [Delete Monitor Group](/api/accounts/load-balancer-monitor-groups#delete) - - [x] [Monitor Group Details](/api/accounts/load-balancer-monitor-groups#details) - - [x] [Patch Monitor Group](/api/accounts/load-balancer-monitor-groups#patch) - - [x] [Update Monitor Group](/api/accounts/load-balancer-monitor-groups#update) - - [x] [List Monitor Group References](/api/accounts/load-balancer-monitor-groups#references) + - [x] [List Monitor Groups](/api/load-balancers/monitor-groups#list) + - [x] [Create Monitor Group](/api/load-balancers/monitor-groups#create) + - [x] [Delete Monitor Group](/api/load-balancers/monitor-groups#delete) + - [x] [Monitor Group Details](/api/load-balancers/monitor-groups#get) + - [x] [Patch Monitor Group](/api/load-balancers/monitor-groups#edit) + - [x] [Update Monitor Group](/api/load-balancers/monitor-groups#update) + - [x] [List Monitor Group References](/api/load-balancers/monitor-groups#references) ## Account Load Balancer Monitors - - [x] [List Monitors](/api/accounts/load-balancer-monitors#list) - - [x] [Create Monitor](/api/accounts/load-balancer-monitors#create) - - [x] [Delete Monitor](/api/accounts/load-balancer-monitors#delete) - - [x] [Monitor Details](/api/accounts/load-balancer-monitors#details) - - [x] [Patch Monitor](/api/accounts/load-balancer-monitors#patch) - - [x] [Update Monitor](/api/accounts/load-balancer-monitors#update) - - [x] [Preview Monitor](/api/accounts/load-balancer-monitors#preview) - - [x] [List Monitor References](/api/accounts/load-balancer-monitors#references) - - [x] [Preview Result](/api/accounts/load-balancers#preview-result) + - [x] [List Monitors](/api/load-balancers/monitors#list) + - [x] [Create Monitor](/api/load-balancers/monitors#create) + - [x] [Delete Monitor](/api/load-balancers/monitors#delete) + - [x] [Monitor Details](/api/load-balancers/monitors#get) + - [x] [Patch Monitor](/api/load-balancers/monitors#edit) + - [x] [Update Monitor](/api/load-balancers/monitors#update) + - [x] [Preview Monitor](/api/load-balancers/monitors#preview) + - [x] [List Monitor References](/api/load-balancers/monitors#references) + - [x] [Preview Result](/api/load-balancers/previews#get) ## Account Load Balancer Pools - - [x] [List Pools](/api/accounts/load-balancer-pools#list) - - [x] [Patch Pools](/api/accounts/load-balancer-pools#patch-multiple-pools) - - [x] [Create Pool](/api/accounts/load-balancer-pools#create) - - [x] [Delete Pool](/api/accounts/load-balancer-pools#delete) - - [x] [Pool Details](/api/accounts/load-balancer-pools#details) - - [x] [Patch Pool](/api/accounts/load-balancer-pools#patch) - - [x] [Update Pool](/api/accounts/load-balancer-pools#update) - - [x] [Pool Health Details](/api/accounts/load-balancer-pools#health) - - [x] [Preview Pool](/api/accounts/load-balancer-pools#preview) - - [x] [List Pool References](/api/accounts/load-balancer-pools#references) + - [x] [List Pools](/api/load-balancers/pools#list) + - [x] [Patch Pools](/api/load-balancers/pools#bulk-edit) + - [x] [Create Pool](/api/load-balancers/pools#create) + - [x] [Delete Pool](/api/load-balancers/pools#delete) + - [x] [Pool Details](/api/load-balancers/pools#get) + - [x] [Patch Pool](/api/load-balancers/pools#edit) + - [x] [Update Pool](/api/load-balancers/pools#update) + - [x] [Pool Health Details](/api/load-balancers/pools#health) + - [x] [Preview Pool](/api/load-balancers/pools#preview) + - [x] [List Pool References](/api/load-balancers/pools#references) ## Account Load Balancer Search - - [x] [Search Resources](/api/accounts/load-balancers#search) + - [x] [Search Resources](/api/load-balancers/searches#list) ## Account Load Balancers - - [x] [List Account Load Balancers](/api/accounts/load-balancers#list) - - [x] [Create Account Load Balancer](/api/accounts/load-balancers#create) - - [x] [List Load Balancer Usage](/api/accounts/load-balancers#usage) - - [x] [Delete Account Load Balancer](/api/accounts/load-balancers#delete) - - [x] [Account Load Balancer Details](/api/accounts/load-balancers#details) - - [x] [Patch Account Load Balancer](/api/accounts/load-balancers#patch) - - [x] [Update Account Load Balancer](/api/accounts/load-balancers#update) + - [x] [List Account Load Balancers](/api/load-balancers#list) + - [x] [Create Account Load Balancer](/api/load-balancers#create) + - [x] [List Load Balancer Usage](/api/load-balancers#usage) + - [x] [Delete Account Load Balancer](/api/load-balancers#delete) + - [x] [Account Load Balancer Details](/api/load-balancers#get) + - [x] [Patch Account Load Balancer](/api/load-balancers#edit) + - [x] [Update Account Load Balancer](/api/load-balancers#update) ## Account Members - [x] [List Members](/api/accounts/members#list) - [x] [Add Member](/api/accounts/members#add) - [x] [Remove Member](/api/accounts/members#remove) - - [x] [Member Details](/api/accounts/members#details) + - [x] [Member Details](/api/accounts/members#get) - [x] [Update Member](/api/accounts/members#update) ## Account Owned API Tokens @@ -217,17 +217,17 @@ Please find below implemented endpoints. ## Account Roles - [x] [List Roles](/api/accounts/roles#list) - - [x] [Role Details](/api/accounts/roles#details) + - [x] [Role Details](/api/accounts/roles#get) ## Account Rulesets - - [x] [List account rulesets](/api/accounts/rulesets#list) - - [x] [Create an account ruleset](/api/accounts/rulesets#create) + - [x] [List account rulesets](/api/rulesets#list) + - [x] [Create an account ruleset](/api/rulesets#create) - [ ] Get an account entry point ruleset - [ ] Update an account entry point ruleset - [ ] List an account entry point ruleset's versions - [ ] Get an account entry point ruleset version - - [x] [Delete an account ruleset](/api/accounts/rulesets#delete) - - [x] [Get an account ruleset](/api/accounts/rulesets#details) + - [x] [Delete an account ruleset](/api/rulesets#delete) + - [x] [Get an account ruleset](/api/rulesets#get) - [ ] Update an account ruleset - [ ] Create an account ruleset rule - [ ] Delete an account ruleset rule @@ -271,7 +271,7 @@ Please find below implemented endpoints. - [x] [List Accounts](/api/accounts/accounts#list) - [x] [Create an account](/api/accounts/accounts#create) - [x] [Delete a specific account](/api/accounts/accounts#delete) - - [x] [Account Details](/api/accounts/accounts#details) + - [x] [Account Details](/api/accounts/accounts#get) - [x] [Update Account](/api/accounts/accounts#update) ## Active session @@ -576,7 +576,7 @@ Please find below implemented endpoints. - [ ] Search ## Available Page Rules settings - - [x] [List available Page Rules settings](/api/zones/page-rules#settings) + - [x] [List available Page Rules settings](/api/page-rules#settings) ## Billable Usage - [ ] Get PayGo Account Billable Usage (Version 1, Alpha) @@ -591,8 +591,8 @@ Please find below implemented endpoints. - [ ] Retrieves a file from Binary Storage ## Bot Settings - - [x] [Get Zone Bot Management Config](/api/zones/bot-management#details) - - [x] [Update Zone Bot Management Config](/api/zones/bot-management#update) + - [x] [Get Zone Bot Management Config](/api/bot-management#get) + - [x] [Update Zone Bot Management Config](/api/bot-management#update) ## Botnet Threat Feed - [ ] Get daily report @@ -1009,7 +1009,7 @@ Please find below implemented endpoints. - [x] [List D1 Databases](/api/d1#list) - [x] [Create D1 Database](/api/d1#create) - [x] [Delete D1 Database](/api/d1#delete) - - [x] [Get D1 Database](/api/d1#details) + - [x] [Get D1 Database](/api/d1#get) - [x] [Export D1 Database as SQL](/api/d1#export) - [x] [Import SQL into your D1 Database](/api/d1#import) - [x] [Query D1 Database](/api/d1#query) @@ -1354,9 +1354,9 @@ Please find below implemented endpoints. - [ ] Update DNS Settings ## DNSSEC - - [x] [Delete DNSSEC records](/api/zones/dnssec#delete) - - [x] [DNSSEC Details](/api/zones/dnssec#details) - - [x] [Edit DNSSEC Status](/api/zones/dnssec#update) + - [x] [Delete DNSSEC records](/api/dnssec#delete) + - [x] [DNSSEC Details](/api/dnssec#get) + - [x] [Edit DNSSEC Status](/api/dnssec#edit) ## Domain Discovery - [ ] Check domain availability @@ -1547,23 +1547,23 @@ Please find below implemented endpoints. ## Filters - [ ] Delete filters - - [x] [List filters](/api/zones/filters#list) - - [x] [Create filters](/api/zones/filters#create) + - [x] [List filters](/api/filters#list) + - [x] [Create filters](/api/filters#create) - [ ] Update filters - - [x] [Delete a filter](/api/zones/filters#delete) - - [x] [Get a filter](/api/zones/filters#details) - - [x] [Update a filter](/api/zones/filters#update) + - [x] [Delete a filter](/api/filters#delete) + - [x] [Get a filter](/api/filters#get) + - [x] [Update a filter](/api/filters#update) ## Firewall rules - [ ] Delete firewall rules - - [x] [List firewall rules](/api/zones/firewall-rules#list) + - [x] [List firewall rules](/api/firewall-rules#list) - [ ] Update priority of firewall rules - - [x] [Create firewall rules](/api/zones/firewall-rules#create) + - [x] [Create firewall rules](/api/firewall-rules#create) - [ ] Update firewall rules - - [x] [Delete a firewall rule](/api/zones/firewall-rules#delete) - - [x] [Get a firewall rule](/api/zones/firewall-rules#details) - - [x] [Update priority of a firewall rule](/api/zones/firewall-rules#update-priority) - - [x] [Update a firewall rule](/api/zones/firewall-rules#update) + - [x] [Delete a firewall rule](/api/firewall-rules#delete) + - [x] [Get a firewall rule](/api/firewall-rules#get) + - [x] [Update priority of a firewall rule](/api/firewall-rules#update-priority) + - [x] [Update a firewall rule](/api/firewall-rules#update) ## Flags - [ ] List flags @@ -1679,10 +1679,10 @@ Please find below implemented endpoints. - [ ] Update an IP Access rule ## IP Access rules for a zone - - [x] [List IP Access rules](/api/zones/access-rules#list) - - [x] [Create an IP Access rule](/api/zones/access-rules#create) - - [x] [Delete an IP Access rule](/api/zones/access-rules#delete) - - [x] [Update an IP Access rule](/api/zones/access-rules#update) + - [x] [List IP Access rules](/api/access-rules#list) + - [x] [Create an IP Access rule](/api/access-rules#create) + - [x] [Delete an IP Access rule](/api/access-rules#delete) + - [x] [Update an IP Access rule](/api/access-rules#edit) ## IP Access rules for an account - [ ] List IP Access rules @@ -1808,39 +1808,39 @@ Please find below implemented endpoints. - [ ] List Healthcheck Events ## Load Balancer Monitors - - [x] [List Monitors](/api/accounts/load-balancer-monitors#list) - - [x] [Create Monitor](/api/accounts/load-balancer-monitors#create) - - [x] [Delete Monitor](/api/accounts/load-balancer-monitors#delete) - - [x] [Monitor Details](/api/accounts/load-balancer-monitors#details) - - [x] [Patch Monitor](/api/accounts/load-balancer-monitors#patch) - - [x] [Update Monitor](/api/accounts/load-balancer-monitors#update) - - [x] [Preview Monitor](/api/accounts/load-balancer-monitors#preview) - - [x] [List Monitor References](/api/accounts/load-balancer-monitors#references) - - [x] [Preview Result](/api/accounts/load-balancers#preview-result) + - [x] [List Monitors](/api/load-balancers/monitors#list) + - [x] [Create Monitor](/api/load-balancers/monitors#create) + - [x] [Delete Monitor](/api/load-balancers/monitors#delete) + - [x] [Monitor Details](/api/load-balancers/monitors#get) + - [x] [Patch Monitor](/api/load-balancers/monitors#edit) + - [x] [Update Monitor](/api/load-balancers/monitors#update) + - [x] [Preview Monitor](/api/load-balancers/monitors#preview) + - [x] [List Monitor References](/api/load-balancers/monitors#references) + - [x] [Preview Result](/api/load-balancers/previews#get) ## Load Balancer Pools - - [x] [List Pools](/api/accounts/load-balancer-pools#list) - - [x] [Patch Pools](/api/accounts/load-balancer-pools#patch-multiple-pools) - - [x] [Create Pool](/api/accounts/load-balancer-pools#create) - - [x] [Delete Pool](/api/accounts/load-balancer-pools#delete) - - [x] [Pool Details](/api/accounts/load-balancer-pools#details) - - [x] [Patch Pool](/api/accounts/load-balancer-pools#patch) - - [x] [Update Pool](/api/accounts/load-balancer-pools#update) - - [x] [Pool Health Details](/api/accounts/load-balancer-pools#health) - - [x] [Preview Pool](/api/accounts/load-balancer-pools#preview) - - [x] [List Pool References](/api/accounts/load-balancer-pools#references) + - [x] [List Pools](/api/load-balancers/pools#list) + - [x] [Patch Pools](/api/load-balancers/pools#bulk-edit) + - [x] [Create Pool](/api/load-balancers/pools#create) + - [x] [Delete Pool](/api/load-balancers/pools#delete) + - [x] [Pool Details](/api/load-balancers/pools#get) + - [x] [Patch Pool](/api/load-balancers/pools#edit) + - [x] [Update Pool](/api/load-balancers/pools#update) + - [x] [Pool Health Details](/api/load-balancers/pools#health) + - [x] [Preview Pool](/api/load-balancers/pools#preview) + - [x] [List Pool References](/api/load-balancers/pools#references) ## Load Balancer Regions - - [x] [List Regions](/api/accounts/load-balancer-regions#list) - - [x] [Get Region](/api/accounts/load-balancer-regions#details) + - [x] [List Regions](/api/load-balancers/regions#list) + - [x] [Get Region](/api/load-balancers/regions#get) ## Load Balancers - - [x] [List Load Balancers](/api/zones/load-balancers#list) - - [x] [Create Load Balancer](/api/zones/load-balancers#create) - - [x] [Delete Load Balancer](/api/zones/load-balancers#delete) - - [x] [Load Balancer Details](/api/zones/load-balancers#details) - - [x] [Patch Load Balancer](/api/zones/load-balancers#patch) - - [x] [Update Load Balancer](/api/zones/load-balancers#update) + - [x] [List Load Balancers](/api/load-balancers#list) + - [x] [Create Load Balancer](/api/load-balancers#create) + - [x] [Delete Load Balancer](/api/load-balancers#delete) + - [x] [Load Balancer Details](/api/load-balancers#get) + - [x] [Patch Load Balancer](/api/load-balancers#edit) + - [x] [Update Load Balancer](/api/load-balancers#update) ## Log Explorer Datasets - [ ] List account datasets @@ -2269,10 +2269,10 @@ Please find below implemented endpoints. - [ ] Modify organization profile. ## Origin CA - - [x] [List Certificates](/api/zones/origin-ca-certificates#list) - - [x] [Create Certificate](/api/zones/origin-ca-certificates#create) - - [x] [Revoke Certificate](/api/zones/origin-ca-certificates#revoke) - - [x] [Get Certificate](/api/zones/origin-ca-certificates#details) + - [x] [List Certificates](/api/origin-ca-certificates#list) + - [x] [Create Certificate](/api/origin-ca-certificates#create) + - [x] [Revoke Certificate](/api/origin-ca-certificates#revoke) + - [x] [Get Certificate](/api/origin-ca-certificates#get) ## Origin Cloud Regions - [ ] List origin cloud region mappings @@ -2299,12 +2299,12 @@ Please find below implemented endpoints. - [ ] Replace Origin TLS Compliance Modes setting ## Page Rules - - [x] [List Page Rules](/api/zones/page-rules#list) - - [x] [Create a Page Rule](/api/zones/page-rules#create) - - [x] [Delete a Page Rule](/api/zones/page-rules#delete) - - [x] [Get a Page Rule](/api/zones/page-rules#details) - - [x] [Edit a Page Rule](/api/zones/page-rules#update) - - [x] [Update a Page Rule](/api/zones/page-rules#overwrite) + - [x] [List Page Rules](/api/page-rules#list) + - [x] [Create a Page Rule](/api/page-rules#create) + - [x] [Delete a Page Rule](/api/page-rules#delete) + - [x] [Get a Page Rule](/api/page-rules#get) + - [x] [Edit a Page Rule](/api/page-rules#edit) + - [x] [Update a Page Rule](/api/page-rules#update) ## Page Shield - [ ] Get Page Shield settings @@ -2465,36 +2465,36 @@ Please find below implemented endpoints. - [ ] Pull Queue Messages ## R2 Account - - [x] [Get Metrics](/api/accounts/r2-metrics#list) + - [x] [Get Metrics](/api/r2/metrics#list) ## R2 Bucket - - [x] [List Buckets](/api/accounts/r2-buckets#list) - - [x] [Create Bucket](/api/accounts/r2-buckets#create) - - [x] [Delete Bucket](/api/accounts/r2-buckets#delete) - - [x] [Get Bucket](/api/accounts/r2-buckets#details) - - [x] [Disable Sippy](/api/accounts/r2-sippy#delete-disable) - - [x] [Get Sippy Configuration](/api/accounts/r2-sippy#details) - - [x] [Enable Sippy](/api/accounts/r2-sippy#update-enable) - - [x] [Create Temporary Access Credentials](/api/accounts/r2-buckets#create-temporary-access-credentials) - - [x] [Patch Bucket](/api/accounts/r2-buckets#update) - - [x] [Get CORS Configuration](/api/accounts/r2-cors#details) - - [x] [Update CORS Configuration](/api/accounts/r2-cors#update) - - [x] [Delete CORS Configuration](/api/accounts/r2-cors#delete) - - [x] [List Custom Domains](/api/accounts/r2-custom-domains#list) - - [x] [Add Custom Domain](/api/accounts/r2-custom-domains#create) - - [x] [Get Custom Domain](/api/accounts/r2-custom-domains#details) - - [x] [Update Custom Domain](/api/accounts/r2-custom-domains#update) - - [x] [Remove Custom Domain](/api/accounts/r2-custom-domains#delete) - - [x] [Get Lifecycle Configuration](/api/accounts/r2-lifecycle#details) - - [x] [Update Lifecycle Configuration](/api/accounts/r2-lifecycle#update) - - [x] [Get Managed Domain Configuration](/api/accounts/r2-managed-domain#details) - - [x] [Update Managed Domain Configuration](/api/accounts/r2-managed-domain#update) - - [x] [Get Lock Configuration](/api/accounts/r2-lock#details) - - [x] [Update Lock Configuration](/api/accounts/r2-lock#update) - - [x] [Read Configuration](/api/accounts/r2-event-notifications#read-configuration) - - [x] [Delete Configuration](/api/accounts/r2-event-notifications#delete-configuration) - - [x] [Create Configuration](/api/accounts/r2-event-notifications#createupdate-configuration) - - [x] [Get Event Notification Rule](/api/accounts/r2-event-notifications#get-queue-configuration) + - [x] [List Buckets](/api/r2/buckets#list) + - [x] [Create Bucket](/api/r2/buckets#create) + - [x] [Delete Bucket](/api/r2/buckets#delete) + - [x] [Get Bucket](/api/r2/buckets#get) + - [x] [Disable Sippy](/api/r2/sippy#delete) + - [x] [Get Sippy Configuration](/api/r2/sippy#get) + - [x] [Enable Sippy](/api/r2/sippy#update) + - [x] [Create Temporary Access Credentials](/api/r2/buckets#create-temporary-credentials) + - [x] [Patch Bucket](/api/r2/buckets#edit) + - [x] [Get CORS Configuration](/api/r2/cors#get) + - [x] [Update CORS Configuration](/api/r2/cors#update) + - [x] [Delete CORS Configuration](/api/r2/cors#delete) + - [x] [List Custom Domains](/api/r2/custom-domains#list) + - [x] [Add Custom Domain](/api/r2/custom-domains#create) + - [x] [Get Custom Domain](/api/r2/custom-domains#get) + - [x] [Update Custom Domain](/api/r2/custom-domains#update) + - [x] [Remove Custom Domain](/api/r2/custom-domains#delete) + - [x] [Get Lifecycle Configuration](/api/r2/lifecycle#get) + - [x] [Update Lifecycle Configuration](/api/r2/lifecycle#update) + - [x] [Get Managed Domain Configuration](/api/r2/managed-domain#get) + - [x] [Update Managed Domain Configuration](/api/r2/managed-domain#update) + - [x] [Get Lock Configuration](/api/r2/lock#get) + - [x] [Update Lock Configuration](/api/r2/lock#update) + - [x] [Read Configuration](/api/r2/event-notifications#list) + - [x] [Delete Configuration](/api/r2/event-notifications#delete) + - [x] [Create Configuration](/api/r2/event-notifications#update) + - [x] [Get Event Notification Rule](/api/r2/event-notifications#get) - [ ] Get Local Uploads Configuration - [ ] Put Local Uploads Configuration @@ -2858,11 +2858,11 @@ Please find below implemented endpoints. - [ ] Get Rate Limiting Analytics ## Rate limits for a zone - - [x] [List rate limits](/api/zones/rate-limits#list) - - [x] [Create a rate limit](/api/zones/rate-limits#create) - - [x] [Delete a rate limit](/api/zones/rate-limits#delete) - - [x] [Get a rate limit](/api/zones/rate-limits#details) - - [x] [Update a rate limit](/api/zones/rate-limits#update) + - [x] [List rate limits](/api/rate-limits#list) + - [x] [Create a rate limit](/api/rate-limits#create) + - [x] [Delete a rate limit](/api/rate-limits#delete) + - [x] [Get a rate limit](/api/rate-limits#get) + - [x] [Update a rate limit](/api/rate-limits#update) ## Recordings - [ ] Fetch all recordings for an App @@ -3153,8 +3153,8 @@ Please find below implemented endpoints. - [ ] Update Spectrum application configuration using a name for the origin ## SSL Verification - - [x] [SSL Verification Details](/api/zones/ssl#verification) - - [x] [Edit SSL Certificate Pack Validation Method](/api/zones/ssl#edit-verification) + - [x] [SSL Verification Details](/api/ssl#verification) + - [x] [Edit SSL Certificate Pack Validation Method](/api/ssl#edit-verification) ## SSO - [ ] Get all SSO connectors @@ -3314,15 +3314,15 @@ Please find below implemented endpoints. - [ ] Update a tunnel route (CIDR Endpoint) - [ ] Create a tunnel route (CIDR Endpoint) - [x] [Delete a tunnel route](/api/tunnel/routes#delete) - - [x] [Get tunnel route](/api/tunnel/routes#details) - - [x] [Update a tunnel route](/api/tunnel/routes#update) + - [x] [Get tunnel route](/api/tunnel/routes#get) + - [x] [Update a tunnel route](/api/tunnel/routes#edit) ## Tunnel Virtual Network - [x] [List virtual networks](/api/tunnel/virtual-networks#list) - [x] [Create a virtual network](/api/tunnel/virtual-networks#create) - [x] [Delete a virtual network](/api/tunnel/virtual-networks#delete) - - [x] [Get a virtual network](/api/tunnel/virtual-networks#details) - - [x] [Update a virtual network](/api/tunnel/virtual-networks#update) + - [x] [Get a virtual network](/api/tunnel/virtual-networks#get) + - [x] [Update a virtual network](/api/tunnel/virtual-networks#edit) ## Turnstile - [ ] List Turnstile Widgets @@ -3333,8 +3333,8 @@ Please find below implemented endpoints. - [ ] Rotate Secret for a Turnstile Widget ## Universal SSL Settings for a Zone - - [x] [Universal SSL Settings Details](/api/zones/ssl#universal-ssl-settings) - - [x] [Edit Universal SSL Settings](/api/zones/ssl#update-universal-ssl-settings) + - [x] [Universal SSL Settings Details](/api/ssl#universal-settings) + - [x] [Edit Universal SSL Settings](/api/ssl#edit-universal-settings) ## URL Intelligence - [ ] Get URL Intelligence @@ -3837,8 +3837,8 @@ Please find below implemented endpoints. - [x] [List Zones](/api/zones#list) - [x] [Create Zone](/api/zones#create) - [x] [Delete Zone](/api/zones#delete) - - [x] [Zone Details](/api/zones#details) - - [x] [Edit Zone](/api/zones#update) + - [x] [Zone Details](/api/zones#get) + - [x] [Edit Zone](/api/zones#edit) - [x] [Rerun the Activation Check](/api/zones#activation-check) - [x] [Purge Cached Content](/api/zones#purge-cached-content) @@ -3860,10 +3860,10 @@ Please find below implemented endpoints. - [ ] Change Origin Max HTTP Version Setting ## Zone Cloud Connector Rules GET - - [x] [Rules](/api/zones/cloud-conenctor-rules#get) + - [x] [Rules](/api/cloud-connector#get) ## Zone Cloud Connector Rules PUT - - [x] [Put Rules](/api/zones/cloud-conenctor-rules#update) + - [x] [Put Rules](/api/cloud-connector#update) ## Zone Environments - [ ] List zone environments @@ -3879,11 +3879,11 @@ Please find below implemented endpoints. - [x] [Create Zone Hold](/api/zones/holds#create) ## Zone Lockdown - - [x] [List Zone Lockdown rules](/api/zones/lockdown#list) - - [x] [Create a Zone Lockdown rule](/api/zones/lockdown#create) - - [x] [Delete a Zone Lockdown rule](/api/zones/lockdown#delete) - - [x] [Get a Zone Lockdown rule](/api/zones/lockdown#details) - - [x] [Update a Zone Lockdown rule](/api/zones/lockdown#update) + - [x] [List Zone Lockdown rules](/api/lockdown#list) + - [x] [Create a Zone Lockdown rule](/api/lockdown#create) + - [x] [Delete a Zone Lockdown rule](/api/lockdown#delete) + - [x] [Get a Zone Lockdown rule](/api/lockdown#get) + - [x] [Update a Zone Lockdown rule](/api/lockdown#update) ## Zone Rate Plan - [ ] List Available Plans @@ -3891,14 +3891,14 @@ Please find below implemented endpoints. - [ ] List Available Rate Plans ## Zone Rulesets - - [x] [List zone rulesets](/api/zones/rulesets#list) - - [x] [Create a zone ruleset](/api/zones/rulesets#create) + - [x] [List zone rulesets](/api/rulesets#list) + - [x] [Create a zone ruleset](/api/rulesets#create) - [ ] Get a zone entry point ruleset - [ ] Update a zone entry point ruleset - [ ] List a zone entry point ruleset's versions - [ ] Get a zone entry point ruleset version - - [x] [Delete a zone ruleset](/api/zones/rulesets#delete) - - [x] [Get a zone ruleset](/api/zones/rulesets#details) + - [x] [Delete a zone ruleset](/api/rulesets#delete) + - [x] [Get a zone ruleset](/api/rulesets#get) - [ ] Update a zone ruleset - [ ] Create a zone ruleset rule - [ ] Delete a zone ruleset rule diff --git a/docs/package-lock.json b/docs/package-lock.json index a97e928..107ebef 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -73,6 +73,7 @@ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.25.2.tgz", "integrity": "sha512-BBt3opiCOxUr9euZ5/ro/Xv8/V7yJ5bjYMqG/C1YAo8MIKAnumZalCN+msbci3Pigy4lIQfPUpfMM27HMGaYEA==", "dev": true, + "peer": true, "dependencies": { "@ampproject/remapping": "^2.2.0", "@babel/code-frame": "^7.24.7", @@ -592,6 +593,7 @@ "url": "https://opencollective.com/csstools" } ], + "peer": true, "engines": { "node": "^14 || ^16 || >=18" }, @@ -614,6 +616,7 @@ "url": "https://opencollective.com/csstools" } ], + "peer": true, "engines": { "node": "^14 || ^16 || >=18" } @@ -2983,6 +2986,7 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-22.1.0.tgz", "integrity": "sha512-AOmuRF0R2/5j1knA3c6G3HOk523Ga+l+ZXltX8SF1+5oqcXijjfTd8fY3XRZqSihEu9XhtQnKYLmkFaoxgsJHw==", "dev": true, + "peer": true, "dependencies": { "undici-types": "~6.13.0" } @@ -3970,6 +3974,7 @@ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", "dev": true, + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -4474,6 +4479,7 @@ "url": "https://github.com/sponsors/ai" } ], + "peer": true, "dependencies": { "caniuse-lite": "^1.0.30001646", "electron-to-chromium": "^1.5.4", @@ -4734,6 +4740,7 @@ "resolved": "https://registry.npmjs.org/change-case/-/change-case-4.1.2.tgz", "integrity": "sha512-bSxY2ws9OtviILG1EiY5K7NNxkqg/JnRnFxLtKQ96JaviiIxi7djMrSd0ECT9AC+lttClmYwKw53BWpOMblo7A==", "dev": true, + "peer": true, "dependencies": { "camel-case": "^4.1.2", "capital-case": "^1.0.4", @@ -6156,6 +6163,7 @@ "resolved": "https://registry.npmjs.org/focus-trap/-/focus-trap-7.5.4.tgz", "integrity": "sha512-N7kHdlgsO/v+iD/dMoJKtsSqs5Dz/dXZVebRgJw23LDk+jMi/974zyiOYDziY2JPp8xivq9BmUGwIJMiuSBi7w==", "dev": true, + "peer": true, "dependencies": { "tabbable": "^6.2.0" } @@ -6285,6 +6293,7 @@ "resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-6.6.2.tgz", "integrity": "sha512-cJaJkxCCxC8qIIcPBF9yGxY0W/tVZS3uEISDxhYIdtk8OL93pe+6Zj7LjCqVV4dzbqcriOZ+kQ/NE4RXZHsIGA==", "dev": true, + "peer": true, "engines": { "node": ">=10" } @@ -9713,6 +9722,7 @@ "resolved": "https://registry.npmjs.org/nuxt/-/nuxt-3.12.4.tgz", "integrity": "sha512-/ddvyc2kgYYIN2UEjP8QIz48O/W3L0lZm7wChIDbOCj0vF/yLLeZHBaTb3aNvS9Hwp269nfjrm8j/mVxQK4RhA==", "dev": true, + "peer": true, "dependencies": { "@nuxt/devalue": "^2.0.2", "@nuxt/devtools": "^1.3.9", @@ -10453,6 +10463,7 @@ "url": "https://github.com/sponsors/ai" } ], + "peer": true, "dependencies": { "nanoid": "^3.3.7", "picocolors": "^1.0.1", @@ -11008,6 +11019,7 @@ "resolved": "https://registry.npmjs.org/postcss-selector-parser/-/postcss-selector-parser-6.1.1.tgz", "integrity": "sha512-b4dlw/9V8A71rLIDsSwVmak9z2DuBUB7CA1/wSdelNEzqsjoSPeADTWNO09lpH49Diy3/JIZ2bSPB1dI3LJCHg==", "dev": true, + "peer": true, "dependencies": { "cssesc": "^3.0.0", "util-deprecate": "^1.0.2" @@ -12742,6 +12754,7 @@ "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.9.tgz", "integrity": "sha512-1SEOvRr6sSdV5IDf9iC+NU4dhwdqzF4zKKq3sAbasUWHEM6lsMhX+eNN5gkPx1BvLFEnZQEUFbXnGj8Qlp83Pg==", "dev": true, + "peer": true, "dependencies": { "@alloc/quick-lru": "^5.2.0", "arg": "^5.0.2", @@ -12855,6 +12868,7 @@ "resolved": "https://registry.npmjs.org/terser/-/terser-5.31.5.tgz", "integrity": "sha512-YPmas0L0rE1UyLL/llTWA0SiDOqIcAQYLeUj7cJYzXHlRTAnMSg9pPe4VJ5PlKvTrPQsdVFuiRiwyeNlYgwh2Q==", "dev": true, + "peer": true, "dependencies": { "@jridgewell/source-map": "^0.3.3", "acorn": "^8.8.2", @@ -13041,6 +13055,7 @@ "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", "dev": true, + "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -13559,6 +13574,7 @@ "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.29.4.tgz", "integrity": "sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==", "dev": true, + "peer": true, "bin": { "rollup": "dist/bin/rollup" }, @@ -14155,6 +14171,7 @@ "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.0.tgz", "integrity": "sha512-5xokfMX0PIiwCMCMb9ZJcMyh5wbBun0zUzKib+L65vAZ8GY9ePZMXxFrHbr/Kyll2+LSCY7xtERPpxkBDKngwg==", "dev": true, + "peer": true, "dependencies": { "esbuild": "^0.21.3", "postcss": "^8.4.40", @@ -14977,6 +14994,7 @@ "resolved": "https://registry.npmjs.org/vue/-/vue-3.4.37.tgz", "integrity": "sha512-3vXvNfkKTBsSJ7JP+LyR7GBuwQuckbWvuwAid3xbqK9ppsKt/DUvfqgZ48fgOLEfpy1IacL5f8QhUVl77RaI7A==", "dev": true, + "peer": true, "dependencies": { "@vue/compiler-dom": "3.4.37", "@vue/compiler-sfc": "3.4.37", @@ -15039,6 +15057,7 @@ "resolved": "https://registry.npmjs.org/vue-router/-/vue-router-4.4.3.tgz", "integrity": "sha512-sv6wmNKx2j3aqJQDMxLFzs/u/mjA9Z5LCgy6BE0f7yFWMjrPLnS/sPNn8ARY/FXw6byV18EFutn5lTO6+UsV5A==", "dev": true, + "peer": true, "dependencies": { "@vue/devtools-api": "^6.6.3" }, diff --git a/src/Client.php b/src/Client.php index cebfa90..4715b48 100644 --- a/src/Client.php +++ b/src/Client.php @@ -16,6 +16,21 @@ * @method \Cloudflare\Endpoints\Workers workers() * @method \Cloudflare\Endpoints\Tunnel tunnel() * @method \Cloudflare\Endpoints\D1 d1() + * @method \Cloudflare\Endpoints\LoadBalancers loadBalancers() + * @method \Cloudflare\Endpoints\Rulesets rulesets() + * @method \Cloudflare\Endpoints\DNS dns() + * @method \Cloudflare\Endpoints\DNSSEC dnssec() + * @method \Cloudflare\Endpoints\PageRules pageRules() + * @method \Cloudflare\Endpoints\Lockdown lockdown() + * @method \Cloudflare\Endpoints\Ssl ssl() + * @method \Cloudflare\Endpoints\OriginCACertificates originCACertificates() + * @method \Cloudflare\Endpoints\Filters filters() + * @method \Cloudflare\Endpoints\FirewallRules firewallRules() + * @method \Cloudflare\Endpoints\AccessRules accessRules() + * @method \Cloudflare\Endpoints\RateLimits rateLimits() + * @method \Cloudflare\Endpoints\BotManagement botManagement() + * @method \Cloudflare\Endpoints\CloudConnector cloudConnector() + * @method \Cloudflare\Endpoints\R2 r2() * * @author Sergkei Melingk * @@ -66,6 +81,21 @@ public function api(string $name): AbstractEndpoint 'workers' => new Endpoints\Workers($this), 'tunnel' => new Endpoints\Tunnel($this), 'd1' => new Endpoints\D1($this), + 'loadBalancers' => new Endpoints\LoadBalancers($this), + 'rulesets' => new Endpoints\Rulesets($this), + 'dns' => new Endpoints\DNS($this), + 'dnssec' => new Endpoints\DNSSEC($this), + 'pageRules' => new Endpoints\PageRules($this), + 'lockdown' => new Endpoints\Lockdown($this), + 'ssl' => new Endpoints\Ssl($this), + 'originCACertificates' => new Endpoints\OriginCACertificates($this), + 'filters' => new Endpoints\Filters($this), + 'firewallRules' => new Endpoints\FirewallRules($this), + 'accessRules' => new Endpoints\AccessRules($this), + 'rateLimits' => new Endpoints\RateLimits($this), + 'botManagement' => new Endpoints\BotManagement($this), + 'cloudConnector' => new Endpoints\CloudConnector($this), + 'r2' => new Endpoints\R2($this), default => throw new InvalidArgumentException(sprintf('Undefined api instance called: "%s"', $name)) }; diff --git a/src/Endpoints/AbstractEndpoint.php b/src/Endpoints/AbstractEndpoint.php index f8e5965..d164712 100644 --- a/src/Endpoints/AbstractEndpoint.php +++ b/src/Endpoints/AbstractEndpoint.php @@ -5,6 +5,7 @@ use Cloudflare\Client; use Cloudflare\HttpClient\HttpClient; use Cloudflare\Exceptions\MissingArgumentException; +use Cloudflare\Exceptions\InvalidArgumentException; abstract class AbstractEndpoint { @@ -69,4 +70,35 @@ protected function requiredAnyParams(array $keys, array $values): void throw new MissingArgumentException($keys); } + + /** + * Resolve a resource path prefix for a resource scoped to either an account or a zone, + * exactly one of which must be provided. + * + * @param string|null $accountId + * @param string|null $zoneId + * + * @throws InvalidArgumentException + * @return string + */ + protected function scopePath(?string $accountId, ?string $zoneId): string + { + if (($accountId === null) === ($zoneId === null)) { + throw new InvalidArgumentException('Provide exactly one of $accountId or $zoneId.'); + } + + return $accountId !== null ? "/accounts/{$accountId}" : "/zones/{$zoneId}"; + } + + /** + * Build the optional `cf-r2-jurisdiction` header. + * + * @param string|null $jurisdiction + * + * @return array + */ + protected function jurisdictionHeader(?string $jurisdiction): array + { + return $jurisdiction === null ? [] : ['headers' => ['cf-r2-jurisdiction' => $jurisdiction]]; + } } diff --git a/src/Endpoints/Zones/AccessRules.php b/src/Endpoints/AccessRules.php similarity index 89% rename from src/Endpoints/Zones/AccessRules.php rename to src/Endpoints/AccessRules.php index abea938..93602fe 100644 --- a/src/Endpoints/Zones/AccessRules.php +++ b/src/Endpoints/AccessRules.php @@ -1,8 +1,7 @@ getHttpClient()->patch("/zones/{$zoneId}/firewall/access_rules/rules/{$ruleId}", $values); } diff --git a/src/Endpoints/Accounts.php b/src/Endpoints/Accounts.php index ddc48e9..769e4ee 100644 --- a/src/Endpoints/Accounts.php +++ b/src/Endpoints/Accounts.php @@ -6,21 +6,6 @@ use Cloudflare\Endpoints\Accounts\Roles; use Cloudflare\Endpoints\Accounts\Members; use Cloudflare\Endpoints\Accounts\AuditLogs; -use Cloudflare\Endpoints\Accounts\Rulesets; -use Cloudflare\Endpoints\Accounts\LoadBalancers; -use Cloudflare\Endpoints\Accounts\LoadBalancerMonitors; -use Cloudflare\Endpoints\Accounts\LoadBalancerPools; -use Cloudflare\Endpoints\Accounts\LoadBalancerRegions; -use Cloudflare\Endpoints\Accounts\LoadBalancerMonitorGroups; -use Cloudflare\Endpoints\Accounts\R2Buckets; -use Cloudflare\Endpoints\Accounts\R2Cors; -use Cloudflare\Endpoints\Accounts\R2Lifecycle; -use Cloudflare\Endpoints\Accounts\R2Lock; -use Cloudflare\Endpoints\Accounts\R2CustomDomains; -use Cloudflare\Endpoints\Accounts\R2ManagedDomain; -use Cloudflare\Endpoints\Accounts\R2Sippy; -use Cloudflare\Endpoints\Accounts\R2EventNotifications; -use Cloudflare\Endpoints\Accounts\R2Metrics; /** * @link https://developers.cloudflare.com/api/operations/accounts-list-accounts @@ -77,13 +62,13 @@ public function create(string $name, string $type, ?string $unit = null): Respon * * @return \Cloudflare\Contracts\ResponseInterface Account Details response. */ - public function details(string $accountId): ResponseInterface + public function get(string $accountId): ResponseInterface { return $this->getHttpClient()->get("/accounts/{$accountId}"); } /** - * Get information about a specific account that you are a member of. + * Update an existing account. * * @link https://developers.cloudflare.com/api/operations/accounts-update-account * @@ -150,154 +135,4 @@ public function auditLogs(): AuditLogs { return new AuditLogs($this->getClient()); } - - /** - * Account Rulesets - * - * @return \Cloudflare\Endpoints\Accounts\Rulesets - */ - public function rulesets(): Rulesets - { - return new Rulesets($this->getClient()); - } - - /** - * Account Load Balancers - * - * @return \Cloudflare\Endpoints\Accounts\LoadBalancers - */ - public function loadBalancers(): LoadBalancers - { - return new LoadBalancers($this->getClient()); - } - - /** - * Account Load Balancer Monitors - * - * @return \Cloudflare\Endpoints\Accounts\LoadBalancerMonitors - */ - public function loadBalancerMonitors(): LoadBalancerMonitors - { - return new LoadBalancerMonitors($this->getClient()); - } - - /** - * Account Load Balancer Pools - * - * @return \Cloudflare\Endpoints\Accounts\LoadBalancerPools - */ - public function loadBalancerPools(): LoadBalancerPools - { - return new LoadBalancerPools($this->getClient()); - } - - /** - * Account Load Balancer Regions - * - * @return \Cloudflare\Endpoints\Accounts\LoadBalancerRegions - */ - public function loadBalancerRegions(): LoadBalancerRegions - { - return new LoadBalancerRegions($this->getClient()); - } - - /** - * Account Load Balancer Monitor Groups - * - * @return \Cloudflare\Endpoints\Accounts\LoadBalancerMonitorGroups - */ - public function loadBalancerMonitorGroups(): LoadBalancerMonitorGroups - { - return new LoadBalancerMonitorGroups($this->getClient()); - } - - /** - * Account R2 Buckets - * - * @return \Cloudflare\Endpoints\Accounts\R2Buckets - */ - public function r2Buckets(): R2Buckets - { - return new R2Buckets($this->getClient()); - } - - /** - * Account R2 Bucket CORS - * - * @return \Cloudflare\Endpoints\Accounts\R2Cors - */ - public function r2Cors(): R2Cors - { - return new R2Cors($this->getClient()); - } - - /** - * Account R2 Bucket Lifecycle - * - * @return \Cloudflare\Endpoints\Accounts\R2Lifecycle - */ - public function r2Lifecycle(): R2Lifecycle - { - return new R2Lifecycle($this->getClient()); - } - - /** - * Account R2 Bucket Object Lock - * - * @return \Cloudflare\Endpoints\Accounts\R2Lock - */ - public function r2Lock(): R2Lock - { - return new R2Lock($this->getClient()); - } - - /** - * Account R2 Bucket Custom Domains - * - * @return \Cloudflare\Endpoints\Accounts\R2CustomDomains - */ - public function r2CustomDomains(): R2CustomDomains - { - return new R2CustomDomains($this->getClient()); - } - - /** - * Account R2 Bucket Managed Domain - * - * @return \Cloudflare\Endpoints\Accounts\R2ManagedDomain - */ - public function r2ManagedDomain(): R2ManagedDomain - { - return new R2ManagedDomain($this->getClient()); - } - - /** - * Account R2 Bucket Sippy - * - * @return \Cloudflare\Endpoints\Accounts\R2Sippy - */ - public function r2Sippy(): R2Sippy - { - return new R2Sippy($this->getClient()); - } - - /** - * Account R2 Bucket Event Notifications - * - * @return \Cloudflare\Endpoints\Accounts\R2EventNotifications - */ - public function r2EventNotifications(): R2EventNotifications - { - return new R2EventNotifications($this->getClient()); - } - - /** - * Account R2 Metrics - * - * @return \Cloudflare\Endpoints\Accounts\R2Metrics - */ - public function r2Metrics(): R2Metrics - { - return new R2Metrics($this->getClient()); - } } diff --git a/src/Endpoints/Accounts/LoadBalancers.php b/src/Endpoints/Accounts/LoadBalancers.php deleted file mode 100644 index db605ef..0000000 --- a/src/Endpoints/Accounts/LoadBalancers.php +++ /dev/null @@ -1,148 +0,0 @@ -getHttpClient()->get("/accounts/{$accountId}/load_balancers"); - } - - /** - * Create a new load balancer for an account. - * - * @link https://developers.cloudflare.com/api/operations/account-level-load-balancers-create-load-balancer - * - * @param string $accountId Account Identifier. - * @param array $values Values to set on the load balancer, e.g. `name`, `default_pools`, `fallback_pool`. - * - * @return ResponseInterface Create a load balancer response - */ - public function create(string $accountId, array $values): ResponseInterface - { - $this->requiredParams(['name', 'default_pools', 'fallback_pool'], $values); - - return $this->getHttpClient()->post("/accounts/{$accountId}/load_balancers", $values); - } - - /** - * Get a single configured load balancer for an account. - * - * @link https://developers.cloudflare.com/api/operations/account-level-load-balancers-load-balancer-details - * - * @param string $accountId Account Identifier. - * @param string $loadBalancerId Load Balancer Identifier. - * - * @return ResponseInterface Load balancer details response - */ - public function details(string $accountId, string $loadBalancerId): ResponseInterface - { - return $this->getHttpClient()->get("/accounts/{$accountId}/load_balancers/{$loadBalancerId}"); - } - - /** - * Update an existing load balancer for an account. - * - * @link https://developers.cloudflare.com/api/operations/account-level-load-balancers-update-load-balancer - * - * @param string $accountId Account Identifier. - * @param string $loadBalancerId Load Balancer Identifier. - * @param array $values Values to set on the load balancer, e.g. `name`, `default_pools`, `fallback_pool`. - * - * @return ResponseInterface Update a load balancer response - */ - public function update(string $accountId, string $loadBalancerId, array $values): ResponseInterface - { - $this->requiredParams(['name', 'default_pools', 'fallback_pool'], $values); - - return $this->getHttpClient()->put("/accounts/{$accountId}/load_balancers/{$loadBalancerId}", $values); - } - - /** - * Delete a load balancer for an account. - * - * @link https://developers.cloudflare.com/api/operations/account-level-load-balancers-delete-load-balancer - * - * @param string $accountId Account Identifier. - * @param string $loadBalancerId Load Balancer Identifier. - * - * @return ResponseInterface Delete a load balancer response - */ - public function delete(string $accountId, string $loadBalancerId): ResponseInterface - { - return $this->getHttpClient()->delete("/accounts/{$accountId}/load_balancers/{$loadBalancerId}"); - } - - /** - * Apply changes to an existing load balancer, overwriting only the supplied properties. - * - * @link https://developers.cloudflare.com/api/operations/account-load-balancers-patch-account-load-balancer - * - * @param string $accountId Account Identifier. - * @param string $loadBalancerId Load Balancer Identifier. - * @param array $values Values to patch on the load balancer. - * - * @return ResponseInterface Patch a load balancer response - */ - public function patch(string $accountId, string $loadBalancerId, array $values): ResponseInterface - { - return $this->getHttpClient()->patch("/accounts/{$accountId}/load_balancers/{$loadBalancerId}", $values); - } - - /** - * Fetches the current load balancer usage for an account. - * - * @link https://developers.cloudflare.com/api/operations/account-load-balancers-list-load-balancer-usage - * - * @param string $accountId Account Identifier. - * - * @return ResponseInterface List load balancer usage response - */ - public function usage(string $accountId): ResponseInterface - { - return $this->getHttpClient()->get("/accounts/{$accountId}/load_balancers/usage"); - } - - /** - * Search load balancing resources (Load Balancers, Pools, Monitors) by name. - * - * @link https://developers.cloudflare.com/api/operations/account-load-balancer-search-search-resources - * - * @param string $accountId Account Identifier. - * @param array $params Query Parameters, e.g. `query`, `references`, `page`, `per_page`. - * - * @return ResponseInterface Search resources response - */ - public function search(string $accountId, array $params = []): ResponseInterface - { - return $this->getHttpClient()->get("/accounts/{$accountId}/load_balancers/search", $params); - } - - /** - * Get the result of a previously requested monitor or pool preview. - * - * @link https://developers.cloudflare.com/api/operations/account-load-balancer-monitors-preview-result - * - * @param string $accountId Account Identifier. - * @param string $previewId Preview Identifier. - * - * @return ResponseInterface Preview result response - */ - public function previewResult(string $accountId, string $previewId): ResponseInterface - { - return $this->getHttpClient()->get("/accounts/{$accountId}/load_balancers/preview/{$previewId}"); - } -} diff --git a/src/Endpoints/Accounts/Members.php b/src/Endpoints/Accounts/Members.php index 0369b86..2efaa79 100644 --- a/src/Endpoints/Accounts/Members.php +++ b/src/Endpoints/Accounts/Members.php @@ -65,7 +65,7 @@ public function delete(string $accountId, string $memberId): ResponseInterface * * @return ResponseInterface Member Details response */ - public function details(string $accountId, string $memberId): ResponseInterface + public function get(string $accountId, string $memberId): ResponseInterface { return $this->getHttpClient()->get("/accounts/{$accountId}/members/{$memberId}"); } diff --git a/src/Endpoints/Accounts/Roles.php b/src/Endpoints/Accounts/Roles.php index b3540cd..31722c2 100644 --- a/src/Endpoints/Accounts/Roles.php +++ b/src/Endpoints/Accounts/Roles.php @@ -32,7 +32,7 @@ public function list(string $accountId, array $params = []): ResponseInterface * * @return ResponseInterface Role Details response */ - public function details(string $accountId, string $roleId): ResponseInterface + public function get(string $accountId, string $roleId): ResponseInterface { return $this->getHttpClient()->get("/accounts/{$accountId}/roles/{$roleId}"); } diff --git a/src/Endpoints/Accounts/Rulesets.php b/src/Endpoints/Accounts/Rulesets.php deleted file mode 100644 index 788230f..0000000 --- a/src/Endpoints/Accounts/Rulesets.php +++ /dev/null @@ -1,76 +0,0 @@ -getHttpClient()->get("/accounts/{$accountId}/rulesets"); - } - - /** - * Creates a ruleset at the account level. - * - * @link https://developers.cloudflare.com/api/operations/createAccountRuleset - * - * @param string $accountId Account Identifier. - * @param array|\Cloudflare\Configurations\Ruleset $values A ruleset object. - * - * @return \Cloudflare\Contracts\ResponseInterface A ruleset response. - */ - public function create(string $accountId, array|Ruleset $values): ResponseInterface - { - if (is_array($values)) { - $this->requiredParams(['name', 'kind', 'phase'], $values); - } else { - $values = $values->toArray(); - } - - return $this->getHttpClient()->post("/accounts/{$accountId}/rulesets", $values); - } - - /** - * Fetches the latest version of an account ruleset. - * - * @link https://developers.cloudflare.com/api/operations/getAccountRuleset - * - * @param string $accountId Account Identifier. - * @param string $rulesetId Ruleset Identifier. - * - * @return \Cloudflare\Contracts\ResponseInterface A ruleset response. - */ - public function details(string $accountId, string $rulesetId): ResponseInterface - { - return $this->getHttpClient()->get("/accounts/{$accountId}/rulesets/{$rulesetId}"); - } - - /** - * Deletes all versions of an existing account ruleset. - * - * @link https://developers.cloudflare.com/api/operations/deleteAccountRuleset - * - * @param string $accountId Account Identifier. - * @param string $rulesetId Ruleset Identifier. - * - * @return \Cloudflare\Contracts\ResponseInterface An empty response. - */ - public function delete(string $accountId, string $rulesetId): ResponseInterface - { - return $this->getHttpClient()->delete("/accounts/{$accountId}/rulesets/{$rulesetId}"); - } - -} diff --git a/src/Endpoints/Zones/BotManagement.php b/src/Endpoints/BotManagement.php similarity index 88% rename from src/Endpoints/Zones/BotManagement.php rename to src/Endpoints/BotManagement.php index da922f3..a5b9459 100644 --- a/src/Endpoints/Zones/BotManagement.php +++ b/src/Endpoints/BotManagement.php @@ -1,8 +1,7 @@ getHttpClient()->get("/zones/{$zoneId}/bot_management"); } diff --git a/src/Endpoints/Zones/CloudConnector.php b/src/Endpoints/CloudConnector.php similarity index 92% rename from src/Endpoints/Zones/CloudConnector.php rename to src/Endpoints/CloudConnector.php index 20597f0..d6a9e04 100644 --- a/src/Endpoints/Zones/CloudConnector.php +++ b/src/Endpoints/CloudConnector.php @@ -1,8 +1,7 @@ getHttpClient()->get("/accounts/{$accountId}/d1/database/{$databaseId}"); } diff --git a/src/Endpoints/Zones/DNS.php b/src/Endpoints/DNS.php similarity index 93% rename from src/Endpoints/Zones/DNS.php rename to src/Endpoints/DNS.php index 04cf885..589edf3 100644 --- a/src/Endpoints/Zones/DNS.php +++ b/src/Endpoints/DNS.php @@ -1,9 +1,8 @@ getHttpClient()->get("/zones/{$zoneId}/dns_records/{$dnsRecordId}"); } /** - * Update an existing DNS record. + * Apply changes to an existing DNS record, overwriting only the supplied properties. * Notes: * - A/AAAA records cannot exist on the same name as CNAME records. * - NS records cannot exist on the same name as any other record type. @@ -129,9 +128,9 @@ public function details(string $zoneId, string $dnsRecordId): ResponseInterface * @param string $zoneId Zone Identifier. * @param string $dnsRecordId DNS ID to update. * - * @return ResponseInterface Update DNS Record response + * @return ResponseInterface Edit DNS Record response */ - public function update(string $zoneId, string $dnsRecordId, array $values): ResponseInterface + public function edit(string $zoneId, string $dnsRecordId, array $values): ResponseInterface { $this->requiredParams(['content', 'name', 'type'], $values); @@ -139,7 +138,7 @@ public function update(string $zoneId, string $dnsRecordId, array $values): Resp } /** - * Overwrite an existing DNS record. + * Update an existing DNS record, overwriting the full configuration. * Notes: * - A/AAAA records cannot exist on the same name as CNAME records. * - NS records cannot exist on the same name as any other record type. @@ -150,9 +149,9 @@ public function update(string $zoneId, string $dnsRecordId, array $values): Resp * @param string $zoneId Zone Identifier. * @param string $dnsRecordId DNS ID to overwrite. * - * @return ResponseInterface Overwrite DNS Record response + * @return ResponseInterface Update DNS Record response */ - public function overwrite(string $zoneId, string $dnsRecordId, array $values): ResponseInterface + public function update(string $zoneId, string $dnsRecordId, array $values): ResponseInterface { $this->requiredParams(['content', 'name', 'type'], $values); diff --git a/src/Endpoints/Zones/DNSSEC.php b/src/Endpoints/DNSSEC.php similarity index 86% rename from src/Endpoints/Zones/DNSSEC.php rename to src/Endpoints/DNSSEC.php index 667c117..d63cd15 100644 --- a/src/Endpoints/Zones/DNSSEC.php +++ b/src/Endpoints/DNSSEC.php @@ -1,8 +1,7 @@ getHttpClient()->get("/zones/{$zoneId}/dnssec"); } @@ -31,9 +30,9 @@ public function details(string $zoneId): ResponseInterface * @param bool $multiSigner If true, multi-signer DNSSEC is enabled on the zone, allowing multiple providers to serve a DNSSEC-signed zone at the same time. This is required for DNSKEY records (except those automatically generated by Cloudflare) to be added to the zone. See [Multi-signer DNSSEC](https://developers.cloudflare.com/dns/dnssec/multi-signer-dnssec/) for details. * @param bool $presigned If true, allows Cloudflare to transfer in a DNSSEC-signed zone including signatures from an external provider, without requiring Cloudflare to sign any records on the fly. Note that this feature has some limitations. See [Cloudflare as Secondary](https://developers.cloudflare.com/dns/zone-setups/zone-transfers/cloudflare-as-secondary/setup/#dnssec) for details. * - * @return ResponseInterface Update DNSSEC Status response + * @return ResponseInterface Edit DNSSEC Status response */ - public function update(string $zoneId, string $status, bool $multiSigner = false, bool $presigned = false): ResponseInterface + public function edit(string $zoneId, string $status, bool $multiSigner = false, bool $presigned = false): ResponseInterface { return $this->getHttpClient()->patch("/zones/{$zoneId}/dnssec", [ 'dnssec_multi_signer' => $multiSigner, diff --git a/src/Endpoints/Zones/Filters.php b/src/Endpoints/Filters.php similarity index 94% rename from src/Endpoints/Zones/Filters.php rename to src/Endpoints/Filters.php index 89d1ec0..dd8b588 100644 --- a/src/Endpoints/Zones/Filters.php +++ b/src/Endpoints/Filters.php @@ -1,8 +1,7 @@ getHttpClient()->get("/zones/{$zoneId}/filters/{$filterId}"); } diff --git a/src/Endpoints/Zones/FirewallRules.php b/src/Endpoints/FirewallRules.php similarity index 95% rename from src/Endpoints/Zones/FirewallRules.php rename to src/Endpoints/FirewallRules.php index 7ab8e37..7b1fc11 100644 --- a/src/Endpoints/Zones/FirewallRules.php +++ b/src/Endpoints/FirewallRules.php @@ -1,8 +1,7 @@ getHttpClient()->get("/zones/{$zoneId}/firewall/rules/{$ruleId}"); } diff --git a/src/Endpoints/LoadBalancers.php b/src/Endpoints/LoadBalancers.php new file mode 100644 index 0000000..3105783 --- /dev/null +++ b/src/Endpoints/LoadBalancers.php @@ -0,0 +1,194 @@ +getHttpClient()->get("{$this->scopePath($accountId, $zoneId)}/load_balancers"); + } + + /** + * Create a new load balancer. + * + * @link https://developers.cloudflare.com/api/operations/account-level-load-balancers-create-load-balancer + * + * @param string|null $accountId Account Identifier. Provide exactly one of $accountId or $zoneId. + * @param string|null $zoneId Zone Identifier. Provide exactly one of $accountId or $zoneId. + * @param array $values Values to set on the load balancer, e.g. `name`, `default_pools`, `fallback_pool`. + * + * @return ResponseInterface Create a load balancer response + */ + public function create(?string $accountId, ?string $zoneId, array $values): ResponseInterface + { + $this->requiredParams(['name', 'default_pools', 'fallback_pool'], $values); + + return $this->getHttpClient()->post("{$this->scopePath($accountId, $zoneId)}/load_balancers", $values); + } + + /** + * Get a single configured load balancer. + * + * @link https://developers.cloudflare.com/api/operations/account-level-load-balancers-load-balancer-details + * + * @param string|null $accountId Account Identifier. Provide exactly one of $accountId or $zoneId. + * @param string|null $zoneId Zone Identifier. Provide exactly one of $accountId or $zoneId. + * @param string $loadBalancerId Load Balancer Identifier. + * + * @return ResponseInterface Load balancer details response + */ + public function get(?string $accountId, ?string $zoneId, string $loadBalancerId): ResponseInterface + { + return $this->getHttpClient()->get("{$this->scopePath($accountId, $zoneId)}/load_balancers/{$loadBalancerId}"); + } + + /** + * Update an existing load balancer, overwriting the full configuration. + * + * @link https://developers.cloudflare.com/api/operations/account-level-load-balancers-update-load-balancer + * + * @param string|null $accountId Account Identifier. Provide exactly one of $accountId or $zoneId. + * @param string|null $zoneId Zone Identifier. Provide exactly one of $accountId or $zoneId. + * @param string $loadBalancerId Load Balancer Identifier. + * @param array $values Values to set on the load balancer, e.g. `name`, `default_pools`, `fallback_pool`. + * + * @return ResponseInterface Update a load balancer response + */ + public function update(?string $accountId, ?string $zoneId, string $loadBalancerId, array $values): ResponseInterface + { + $this->requiredParams(['name', 'default_pools', 'fallback_pool'], $values); + + return $this->getHttpClient()->put("{$this->scopePath($accountId, $zoneId)}/load_balancers/{$loadBalancerId}", $values); + } + + /** + * Apply changes to an existing load balancer, overwriting only the supplied properties. + * + * @link https://developers.cloudflare.com/api/operations/account-load-balancers-patch-account-load-balancer + * + * @param string|null $accountId Account Identifier. Provide exactly one of $accountId or $zoneId. + * @param string|null $zoneId Zone Identifier. Provide exactly one of $accountId or $zoneId. + * @param string $loadBalancerId Load Balancer Identifier. + * @param array $values Values to patch on the load balancer. + * + * @return ResponseInterface Patch a load balancer response + */ + public function edit(?string $accountId, ?string $zoneId, string $loadBalancerId, array $values): ResponseInterface + { + return $this->getHttpClient()->patch("{$this->scopePath($accountId, $zoneId)}/load_balancers/{$loadBalancerId}", $values); + } + + /** + * Delete a load balancer. + * + * @link https://developers.cloudflare.com/api/operations/account-level-load-balancers-delete-load-balancer + * + * @param string|null $accountId Account Identifier. Provide exactly one of $accountId or $zoneId. + * @param string|null $zoneId Zone Identifier. Provide exactly one of $accountId or $zoneId. + * @param string $loadBalancerId Load Balancer Identifier. + * + * @return ResponseInterface Delete a load balancer response + */ + public function delete(?string $accountId, ?string $zoneId, string $loadBalancerId): ResponseInterface + { + return $this->getHttpClient()->delete("{$this->scopePath($accountId, $zoneId)}/load_balancers/{$loadBalancerId}"); + } + + /** + * Fetch the current load balancer usage for an account. + * + * @link https://developers.cloudflare.com/api/operations/account-load-balancers-list-load-balancer-usage + * + * @param string $accountId Account Identifier. + * + * @return ResponseInterface List load balancer usage response + */ + public function usage(string $accountId): ResponseInterface + { + return $this->getHttpClient()->get("/accounts/{$accountId}/load_balancers/usage"); + } + + /** + * Load Balancer Pools + * + * @return \Cloudflare\Endpoints\LoadBalancers\Pools + */ + public function pools(): Pools + { + return new Pools($this->getClient()); + } + + /** + * Load Balancer Monitors + * + * @return \Cloudflare\Endpoints\LoadBalancers\Monitors + */ + public function monitors(): Monitors + { + return new Monitors($this->getClient()); + } + + /** + * Load Balancer Monitor Groups + * + * @return \Cloudflare\Endpoints\LoadBalancers\MonitorGroups + */ + public function monitorGroups(): MonitorGroups + { + return new MonitorGroups($this->getClient()); + } + + /** + * Load Balancer Regions + * + * @return \Cloudflare\Endpoints\LoadBalancers\Regions + */ + public function regions(): Regions + { + return new Regions($this->getClient()); + } + + /** + * Load Balancer Resource Search + * + * @return \Cloudflare\Endpoints\LoadBalancers\Searches + */ + public function searches(): Searches + { + return new Searches($this->getClient()); + } + + /** + * Load Balancer Monitor/Pool Preview Results + * + * @return \Cloudflare\Endpoints\LoadBalancers\Previews + */ + public function previews(): Previews + { + return new Previews($this->getClient()); + } +} diff --git a/src/Endpoints/Accounts/LoadBalancerMonitorGroups.php b/src/Endpoints/LoadBalancers/MonitorGroups.php similarity index 93% rename from src/Endpoints/Accounts/LoadBalancerMonitorGroups.php rename to src/Endpoints/LoadBalancers/MonitorGroups.php index 1498656..8783946 100644 --- a/src/Endpoints/Accounts/LoadBalancerMonitorGroups.php +++ b/src/Endpoints/LoadBalancers/MonitorGroups.php @@ -1,11 +1,11 @@ getHttpClient()->get("/accounts/{$accountId}/load_balancers/monitor_groups/{$monitorGroupId}"); } @@ -64,13 +64,13 @@ public function details(string $accountId, string $monitorGroupId): ResponseInte * * @return ResponseInterface Patch a monitor group response */ - public function patch(string $accountId, string $monitorGroupId, array $values): ResponseInterface + public function edit(string $accountId, string $monitorGroupId, array $values): ResponseInterface { return $this->getHttpClient()->patch("/accounts/{$accountId}/load_balancers/monitor_groups/{$monitorGroupId}", $values); } /** - * Update an existing load balancer monitor group for an account. + * Update an existing load balancer monitor group for an account, overwriting the full configuration. * * @link https://developers.cloudflare.com/api/operations/account-load-balancer-monitor-groups-update-monitor-group * diff --git a/src/Endpoints/Accounts/LoadBalancerMonitors.php b/src/Endpoints/LoadBalancers/Monitors.php similarity index 92% rename from src/Endpoints/Accounts/LoadBalancerMonitors.php rename to src/Endpoints/LoadBalancers/Monitors.php index c32d8cc..1febc3d 100644 --- a/src/Endpoints/Accounts/LoadBalancerMonitors.php +++ b/src/Endpoints/LoadBalancers/Monitors.php @@ -1,11 +1,11 @@ getHttpClient()->get("/accounts/{$accountId}/load_balancers/monitors/{$monitorId}"); } /** - * Update an existing load balancer monitor for an account. + * Update an existing load balancer monitor for an account, overwriting the full configuration. * * @link https://developers.cloudflare.com/api/operations/load-balancer-monitors-update-monitor * @@ -67,6 +67,22 @@ public function update(string $accountId, string $monitorId, array $values): Res return $this->getHttpClient()->put("/accounts/{$accountId}/load_balancers/monitors/{$monitorId}", $values); } + /** + * Apply changes to an existing monitor, overwriting only the supplied properties. + * + * @link https://developers.cloudflare.com/api/operations/account-load-balancer-monitors-patch-monitor + * + * @param string $accountId Account Identifier. + * @param string $monitorId Monitor Identifier. + * @param array $values Values to patch on the monitor. + * + * @return ResponseInterface Patch a monitor response + */ + public function edit(string $accountId, string $monitorId, array $values): ResponseInterface + { + return $this->getHttpClient()->patch("/accounts/{$accountId}/load_balancers/monitors/{$monitorId}", $values); + } + /** * Delete a load balancer monitor for an account. * @@ -98,22 +114,6 @@ public function preview(string $accountId, string $monitorId, array $values = [] return $this->getHttpClient()->post("/accounts/{$accountId}/load_balancers/monitors/{$monitorId}/preview", $values); } - /** - * Apply changes to an existing monitor, overwriting only the supplied properties. - * - * @link https://developers.cloudflare.com/api/operations/account-load-balancer-monitors-patch-monitor - * - * @param string $accountId Account Identifier. - * @param string $monitorId Monitor Identifier. - * @param array $values Values to patch on the monitor. - * - * @return ResponseInterface Patch a monitor response - */ - public function patch(string $accountId, string $monitorId, array $values): ResponseInterface - { - return $this->getHttpClient()->patch("/accounts/{$accountId}/load_balancers/monitors/{$monitorId}", $values); - } - /** * List the load balancers and pools that reference a given monitor. * diff --git a/src/Endpoints/Accounts/LoadBalancerPools.php b/src/Endpoints/LoadBalancers/Pools.php similarity index 93% rename from src/Endpoints/Accounts/LoadBalancerPools.php rename to src/Endpoints/LoadBalancers/Pools.php index 526ba5b..ee7ecb1 100644 --- a/src/Endpoints/Accounts/LoadBalancerPools.php +++ b/src/Endpoints/LoadBalancers/Pools.php @@ -1,11 +1,11 @@ getHttpClient()->get("/accounts/{$accountId}/load_balancers/pools/{$poolId}"); } /** - * Update an existing load balancer pool for an account. + * Update an existing load balancer pool for an account, overwriting the full configuration. * * @link https://developers.cloudflare.com/api/operations/load-balancer-pools-update-pool * @@ -72,80 +72,80 @@ public function update(string $accountId, string $poolId, array $values): Respon } /** - * Delete a load balancer pool for an account. + * Apply changes to an existing pool, overwriting only the supplied properties. * - * @link https://developers.cloudflare.com/api/operations/load-balancer-pools-delete-pool + * @link https://developers.cloudflare.com/api/operations/account-load-balancer-pools-patch-pool * * @param string $accountId Account Identifier. * @param string $poolId Pool Identifier. + * @param array $values Values to patch on the pool. * - * @return ResponseInterface Delete a pool response + * @return ResponseInterface Patch a pool response */ - public function delete(string $accountId, string $poolId): ResponseInterface + public function edit(string $accountId, string $poolId, array $values): ResponseInterface { - return $this->getHttpClient()->delete("/accounts/{$accountId}/load_balancers/pools/{$poolId}"); + return $this->getHttpClient()->patch("/accounts/{$accountId}/load_balancers/pools/{$poolId}", $values); } /** - * Fetch the latest pool health status for a single pool. + * Apply changes to a number of existing pools, overwriting the supplied properties. Returns the list of affected pools. * - * @link https://developers.cloudflare.com/api/operations/load-balancer-pools-pool-health-details + * @link https://developers.cloudflare.com/api/operations/account-load-balancer-pools-patch-pools * * @param string $accountId Account Identifier. - * @param string $poolId Pool Identifier. + * @param array $values List of pool patches to apply, each identified by `id`. * - * @return ResponseInterface Pool health details response + * @return ResponseInterface Patch pools response */ - public function health(string $accountId, string $poolId): ResponseInterface + public function bulkEdit(string $accountId, array $values): ResponseInterface { - return $this->getHttpClient()->get("/accounts/{$accountId}/load_balancers/pools/{$poolId}/health"); + return $this->getHttpClient()->patch("/accounts/{$accountId}/load_balancers/pools", $values); } /** - * Preview pool health using the specified monitor and show the effective response. + * Delete a load balancer pool for an account. * - * @link https://developers.cloudflare.com/api/operations/load-balancer-pools-preview-pool + * @link https://developers.cloudflare.com/api/operations/load-balancer-pools-delete-pool * * @param string $accountId Account Identifier. * @param string $poolId Pool Identifier. - * @param array $values The monitor details to run the preview with. * - * @return ResponseInterface Preview pool response + * @return ResponseInterface Delete a pool response */ - public function preview(string $accountId, string $poolId, array $values = []): ResponseInterface + public function delete(string $accountId, string $poolId): ResponseInterface { - return $this->getHttpClient()->post("/accounts/{$accountId}/load_balancers/pools/{$poolId}/preview", $values); + return $this->getHttpClient()->delete("/accounts/{$accountId}/load_balancers/pools/{$poolId}"); } /** - * Apply changes to an existing pool, overwriting only the supplied properties. + * Fetch the latest pool health status for a single pool. * - * @link https://developers.cloudflare.com/api/operations/account-load-balancer-pools-patch-pool + * @link https://developers.cloudflare.com/api/operations/load-balancer-pools-pool-health-details * * @param string $accountId Account Identifier. * @param string $poolId Pool Identifier. - * @param array $values Values to patch on the pool. * - * @return ResponseInterface Patch a pool response + * @return ResponseInterface Pool health details response */ - public function patch(string $accountId, string $poolId, array $values): ResponseInterface + public function health(string $accountId, string $poolId): ResponseInterface { - return $this->getHttpClient()->patch("/accounts/{$accountId}/load_balancers/pools/{$poolId}", $values); + return $this->getHttpClient()->get("/accounts/{$accountId}/load_balancers/pools/{$poolId}/health"); } /** - * Apply changes to a number of existing pools, overwriting the supplied properties. Returns the list of affected pools. + * Preview pool health using the specified monitor and show the effective response. * - * @link https://developers.cloudflare.com/api/operations/account-load-balancer-pools-patch-pools + * @link https://developers.cloudflare.com/api/operations/load-balancer-pools-preview-pool * * @param string $accountId Account Identifier. - * @param array $values List of pool patches to apply, each identified by `id`. + * @param string $poolId Pool Identifier. + * @param array $values The monitor details to run the preview with. * - * @return ResponseInterface Patch pools response + * @return ResponseInterface Preview pool response */ - public function patchMultiplePools(string $accountId, array $values): ResponseInterface + public function preview(string $accountId, string $poolId, array $values = []): ResponseInterface { - return $this->getHttpClient()->patch("/accounts/{$accountId}/load_balancers/pools", $values); + return $this->getHttpClient()->post("/accounts/{$accountId}/load_balancers/pools/{$poolId}/preview", $values); } /** diff --git a/src/Endpoints/LoadBalancers/Previews.php b/src/Endpoints/LoadBalancers/Previews.php new file mode 100644 index 0000000..064d007 --- /dev/null +++ b/src/Endpoints/LoadBalancers/Previews.php @@ -0,0 +1,24 @@ +getHttpClient()->get("/accounts/{$accountId}/load_balancers/preview/{$previewId}"); + } +} diff --git a/src/Endpoints/Accounts/LoadBalancerRegions.php b/src/Endpoints/LoadBalancers/Regions.php similarity index 85% rename from src/Endpoints/Accounts/LoadBalancerRegions.php rename to src/Endpoints/LoadBalancers/Regions.php index 704b9b5..4480b4e 100644 --- a/src/Endpoints/Accounts/LoadBalancerRegions.php +++ b/src/Endpoints/LoadBalancers/Regions.php @@ -1,11 +1,11 @@ getHttpClient()->get("/accounts/{$accountId}/load_balancers/regions/{$regionId}"); } diff --git a/src/Endpoints/LoadBalancers/Searches.php b/src/Endpoints/LoadBalancers/Searches.php new file mode 100644 index 0000000..c4b6f46 --- /dev/null +++ b/src/Endpoints/LoadBalancers/Searches.php @@ -0,0 +1,24 @@ +getHttpClient()->get("/accounts/{$accountId}/load_balancers/search", $params); + } +} diff --git a/src/Endpoints/Zones/Lockdown.php b/src/Endpoints/Lockdown.php similarity index 96% rename from src/Endpoints/Zones/Lockdown.php rename to src/Endpoints/Lockdown.php index 5b56565..b8b29b2 100644 --- a/src/Endpoints/Zones/Lockdown.php +++ b/src/Endpoints/Lockdown.php @@ -1,8 +1,7 @@ getHttpClient()->get("/zones/{$zoneId}/firewall/lockdowns/{$lockdownId}"); } diff --git a/src/Endpoints/Zones/OriginCACertificates.php b/src/Endpoints/OriginCACertificates.php similarity index 94% rename from src/Endpoints/Zones/OriginCACertificates.php rename to src/Endpoints/OriginCACertificates.php index 6d8c3cf..8aeede5 100644 --- a/src/Endpoints/Zones/OriginCACertificates.php +++ b/src/Endpoints/OriginCACertificates.php @@ -1,8 +1,7 @@ getHttpClient()->get("/certificates/{$certificateId}"); } diff --git a/src/Endpoints/Zones/PageRules.php b/src/Endpoints/PageRules.php similarity index 90% rename from src/Endpoints/Zones/PageRules.php rename to src/Endpoints/PageRules.php index 06d5db0..57903ee 100644 --- a/src/Endpoints/Zones/PageRules.php +++ b/src/Endpoints/PageRules.php @@ -1,8 +1,7 @@ getHttpClient()->get("/zones/{$zoneId}/pagerules/{$pageRuleId}"); } @@ -84,7 +83,7 @@ public function details(string $zoneId, string $pageRuleId): ResponseInterface * * @return \Cloudflare\Contracts\ResponseInterface Edit a Page Rule response */ - public function update(string $zoneId, string $pageRuleId, array|PageRule $values): ResponseInterface + public function edit(string $zoneId, string $pageRuleId, array|PageRule $values): ResponseInterface { if (is_array($values)) { $this->requiredParams(['actions', 'targets'], $values); @@ -104,9 +103,9 @@ public function update(string $zoneId, string $pageRuleId, array|PageRule $value * @param string $pageRuleId Page Rule Identifier. * @param array|\Cloudflare\Configurations\Zones\PageRule $values Values to set on Page Rule. * - * @return \Cloudflare\Contracts\ResponseInterface Overwrite Page Rule response + * @return \Cloudflare\Contracts\ResponseInterface Update Page Rule response */ - public function overwrite(string $zoneId, string $pageRuleId, PageRule|array $values): ResponseInterface + public function update(string $zoneId, string $pageRuleId, PageRule|array $values): ResponseInterface { if (is_array($values)) { $this->requiredParams(['actions', 'targets'], $values); diff --git a/src/Endpoints/R2.php b/src/Endpoints/R2.php new file mode 100644 index 0000000..2bcf50b --- /dev/null +++ b/src/Endpoints/R2.php @@ -0,0 +1,106 @@ +getClient()); + } + + /** + * R2 Bucket CORS + * + * @return \Cloudflare\Endpoints\R2\Cors + */ + public function cors(): Cors + { + return new Cors($this->getClient()); + } + + /** + * R2 Bucket Lifecycle + * + * @return \Cloudflare\Endpoints\R2\Lifecycle + */ + public function lifecycle(): Lifecycle + { + return new Lifecycle($this->getClient()); + } + + /** + * R2 Bucket Object Lock + * + * @return \Cloudflare\Endpoints\R2\Lock + */ + public function lock(): Lock + { + return new Lock($this->getClient()); + } + + /** + * R2 Bucket Custom Domains + * + * @return \Cloudflare\Endpoints\R2\CustomDomains + */ + public function customDomains(): CustomDomains + { + return new CustomDomains($this->getClient()); + } + + /** + * R2 Bucket Managed Domain + * + * @return \Cloudflare\Endpoints\R2\ManagedDomain + */ + public function managedDomain(): ManagedDomain + { + return new ManagedDomain($this->getClient()); + } + + /** + * R2 Bucket Sippy + * + * @return \Cloudflare\Endpoints\R2\Sippy + */ + public function sippy(): Sippy + { + return new Sippy($this->getClient()); + } + + /** + * R2 Bucket Event Notifications + * + * @return \Cloudflare\Endpoints\R2\EventNotifications + */ + public function eventNotifications(): EventNotifications + { + return new EventNotifications($this->getClient()); + } + + /** + * R2 Metrics + * + * @return \Cloudflare\Endpoints\R2\Metrics + */ + public function metrics(): Metrics + { + return new Metrics($this->getClient()); + } +} diff --git a/src/Endpoints/Accounts/R2Buckets.php b/src/Endpoints/R2/Buckets.php similarity index 84% rename from src/Endpoints/Accounts/R2Buckets.php rename to src/Endpoints/R2/Buckets.php index 2388f32..f51c1c5 100644 --- a/src/Endpoints/Accounts/R2Buckets.php +++ b/src/Endpoints/R2/Buckets.php @@ -1,24 +1,12 @@ ['cf-r2-jurisdiction' => $jurisdiction]]; - } - /** * Returns a list of buckets for an account. * @@ -64,13 +52,13 @@ public function create(string $accountId, array $values, ?string $jurisdiction = * * @return ResponseInterface Bucket details response */ - public function details(string $accountId, string $bucketName, ?string $jurisdiction = null): ResponseInterface + public function get(string $accountId, string $bucketName, ?string $jurisdiction = null): ResponseInterface { return $this->getHttpClient()->get("/accounts/{$accountId}/r2/buckets/{$bucketName}", null, $this->jurisdictionHeader($jurisdiction)); } /** - * Update the storage class of an existing bucket. + * Apply changes to the storage class of an existing bucket. * * @link https://developers.cloudflare.com/api/operations/r2-update-bucket * @@ -79,9 +67,9 @@ public function details(string $accountId, string $bucketName, ?string $jurisdic * @param string $storageClass Storage class to set on the bucket, e.g. `Standard` or `InfrequentAccess`. * @param string|null $jurisdiction Jurisdiction where objects in this bucket are guaranteed to be stored. * - * @return ResponseInterface Update a bucket response + * @return ResponseInterface Edit a bucket response */ - public function update(string $accountId, string $bucketName, string $storageClass, ?string $jurisdiction = null): ResponseInterface + public function edit(string $accountId, string $bucketName, string $storageClass, ?string $jurisdiction = null): ResponseInterface { $options = $this->jurisdictionHeader($jurisdiction); $options['headers'] = array_merge($options['headers'] ?? [], [ diff --git a/src/Endpoints/Accounts/R2Cors.php b/src/Endpoints/R2/Cors.php similarity index 81% rename from src/Endpoints/Accounts/R2Cors.php rename to src/Endpoints/R2/Cors.php index 10f6a02..64507c2 100644 --- a/src/Endpoints/Accounts/R2Cors.php +++ b/src/Endpoints/R2/Cors.php @@ -1,24 +1,12 @@ ['cf-r2-jurisdiction' => $jurisdiction]]; - } - /** * Get the CORS configuration for a bucket. * @@ -30,7 +18,7 @@ private function jurisdictionHeader(?string $jurisdiction): array * * @return ResponseInterface CORS configuration response */ - public function details(string $accountId, string $bucketName, ?string $jurisdiction = null): ResponseInterface + public function get(string $accountId, string $bucketName, ?string $jurisdiction = null): ResponseInterface { return $this->getHttpClient()->get("/accounts/{$accountId}/r2/buckets/{$bucketName}/cors", null, $this->jurisdictionHeader($jurisdiction)); } diff --git a/src/Endpoints/Accounts/R2CustomDomains.php b/src/Endpoints/R2/CustomDomains.php similarity index 88% rename from src/Endpoints/Accounts/R2CustomDomains.php rename to src/Endpoints/R2/CustomDomains.php index d1e113b..1775a03 100644 --- a/src/Endpoints/Accounts/R2CustomDomains.php +++ b/src/Endpoints/R2/CustomDomains.php @@ -1,24 +1,12 @@ ['cf-r2-jurisdiction' => $jurisdiction]]; - } - /** * List custom domains for a bucket. * @@ -66,7 +54,7 @@ public function create(string $accountId, string $bucketName, array $values, ?st * * @return ResponseInterface Custom domain details response */ - public function details(string $accountId, string $bucketName, string $domain, ?string $jurisdiction = null): ResponseInterface + public function get(string $accountId, string $bucketName, string $domain, ?string $jurisdiction = null): ResponseInterface { return $this->getHttpClient()->get("/accounts/{$accountId}/r2/buckets/{$bucketName}/domains/custom/{$domain}", null, $this->jurisdictionHeader($jurisdiction)); } diff --git a/src/Endpoints/Accounts/R2EventNotifications.php b/src/Endpoints/R2/EventNotifications.php similarity index 86% rename from src/Endpoints/Accounts/R2EventNotifications.php rename to src/Endpoints/R2/EventNotifications.php index 8667b95..47d38a6 100644 --- a/src/Endpoints/Accounts/R2EventNotifications.php +++ b/src/Endpoints/R2/EventNotifications.php @@ -1,24 +1,12 @@ ['cf-r2-jurisdiction' => $jurisdiction]]; - } - /** * Read the event notification configuration for a bucket, listing rules for all configured queues. * @@ -47,7 +35,7 @@ public function list(string $accountId, string $bucketName, ?string $jurisdictio * * @return ResponseInterface Queue configuration response */ - public function details(string $accountId, string $bucketName, string $queueId, ?string $jurisdiction = null): ResponseInterface + public function get(string $accountId, string $bucketName, string $queueId, ?string $jurisdiction = null): ResponseInterface { return $this->getHttpClient()->get("/accounts/{$accountId}/event_notifications/r2/{$bucketName}/configuration/queues/{$queueId}", null, $this->jurisdictionHeader($jurisdiction)); } diff --git a/src/Endpoints/Accounts/R2Lifecycle.php b/src/Endpoints/R2/Lifecycle.php similarity index 75% rename from src/Endpoints/Accounts/R2Lifecycle.php rename to src/Endpoints/R2/Lifecycle.php index 8f07f4d..da415af 100644 --- a/src/Endpoints/Accounts/R2Lifecycle.php +++ b/src/Endpoints/R2/Lifecycle.php @@ -1,24 +1,12 @@ ['cf-r2-jurisdiction' => $jurisdiction]]; - } - /** * Get the lifecycle configuration for a bucket. * @@ -30,7 +18,7 @@ private function jurisdictionHeader(?string $jurisdiction): array * * @return ResponseInterface Lifecycle configuration response */ - public function details(string $accountId, string $bucketName, ?string $jurisdiction = null): ResponseInterface + public function get(string $accountId, string $bucketName, ?string $jurisdiction = null): ResponseInterface { return $this->getHttpClient()->get("/accounts/{$accountId}/r2/buckets/{$bucketName}/lifecycle", null, $this->jurisdictionHeader($jurisdiction)); } diff --git a/src/Endpoints/Accounts/R2Lock.php b/src/Endpoints/R2/Lock.php similarity index 75% rename from src/Endpoints/Accounts/R2Lock.php rename to src/Endpoints/R2/Lock.php index 90399f9..dfdf3ad 100644 --- a/src/Endpoints/Accounts/R2Lock.php +++ b/src/Endpoints/R2/Lock.php @@ -1,24 +1,12 @@ ['cf-r2-jurisdiction' => $jurisdiction]]; - } - /** * Get the object lock configuration for a bucket. * @@ -30,7 +18,7 @@ private function jurisdictionHeader(?string $jurisdiction): array * * @return ResponseInterface Lock configuration response */ - public function details(string $accountId, string $bucketName, ?string $jurisdiction = null): ResponseInterface + public function get(string $accountId, string $bucketName, ?string $jurisdiction = null): ResponseInterface { return $this->getHttpClient()->get("/accounts/{$accountId}/r2/buckets/{$bucketName}/lock", null, $this->jurisdictionHeader($jurisdiction)); } diff --git a/src/Endpoints/Accounts/R2ManagedDomain.php b/src/Endpoints/R2/ManagedDomain.php similarity index 75% rename from src/Endpoints/Accounts/R2ManagedDomain.php rename to src/Endpoints/R2/ManagedDomain.php index 19ae2d4..3e9dda7 100644 --- a/src/Endpoints/Accounts/R2ManagedDomain.php +++ b/src/Endpoints/R2/ManagedDomain.php @@ -1,24 +1,12 @@ ['cf-r2-jurisdiction' => $jurisdiction]]; - } - /** * Get the managed (`r2.dev`) domain configuration for a bucket. * @@ -30,7 +18,7 @@ private function jurisdictionHeader(?string $jurisdiction): array * * @return ResponseInterface Managed domain details response */ - public function details(string $accountId, string $bucketName, ?string $jurisdiction = null): ResponseInterface + public function get(string $accountId, string $bucketName, ?string $jurisdiction = null): ResponseInterface { return $this->getHttpClient()->get("/accounts/{$accountId}/r2/buckets/{$bucketName}/domains/managed", null, $this->jurisdictionHeader($jurisdiction)); } diff --git a/src/Endpoints/Accounts/R2Metrics.php b/src/Endpoints/R2/Metrics.php similarity index 88% rename from src/Endpoints/Accounts/R2Metrics.php rename to src/Endpoints/R2/Metrics.php index cb8e905..af111eb 100644 --- a/src/Endpoints/Accounts/R2Metrics.php +++ b/src/Endpoints/R2/Metrics.php @@ -1,11 +1,11 @@ ['cf-r2-jurisdiction' => $jurisdiction]]; - } - /** * Get the Sippy configuration for a bucket. * @@ -30,7 +18,7 @@ private function jurisdictionHeader(?string $jurisdiction): array * * @return ResponseInterface Sippy configuration response */ - public function details(string $accountId, string $bucketName, ?string $jurisdiction = null): ResponseInterface + public function get(string $accountId, string $bucketName, ?string $jurisdiction = null): ResponseInterface { return $this->getHttpClient()->get("/accounts/{$accountId}/r2/buckets/{$bucketName}/sippy", null, $this->jurisdictionHeader($jurisdiction)); } diff --git a/src/Endpoints/Zones/RateLimits.php b/src/Endpoints/RateLimits.php similarity index 94% rename from src/Endpoints/Zones/RateLimits.php rename to src/Endpoints/RateLimits.php index 8401da1..631e66b 100644 --- a/src/Endpoints/Zones/RateLimits.php +++ b/src/Endpoints/RateLimits.php @@ -1,8 +1,7 @@ getHttpClient()->get("/zones/{$zoneId}/rate_limits/{$rateLimitId}"); } diff --git a/src/Endpoints/Rulesets.php b/src/Endpoints/Rulesets.php new file mode 100644 index 0000000..c4c129b --- /dev/null +++ b/src/Endpoints/Rulesets.php @@ -0,0 +1,95 @@ +getHttpClient()->get("{$this->scopePath($accountId, $zoneId)}/rulesets"); + } + + /** + * Creates a ruleset. + * + * @link https://developers.cloudflare.com/api/operations/createAccountRuleset + * + * @param string|null $accountId Account Identifier. Provide exactly one of $accountId or $zoneId. + * @param string|null $zoneId Zone Identifier. Provide exactly one of $accountId or $zoneId. + * @param array|\Cloudflare\Configurations\Ruleset $values A ruleset object. + * + * @return ResponseInterface A ruleset response. + */ + public function create(?string $accountId, ?string $zoneId, array|Ruleset $values): ResponseInterface + { + if (is_array($values)) { + $this->requiredParams(['name', 'kind', 'phase'], $values); + } else { + $values = $values->toArray(); + } + + return $this->getHttpClient()->post("{$this->scopePath($accountId, $zoneId)}/rulesets", $values); + } + + /** + * Fetches the latest version of a ruleset. + * + * @link https://developers.cloudflare.com/api/operations/getAccountRuleset + * + * @param string|null $accountId Account Identifier. Provide exactly one of $accountId or $zoneId. + * @param string|null $zoneId Zone Identifier. Provide exactly one of $accountId or $zoneId. + * @param string $rulesetId Ruleset Identifier. + * + * @return ResponseInterface A ruleset response. + */ + public function get(?string $accountId, ?string $zoneId, string $rulesetId): ResponseInterface + { + return $this->getHttpClient()->get("{$this->scopePath($accountId, $zoneId)}/rulesets/{$rulesetId}"); + } + + /** + * Deletes all versions of an existing ruleset. + * + * @link https://developers.cloudflare.com/api/operations/deleteAccountRuleset + * + * @param string|null $accountId Account Identifier. Provide exactly one of $accountId or $zoneId. + * @param string|null $zoneId Zone Identifier. Provide exactly one of $accountId or $zoneId. + * @param string $rulesetId Ruleset Identifier. + * + * @return ResponseInterface An empty response. + */ + public function delete(?string $accountId, ?string $zoneId, string $rulesetId): ResponseInterface + { + return $this->getHttpClient()->delete("{$this->scopePath($accountId, $zoneId)}/rulesets/{$rulesetId}"); + } + + /** + * Ruleset Rules + * + * @return \Cloudflare\Endpoints\Rulesets\Rules + */ + public function rules(): Rules + { + return new Rules($this->getClient()); + } +} diff --git a/src/Endpoints/Rulesets/Rules.php b/src/Endpoints/Rulesets/Rules.php new file mode 100644 index 0000000..ae4ce18 --- /dev/null +++ b/src/Endpoints/Rulesets/Rules.php @@ -0,0 +1,33 @@ +requiredParams(['name', 'kind', 'phase', 'rules'], $values); + } else { + $values = $values->toArray(); + } + + return $this->getHttpClient()->post("{$this->scopePath($accountId, $zoneId)}/rulesets/{$rulesetId}/rules", $values); + } +} diff --git a/src/Endpoints/Zones/Ssl.php b/src/Endpoints/Ssl.php similarity index 93% rename from src/Endpoints/Zones/Ssl.php rename to src/Endpoints/Ssl.php index 853a41d..c8a9007 100644 --- a/src/Endpoints/Zones/Ssl.php +++ b/src/Endpoints/Ssl.php @@ -1,8 +1,7 @@ getHttpClient()->patch("/zones/{$zoneId}/ssl/universal/settings", [ 'enabled' => $enabled, diff --git a/src/Endpoints/Tunnel/Routes.php b/src/Endpoints/Tunnel/Routes.php index 20b365e..edeb2c7 100644 --- a/src/Endpoints/Tunnel/Routes.php +++ b/src/Endpoints/Tunnel/Routes.php @@ -86,7 +86,7 @@ public function create(string $accountId, string $network, ?string $virtualNetwo * * @return \Cloudflare\Contracts\ResponseInterface Get a tunnel route response */ - public function details(string $accountId, string $routeId): ResponseInterface + public function get(string $accountId, string $routeId): ResponseInterface { return $this->getHttpClient()->get("/accounts/{$accountId}/teamnet/routes/{$routeId}"); } @@ -100,7 +100,7 @@ public function details(string $accountId, string $routeId): ResponseInterface * * @return \Cloudflare\Contracts\ResponseInterface Update a tunnel route response */ - public function update(string $accountId, string $routeId, array $values = []): ResponseInterface + public function edit(string $accountId, string $routeId, array $values = []): ResponseInterface { return $this->getHttpClient()->patch("/accounts/{$accountId}/teamnet/routes/{$routeId}", $values); } diff --git a/src/Endpoints/Tunnel/VirtualNetworks.php b/src/Endpoints/Tunnel/VirtualNetworks.php index 197553c..adf05eb 100644 --- a/src/Endpoints/Tunnel/VirtualNetworks.php +++ b/src/Endpoints/Tunnel/VirtualNetworks.php @@ -60,7 +60,7 @@ public function create(string $accountId, string $name, bool $isDefault = false, * * @return \Cloudflare\Contracts\ResponseInterface A virtual network response. */ - public function details(string $accountId, string $virtualNetworkId): ResponseInterface + public function get(string $accountId, string $virtualNetworkId): ResponseInterface { return $this->getHttpClient()->get("/accounts/{$accountId}/teamnet/virtual_networks/{$virtualNetworkId}"); } @@ -76,7 +76,7 @@ public function details(string $accountId, string $virtualNetworkId): ResponseIn * * @return \Cloudflare\Contracts\ResponseInterface Update a virtual network response */ - public function update(string $accountId, string $virtualNetworkId, array $values = []): ResponseInterface + public function edit(string $accountId, string $virtualNetworkId, array $values = []): ResponseInterface { return $this->getHttpClient()->patch("/accounts/{$accountId}/teamnet/virtual_networks/{$virtualNetworkId}", $values); } diff --git a/src/Endpoints/Workers/Deployments.php b/src/Endpoints/Workers/Deployments.php index 4647216..060eecf 100644 --- a/src/Endpoints/Workers/Deployments.php +++ b/src/Endpoints/Workers/Deployments.php @@ -18,7 +18,7 @@ class Deployments extends AbstractEndpoint * * @return \Cloudflare\Contracts\ResponseInterface List Deployments response */ - public function get(string $accountId, string $scriptMame): ResponseInterface + public function list(string $accountId, string $scriptMame): ResponseInterface { return $this->getHttpClient()->get("/accounts/{$accountId}/workers/scripts/{$scriptMame}/deployments"); } diff --git a/src/Endpoints/Workers/Domains.php b/src/Endpoints/Workers/Domains.php index c270421..c5ad01d 100644 --- a/src/Endpoints/Workers/Domains.php +++ b/src/Endpoints/Workers/Domains.php @@ -17,7 +17,7 @@ class Domains extends AbstractEndpoint * * @return ResponseInterface List Domains response */ - public function get(string $accountId, array $params = []): ResponseInterface + public function list(string $accountId, array $params = []): ResponseInterface { return $this->getHttpClient()->get("/accounts/{$accountId}/workers/domains", $params); } @@ -64,7 +64,7 @@ public function detach(string $accountId, string $domainId): ResponseInterface * * @return ResponseInterface Get a Domain response */ - public function domain(string $accountId, string $domainId): ResponseInterface + public function get(string $accountId, string $domainId): ResponseInterface { return $this->getHttpClient()->get("/accounts/{$accountId}/workers/domains/{$domainId}"); } diff --git a/src/Endpoints/Workers/KV.php b/src/Endpoints/Workers/KV.php index 52e0bf8..72ca740 100644 --- a/src/Endpoints/Workers/KV.php +++ b/src/Endpoints/Workers/KV.php @@ -50,7 +50,7 @@ public function create(string $accountId, string $title): ResponseInterface * * @return ResponseInterface Get a Namespace response */ - public function details(string $accountId, string $namespaceId): ResponseInterface + public function get(string $accountId, string $namespaceId): ResponseInterface { return $this->getHttpClient()->get("/accounts/{$accountId}/storage/kv/namespaces/{$namespaceId}"); } diff --git a/src/Endpoints/Workers/Logs.php b/src/Endpoints/Workers/Logs.php index 7d3179d..487bafb 100644 --- a/src/Endpoints/Workers/Logs.php +++ b/src/Endpoints/Workers/Logs.php @@ -17,7 +17,7 @@ class Logs extends AbstractEndpoint * * @return ResponseInterface List Tails response */ - public function get(string $accountId, string $scriptName): ResponseInterface + public function list(string $accountId, string $scriptName): ResponseInterface { return $this->getHttpClient()->get("/accounts/{$accountId}/workers/scripts/{$scriptName}/tails"); } diff --git a/src/Endpoints/Workers/Routes.php b/src/Endpoints/Workers/Routes.php index a2f6149..e2b70c0 100644 --- a/src/Endpoints/Workers/Routes.php +++ b/src/Endpoints/Workers/Routes.php @@ -16,7 +16,7 @@ class Routes extends AbstractEndpoint * * @return ResponseInterface List available Workers Routes response. */ - public function get(string $zoneId, array $params = []): ResponseInterface + public function list(string $zoneId, array $params = []): ResponseInterface { return $this->getHttpClient()->get("/zones/{$zoneId}/workers/routes", $params); } @@ -48,7 +48,7 @@ public function create(string $zoneId, array $values): ResponseInterface * * @return ResponseInterface Get Route response */ - public function details(string $zoneId, string $routeId): ResponseInterface + public function get(string $zoneId, string $routeId): ResponseInterface { return $this->getHttpClient()->get("/zones/{$zoneId}/workers/routes/{$routeId}"); } diff --git a/src/Endpoints/Workers/Scripts.php b/src/Endpoints/Workers/Scripts.php index 6e297a3..59dc8df 100644 --- a/src/Endpoints/Workers/Scripts.php +++ b/src/Endpoints/Workers/Scripts.php @@ -17,7 +17,7 @@ class Scripts extends AbstractEndpoint * * @return ResponseInterface List Workers response */ - public function get(string $accountId): ResponseInterface + public function list(string $accountId): ResponseInterface { return $this->getHttpClient()->get("/accounts/{$accountId}/workers/scripts"); } diff --git a/src/Endpoints/Workers/Versions.php b/src/Endpoints/Workers/Versions.php index 8af213a..37fffc7 100644 --- a/src/Endpoints/Workers/Versions.php +++ b/src/Endpoints/Workers/Versions.php @@ -52,7 +52,7 @@ public function upload(string $accountId, string $scriptName): ResponseInterface * * @return ResponseInterface Get Version Detail response */ - public function details(string $accountId, string $scriptName, string $versionId): ResponseInterface + public function get(string $accountId, string $scriptName, string $versionId): ResponseInterface { return $this->getHttpClient()->get("/accounts/{$accountId}/workers/scripts/{$scriptName}/versions/{$versionId}"); } diff --git a/src/Endpoints/Zones.php b/src/Endpoints/Zones.php index c2e3997..57b2ca4 100644 --- a/src/Endpoints/Zones.php +++ b/src/Endpoints/Zones.php @@ -3,23 +3,7 @@ namespace Cloudflare\Endpoints; use Cloudflare\Contracts\ResponseInterface; -use Cloudflare\Endpoints\Zones\Cache; -use Cloudflare\Endpoints\Zones\CloudConnector; -use Cloudflare\Endpoints\Zones\DNS; -use Cloudflare\Endpoints\Zones\DNSSEC; -use Cloudflare\Endpoints\Zones\PageRules; -use Cloudflare\Endpoints\Zones\Hold; -use Cloudflare\Endpoints\Zones\Lockdown; -use Cloudflare\Endpoints\Zones\Rulesets; -use Cloudflare\Endpoints\Zones\Rules; -use Cloudflare\Endpoints\Zones\Ssl; -use Cloudflare\Endpoints\Zones\OriginCACertificates; -use Cloudflare\Endpoints\Zones\Filters; -use Cloudflare\Endpoints\Zones\FirewallRules; -use Cloudflare\Endpoints\Zones\AccessRules; -use Cloudflare\Endpoints\Zones\RateLimits; -use Cloudflare\Endpoints\Zones\BotManagement; -use Cloudflare\Endpoints\Zones\LoadBalancers; +use Cloudflare\Endpoints\Zones\Holds; use Cloudflare\Configurations\Zones\CachePurge; /** @@ -79,7 +63,7 @@ public function create(string $accountId, string $name, string $type = 'full'): * * @return \Cloudflare\Contracts\ResponseInterface Zone Details response. */ - public function details(string $zoneId): ResponseInterface + public function get(string $zoneId): ResponseInterface { return $this->getHttpClient()->get("/zones/{$zoneId}"); } @@ -109,7 +93,7 @@ public function delete(string $zoneId): ResponseInterface * * @return \Cloudflare\Contracts\ResponseInterface */ - public function update(string $zoneId, string $type, array $vanityNameServers = []): ResponseInterface + public function edit(string $zoneId, string $type, array $vanityNameServers = []): ResponseInterface { $options = [ @@ -159,172 +143,13 @@ public function purge(string $zoneId, array|CachePurge $purgeBy): ResponseInterf return $this->getHttpClient()->post("/zones/{$zoneId}/purge_cache", $purgeBy); } - /** - * Zone cache settings - * - * @return \Cloudflare\Endpoints\Zones\Cache - */ - public function cache(): Cache - { - return new Cache($this->getClient()); - } - - /** - * Zone Cloud Connector rules - * - * @return \Cloudflare\Endpoints\Zones\CloudConnector - */ - public function cloudConnector(): CloudConnector - { - return new CloudConnector($this->getClient()); - } - - /** - * Zone DNS - * - * @return \Cloudflare\Endpoints\Zones\DNS - */ - public function dns(): DNS - { - return new DNS($this->getClient()); - } - - /** - * Zone DNSSEC - * - * @return \Cloudflare\Endpoints\Zones\DNSSEC - */ - public function dnssec(): DNSSEC - { - return new DNSSEC($this->getClient()); - } - - /** - * Zone PageRules - * - * @return \Cloudflare\Endpoints\Zones\PageRules - */ - public function pageRules(): PageRules - { - return new PageRules($this->getClient()); - } - /** * Zone Holds * - * @return \Cloudflare\Endpoints\Zones\Hold - */ - public function holds(): Hold - { - return new Hold($this->getClient()); - } - - /** - * Zone Lockdown - * - * @return \Cloudflare\Endpoints\Zones\Lockdown - */ - public function lockdowns(): Lockdown - { - return new Lockdown($this->getClient()); - } - - /** - * Zone Rulesets - * - * @return \Cloudflare\Endpoints\Zones\Rulesets - */ - public function rulesets(): Rulesets - { - return new Rulesets($this->getClient()); - } - - /** - * Zone Rules - * @return \Cloudflare\Endpoints\Zones\Rules - */ - public function rules(): Rules - { - return new Rules($this->getClient()); - } - - /** - * Zone SSL/TLS settings - * - * @return \Cloudflare\Endpoints\Zones\Ssl - */ - public function ssl(): Ssl - { - return new Ssl($this->getClient()); - } - - /** - * Zone Origin CA Certificates - * - * @return \Cloudflare\Endpoints\Zones\OriginCACertificates - */ - public function originCACertificates(): OriginCACertificates - { - return new OriginCACertificates($this->getClient()); - } - - /** - * Zone Filters - * - * @return \Cloudflare\Endpoints\Zones\Filters - */ - public function filters(): Filters - { - return new Filters($this->getClient()); - } - - /** - * Zone Firewall Rules - * - * @return \Cloudflare\Endpoints\Zones\FirewallRules - */ - public function firewallRules(): FirewallRules - { - return new FirewallRules($this->getClient()); - } - - /** - * Zone IP Access Rules - * - * @return \Cloudflare\Endpoints\Zones\AccessRules - */ - public function accessRules(): AccessRules - { - return new AccessRules($this->getClient()); - } - - /** - * Zone Rate Limits - * - * @return \Cloudflare\Endpoints\Zones\RateLimits - */ - public function rateLimits(): RateLimits - { - return new RateLimits($this->getClient()); - } - - /** - * Zone Bot Management - * - * @return \Cloudflare\Endpoints\Zones\BotManagement - */ - public function botManagement(): BotManagement - { - return new BotManagement($this->getClient()); - } - - /** - * Zone Load Balancers - * - * @return \Cloudflare\Endpoints\Zones\LoadBalancers + * @return \Cloudflare\Endpoints\Zones\Holds */ - public function loadBalancers(): LoadBalancers + public function holds(): Holds { - return new LoadBalancers($this->getClient()); + return new Holds($this->getClient()); } } diff --git a/src/Endpoints/Zones/Cache.php b/src/Endpoints/Zones/Cache.php deleted file mode 100644 index fb9d6a8..0000000 --- a/src/Endpoints/Zones/Cache.php +++ /dev/null @@ -1,9 +0,0 @@ -getHttpClient()->get("/zones/{$zoneId}/hold"); } diff --git a/src/Endpoints/Zones/LoadBalancers.php b/src/Endpoints/Zones/LoadBalancers.php deleted file mode 100644 index f63112f..0000000 --- a/src/Endpoints/Zones/LoadBalancers.php +++ /dev/null @@ -1,104 +0,0 @@ -getHttpClient()->get("/zones/{$zoneId}/load_balancers"); - } - - /** - * Create a new load balancer for a zone. - * - * @link https://developers.cloudflare.com/api/operations/zone-level-load-balancers-create-load-balancer - * - * @param string $zoneId Zone Identifier. - * @param array $values Values to set on the load balancer, e.g. `name`, `default_pools`, `fallback_pool`. - * - * @return ResponseInterface Create a load balancer response - */ - public function create(string $zoneId, array $values): ResponseInterface - { - $this->requiredParams(['name', 'default_pools', 'fallback_pool'], $values); - - return $this->getHttpClient()->post("/zones/{$zoneId}/load_balancers", $values); - } - - /** - * Get a single configured load balancer for a zone. - * - * @link https://developers.cloudflare.com/api/operations/zone-level-load-balancers-load-balancer-details - * - * @param string $zoneId Zone Identifier. - * @param string $loadBalancerId Load Balancer Identifier. - * - * @return ResponseInterface Load balancer details response - */ - public function details(string $zoneId, string $loadBalancerId): ResponseInterface - { - return $this->getHttpClient()->get("/zones/{$zoneId}/load_balancers/{$loadBalancerId}"); - } - - /** - * Update an existing load balancer for a zone. - * - * @link https://developers.cloudflare.com/api/operations/zone-level-load-balancers-update-load-balancer - * - * @param string $zoneId Zone Identifier. - * @param string $loadBalancerId Load Balancer Identifier. - * @param array $values Values to set on the load balancer, e.g. `name`, `default_pools`, `fallback_pool`. - * - * @return ResponseInterface Update a load balancer response - */ - public function update(string $zoneId, string $loadBalancerId, array $values): ResponseInterface - { - $this->requiredParams(['name', 'default_pools', 'fallback_pool'], $values); - - return $this->getHttpClient()->put("/zones/{$zoneId}/load_balancers/{$loadBalancerId}", $values); - } - - /** - * Delete a load balancer for a zone. - * - * @link https://developers.cloudflare.com/api/operations/zone-level-load-balancers-delete-load-balancer - * - * @param string $zoneId Zone Identifier. - * @param string $loadBalancerId Load Balancer Identifier. - * - * @return ResponseInterface Delete a load balancer response - */ - public function delete(string $zoneId, string $loadBalancerId): ResponseInterface - { - return $this->getHttpClient()->delete("/zones/{$zoneId}/load_balancers/{$loadBalancerId}"); - } - - /** - * Apply changes to an existing load balancer, overwriting only the supplied properties. - * - * @link https://developers.cloudflare.com/api/operations/load-balancers-patch-load-balancer - * - * @param string $zoneId Zone Identifier. - * @param string $loadBalancerId Load Balancer Identifier. - * @param array $values Values to patch on the load balancer. - * - * @return ResponseInterface Patch a load balancer response - */ - public function patch(string $zoneId, string $loadBalancerId, array $values): ResponseInterface - { - return $this->getHttpClient()->patch("/zones/{$zoneId}/load_balancers/{$loadBalancerId}", $values); - } -} diff --git a/src/Endpoints/Zones/Rules.php b/src/Endpoints/Zones/Rules.php deleted file mode 100644 index 19c3fab..0000000 --- a/src/Endpoints/Zones/Rules.php +++ /dev/null @@ -1,21 +0,0 @@ -requiredParams(['name', 'kind', 'phase', 'rules'], $values); - } else { - $values = $values->toArray(); - } - - return $this->getHttpClient()->post("/zones/{$zoneId}/rulesets/{$rulesetId}/rules", $values); - } -} diff --git a/src/Endpoints/Zones/Rulesets.php b/src/Endpoints/Zones/Rulesets.php deleted file mode 100644 index b48cf17..0000000 --- a/src/Endpoints/Zones/Rulesets.php +++ /dev/null @@ -1,76 +0,0 @@ -getHttpClient()->get("/zones/{$zoneId}/rulesets"); - } - - /** - * Creates a ruleset at the zone level. - * - * @link https://developers.cloudflare.com/api/operations/createZoneRuleset - * - * @param string $zoneId Zone Identifier. - * @param array|\Cloudflare\Configurations\Ruleset $values A ruleset object. - * - * @return \Cloudflare\Contracts\ResponseInterface A ruleset response. - */ - public function create(string $zoneId, array|Ruleset $values): ResponseInterface - { - if (is_array($values)) { - $this->requiredParams(['name', 'kind', 'phase'], $values); - } else { - $values = $values->toArray(); - } - - return $this->getHttpClient()->post("/zones/{$zoneId}/rulesets", $values); - } - - /** - * Fetches the latest version of a zone ruleset. - * - * @link https://developers.cloudflare.com/api/operations/getZoneRuleset - * - * @param string $zoneId Zone Identifier. - * @param string $rulesetId Ruleset Identifier. - * - * @return \Cloudflare\Contracts\ResponseInterface A ruleset response. - */ - public function details(string $zoneId, string $rulesetId): ResponseInterface - { - return $this->getHttpClient()->get("/zones/{$zoneId}/rulesets/{$rulesetId}"); - } - - /** - * Deletes all versions of an existing zone ruleset. - * - * @link https://developers.cloudflare.com/api/operations/deleteZoneRuleset - * - * @param string $zoneId Zone Identifier. - * @param string $rulesetId Ruleset Identifier. - * - * @return \Cloudflare\Contracts\ResponseInterface An empty response. - */ - public function delete(string $zoneId, string $rulesetId): ResponseInterface - { - return $this->getHttpClient()->delete("/zones/{$zoneId}/rulesets/{$rulesetId}"); - } - -} diff --git a/test/Tests/D1Test.php b/test/Tests/D1Test.php index ae47d5f..465a82d 100644 --- a/test/Tests/D1Test.php +++ b/test/Tests/D1Test.php @@ -63,7 +63,7 @@ public function shouldGetDetails() new Response(200, [], json_encode(['success' => true, 'result' => ['uuid' => 'database_id']])), ]); - $response = $client->d1()->details('account_id', 'database_id'); + $response = $client->d1()->get('account_id', 'database_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); diff --git a/test/Tests/Endpoints/AccessRulesTest.php b/test/Tests/Endpoints/AccessRulesTest.php new file mode 100644 index 0000000..af1d40f --- /dev/null +++ b/test/Tests/Endpoints/AccessRulesTest.php @@ -0,0 +1,72 @@ +mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => [['id' => 'rule_id']]])), + ]); + + $response = $client->accessRules()->list('zone_id'); + + $this->assertTrue($response->successful()); + $this->assertSame('GET', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/firewall/access_rules/rules', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldCreate() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'rule_id']])), + ]); + + $response = $client->accessRules()->create('zone_id', [ + 'mode' => 'block', + 'configuration' => ['target' => 'ip', 'value' => '192.0.2.1'], + ]); + + $this->assertTrue($response->successful()); + $this->assertSame('POST', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/firewall/access_rules/rules', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldEdit() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'rule_id']])), + ]); + + $response = $client->accessRules()->edit('zone_id', 'rule_id', ['mode' => 'challenge']); + + $this->assertTrue($response->successful()); + $this->assertSame('PATCH', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/firewall/access_rules/rules/rule_id', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldDelete() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'rule_id']])), + ]); + + $response = $client->accessRules()->delete('zone_id', 'rule_id'); + + $this->assertTrue($response->successful()); + $this->assertSame('DELETE', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/firewall/access_rules/rules/rule_id', $this->lastRequest()->getUri()->getPath()); + } +} diff --git a/test/Tests/Endpoints/Accounts/MembersTest.php b/test/Tests/Endpoints/Accounts/MembersTest.php index ac36a6b..aaf2e8a 100644 --- a/test/Tests/Endpoints/Accounts/MembersTest.php +++ b/test/Tests/Endpoints/Accounts/MembersTest.php @@ -63,7 +63,7 @@ public function shouldGetDetails() new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'member_id']])), ]); - $response = $client->accounts()->members()->details('account_id', 'member_id'); + $response = $client->accounts()->members()->get('account_id', 'member_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); diff --git a/test/Tests/Endpoints/Accounts/RolesTest.php b/test/Tests/Endpoints/Accounts/RolesTest.php index df42300..8f2be20 100644 --- a/test/Tests/Endpoints/Accounts/RolesTest.php +++ b/test/Tests/Endpoints/Accounts/RolesTest.php @@ -32,7 +32,7 @@ public function shouldGetDetails() new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'role_id']])), ]); - $response = $client->accounts()->roles()->details('account_id', 'role_id'); + $response = $client->accounts()->roles()->get('account_id', 'role_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); diff --git a/test/Tests/Endpoints/AccountsTest.php b/test/Tests/Endpoints/AccountsTest.php index 5020a06..205011d 100644 --- a/test/Tests/Endpoints/AccountsTest.php +++ b/test/Tests/Endpoints/AccountsTest.php @@ -66,7 +66,7 @@ public function shouldGetDetails() new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'account_id']])), ]); - $response = $client->accounts()->details('account_id'); + $response = $client->accounts()->get('account_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); diff --git a/test/Tests/Endpoints/BotManagementTest.php b/test/Tests/Endpoints/BotManagementTest.php new file mode 100644 index 0000000..7b5be29 --- /dev/null +++ b/test/Tests/Endpoints/BotManagementTest.php @@ -0,0 +1,41 @@ +mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => ['fight_mode' => true]])), + ]); + + $response = $client->botManagement()->get('zone_id'); + + $this->assertTrue($response->successful()); + $this->assertSame('GET', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/bot_management', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldUpdate() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => ['fight_mode' => false]])), + ]); + + $response = $client->botManagement()->update('zone_id', ['fight_mode' => false]); + + $this->assertTrue($response->successful()); + $this->assertSame('PUT', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/bot_management', $this->lastRequest()->getUri()->getPath()); + } +} diff --git a/test/Tests/Endpoints/Zones/CloudConnectorTest.php b/test/Tests/Endpoints/CloudConnectorTest.php similarity index 75% rename from test/Tests/Endpoints/Zones/CloudConnectorTest.php rename to test/Tests/Endpoints/CloudConnectorTest.php index 21d8182..d9232e8 100644 --- a/test/Tests/Endpoints/Zones/CloudConnectorTest.php +++ b/test/Tests/Endpoints/CloudConnectorTest.php @@ -1,11 +1,11 @@ mockClient([ - new Response(200, [], json_encode(['success' => true, 'result' => [['id' => 'rule_id']]])), + new Response(200, [], json_encode(['success' => true, 'result' => []])), ]); - $response = $client->zones()->cloudConnector()->get('zone_id'); + $response = $client->cloudConnector()->get('zone_id'); $this->assertTrue($response->successful()); - $this->assertSame('rule_id', $response->json('result.0.id')); $this->assertSame('GET', $this->lastRequest()->getMethod()); $this->assertSame('/client/v4/zones/zone_id/cloud_connector/rules', $this->lastRequest()->getUri()->getPath()); } @@ -30,14 +29,14 @@ public function shouldGet() public function shouldUpdate() { $client = $this->mockClient([ - new Response(200, [], json_encode(['success' => true, 'result' => [['id' => 'rule_id']]])), + new Response(200, [], json_encode(['success' => true, 'result' => []])), ]); - $response = $client->zones()->cloudConnector()->update('zone_id', [ + $response = $client->cloudConnector()->update('zone_id', [ 'name' => 'my rule', 'expression' => 'true', 'provider' => 'aws_s3', - 'parameters' => ['host' => 'example.com'], + 'enabled' => true, ]); $this->assertTrue($response->successful()); diff --git a/test/Tests/Endpoints/Zones/DNSSECTest.php b/test/Tests/Endpoints/DNSSECTest.php similarity index 70% rename from test/Tests/Endpoints/Zones/DNSSECTest.php rename to test/Tests/Endpoints/DNSSECTest.php index 8b4b426..0aca323 100644 --- a/test/Tests/Endpoints/Zones/DNSSECTest.php +++ b/test/Tests/Endpoints/DNSSECTest.php @@ -1,48 +1,42 @@ mockClient([ new Response(200, [], json_encode(['success' => true, 'result' => ['status' => 'active']])), ]); - $response = $client->zones()->dnssec()->details('zone_id'); + $response = $client->dnssec()->get('zone_id'); $this->assertTrue($response->successful()); - $this->assertSame('active', $response->json('result.status')); $this->assertSame('GET', $this->lastRequest()->getMethod()); $this->assertSame('/client/v4/zones/zone_id/dnssec', $this->lastRequest()->getUri()->getPath()); } #[Test] - public function shouldUpdate() + public function shouldEdit() { $client = $this->mockClient([ new Response(200, [], json_encode(['success' => true, 'result' => ['status' => 'active']])), ]); - $response = $client->zones()->dnssec()->update('zone_id', 'active', true, true); + $response = $client->dnssec()->edit('zone_id', 'active'); $this->assertTrue($response->successful()); $this->assertSame('PATCH', $this->lastRequest()->getMethod()); $this->assertSame('/client/v4/zones/zone_id/dnssec', $this->lastRequest()->getUri()->getPath()); - $this->assertSame([ - 'dnssec_multi_signer' => true, - 'dnssec_presigned' => true, - 'status' => 'active', - ], json_decode((string) $this->lastRequest()->getBody(), true)); } #[Test] @@ -52,7 +46,7 @@ public function shouldDelete() new Response(200, [], json_encode(['success' => true, 'result' => null])), ]); - $response = $client->zones()->dnssec()->delete('zone_id'); + $response = $client->dnssec()->delete('zone_id'); $this->assertTrue($response->successful()); $this->assertSame('DELETE', $this->lastRequest()->getMethod()); diff --git a/test/Tests/Endpoints/Zones/DNSTest.php b/test/Tests/Endpoints/DNSTest.php similarity index 77% rename from test/Tests/Endpoints/Zones/DNSTest.php rename to test/Tests/Endpoints/DNSTest.php index 57cfe19..174f79c 100644 --- a/test/Tests/Endpoints/Zones/DNSTest.php +++ b/test/Tests/Endpoints/DNSTest.php @@ -1,12 +1,11 @@ true, 'result' => []])), ]); - $response = $client->zones()->dns()->scan('zone_id'); + $response = $client->dns()->scan('zone_id'); $this->assertTrue($response->successful()); $this->assertSame('POST', $this->lastRequest()->getMethod()); @@ -33,7 +32,7 @@ public function shouldList() new Response(200, [], json_encode(['success' => true, 'result' => [['id' => 'record_id']]])), ]); - $response = $client->zones()->dns()->list('zone_id'); + $response = $client->dns()->list('zone_id'); $this->assertTrue($response->successful()); $this->assertSame('record_id', $response->json('result.0.id')); @@ -48,10 +47,10 @@ public function shouldCreate() new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'record_id']])), ]); - $response = $client->zones()->dns()->create('zone_id', [ - 'type' => 'A', + $response = $client->dns()->create('zone_id', [ + 'content' => '192.0.2.1', 'name' => 'example.com', - 'content' => '127.0.0.1', + 'type' => 'A', ]); $this->assertTrue($response->successful()); @@ -59,24 +58,14 @@ public function shouldCreate() $this->assertSame('/client/v4/zones/zone_id/dns_records', $this->lastRequest()->getUri()->getPath()); } - #[Test] - public function shouldThrowWhenCreateMissingRequiredParams() - { - $client = $this->mockClient([]); - - $this->expectException(MissingArgumentException::class); - - $client->zones()->dns()->create('zone_id', ['name' => 'example.com']); - } - #[Test] public function shouldExport() { $client = $this->mockClient([ - new Response(200, [], 'example.com. 300 IN A 127.0.0.1'), + new Response(200, [], 'zone file contents'), ]); - $response = $client->zones()->dns()->export('zone_id'); + $response = $client->dns()->export('zone_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); @@ -90,7 +79,7 @@ public function shouldImport() new Response(200, [], json_encode(['success' => true, 'result' => ['recs_added' => 1]])), ]); - $response = $client->zones()->dns()->import('zone_id', 'example.com. 300 IN A 127.0.0.1'); + $response = $client->dns()->import('zone_id', 'example.com. 1 IN A 192.0.2.1'); $this->assertTrue($response->successful()); $this->assertSame('POST', $this->lastRequest()->getMethod()); @@ -98,13 +87,13 @@ public function shouldImport() } #[Test] - public function shouldGetDetails() + public function shouldGet() { $client = $this->mockClient([ new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'record_id']])), ]); - $response = $client->zones()->dns()->details('zone_id', 'record_id'); + $response = $client->dns()->get('zone_id', 'record_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); @@ -112,16 +101,16 @@ public function shouldGetDetails() } #[Test] - public function shouldUpdate() + public function shouldEdit() { $client = $this->mockClient([ new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'record_id']])), ]); - $response = $client->zones()->dns()->update('zone_id', 'record_id', [ - 'type' => 'A', + $response = $client->dns()->edit('zone_id', 'record_id', [ + 'content' => '192.0.2.2', 'name' => 'example.com', - 'content' => '127.0.0.1', + 'type' => 'A', ]); $this->assertTrue($response->successful()); @@ -130,16 +119,16 @@ public function shouldUpdate() } #[Test] - public function shouldOverwrite() + public function shouldUpdate() { $client = $this->mockClient([ new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'record_id']])), ]); - $response = $client->zones()->dns()->overwrite('zone_id', 'record_id', [ - 'type' => 'A', + $response = $client->dns()->update('zone_id', 'record_id', [ + 'content' => '192.0.2.2', 'name' => 'example.com', - 'content' => '127.0.0.1', + 'type' => 'A', ]); $this->assertTrue($response->successful()); @@ -154,7 +143,7 @@ public function shouldDelete() new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'record_id']])), ]); - $response = $client->zones()->dns()->delete('zone_id', 'record_id'); + $response = $client->dns()->delete('zone_id', 'record_id'); $this->assertTrue($response->successful()); $this->assertSame('DELETE', $this->lastRequest()->getMethod()); diff --git a/test/Tests/Endpoints/FiltersTest.php b/test/Tests/Endpoints/FiltersTest.php new file mode 100644 index 0000000..77f5149 --- /dev/null +++ b/test/Tests/Endpoints/FiltersTest.php @@ -0,0 +1,83 @@ +mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => [['id' => 'filter_id']]])), + ]); + + $response = $client->filters()->list('zone_id'); + + $this->assertTrue($response->successful()); + $this->assertSame('GET', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/filters', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldGet() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'filter_id']])), + ]); + + $response = $client->filters()->get('zone_id', 'filter_id'); + + $this->assertTrue($response->successful()); + $this->assertSame('GET', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/filters/filter_id', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldCreate() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => [['id' => 'filter_id']]])), + ]); + + $response = $client->filters()->create('zone_id', [['expression' => 'ip.src eq 127.0.0.1']]); + + $this->assertTrue($response->successful()); + $this->assertSame('POST', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/filters', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldUpdate() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'filter_id']])), + ]); + + $response = $client->filters()->update('zone_id', 'filter_id', ['expression' => 'ip.src eq 127.0.0.1']); + + $this->assertTrue($response->successful()); + $this->assertSame('PUT', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/filters/filter_id', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldDelete() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'filter_id']])), + ]); + + $response = $client->filters()->delete('zone_id', 'filter_id'); + + $this->assertTrue($response->successful()); + $this->assertSame('DELETE', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/filters/filter_id', $this->lastRequest()->getUri()->getPath()); + } +} diff --git a/test/Tests/Endpoints/FirewallRulesTest.php b/test/Tests/Endpoints/FirewallRulesTest.php new file mode 100644 index 0000000..5141031 --- /dev/null +++ b/test/Tests/Endpoints/FirewallRulesTest.php @@ -0,0 +1,102 @@ +mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => [['id' => 'rule_id']]])), + ]); + + $response = $client->firewallRules()->list('zone_id'); + + $this->assertTrue($response->successful()); + $this->assertSame('GET', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/firewall/rules', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldGet() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'rule_id']])), + ]); + + $response = $client->firewallRules()->get('zone_id', 'rule_id'); + + $this->assertTrue($response->successful()); + $this->assertSame('GET', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/firewall/rules/rule_id', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldCreate() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => [['id' => 'rule_id']]])), + ]); + + $response = $client->firewallRules()->create('zone_id', [ + ['action' => 'block', 'filter' => ['expression' => 'ip.src eq 127.0.0.1']], + ]); + + $this->assertTrue($response->successful()); + $this->assertSame('POST', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/firewall/rules', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldUpdate() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'rule_id']])), + ]); + + $response = $client->firewallRules()->update('zone_id', 'rule_id', [ + 'action' => 'block', + 'filter' => ['id' => 'filter_id'], + ]); + + $this->assertTrue($response->successful()); + $this->assertSame('PUT', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/firewall/rules/rule_id', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldUpdatePriority() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'rule_id', 'priority' => 5]])), + ]); + + $response = $client->firewallRules()->updatePriority('zone_id', 'rule_id', 5); + + $this->assertTrue($response->successful()); + $this->assertSame('PATCH', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/firewall/rules/rule_id', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldDelete() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'rule_id']])), + ]); + + $response = $client->firewallRules()->delete('zone_id', 'rule_id'); + + $this->assertTrue($response->successful()); + $this->assertSame('DELETE', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/firewall/rules/rule_id', $this->lastRequest()->getUri()->getPath()); + } +} diff --git a/test/Tests/Endpoints/Accounts/LoadBalancerMonitorGroupsTest.php b/test/Tests/Endpoints/LoadBalancers/MonitorGroupsTest.php similarity index 86% rename from test/Tests/Endpoints/Accounts/LoadBalancerMonitorGroupsTest.php rename to test/Tests/Endpoints/LoadBalancers/MonitorGroupsTest.php index 2778d20..e336c03 100644 --- a/test/Tests/Endpoints/Accounts/LoadBalancerMonitorGroupsTest.php +++ b/test/Tests/Endpoints/LoadBalancers/MonitorGroupsTest.php @@ -1,13 +1,13 @@ accounts()->loadBalancerMonitorGroups()->list('account_id'); + $response = $client->loadBalancers()->monitorGroups()->list('account_id'); $this->assertTrue($response->successful()); $this->assertSame('monitor_group_id', $response->json('result.0.id')); @@ -44,7 +44,7 @@ public function shouldCreateMonitorGroup() ])), ]); - $response = $client->accounts()->loadBalancerMonitorGroups()->create('account_id', [ + $response = $client->loadBalancers()->monitorGroups()->create('account_id', [ 'description' => 'Primary datacenter monitors', 'members' => [ ['monitor_id' => 'monitor_id', 'enabled' => true, 'monitoring_only' => false, 'must_be_healthy' => true], @@ -70,7 +70,7 @@ public function shouldGetMonitorGroupDetails() ])), ]); - $response = $client->accounts()->loadBalancerMonitorGroups()->details('account_id', 'monitor_group_id'); + $response = $client->loadBalancers()->monitorGroups()->get('account_id', 'monitor_group_id'); $this->assertTrue($response->successful()); $this->assertSame('monitor_group_id', $response->json('result.id')); @@ -80,7 +80,7 @@ public function shouldGetMonitorGroupDetails() } #[Test] - public function shouldPatchMonitorGroup() + public function shouldEditMonitorGroup() { $client = $this->mockClient([ new Response(200, [], json_encode([ @@ -92,7 +92,7 @@ public function shouldPatchMonitorGroup() ])), ]); - $response = $client->accounts()->loadBalancerMonitorGroups()->patch('account_id', 'monitor_group_id', [ + $response = $client->loadBalancers()->monitorGroups()->edit('account_id', 'monitor_group_id', [ 'description' => 'Secondary datacenter monitors', ]); @@ -116,7 +116,7 @@ public function shouldUpdateMonitorGroup() ])), ]); - $response = $client->accounts()->loadBalancerMonitorGroups()->update('account_id', 'monitor_group_id', [ + $response = $client->loadBalancers()->monitorGroups()->update('account_id', 'monitor_group_id', [ 'description' => 'Primary datacenter monitors', 'members' => [ ['monitor_id' => 'monitor_id', 'enabled' => true, 'monitoring_only' => false, 'must_be_healthy' => true], @@ -142,7 +142,7 @@ public function shouldDeleteMonitorGroup() ])), ]); - $response = $client->accounts()->loadBalancerMonitorGroups()->delete('account_id', 'monitor_group_id'); + $response = $client->loadBalancers()->monitorGroups()->delete('account_id', 'monitor_group_id'); $this->assertTrue($response->successful()); @@ -162,7 +162,7 @@ public function shouldListMonitorGroupReferences() ])), ]); - $response = $client->accounts()->loadBalancerMonitorGroups()->references('account_id', 'monitor_group_id'); + $response = $client->loadBalancers()->monitorGroups()->references('account_id', 'monitor_group_id'); $this->assertTrue($response->successful()); $this->assertSame('pool_id', $response->json('result.0.resource_id')); diff --git a/test/Tests/Endpoints/Accounts/LoadBalancerMonitorsTest.php b/test/Tests/Endpoints/LoadBalancers/MonitorsTest.php similarity index 86% rename from test/Tests/Endpoints/Accounts/LoadBalancerMonitorsTest.php rename to test/Tests/Endpoints/LoadBalancers/MonitorsTest.php index 5815729..f86ffd2 100644 --- a/test/Tests/Endpoints/Accounts/LoadBalancerMonitorsTest.php +++ b/test/Tests/Endpoints/LoadBalancers/MonitorsTest.php @@ -1,13 +1,13 @@ accounts()->loadBalancerMonitors()->list('account_id'); + $response = $client->loadBalancers()->monitors()->list('account_id'); $this->assertTrue($response->successful()); $this->assertSame('monitor_id', $response->json('result.0.id')); @@ -44,7 +44,7 @@ public function shouldCreateMonitor() ])), ]); - $response = $client->accounts()->loadBalancerMonitors()->create('account_id', [ + $response = $client->loadBalancers()->monitors()->create('account_id', [ 'type' => 'http', 'method' => 'GET', 'path' => '/health', @@ -69,7 +69,7 @@ public function shouldGetMonitorDetails() ])), ]); - $response = $client->accounts()->loadBalancerMonitors()->details('account_id', 'monitor_id'); + $response = $client->loadBalancers()->monitors()->get('account_id', 'monitor_id'); $this->assertTrue($response->successful()); $this->assertSame('monitor_id', $response->json('result.id')); @@ -91,7 +91,7 @@ public function shouldUpdateMonitor() ])), ]); - $response = $client->accounts()->loadBalancerMonitors()->update('account_id', 'monitor_id', [ + $response = $client->loadBalancers()->monitors()->update('account_id', 'monitor_id', [ 'type' => 'http', 'method' => 'POST', ]); @@ -104,70 +104,70 @@ public function shouldUpdateMonitor() } #[Test] - public function shouldDeleteMonitor() + public function shouldEditMonitor() { $client = $this->mockClient([ new Response(200, [], json_encode([ 'success' => true, 'result' => [ 'id' => 'monitor_id', + 'method' => 'POST', ], ])), ]); - $response = $client->accounts()->loadBalancerMonitors()->delete('account_id', 'monitor_id'); + $response = $client->loadBalancers()->monitors()->edit('account_id', 'monitor_id', [ + 'method' => 'POST', + ]); $this->assertTrue($response->successful()); + $this->assertSame('POST', $response->json('result.method')); - $this->assertSame('DELETE', $this->lastRequest()->getMethod()); + $this->assertSame('PATCH', $this->lastRequest()->getMethod()); $this->assertSame('/client/v4/accounts/account_id/load_balancers/monitors/monitor_id', $this->lastRequest()->getUri()->getPath()); } #[Test] - public function shouldPreviewMonitor() + public function shouldDeleteMonitor() { $client = $this->mockClient([ new Response(200, [], json_encode([ 'success' => true, 'result' => [ - 'preview_id' => 'preview_id', + 'id' => 'monitor_id', ], ])), ]); - $response = $client->accounts()->loadBalancerMonitors()->preview('account_id', 'monitor_id', [ - 'pools' => ['pool_id'], - ]); + $response = $client->loadBalancers()->monitors()->delete('account_id', 'monitor_id'); $this->assertTrue($response->successful()); - $this->assertSame('preview_id', $response->json('result.preview_id')); - $this->assertSame('POST', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/accounts/account_id/load_balancers/monitors/monitor_id/preview', $this->lastRequest()->getUri()->getPath()); + $this->assertSame('DELETE', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/accounts/account_id/load_balancers/monitors/monitor_id', $this->lastRequest()->getUri()->getPath()); } #[Test] - public function shouldPatchMonitor() + public function shouldPreviewMonitor() { $client = $this->mockClient([ new Response(200, [], json_encode([ 'success' => true, 'result' => [ - 'id' => 'monitor_id', - 'method' => 'POST', + 'preview_id' => 'preview_id', ], ])), ]); - $response = $client->accounts()->loadBalancerMonitors()->patch('account_id', 'monitor_id', [ - 'method' => 'POST', + $response = $client->loadBalancers()->monitors()->preview('account_id', 'monitor_id', [ + 'pools' => ['pool_id'], ]); $this->assertTrue($response->successful()); - $this->assertSame('POST', $response->json('result.method')); + $this->assertSame('preview_id', $response->json('result.preview_id')); - $this->assertSame('PATCH', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/accounts/account_id/load_balancers/monitors/monitor_id', $this->lastRequest()->getUri()->getPath()); + $this->assertSame('POST', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/accounts/account_id/load_balancers/monitors/monitor_id/preview', $this->lastRequest()->getUri()->getPath()); } #[Test] @@ -182,7 +182,7 @@ public function shouldListMonitorReferences() ])), ]); - $response = $client->accounts()->loadBalancerMonitors()->references('account_id', 'monitor_id'); + $response = $client->loadBalancers()->monitors()->references('account_id', 'monitor_id'); $this->assertTrue($response->successful()); $this->assertSame('load_balancer_id', $response->json('result.0.resource_id')); diff --git a/test/Tests/Endpoints/Accounts/LoadBalancerPoolsTest.php b/test/Tests/Endpoints/LoadBalancers/PoolsTest.php similarity index 86% rename from test/Tests/Endpoints/Accounts/LoadBalancerPoolsTest.php rename to test/Tests/Endpoints/LoadBalancers/PoolsTest.php index 7b9d520..e74e135 100644 --- a/test/Tests/Endpoints/Accounts/LoadBalancerPoolsTest.php +++ b/test/Tests/Endpoints/LoadBalancers/PoolsTest.php @@ -1,13 +1,13 @@ accounts()->loadBalancerPools()->list('account_id'); + $response = $client->loadBalancers()->pools()->list('account_id'); $this->assertTrue($response->successful()); $this->assertSame('pool_id', $response->json('result.0.id')); @@ -44,7 +44,7 @@ public function shouldCreatePool() ])), ]); - $response = $client->accounts()->loadBalancerPools()->create('account_id', [ + $response = $client->loadBalancers()->pools()->create('account_id', [ 'name' => 'primary-pool', 'origins' => [ ['name' => 'origin-1', 'address' => '192.0.2.1'], @@ -70,7 +70,7 @@ public function shouldGetPoolDetails() ])), ]); - $response = $client->accounts()->loadBalancerPools()->details('account_id', 'pool_id'); + $response = $client->loadBalancers()->pools()->get('account_id', 'pool_id'); $this->assertTrue($response->successful()); $this->assertSame('pool_id', $response->json('result.id')); @@ -92,7 +92,7 @@ public function shouldUpdatePool() ])), ]); - $response = $client->accounts()->loadBalancerPools()->update('account_id', 'pool_id', [ + $response = $client->loadBalancers()->pools()->update('account_id', 'pool_id', [ 'name' => 'primary-pool', 'origins' => [ ['name' => 'origin-1', 'address' => '192.0.2.1'], @@ -108,115 +108,115 @@ public function shouldUpdatePool() } #[Test] - public function shouldDeletePool() + public function shouldEditPool() { $client = $this->mockClient([ new Response(200, [], json_encode([ 'success' => true, 'result' => [ 'id' => 'pool_id', + 'enabled' => false, ], ])), ]); - $response = $client->accounts()->loadBalancerPools()->delete('account_id', 'pool_id'); + $response = $client->loadBalancers()->pools()->edit('account_id', 'pool_id', [ + 'enabled' => false, + ]); $this->assertTrue($response->successful()); + $this->assertFalse($response->json('result.enabled')); - $this->assertSame('DELETE', $this->lastRequest()->getMethod()); + $this->assertSame('PATCH', $this->lastRequest()->getMethod()); $this->assertSame('/client/v4/accounts/account_id/load_balancers/pools/pool_id', $this->lastRequest()->getUri()->getPath()); } #[Test] - public function shouldGetPoolHealth() + public function shouldBulkEditPools() { $client = $this->mockClient([ new Response(200, [], json_encode([ 'success' => true, 'result' => [ - 'pool_id' => 'pool_id', - 'healthy' => true, + ['id' => 'pool_id', 'enabled' => false], ], ])), ]); - $response = $client->accounts()->loadBalancerPools()->health('account_id', 'pool_id'); + $response = $client->loadBalancers()->pools()->bulkEdit('account_id', [ + ['id' => 'pool_id', 'enabled' => false], + ]); $this->assertTrue($response->successful()); - $this->assertTrue($response->json('result.healthy')); + $this->assertFalse($response->json('result.0.enabled')); - $this->assertSame('GET', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/accounts/account_id/load_balancers/pools/pool_id/health', $this->lastRequest()->getUri()->getPath()); + $this->assertSame('PATCH', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/accounts/account_id/load_balancers/pools', $this->lastRequest()->getUri()->getPath()); } #[Test] - public function shouldPreviewPool() + public function shouldDeletePool() { $client = $this->mockClient([ new Response(200, [], json_encode([ 'success' => true, 'result' => [ - 'preview_id' => 'preview_id', + 'id' => 'pool_id', ], ])), ]); - $response = $client->accounts()->loadBalancerPools()->preview('account_id', 'pool_id', [ - 'monitor' => 'monitor_id', - ]); + $response = $client->loadBalancers()->pools()->delete('account_id', 'pool_id'); $this->assertTrue($response->successful()); - $this->assertSame('preview_id', $response->json('result.preview_id')); - $this->assertSame('POST', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/accounts/account_id/load_balancers/pools/pool_id/preview', $this->lastRequest()->getUri()->getPath()); + $this->assertSame('DELETE', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/accounts/account_id/load_balancers/pools/pool_id', $this->lastRequest()->getUri()->getPath()); } #[Test] - public function shouldPatchPool() + public function shouldGetPoolHealth() { $client = $this->mockClient([ new Response(200, [], json_encode([ 'success' => true, 'result' => [ - 'id' => 'pool_id', - 'enabled' => false, + 'pool_id' => 'pool_id', + 'healthy' => true, ], ])), ]); - $response = $client->accounts()->loadBalancerPools()->patch('account_id', 'pool_id', [ - 'enabled' => false, - ]); + $response = $client->loadBalancers()->pools()->health('account_id', 'pool_id'); $this->assertTrue($response->successful()); - $this->assertFalse($response->json('result.enabled')); + $this->assertTrue($response->json('result.healthy')); - $this->assertSame('PATCH', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/accounts/account_id/load_balancers/pools/pool_id', $this->lastRequest()->getUri()->getPath()); + $this->assertSame('GET', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/accounts/account_id/load_balancers/pools/pool_id/health', $this->lastRequest()->getUri()->getPath()); } #[Test] - public function shouldPatchMultiplePools() + public function shouldPreviewPool() { $client = $this->mockClient([ new Response(200, [], json_encode([ 'success' => true, 'result' => [ - ['id' => 'pool_id', 'enabled' => false], + 'preview_id' => 'preview_id', ], ])), ]); - $response = $client->accounts()->loadBalancerPools()->patchMultiplePools('account_id', [ - ['id' => 'pool_id', 'enabled' => false], + $response = $client->loadBalancers()->pools()->preview('account_id', 'pool_id', [ + 'monitor' => 'monitor_id', ]); $this->assertTrue($response->successful()); - $this->assertFalse($response->json('result.0.enabled')); + $this->assertSame('preview_id', $response->json('result.preview_id')); - $this->assertSame('PATCH', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/accounts/account_id/load_balancers/pools', $this->lastRequest()->getUri()->getPath()); + $this->assertSame('POST', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/accounts/account_id/load_balancers/pools/pool_id/preview', $this->lastRequest()->getUri()->getPath()); } #[Test] @@ -231,7 +231,7 @@ public function shouldListPoolReferences() ])), ]); - $response = $client->accounts()->loadBalancerPools()->references('account_id', 'pool_id'); + $response = $client->loadBalancers()->pools()->references('account_id', 'pool_id'); $this->assertTrue($response->successful()); $this->assertSame('load_balancer_id', $response->json('result.0.resource_id')); diff --git a/test/Tests/Endpoints/LoadBalancers/PreviewsTest.php b/test/Tests/Endpoints/LoadBalancers/PreviewsTest.php new file mode 100644 index 0000000..489073d --- /dev/null +++ b/test/Tests/Endpoints/LoadBalancers/PreviewsTest.php @@ -0,0 +1,34 @@ +mockClient([ + new Response(200, [], json_encode([ + 'success' => true, + 'result' => [ + 'preview_id' => 'preview_id', + ], + ])), + ]); + + $response = $client->loadBalancers()->previews()->get('account_id', 'preview_id'); + + $this->assertTrue($response->successful()); + $this->assertSame('preview_id', $response->json('result.preview_id')); + + $this->assertSame('GET', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/accounts/account_id/load_balancers/preview/preview_id', $this->lastRequest()->getUri()->getPath()); + } +} diff --git a/test/Tests/Endpoints/Accounts/LoadBalancerRegionsTest.php b/test/Tests/Endpoints/LoadBalancers/RegionsTest.php similarity index 84% rename from test/Tests/Endpoints/Accounts/LoadBalancerRegionsTest.php rename to test/Tests/Endpoints/LoadBalancers/RegionsTest.php index 3d64ac0..64f3462 100644 --- a/test/Tests/Endpoints/Accounts/LoadBalancerRegionsTest.php +++ b/test/Tests/Endpoints/LoadBalancers/RegionsTest.php @@ -1,13 +1,13 @@ accounts()->loadBalancerRegions()->list('account_id'); + $response = $client->loadBalancers()->regions()->list('account_id'); $this->assertTrue($response->successful()); $this->assertSame('WNAM', $response->json('result.0.region_code')); @@ -44,7 +44,7 @@ public function shouldGetRegionDetails() ])), ]); - $response = $client->accounts()->loadBalancerRegions()->details('account_id', 'WNAM'); + $response = $client->loadBalancers()->regions()->get('account_id', 'WNAM'); $this->assertTrue($response->successful()); $this->assertSame('WNAM', $response->json('result.region_code')); diff --git a/test/Tests/Endpoints/LoadBalancers/SearchesTest.php b/test/Tests/Endpoints/LoadBalancers/SearchesTest.php new file mode 100644 index 0000000..7f2d35c --- /dev/null +++ b/test/Tests/Endpoints/LoadBalancers/SearchesTest.php @@ -0,0 +1,36 @@ +mockClient([ + new Response(200, [], json_encode([ + 'success' => true, + 'result' => [ + ['id' => 'load_balancer_id'], + ], + ])), + ]); + + $response = $client->loadBalancers()->searches()->list('account_id', [ + 'query' => 'www.example.com', + ]); + + $this->assertTrue($response->successful()); + $this->assertSame('load_balancer_id', $response->json('result.0.id')); + + $this->assertSame('GET', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/accounts/account_id/load_balancers/search', $this->lastRequest()->getUri()->getPath()); + } +} diff --git a/test/Tests/Endpoints/Accounts/LoadBalancersTest.php b/test/Tests/Endpoints/LoadBalancersTest.php similarity index 66% rename from test/Tests/Endpoints/Accounts/LoadBalancersTest.php rename to test/Tests/Endpoints/LoadBalancersTest.php index 232c1cc..c244184 100644 --- a/test/Tests/Endpoints/Accounts/LoadBalancersTest.php +++ b/test/Tests/Endpoints/LoadBalancersTest.php @@ -1,8 +1,9 @@ mockClient([ new Response(200, [], json_encode([ @@ -23,7 +24,7 @@ public function shouldListLoadBalancers() ])), ]); - $response = $client->accounts()->loadBalancers()->list('account_id'); + $response = $client->loadBalancers()->list(accountId: 'account_id'); $this->assertTrue($response->successful()); $this->assertSame('load_balancer_id', $response->json('result.0.id')); @@ -33,80 +34,72 @@ public function shouldListLoadBalancers() } #[Test] - public function shouldCreateLoadBalancer() + public function shouldListLoadBalancersForZone() { $client = $this->mockClient([ new Response(200, [], json_encode([ 'success' => true, 'result' => [ - 'id' => 'load_balancer_id', + ['id' => 'load_balancer_id'], ], ])), ]); - $response = $client->accounts()->loadBalancers()->create('account_id', [ - 'name' => 'www.example.com', - 'default_pools' => ['pool_id'], - 'fallback_pool' => 'pool_id', - ]); + $response = $client->loadBalancers()->list(zoneId: 'zone_id'); $this->assertTrue($response->successful()); - $this->assertSame('load_balancer_id', $response->json('result.id')); - $this->assertSame('POST', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/accounts/account_id/load_balancers', $this->lastRequest()->getUri()->getPath()); + $this->assertSame('GET', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/load_balancers', $this->lastRequest()->getUri()->getPath()); } #[Test] - public function shouldGetLoadBalancerDetails() + public function shouldThrowWhenNeitherScopeProvided() { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'load_balancer_id', - ], - ])), - ]); + $client = $this->mockClient([]); - $response = $client->accounts()->loadBalancers()->details('account_id', 'load_balancer_id'); + $this->expectException(InvalidArgumentException::class); - $this->assertTrue($response->successful()); - $this->assertSame('load_balancer_id', $response->json('result.id')); + $client->loadBalancers()->list(); + } - $this->assertSame('GET', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/accounts/account_id/load_balancers/load_balancer_id', $this->lastRequest()->getUri()->getPath()); + #[Test] + public function shouldThrowWhenBothScopesProvided() + { + $client = $this->mockClient([]); + + $this->expectException(InvalidArgumentException::class); + + $client->loadBalancers()->list(accountId: 'account_id', zoneId: 'zone_id'); } #[Test] - public function shouldUpdateLoadBalancer() + public function shouldCreateLoadBalancerForZone() { $client = $this->mockClient([ new Response(200, [], json_encode([ 'success' => true, 'result' => [ 'id' => 'load_balancer_id', - 'enabled' => false, ], ])), ]); - $response = $client->accounts()->loadBalancers()->update('account_id', 'load_balancer_id', [ + $response = $client->loadBalancers()->create(null, 'zone_id', [ 'name' => 'www.example.com', 'default_pools' => ['pool_id'], 'fallback_pool' => 'pool_id', - 'enabled' => false, ]); $this->assertTrue($response->successful()); - $this->assertFalse($response->json('result.enabled')); + $this->assertSame('load_balancer_id', $response->json('result.id')); - $this->assertSame('PUT', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/accounts/account_id/load_balancers/load_balancer_id', $this->lastRequest()->getUri()->getPath()); + $this->assertSame('POST', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/load_balancers', $this->lastRequest()->getUri()->getPath()); } #[Test] - public function shouldDeleteLoadBalancer() + public function shouldGetLoadBalancerDetailsForAccount() { $client = $this->mockClient([ new Response(200, [], json_encode([ @@ -117,16 +110,17 @@ public function shouldDeleteLoadBalancer() ])), ]); - $response = $client->accounts()->loadBalancers()->delete('account_id', 'load_balancer_id'); + $response = $client->loadBalancers()->get('account_id', null, 'load_balancer_id'); $this->assertTrue($response->successful()); + $this->assertSame('load_balancer_id', $response->json('result.id')); - $this->assertSame('DELETE', $this->lastRequest()->getMethod()); + $this->assertSame('GET', $this->lastRequest()->getMethod()); $this->assertSame('/client/v4/accounts/account_id/load_balancers/load_balancer_id', $this->lastRequest()->getUri()->getPath()); } #[Test] - public function shouldPatchLoadBalancer() + public function shouldUpdateLoadBalancerForZone() { $client = $this->mockClient([ new Response(200, [], json_encode([ @@ -138,79 +132,82 @@ public function shouldPatchLoadBalancer() ])), ]); - $response = $client->accounts()->loadBalancers()->patch('account_id', 'load_balancer_id', [ + $response = $client->loadBalancers()->update(null, 'zone_id', 'load_balancer_id', [ + 'name' => 'www.example.com', + 'default_pools' => ['pool_id'], + 'fallback_pool' => 'pool_id', 'enabled' => false, ]); $this->assertTrue($response->successful()); $this->assertFalse($response->json('result.enabled')); - $this->assertSame('PATCH', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/accounts/account_id/load_balancers/load_balancer_id', $this->lastRequest()->getUri()->getPath()); + $this->assertSame('PUT', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/load_balancers/load_balancer_id', $this->lastRequest()->getUri()->getPath()); } #[Test] - public function shouldGetLoadBalancerUsage() + public function shouldEditLoadBalancerForAccount() { $client = $this->mockClient([ new Response(200, [], json_encode([ 'success' => true, 'result' => [ - 'load_balancers' => 1, + 'id' => 'load_balancer_id', + 'enabled' => false, ], ])), ]); - $response = $client->accounts()->loadBalancers()->usage('account_id'); + $response = $client->loadBalancers()->edit('account_id', null, 'load_balancer_id', [ + 'enabled' => false, + ]); $this->assertTrue($response->successful()); - $this->assertSame(1, $response->json('result.load_balancers')); + $this->assertFalse($response->json('result.enabled')); - $this->assertSame('GET', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/accounts/account_id/load_balancers/usage', $this->lastRequest()->getUri()->getPath()); + $this->assertSame('PATCH', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/accounts/account_id/load_balancers/load_balancer_id', $this->lastRequest()->getUri()->getPath()); } #[Test] - public function shouldSearchLoadBalancerResources() + public function shouldDeleteLoadBalancerForZone() { $client = $this->mockClient([ new Response(200, [], json_encode([ 'success' => true, 'result' => [ - ['id' => 'load_balancer_id'], + 'id' => 'load_balancer_id', ], ])), ]); - $response = $client->accounts()->loadBalancers()->search('account_id', [ - 'query' => 'www.example.com', - ]); + $response = $client->loadBalancers()->delete(null, 'zone_id', 'load_balancer_id'); $this->assertTrue($response->successful()); - $this->assertSame('load_balancer_id', $response->json('result.0.id')); - $this->assertSame('GET', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/accounts/account_id/load_balancers/search', $this->lastRequest()->getUri()->getPath()); + $this->assertSame('DELETE', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/load_balancers/load_balancer_id', $this->lastRequest()->getUri()->getPath()); } #[Test] - public function shouldGetPreviewResult() + public function shouldGetLoadBalancerUsage() { $client = $this->mockClient([ new Response(200, [], json_encode([ 'success' => true, 'result' => [ - 'preview_id' => 'preview_id', + 'load_balancers' => 1, ], ])), ]); - $response = $client->accounts()->loadBalancers()->previewResult('account_id', 'preview_id'); + $response = $client->loadBalancers()->usage('account_id'); $this->assertTrue($response->successful()); - $this->assertSame('preview_id', $response->json('result.preview_id')); + $this->assertSame(1, $response->json('result.load_balancers')); $this->assertSame('GET', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/accounts/account_id/load_balancers/preview/preview_id', $this->lastRequest()->getUri()->getPath()); + $this->assertSame('/client/v4/accounts/account_id/load_balancers/usage', $this->lastRequest()->getUri()->getPath()); } } diff --git a/test/Tests/Endpoints/Zones/LockdownTest.php b/test/Tests/Endpoints/LockdownTest.php similarity index 66% rename from test/Tests/Endpoints/Zones/LockdownTest.php rename to test/Tests/Endpoints/LockdownTest.php index cfeee96..2eaf091 100644 --- a/test/Tests/Endpoints/Zones/LockdownTest.php +++ b/test/Tests/Endpoints/LockdownTest.php @@ -1,11 +1,11 @@ true, 'result' => [['id' => 'lockdown_id']]])), ]); - $response = $client->zones()->lockdowns()->list('zone_id'); + $response = $client->lockdown()->list('zone_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); @@ -26,32 +26,17 @@ public function shouldList() } #[Test] - public function shouldCreateWithSingleIp() + public function shouldCreate() { $client = $this->mockClient([ new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'lockdown_id']])), ]); - $response = $client->zones()->lockdowns()->create('zone_id', '127.0.0.1', ['example.com/*']); + $response = $client->lockdown()->create('zone_id', '192.0.2.1', ['example.com/*']); $this->assertTrue($response->successful()); $this->assertSame('POST', $this->lastRequest()->getMethod()); - $body = json_decode((string) $this->lastRequest()->getBody(), true); - $this->assertSame('ip', $body['configurations']['target']); - } - - #[Test] - public function shouldCreateWithIpRange() - { - $client = $this->mockClient([ - new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'lockdown_id']])), - ]); - - $response = $client->zones()->lockdowns()->create('zone_id', '127.0.0.1/16', ['example.com/*']); - - $this->assertTrue($response->successful()); - $body = json_decode((string) $this->lastRequest()->getBody(), true); - $this->assertSame('ip_range', $body['configurations']['target']); + $this->assertSame('/client/v4/zones/zone_id/firewall/lockdowns', $this->lastRequest()->getUri()->getPath()); } #[Test] @@ -61,7 +46,7 @@ public function shouldGetDetails() new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'lockdown_id']])), ]); - $response = $client->zones()->lockdowns()->details('zone_id', 'lockdown_id'); + $response = $client->lockdown()->get('zone_id', 'lockdown_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); @@ -75,7 +60,7 @@ public function shouldUpdate() new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'lockdown_id']])), ]); - $response = $client->zones()->lockdowns()->update('zone_id', 'lockdown_id', '127.0.0.1', ['example.com/*']); + $response = $client->lockdown()->update('zone_id', 'lockdown_id', '192.0.2.1', ['example.com/*']); $this->assertTrue($response->successful()); $this->assertSame('PUT', $this->lastRequest()->getMethod()); @@ -89,7 +74,7 @@ public function shouldDelete() new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'lockdown_id']])), ]); - $response = $client->zones()->lockdowns()->delete('zone_id', 'lockdown_id'); + $response = $client->lockdown()->delete('zone_id', 'lockdown_id'); $this->assertTrue($response->successful()); $this->assertSame('DELETE', $this->lastRequest()->getMethod()); diff --git a/test/Tests/Endpoints/OriginCACertificatesTest.php b/test/Tests/Endpoints/OriginCACertificatesTest.php new file mode 100644 index 0000000..24e45e0 --- /dev/null +++ b/test/Tests/Endpoints/OriginCACertificatesTest.php @@ -0,0 +1,69 @@ +mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => [['id' => 'certificate_id']]])), + ]); + + $response = $client->originCACertificates()->list(); + + $this->assertTrue($response->successful()); + $this->assertSame('GET', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/certificates', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldCreate() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'certificate_id']])), + ]); + + $response = $client->originCACertificates()->create('csr', ['example.com']); + + $this->assertTrue($response->successful()); + $this->assertSame('POST', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/certificates', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldGet() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'certificate_id']])), + ]); + + $response = $client->originCACertificates()->get('certificate_id'); + + $this->assertTrue($response->successful()); + $this->assertSame('GET', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/certificates/certificate_id', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldRevoke() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'certificate_id']])), + ]); + + $response = $client->originCACertificates()->revoke('certificate_id'); + + $this->assertTrue($response->successful()); + $this->assertSame('DELETE', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/certificates/certificate_id', $this->lastRequest()->getUri()->getPath()); + } +} diff --git a/test/Tests/Endpoints/Zones/PageRulesTest.php b/test/Tests/Endpoints/PageRulesTest.php similarity index 56% rename from test/Tests/Endpoints/Zones/PageRulesTest.php rename to test/Tests/Endpoints/PageRulesTest.php index 48c734c..286132d 100644 --- a/test/Tests/Endpoints/Zones/PageRulesTest.php +++ b/test/Tests/Endpoints/PageRulesTest.php @@ -1,12 +1,11 @@ true, 'result' => []])), ]); - $response = $client->zones()->pageRules()->settings('zone_id'); + $response = $client->pageRules()->settings('zone_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); @@ -33,7 +32,7 @@ public function shouldList() new Response(200, [], json_encode(['success' => true, 'result' => [['id' => 'page_rule_id']]])), ]); - $response = $client->zones()->pageRules()->list('zone_id'); + $response = $client->pageRules()->list('zone_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); @@ -41,15 +40,15 @@ public function shouldList() } #[Test] - public function shouldCreateWithArray() + public function shouldCreate() { $client = $this->mockClient([ new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'page_rule_id']])), ]); - $response = $client->zones()->pageRules()->create('zone_id', [ - 'targets' => [['target' => 'url', 'constraint' => ['operator' => 'matches', 'value' => 'example.com/*']]], - 'actions' => [['id' => 'ssl', 'value' => 'flexible']], + $response = $client->pageRules()->create('zone_id', [ + 'targets' => [['target' => 'url', 'constraint' => ['operator' => 'matches', 'value' => '*example.com/*']]], + 'actions' => [['id' => 'always_use_https']], ]); $this->assertTrue($response->successful()); @@ -57,21 +56,6 @@ public function shouldCreateWithArray() $this->assertSame('/client/v4/zones/zone_id/pagerules', $this->lastRequest()->getUri()->getPath()); } - #[Test] - public function shouldCreateWithPageRuleObject() - { - $client = $this->mockClient([ - new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'page_rule_id']])), - ]); - - $pageRule = (new PageRule('example.com/*'))->enable()->ssl('flexible'); - - $response = $client->zones()->pageRules()->create('zone_id', $pageRule); - - $this->assertTrue($response->successful()); - $this->assertSame('POST', $this->lastRequest()->getMethod()); - } - #[Test] public function shouldGetDetails() { @@ -79,7 +63,7 @@ public function shouldGetDetails() new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'page_rule_id']])), ]); - $response = $client->zones()->pageRules()->details('zone_id', 'page_rule_id'); + $response = $client->pageRules()->get('zone_id', 'page_rule_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); @@ -87,15 +71,15 @@ public function shouldGetDetails() } #[Test] - public function shouldUpdateWithArray() + public function shouldEdit() { $client = $this->mockClient([ new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'page_rule_id']])), ]); - $response = $client->zones()->pageRules()->update('zone_id', 'page_rule_id', [ - 'targets' => [['target' => 'url', 'constraint' => ['operator' => 'matches', 'value' => 'example.com/*']]], - 'actions' => [['id' => 'ssl', 'value' => 'flexible']], + $response = $client->pageRules()->edit('zone_id', 'page_rule_id', [ + 'targets' => [['target' => 'url', 'constraint' => ['operator' => 'matches', 'value' => '*example.com/*']]], + 'actions' => [['id' => 'always_use_https']], ]); $this->assertTrue($response->successful()); @@ -104,30 +88,15 @@ public function shouldUpdateWithArray() } #[Test] - public function shouldUpdateWithPageRuleObject() - { - $client = $this->mockClient([ - new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'page_rule_id']])), - ]); - - $pageRule = (new PageRule('example.com/*'))->disable(); - - $response = $client->zones()->pageRules()->update('zone_id', 'page_rule_id', $pageRule); - - $this->assertTrue($response->successful()); - $this->assertSame('PATCH', $this->lastRequest()->getMethod()); - } - - #[Test] - public function shouldOverwriteWithArray() + public function shouldUpdate() { $client = $this->mockClient([ new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'page_rule_id']])), ]); - $response = $client->zones()->pageRules()->overwrite('zone_id', 'page_rule_id', [ - 'targets' => [['target' => 'url', 'constraint' => ['operator' => 'matches', 'value' => 'example.com/*']]], - 'actions' => [['id' => 'ssl', 'value' => 'flexible']], + $response = $client->pageRules()->update('zone_id', 'page_rule_id', [ + 'targets' => [['target' => 'url', 'constraint' => ['operator' => 'matches', 'value' => '*example.com/*']]], + 'actions' => [['id' => 'always_use_https']], ]); $this->assertTrue($response->successful()); @@ -135,21 +104,6 @@ public function shouldOverwriteWithArray() $this->assertSame('/client/v4/zones/zone_id/pagerules/page_rule_id', $this->lastRequest()->getUri()->getPath()); } - #[Test] - public function shouldOverwriteWithPageRuleObject() - { - $client = $this->mockClient([ - new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'page_rule_id']])), - ]); - - $pageRule = new PageRule('example.com/*'); - - $response = $client->zones()->pageRules()->overwrite('zone_id', 'page_rule_id', $pageRule); - - $this->assertTrue($response->successful()); - $this->assertSame('PUT', $this->lastRequest()->getMethod()); - } - #[Test] public function shouldDelete() { @@ -157,7 +111,7 @@ public function shouldDelete() new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'page_rule_id']])), ]); - $response = $client->zones()->pageRules()->delete('zone_id', 'page_rule_id'); + $response = $client->pageRules()->delete('zone_id', 'page_rule_id'); $this->assertTrue($response->successful()); $this->assertSame('DELETE', $this->lastRequest()->getMethod()); diff --git a/test/Tests/Endpoints/Accounts/R2BucketsTest.php b/test/Tests/Endpoints/R2/BucketsTest.php similarity index 86% rename from test/Tests/Endpoints/Accounts/R2BucketsTest.php rename to test/Tests/Endpoints/R2/BucketsTest.php index 430fe44..a034c82 100644 --- a/test/Tests/Endpoints/Accounts/R2BucketsTest.php +++ b/test/Tests/Endpoints/R2/BucketsTest.php @@ -1,13 +1,13 @@ accounts()->r2Buckets()->list('account_id'); + $response = $client->r2()->buckets()->list('account_id'); $this->assertTrue($response->successful()); $this->assertSame('my-bucket', $response->json('result.buckets.0.name')); @@ -46,7 +46,7 @@ public function shouldCreateBucket() ])), ]); - $response = $client->accounts()->r2Buckets()->create('account_id', [ + $response = $client->r2()->buckets()->create('account_id', [ 'name' => 'my-bucket', ]); @@ -69,7 +69,7 @@ public function shouldGetBucketDetails() ])), ]); - $response = $client->accounts()->r2Buckets()->details('account_id', 'my-bucket'); + $response = $client->r2()->buckets()->get('account_id', 'my-bucket'); $this->assertTrue($response->successful()); $this->assertSame('my-bucket', $response->json('result.name')); @@ -79,7 +79,7 @@ public function shouldGetBucketDetails() } #[Test] - public function shouldUpdateBucketStorageClass() + public function shouldEditBucketStorageClass() { $client = $this->mockClient([ new Response(200, [], json_encode([ @@ -91,7 +91,7 @@ public function shouldUpdateBucketStorageClass() ])), ]); - $response = $client->accounts()->r2Buckets()->update('account_id', 'my-bucket', 'InfrequentAccess'); + $response = $client->r2()->buckets()->edit('account_id', 'my-bucket', 'InfrequentAccess'); $this->assertTrue($response->successful()); $this->assertSame('InfrequentAccess', $response->json('result.storageClass')); @@ -111,7 +111,7 @@ public function shouldDeleteBucket() ])), ]); - $response = $client->accounts()->r2Buckets()->delete('account_id', 'my-bucket'); + $response = $client->r2()->buckets()->delete('account_id', 'my-bucket'); $this->assertTrue($response->successful()); @@ -129,7 +129,7 @@ public function shouldDeleteBucketWithJurisdictionHeader() ])), ]); - $response = $client->accounts()->r2Buckets()->delete('account_id', 'my-bucket', 'eu'); + $response = $client->r2()->buckets()->delete('account_id', 'my-bucket', 'eu'); $this->assertTrue($response->successful()); $this->assertSame('eu', $this->lastRequest()->getHeaderLine('cf-r2-jurisdiction')); @@ -147,7 +147,7 @@ public function shouldCreateTemporaryCredentials() ])), ]); - $response = $client->accounts()->r2Buckets()->createTemporaryCredentials('account_id', [ + $response = $client->r2()->buckets()->createTemporaryCredentials('account_id', [ 'bucket' => 'my-bucket', 'permission' => 'object-read-only', 'ttlSeconds' => 3600, diff --git a/test/Tests/Endpoints/Accounts/R2CorsTest.php b/test/Tests/Endpoints/R2/CorsTest.php similarity index 87% rename from test/Tests/Endpoints/Accounts/R2CorsTest.php rename to test/Tests/Endpoints/R2/CorsTest.php index 967d360..11be97f 100644 --- a/test/Tests/Endpoints/Accounts/R2CorsTest.php +++ b/test/Tests/Endpoints/R2/CorsTest.php @@ -1,13 +1,13 @@ accounts()->r2Cors()->details('account_id', 'my-bucket'); + $response = $client->r2()->cors()->get('account_id', 'my-bucket'); $this->assertTrue($response->successful()); $this->assertSame('rule-1', $response->json('result.rules.0.id')); @@ -48,7 +48,7 @@ public function shouldUpdateCorsConfiguration() ])), ]); - $response = $client->accounts()->r2Cors()->update('account_id', 'my-bucket', [ + $response = $client->r2()->cors()->update('account_id', 'my-bucket', [ ['id' => 'rule-1', 'allowed' => ['methods' => ['GET'], 'origins' => ['*']]], ]); @@ -70,7 +70,7 @@ public function shouldDeleteCorsConfiguration() ])), ]); - $response = $client->accounts()->r2Cors()->delete('account_id', 'my-bucket'); + $response = $client->r2()->cors()->delete('account_id', 'my-bucket'); $this->assertTrue($response->successful()); diff --git a/test/Tests/Endpoints/Accounts/R2CustomDomainsTest.php b/test/Tests/Endpoints/R2/CustomDomainsTest.php similarity index 85% rename from test/Tests/Endpoints/Accounts/R2CustomDomainsTest.php rename to test/Tests/Endpoints/R2/CustomDomainsTest.php index 7566bc3..649ed55 100644 --- a/test/Tests/Endpoints/Accounts/R2CustomDomainsTest.php +++ b/test/Tests/Endpoints/R2/CustomDomainsTest.php @@ -1,13 +1,13 @@ accounts()->r2CustomDomains()->list('account_id', 'my-bucket'); + $response = $client->r2()->customDomains()->list('account_id', 'my-bucket'); $this->assertTrue($response->successful()); $this->assertSame('assets.example.com', $response->json('result.domains.0.domain')); @@ -46,7 +46,7 @@ public function shouldCreateCustomDomain() ])), ]); - $response = $client->accounts()->r2CustomDomains()->create('account_id', 'my-bucket', [ + $response = $client->r2()->customDomains()->create('account_id', 'my-bucket', [ 'domain' => 'assets.example.com', 'zoneId' => 'zone_id', 'enabled' => true, @@ -71,7 +71,7 @@ public function shouldGetCustomDomainDetails() ])), ]); - $response = $client->accounts()->r2CustomDomains()->details('account_id', 'my-bucket', 'assets.example.com'); + $response = $client->r2()->customDomains()->get('account_id', 'my-bucket', 'assets.example.com'); $this->assertTrue($response->successful()); $this->assertSame('assets.example.com', $response->json('result.domain')); @@ -93,7 +93,7 @@ public function shouldUpdateCustomDomain() ])), ]); - $response = $client->accounts()->r2CustomDomains()->update('account_id', 'my-bucket', 'assets.example.com', [ + $response = $client->r2()->customDomains()->update('account_id', 'my-bucket', 'assets.example.com', [ 'enabled' => false, ]); @@ -114,7 +114,7 @@ public function shouldDeleteCustomDomain() ])), ]); - $response = $client->accounts()->r2CustomDomains()->delete('account_id', 'my-bucket', 'assets.example.com'); + $response = $client->r2()->customDomains()->delete('account_id', 'my-bucket', 'assets.example.com'); $this->assertTrue($response->successful()); diff --git a/test/Tests/Endpoints/Accounts/R2EventNotificationsTest.php b/test/Tests/Endpoints/R2/EventNotificationsTest.php similarity index 84% rename from test/Tests/Endpoints/Accounts/R2EventNotificationsTest.php rename to test/Tests/Endpoints/R2/EventNotificationsTest.php index 85adc46..b3cfffa 100644 --- a/test/Tests/Endpoints/Accounts/R2EventNotificationsTest.php +++ b/test/Tests/Endpoints/R2/EventNotificationsTest.php @@ -1,13 +1,13 @@ accounts()->r2EventNotifications()->list('account_id', 'my-bucket'); + $response = $client->r2()->eventNotifications()->list('account_id', 'my-bucket'); $this->assertTrue($response->successful()); $this->assertSame('queue_id', $response->json('result.queues.0.queueId')); @@ -47,7 +47,7 @@ public function shouldGetQueueConfigurationDetails() ])), ]); - $response = $client->accounts()->r2EventNotifications()->details('account_id', 'my-bucket', 'queue_id'); + $response = $client->r2()->eventNotifications()->get('account_id', 'my-bucket', 'queue_id'); $this->assertTrue($response->successful()); $this->assertSame('queue_id', $response->json('result.queueId')); @@ -66,7 +66,7 @@ public function shouldCreateConfiguration() ])), ]); - $response = $client->accounts()->r2EventNotifications()->update('account_id', 'my-bucket', 'queue_id', [ + $response = $client->r2()->eventNotifications()->update('account_id', 'my-bucket', 'queue_id', [ 'rules' => [ ['actions' => ['PutObject']], ], @@ -88,7 +88,7 @@ public function shouldDeleteConfiguration() ])), ]); - $response = $client->accounts()->r2EventNotifications()->delete('account_id', 'my-bucket', 'queue_id'); + $response = $client->r2()->eventNotifications()->delete('account_id', 'my-bucket', 'queue_id'); $this->assertTrue($response->successful()); diff --git a/test/Tests/Endpoints/Accounts/R2LifecycleTest.php b/test/Tests/Endpoints/R2/LifecycleTest.php similarity index 86% rename from test/Tests/Endpoints/Accounts/R2LifecycleTest.php rename to test/Tests/Endpoints/R2/LifecycleTest.php index b5a6132..dd26f38 100644 --- a/test/Tests/Endpoints/Accounts/R2LifecycleTest.php +++ b/test/Tests/Endpoints/R2/LifecycleTest.php @@ -1,13 +1,13 @@ accounts()->r2Lifecycle()->details('account_id', 'my-bucket'); + $response = $client->r2()->lifecycle()->get('account_id', 'my-bucket'); $this->assertTrue($response->successful()); $this->assertSame('rule-1', $response->json('result.rules.0.id')); @@ -48,7 +48,7 @@ public function shouldUpdateLifecycleConfiguration() ])), ]); - $response = $client->accounts()->r2Lifecycle()->update('account_id', 'my-bucket', [ + $response = $client->r2()->lifecycle()->update('account_id', 'my-bucket', [ ['id' => 'rule-1', 'conditions' => ['maxAge' => 3600]], ]); diff --git a/test/Tests/Endpoints/Accounts/R2LockTest.php b/test/Tests/Endpoints/R2/LockTest.php similarity index 87% rename from test/Tests/Endpoints/Accounts/R2LockTest.php rename to test/Tests/Endpoints/R2/LockTest.php index 5c419c4..cc43aae 100644 --- a/test/Tests/Endpoints/Accounts/R2LockTest.php +++ b/test/Tests/Endpoints/R2/LockTest.php @@ -1,13 +1,13 @@ accounts()->r2Lock()->details('account_id', 'my-bucket'); + $response = $client->r2()->lock()->get('account_id', 'my-bucket'); $this->assertTrue($response->successful()); $this->assertSame('rule-1', $response->json('result.rules.0.id')); @@ -48,7 +48,7 @@ public function shouldUpdateLockConfiguration() ])), ]); - $response = $client->accounts()->r2Lock()->update('account_id', 'my-bucket', [ + $response = $client->r2()->lock()->update('account_id', 'my-bucket', [ ['id' => 'rule-1', 'condition' => ['type' => 'Age', 'maxAgeSeconds' => 86400]], ]); diff --git a/test/Tests/Endpoints/Accounts/R2ManagedDomainTest.php b/test/Tests/Endpoints/R2/ManagedDomainTest.php similarity index 84% rename from test/Tests/Endpoints/Accounts/R2ManagedDomainTest.php rename to test/Tests/Endpoints/R2/ManagedDomainTest.php index 110eabd..10577c7 100644 --- a/test/Tests/Endpoints/Accounts/R2ManagedDomainTest.php +++ b/test/Tests/Endpoints/R2/ManagedDomainTest.php @@ -1,13 +1,13 @@ accounts()->r2ManagedDomain()->details('account_id', 'my-bucket'); + $response = $client->r2()->managedDomain()->get('account_id', 'my-bucket'); $this->assertTrue($response->successful()); $this->assertTrue($response->json('result.enabled')); @@ -44,7 +44,7 @@ public function shouldUpdateManagedDomain() ])), ]); - $response = $client->accounts()->r2ManagedDomain()->update('account_id', 'my-bucket', false); + $response = $client->r2()->managedDomain()->update('account_id', 'my-bucket', false); $this->assertTrue($response->successful()); $this->assertFalse($response->json('result.enabled')); diff --git a/test/Tests/Endpoints/Accounts/R2MetricsTest.php b/test/Tests/Endpoints/R2/MetricsTest.php similarity index 83% rename from test/Tests/Endpoints/Accounts/R2MetricsTest.php rename to test/Tests/Endpoints/R2/MetricsTest.php index 9d813c4..2d20c4c 100644 --- a/test/Tests/Endpoints/Accounts/R2MetricsTest.php +++ b/test/Tests/Endpoints/R2/MetricsTest.php @@ -1,13 +1,13 @@ accounts()->r2Metrics()->list('account_id'); + $response = $client->r2()->metrics()->list('account_id'); $this->assertTrue($response->successful()); $this->assertSame(1024, $response->json('result.payloadSize')); diff --git a/test/Tests/Endpoints/Accounts/R2SippyTest.php b/test/Tests/Endpoints/R2/SippyTest.php similarity index 85% rename from test/Tests/Endpoints/Accounts/R2SippyTest.php rename to test/Tests/Endpoints/R2/SippyTest.php index e8c0f09..ff1a2b3 100644 --- a/test/Tests/Endpoints/Accounts/R2SippyTest.php +++ b/test/Tests/Endpoints/R2/SippyTest.php @@ -1,13 +1,13 @@ accounts()->r2Sippy()->details('account_id', 'my-bucket'); + $response = $client->r2()->sippy()->get('account_id', 'my-bucket'); $this->assertTrue($response->successful()); $this->assertTrue($response->json('result.enabled')); @@ -44,7 +44,7 @@ public function shouldEnableSippy() ])), ]); - $response = $client->accounts()->r2Sippy()->update('account_id', 'my-bucket', [ + $response = $client->r2()->sippy()->update('account_id', 'my-bucket', [ 'source' => ['provider' => 'aws', 'bucket' => 'source-bucket'], 'destination' => ['provider' => 'r2'], ]); @@ -66,7 +66,7 @@ public function shouldDisableSippy() ])), ]); - $response = $client->accounts()->r2Sippy()->delete('account_id', 'my-bucket'); + $response = $client->r2()->sippy()->delete('account_id', 'my-bucket'); $this->assertTrue($response->successful()); diff --git a/test/Tests/Endpoints/RateLimitsTest.php b/test/Tests/Endpoints/RateLimitsTest.php new file mode 100644 index 0000000..830c721 --- /dev/null +++ b/test/Tests/Endpoints/RateLimitsTest.php @@ -0,0 +1,93 @@ +mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => [['id' => 'rate_limit_id']]])), + ]); + + $response = $client->rateLimits()->list('zone_id'); + + $this->assertTrue($response->successful()); + $this->assertSame('GET', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/rate_limits', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldGet() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'rate_limit_id']])), + ]); + + $response = $client->rateLimits()->get('zone_id', 'rate_limit_id'); + + $this->assertTrue($response->successful()); + $this->assertSame('GET', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/rate_limits/rate_limit_id', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldCreate() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'rate_limit_id']])), + ]); + + $response = $client->rateLimits()->create('zone_id', [ + 'threshold' => 1000, + 'period' => 60, + 'match' => ['request' => ['url' => '*example.com/*']], + 'action' => ['mode' => 'simulate', 'timeout' => 60], + ]); + + $this->assertTrue($response->successful()); + $this->assertSame('POST', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/rate_limits', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldUpdate() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'rate_limit_id']])), + ]); + + $response = $client->rateLimits()->update('zone_id', 'rate_limit_id', [ + 'threshold' => 2000, + 'period' => 60, + 'match' => ['request' => ['url' => '*example.com/*']], + 'action' => ['mode' => 'simulate', 'timeout' => 60], + ]); + + $this->assertTrue($response->successful()); + $this->assertSame('PUT', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/rate_limits/rate_limit_id', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldDelete() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'rate_limit_id']])), + ]); + + $response = $client->rateLimits()->delete('zone_id', 'rate_limit_id'); + + $this->assertTrue($response->successful()); + $this->assertSame('DELETE', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/rate_limits/rate_limit_id', $this->lastRequest()->getUri()->getPath()); + } +} diff --git a/test/Tests/Endpoints/Zones/RulesTest.php b/test/Tests/Endpoints/Rulesets/RulesTest.php similarity index 77% rename from test/Tests/Endpoints/Zones/RulesTest.php rename to test/Tests/Endpoints/Rulesets/RulesTest.php index 11f144f..7a2b4e5 100644 --- a/test/Tests/Endpoints/Zones/RulesTest.php +++ b/test/Tests/Endpoints/Rulesets/RulesTest.php @@ -1,6 +1,6 @@ true, 'result' => ['id' => 'rule_id']])), ]); - $response = $client->zones()->rules()->create('zone_id', 'ruleset_id', [ + $response = $client->rulesets()->rules()->create(null, 'zone_id', 'ruleset_id', [ 'action' => 'block', 'expression' => 'true', ]); @@ -38,9 +38,10 @@ public function shouldCreateWithRuleObject() $rule = (new BlockRule(['error' => 'blocked']))->enable()->setExpression('true'); - $response = $client->zones()->rules()->create('zone_id', 'ruleset_id', $rule); + $response = $client->rulesets()->rules()->create('account_id', null, 'ruleset_id', $rule); $this->assertTrue($response->successful()); $this->assertSame('POST', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/accounts/account_id/rulesets/ruleset_id/rules', $this->lastRequest()->getUri()->getPath()); } } diff --git a/test/Tests/Endpoints/Accounts/RulesetsTest.php b/test/Tests/Endpoints/RulesetsTest.php similarity index 65% rename from test/Tests/Endpoints/Accounts/RulesetsTest.php rename to test/Tests/Endpoints/RulesetsTest.php index 2d13a77..860f147 100644 --- a/test/Tests/Endpoints/Accounts/RulesetsTest.php +++ b/test/Tests/Endpoints/RulesetsTest.php @@ -1,9 +1,10 @@ mockClient([ new Response(200, [], json_encode(['success' => true, 'result' => [['id' => 'ruleset_id']]])), ]); - $response = $client->accounts()->rulesets()->get('account_id'); + $response = $client->rulesets()->list(accountId: 'account_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); @@ -28,57 +29,46 @@ public function shouldGet() } #[Test] - public function shouldCreateWithArray() + public function shouldListForZone() { $client = $this->mockClient([ - new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'ruleset_id']])), + new Response(200, [], json_encode(['success' => true, 'result' => [['id' => 'ruleset_id']]])), ]); - $response = $client->accounts()->rulesets()->create('account_id', [ - 'name' => 'my ruleset', - 'kind' => 'root', - 'phase' => 'http_request_firewall_custom', - 'rules' => [['action' => 'block', 'expression' => 'true']], - ]); + $response = $client->rulesets()->list(zoneId: 'zone_id'); $this->assertTrue($response->successful()); - $this->assertSame('POST', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/accounts/account_id/rulesets', $this->lastRequest()->getUri()->getPath()); + $this->assertSame('GET', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/rulesets', $this->lastRequest()->getUri()->getPath()); } #[Test] - public function shouldCreateWithEmptyRulesArray() + public function shouldThrowWhenNeitherScopeProvided() { - $client = $this->mockClient([ - new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'ruleset_id']])), - ]); + $client = $this->mockClient([]); - $response = $client->accounts()->rulesets()->create('account_id', [ - 'name' => 'my ruleset', - 'kind' => 'root', - 'phase' => 'http_request_firewall_custom', - 'rules' => [], - ]); + $this->expectException(InvalidArgumentException::class); - $this->assertTrue($response->successful()); - $this->assertSame('POST', $this->lastRequest()->getMethod()); + $client->rulesets()->list(); } #[Test] - public function shouldCreateWithoutRulesKey() + public function shouldCreateWithArray() { $client = $this->mockClient([ new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'ruleset_id']])), ]); - $response = $client->accounts()->rulesets()->create('account_id', [ + $response = $client->rulesets()->create('account_id', null, [ 'name' => 'my ruleset', 'kind' => 'root', 'phase' => 'http_request_firewall_custom', + 'rules' => [['action' => 'block', 'expression' => 'true']], ]); $this->assertTrue($response->successful()); $this->assertSame('POST', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/accounts/account_id/rulesets', $this->lastRequest()->getUri()->getPath()); } #[Test] @@ -90,10 +80,11 @@ public function shouldCreateWithRulesetObject() $ruleset = (new Ruleset('my ruleset'))->addRule((new BlockRule(['error' => 'blocked']))->setExpression('true')); - $response = $client->accounts()->rulesets()->create('account_id', $ruleset); + $response = $client->rulesets()->create(null, 'zone_id', $ruleset); $this->assertTrue($response->successful()); $this->assertSame('POST', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/rulesets', $this->lastRequest()->getUri()->getPath()); } #[Test] @@ -103,7 +94,7 @@ public function shouldGetDetails() new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'ruleset_id']])), ]); - $response = $client->accounts()->rulesets()->details('account_id', 'ruleset_id'); + $response = $client->rulesets()->get('account_id', null, 'ruleset_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); @@ -117,10 +108,10 @@ public function shouldDelete() new Response(200, [], json_encode(['success' => true, 'result' => null])), ]); - $response = $client->accounts()->rulesets()->delete('account_id', 'ruleset_id'); + $response = $client->rulesets()->delete(null, 'zone_id', 'ruleset_id'); $this->assertTrue($response->successful()); $this->assertSame('DELETE', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/accounts/account_id/rulesets/ruleset_id', $this->lastRequest()->getUri()->getPath()); + $this->assertSame('/client/v4/zones/zone_id/rulesets/ruleset_id', $this->lastRequest()->getUri()->getPath()); } } diff --git a/test/Tests/Endpoints/SslTest.php b/test/Tests/Endpoints/SslTest.php new file mode 100644 index 0000000..0e8e77f --- /dev/null +++ b/test/Tests/Endpoints/SslTest.php @@ -0,0 +1,69 @@ +mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => []])), + ]); + + $response = $client->ssl()->verification('zone_id'); + + $this->assertTrue($response->successful()); + $this->assertSame('GET', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/ssl/verification', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldEditVerification() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => []])), + ]); + + $response = $client->ssl()->editVerification('zone_id', 'cert_pack_uuid', 'txt'); + + $this->assertTrue($response->successful()); + $this->assertSame('PATCH', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/ssl/verification/cert_pack_uuid', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldGetUniversalSettings() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => ['enabled' => true]])), + ]); + + $response = $client->ssl()->universalSettings('zone_id'); + + $this->assertTrue($response->successful()); + $this->assertSame('GET', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/ssl/universal/settings', $this->lastRequest()->getUri()->getPath()); + } + + #[Test] + public function shouldEditUniversalSettings() + { + $client = $this->mockClient([ + new Response(200, [], json_encode(['success' => true, 'result' => ['enabled' => false]])), + ]); + + $response = $client->ssl()->editUniversalSettings('zone_id', false); + + $this->assertTrue($response->successful()); + $this->assertSame('PATCH', $this->lastRequest()->getMethod()); + $this->assertSame('/client/v4/zones/zone_id/ssl/universal/settings', $this->lastRequest()->getUri()->getPath()); + } +} diff --git a/test/Tests/Endpoints/Tunnel/RoutesTest.php b/test/Tests/Endpoints/Tunnel/RoutesTest.php index 6fb96c2..cdd4c35 100644 --- a/test/Tests/Endpoints/Tunnel/RoutesTest.php +++ b/test/Tests/Endpoints/Tunnel/RoutesTest.php @@ -91,7 +91,7 @@ public function shouldGetDetails() new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'route_id']])), ]); - $response = $client->tunnel()->routes()->details('account_id', 'route_id'); + $response = $client->tunnel()->routes()->get('account_id', 'route_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); @@ -105,7 +105,7 @@ public function shouldUpdate() new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'route_id']])), ]); - $response = $client->tunnel()->routes()->update('account_id', 'route_id', ['comment' => 'updated']); + $response = $client->tunnel()->routes()->edit('account_id', 'route_id', ['comment' => 'updated']); $this->assertTrue($response->successful()); $this->assertSame('PATCH', $this->lastRequest()->getMethod()); diff --git a/test/Tests/Endpoints/Tunnel/VirtualNetworksTest.php b/test/Tests/Endpoints/Tunnel/VirtualNetworksTest.php index 112d7a5..62db583 100644 --- a/test/Tests/Endpoints/Tunnel/VirtualNetworksTest.php +++ b/test/Tests/Endpoints/Tunnel/VirtualNetworksTest.php @@ -66,7 +66,7 @@ public function shouldGetDetails() new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'vnet_id']])), ]); - $response = $client->tunnel()->virtualNetworks()->details('account_id', 'vnet_id'); + $response = $client->tunnel()->virtualNetworks()->get('account_id', 'vnet_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); @@ -80,7 +80,7 @@ public function shouldUpdate() new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'vnet_id']])), ]); - $response = $client->tunnel()->virtualNetworks()->update('account_id', 'vnet_id', ['comment' => 'updated']); + $response = $client->tunnel()->virtualNetworks()->edit('account_id', 'vnet_id', ['comment' => 'updated']); $this->assertTrue($response->successful()); $this->assertSame('PATCH', $this->lastRequest()->getMethod()); diff --git a/test/Tests/Endpoints/Workers/DeploymentsTest.php b/test/Tests/Endpoints/Workers/DeploymentsTest.php index 4a75f9a..6e6010a 100644 --- a/test/Tests/Endpoints/Workers/DeploymentsTest.php +++ b/test/Tests/Endpoints/Workers/DeploymentsTest.php @@ -19,7 +19,7 @@ public function shouldGet() new Response(200, [], json_encode(['success' => true, 'result' => [['id' => 'deployment_id']]])), ]); - $response = $client->workers()->deployments()->get('account_id', 'script_name'); + $response = $client->workers()->deployments()->list('account_id', 'script_name'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); diff --git a/test/Tests/Endpoints/Workers/DomainsTest.php b/test/Tests/Endpoints/Workers/DomainsTest.php index 69584f9..5971502 100644 --- a/test/Tests/Endpoints/Workers/DomainsTest.php +++ b/test/Tests/Endpoints/Workers/DomainsTest.php @@ -18,7 +18,7 @@ public function shouldGet() new Response(200, [], json_encode(['success' => true, 'result' => [['id' => 'domain_id']]])), ]); - $response = $client->workers()->domains()->get('account_id'); + $response = $client->workers()->domains()->list('account_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); @@ -65,7 +65,7 @@ public function shouldGetDomain() new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'domain_id']])), ]); - $response = $client->workers()->domains()->domain('account_id', 'domain_id'); + $response = $client->workers()->domains()->get('account_id', 'domain_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); diff --git a/test/Tests/Endpoints/Workers/KVTest.php b/test/Tests/Endpoints/Workers/KVTest.php index 5ccf4cd..1dcf200 100644 --- a/test/Tests/Endpoints/Workers/KVTest.php +++ b/test/Tests/Endpoints/Workers/KVTest.php @@ -47,7 +47,7 @@ public function shouldGetDetails() new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'namespace_id']])), ]); - $response = $client->workers()->kv()->details('account_id', 'namespace_id'); + $response = $client->workers()->kv()->get('account_id', 'namespace_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); diff --git a/test/Tests/Endpoints/Workers/LogsTest.php b/test/Tests/Endpoints/Workers/LogsTest.php index 262a503..900731c 100644 --- a/test/Tests/Endpoints/Workers/LogsTest.php +++ b/test/Tests/Endpoints/Workers/LogsTest.php @@ -18,7 +18,7 @@ public function shouldGet() new Response(200, [], json_encode(['success' => true, 'result' => [['id' => 'tail_id']]])), ]); - $response = $client->workers()->logs()->get('account_id', 'script_name'); + $response = $client->workers()->logs()->list('account_id', 'script_name'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); diff --git a/test/Tests/Endpoints/Workers/RoutesTest.php b/test/Tests/Endpoints/Workers/RoutesTest.php index 4994756..6bb3a46 100644 --- a/test/Tests/Endpoints/Workers/RoutesTest.php +++ b/test/Tests/Endpoints/Workers/RoutesTest.php @@ -18,7 +18,7 @@ public function shouldGet() new Response(200, [], json_encode(['success' => true, 'result' => [['id' => 'route_id']]])), ]); - $response = $client->workers()->routes()->get('zone_id'); + $response = $client->workers()->routes()->list('zone_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); @@ -49,7 +49,7 @@ public function shouldGetDetails() new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'route_id']])), ]); - $response = $client->workers()->routes()->details('zone_id', 'route_id'); + $response = $client->workers()->routes()->get('zone_id', 'route_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); diff --git a/test/Tests/Endpoints/Workers/ScriptsTest.php b/test/Tests/Endpoints/Workers/ScriptsTest.php index 4c3a588..48cec92 100644 --- a/test/Tests/Endpoints/Workers/ScriptsTest.php +++ b/test/Tests/Endpoints/Workers/ScriptsTest.php @@ -19,7 +19,7 @@ public function shouldGet() new Response(200, [], json_encode(['success' => true, 'result' => [['id' => 'script_name']]])), ]); - $response = $client->workers()->scripts()->get('account_id'); + $response = $client->workers()->scripts()->list('account_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); diff --git a/test/Tests/Endpoints/Workers/VersionsTest.php b/test/Tests/Endpoints/Workers/VersionsTest.php index 9500663..eba5837 100644 --- a/test/Tests/Endpoints/Workers/VersionsTest.php +++ b/test/Tests/Endpoints/Workers/VersionsTest.php @@ -43,7 +43,7 @@ public function shouldGetDetails() new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'version_id']])), ]); - $response = $client->workers()->versions()->details('account_id', 'script_name', 'version_id'); + $response = $client->workers()->versions()->get('account_id', 'script_name', 'version_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); diff --git a/test/Tests/Endpoints/Zones/AccessRulesTest.php b/test/Tests/Endpoints/Zones/AccessRulesTest.php deleted file mode 100644 index 589ceee..0000000 --- a/test/Tests/Endpoints/Zones/AccessRulesTest.php +++ /dev/null @@ -1,105 +0,0 @@ -mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - ['id' => 'rule_id'], - ], - ])), - ]); - - $response = $client->zones()->accessRules()->list('zone_id'); - - $this->assertTrue($response->successful()); - $this->assertSame('rule_id', $response->json('result.0.id')); - - $this->assertSame('GET', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/firewall/access_rules/rules', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldCreateAccessRule() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'rule_id', - ], - ])), - ]); - - $response = $client->zones()->accessRules()->create('zone_id', [ - 'mode' => 'block', - 'configuration' => [ - 'target' => 'ip', - 'value' => '127.0.0.1', - ], - ]); - - $this->assertTrue($response->successful()); - $this->assertSame('rule_id', $response->json('result.id')); - - $this->assertSame('POST', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/firewall/access_rules/rules', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldUpdateAccessRule() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'rule_id', - 'mode' => 'challenge', - ], - ])), - ]); - - $response = $client->zones()->accessRules()->update('zone_id', 'rule_id', [ - 'mode' => 'challenge', - ]); - - $this->assertTrue($response->successful()); - $this->assertSame('challenge', $response->json('result.mode')); - - $this->assertSame('PATCH', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/firewall/access_rules/rules/rule_id', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldDeleteAccessRule() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'rule_id', - ], - ])), - ]); - - $response = $client->zones()->accessRules()->delete('zone_id', 'rule_id'); - - $this->assertTrue($response->successful()); - - $this->assertSame('DELETE', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/firewall/access_rules/rules/rule_id', $this->lastRequest()->getUri()->getPath()); - } -} diff --git a/test/Tests/Endpoints/Zones/BotManagementTest.php b/test/Tests/Endpoints/Zones/BotManagementTest.php deleted file mode 100644 index 468f467..0000000 --- a/test/Tests/Endpoints/Zones/BotManagementTest.php +++ /dev/null @@ -1,58 +0,0 @@ -mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'fight_mode' => true, - ], - ])), - ]); - - $response = $client->zones()->botManagement()->details('zone_id'); - - $this->assertTrue($response->successful()); - $this->assertTrue($response->json('result.fight_mode')); - - $this->assertSame('GET', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/bot_management', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldUpdateBotManagement() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'fight_mode' => false, - ], - ])), - ]); - - $response = $client->zones()->botManagement()->update('zone_id', [ - 'fight_mode' => false, - ]); - - $this->assertTrue($response->successful()); - $this->assertFalse($response->json('result.fight_mode')); - - $this->assertSame('PUT', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/bot_management', $this->lastRequest()->getUri()->getPath()); - $this->assertSame(['fight_mode' => false], json_decode((string) $this->lastRequest()->getBody(), true)); - } -} diff --git a/test/Tests/Endpoints/Zones/FiltersTest.php b/test/Tests/Endpoints/Zones/FiltersTest.php deleted file mode 100644 index 091a166..0000000 --- a/test/Tests/Endpoints/Zones/FiltersTest.php +++ /dev/null @@ -1,126 +0,0 @@ -mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - ['id' => 'filter_id'], - ], - ])), - ]); - - $response = $client->zones()->filters()->list('zone_id'); - - $this->assertTrue($response->successful()); - $this->assertSame('filter_id', $response->json('result.0.id')); - - $this->assertSame('GET', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/filters', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldGetFilterDetails() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'filter_id', - ], - ])), - ]); - - $response = $client->zones()->filters()->details('zone_id', 'filter_id'); - - $this->assertTrue($response->successful()); - $this->assertSame('filter_id', $response->json('result.id')); - - $this->assertSame('GET', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/filters/filter_id', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldCreateFilters() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - ['id' => 'filter_id'], - ], - ])), - ]); - - $response = $client->zones()->filters()->create('zone_id', [ - ['expression' => 'ip.src eq 127.0.0.1'], - ]); - - $this->assertTrue($response->successful()); - $this->assertSame('filter_id', $response->json('result.0.id')); - - $this->assertSame('POST', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/filters', $this->lastRequest()->getUri()->getPath()); - $this->assertSame([ - ['expression' => 'ip.src eq 127.0.0.1'], - ], json_decode((string) $this->lastRequest()->getBody(), true)); - } - - #[Test] - public function shouldUpdateFilter() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'filter_id', - 'paused' => true, - ], - ])), - ]); - - $response = $client->zones()->filters()->update('zone_id', 'filter_id', [ - 'expression' => 'ip.src eq 127.0.0.1', - 'paused' => true, - ]); - - $this->assertTrue($response->successful()); - $this->assertTrue($response->json('result.paused')); - - $this->assertSame('PUT', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/filters/filter_id', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldDeleteFilter() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'filter_id', - ], - ])), - ]); - - $response = $client->zones()->filters()->delete('zone_id', 'filter_id'); - - $this->assertTrue($response->successful()); - - $this->assertSame('DELETE', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/filters/filter_id', $this->lastRequest()->getUri()->getPath()); - } -} diff --git a/test/Tests/Endpoints/Zones/FirewallRulesTest.php b/test/Tests/Endpoints/Zones/FirewallRulesTest.php deleted file mode 100644 index 5d54c33..0000000 --- a/test/Tests/Endpoints/Zones/FirewallRulesTest.php +++ /dev/null @@ -1,149 +0,0 @@ -mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - ['id' => 'rule_id'], - ], - ])), - ]); - - $response = $client->zones()->firewallRules()->list('zone_id'); - - $this->assertTrue($response->successful()); - $this->assertSame('rule_id', $response->json('result.0.id')); - - $this->assertSame('GET', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/firewall/rules', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldGetFirewallRuleDetails() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'rule_id', - ], - ])), - ]); - - $response = $client->zones()->firewallRules()->details('zone_id', 'rule_id'); - - $this->assertTrue($response->successful()); - $this->assertSame('rule_id', $response->json('result.id')); - - $this->assertSame('GET', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/firewall/rules/rule_id', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldCreateFirewallRules() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - ['id' => 'rule_id'], - ], - ])), - ]); - - $response = $client->zones()->firewallRules()->create('zone_id', [ - [ - 'action' => 'block', - 'filter' => ['id' => 'filter_id'], - ], - ]); - - $this->assertTrue($response->successful()); - $this->assertSame('rule_id', $response->json('result.0.id')); - - $this->assertSame('POST', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/firewall/rules', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldUpdateFirewallRule() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'rule_id', - 'action' => 'challenge', - ], - ])), - ]); - - $response = $client->zones()->firewallRules()->update('zone_id', 'rule_id', [ - 'action' => 'challenge', - 'filter' => ['id' => 'filter_id'], - ]); - - $this->assertTrue($response->successful()); - $this->assertSame('challenge', $response->json('result.action')); - - $this->assertSame('PUT', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/firewall/rules/rule_id', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldUpdateFirewallRulePriority() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'rule_id', - 'priority' => 5, - ], - ])), - ]); - - $response = $client->zones()->firewallRules()->updatePriority('zone_id', 'rule_id', 5); - - $this->assertTrue($response->successful()); - $this->assertSame(5, $response->json('result.priority')); - - $this->assertSame('PATCH', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/firewall/rules/rule_id', $this->lastRequest()->getUri()->getPath()); - $this->assertSame(['priority' => 5], json_decode((string) $this->lastRequest()->getBody(), true)); - } - - #[Test] - public function shouldDeleteFirewallRule() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'rule_id', - ], - ])), - ]); - - $response = $client->zones()->firewallRules()->delete('zone_id', 'rule_id'); - - $this->assertTrue($response->successful()); - - $this->assertSame('DELETE', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/firewall/rules/rule_id', $this->lastRequest()->getUri()->getPath()); - } -} diff --git a/test/Tests/Endpoints/Zones/HoldTest.php b/test/Tests/Endpoints/Zones/HoldsTest.php similarity index 96% rename from test/Tests/Endpoints/Zones/HoldTest.php rename to test/Tests/Endpoints/Zones/HoldsTest.php index 9e7d3f4..4119098 100644 --- a/test/Tests/Endpoints/Zones/HoldTest.php +++ b/test/Tests/Endpoints/Zones/HoldsTest.php @@ -7,7 +7,7 @@ use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; -class HoldTest extends TestCase +class HoldsTest extends TestCase { use InteractsWithMockClient; @@ -18,7 +18,7 @@ public function shouldGetDetails() new Response(200, [], json_encode(['success' => true, 'result' => ['hold' => true]])), ]); - $response = $client->zones()->holds()->details('zone_id'); + $response = $client->zones()->holds()->get('zone_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); diff --git a/test/Tests/Endpoints/Zones/LoadBalancersTest.php b/test/Tests/Endpoints/Zones/LoadBalancersTest.php deleted file mode 100644 index 4ad5f4f..0000000 --- a/test/Tests/Endpoints/Zones/LoadBalancersTest.php +++ /dev/null @@ -1,151 +0,0 @@ -mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - ['id' => 'load_balancer_id'], - ], - ])), - ]); - - $response = $client->zones()->loadBalancers()->list('zone_id'); - - $this->assertTrue($response->successful()); - $this->assertSame('load_balancer_id', $response->json('result.0.id')); - - $this->assertSame('GET', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/load_balancers', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldCreateLoadBalancer() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'load_balancer_id', - ], - ])), - ]); - - $response = $client->zones()->loadBalancers()->create('zone_id', [ - 'name' => 'www.example.com', - 'default_pools' => ['pool_id'], - 'fallback_pool' => 'pool_id', - ]); - - $this->assertTrue($response->successful()); - $this->assertSame('load_balancer_id', $response->json('result.id')); - - $this->assertSame('POST', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/load_balancers', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldGetLoadBalancerDetails() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'load_balancer_id', - ], - ])), - ]); - - $response = $client->zones()->loadBalancers()->details('zone_id', 'load_balancer_id'); - - $this->assertTrue($response->successful()); - $this->assertSame('load_balancer_id', $response->json('result.id')); - - $this->assertSame('GET', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/load_balancers/load_balancer_id', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldUpdateLoadBalancer() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'load_balancer_id', - 'enabled' => false, - ], - ])), - ]); - - $response = $client->zones()->loadBalancers()->update('zone_id', 'load_balancer_id', [ - 'name' => 'www.example.com', - 'default_pools' => ['pool_id'], - 'fallback_pool' => 'pool_id', - 'enabled' => false, - ]); - - $this->assertTrue($response->successful()); - $this->assertFalse($response->json('result.enabled')); - - $this->assertSame('PUT', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/load_balancers/load_balancer_id', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldDeleteLoadBalancer() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'load_balancer_id', - ], - ])), - ]); - - $response = $client->zones()->loadBalancers()->delete('zone_id', 'load_balancer_id'); - - $this->assertTrue($response->successful()); - - $this->assertSame('DELETE', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/load_balancers/load_balancer_id', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldPatchLoadBalancer() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'load_balancer_id', - 'enabled' => false, - ], - ])), - ]); - - $response = $client->zones()->loadBalancers()->patch('zone_id', 'load_balancer_id', [ - 'enabled' => false, - ]); - - $this->assertTrue($response->successful()); - $this->assertFalse($response->json('result.enabled')); - - $this->assertSame('PATCH', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/load_balancers/load_balancer_id', $this->lastRequest()->getUri()->getPath()); - } -} diff --git a/test/Tests/Endpoints/Zones/OriginCACertificatesTest.php b/test/Tests/Endpoints/Zones/OriginCACertificatesTest.php deleted file mode 100644 index d58a1d8..0000000 --- a/test/Tests/Endpoints/Zones/OriginCACertificatesTest.php +++ /dev/null @@ -1,104 +0,0 @@ -mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - ['id' => 'certificate_id'], - ], - ])), - ]); - - $response = $client->zones()->originCACertificates()->list(['zone_id' => 'zone_id']); - - $this->assertTrue($response->successful()); - $this->assertSame('certificate_id', $response->json('result.0.id')); - - $this->assertSame('GET', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/certificates', $this->lastRequest()->getUri()->getPath()); - $this->assertSame('zone_id=zone_id', $this->lastRequest()->getUri()->getQuery()); - } - - #[Test] - public function shouldCreateCertificate() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'certificate_id', - ], - ])), - ]); - - $response = $client->zones()->originCACertificates()->create('csr_value', ['example.com']); - - $this->assertTrue($response->successful()); - $this->assertSame('certificate_id', $response->json('result.id')); - - $this->assertSame('POST', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/certificates', $this->lastRequest()->getUri()->getPath()); - $this->assertSame([ - 'csr' => 'csr_value', - 'hostnames' => ['example.com'], - 'requested_validity' => 5475, - 'request_type' => 'origin-rsa', - ], json_decode((string) $this->lastRequest()->getBody(), true)); - } - - #[Test] - public function shouldGetCertificateDetails() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'certificate_id', - ], - ])), - ]); - - $response = $client->zones()->originCACertificates()->details('certificate_id'); - - $this->assertTrue($response->successful()); - $this->assertSame('certificate_id', $response->json('result.id')); - - $this->assertSame('GET', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/certificates/certificate_id', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldRevokeCertificate() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'certificate_id', - ], - ])), - ]); - - $response = $client->zones()->originCACertificates()->revoke('certificate_id'); - - $this->assertTrue($response->successful()); - $this->assertSame('certificate_id', $response->json('result.id')); - - $this->assertSame('DELETE', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/certificates/certificate_id', $this->lastRequest()->getUri()->getPath()); - } -} diff --git a/test/Tests/Endpoints/Zones/RateLimitsTest.php b/test/Tests/Endpoints/Zones/RateLimitsTest.php deleted file mode 100644 index 8c6af34..0000000 --- a/test/Tests/Endpoints/Zones/RateLimitsTest.php +++ /dev/null @@ -1,132 +0,0 @@ -mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - ['id' => 'rate_limit_id'], - ], - ])), - ]); - - $response = $client->zones()->rateLimits()->list('zone_id'); - - $this->assertTrue($response->successful()); - $this->assertSame('rate_limit_id', $response->json('result.0.id')); - - $this->assertSame('GET', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/rate_limits', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldGetRateLimitDetails() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'rate_limit_id', - ], - ])), - ]); - - $response = $client->zones()->rateLimits()->details('zone_id', 'rate_limit_id'); - - $this->assertTrue($response->successful()); - $this->assertSame('rate_limit_id', $response->json('result.id')); - - $this->assertSame('GET', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/rate_limits/rate_limit_id', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldCreateRateLimit() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'rate_limit_id', - ], - ])), - ]); - - $response = $client->zones()->rateLimits()->create('zone_id', [ - 'threshold' => 100, - 'period' => 60, - 'match' => [ - 'request' => ['url' => '*.example.com/*'], - ], - 'action' => ['mode' => 'simulate'], - ]); - - $this->assertTrue($response->successful()); - $this->assertSame('rate_limit_id', $response->json('result.id')); - - $this->assertSame('POST', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/rate_limits', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldUpdateRateLimit() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'rate_limit_id', - 'threshold' => 200, - ], - ])), - ]); - - $response = $client->zones()->rateLimits()->update('zone_id', 'rate_limit_id', [ - 'threshold' => 200, - 'period' => 60, - 'match' => [ - 'request' => ['url' => '*.example.com/*'], - ], - 'action' => ['mode' => 'simulate'], - ]); - - $this->assertTrue($response->successful()); - $this->assertSame(200, $response->json('result.threshold')); - - $this->assertSame('PUT', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/rate_limits/rate_limit_id', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldDeleteRateLimit() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'id' => 'rate_limit_id', - ], - ])), - ]); - - $response = $client->zones()->rateLimits()->delete('zone_id', 'rate_limit_id'); - - $this->assertTrue($response->successful()); - - $this->assertSame('DELETE', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/rate_limits/rate_limit_id', $this->lastRequest()->getUri()->getPath()); - } -} diff --git a/test/Tests/Endpoints/Zones/RulesetsTest.php b/test/Tests/Endpoints/Zones/RulesetsTest.php deleted file mode 100644 index a4333f7..0000000 --- a/test/Tests/Endpoints/Zones/RulesetsTest.php +++ /dev/null @@ -1,126 +0,0 @@ -mockClient([ - new Response(200, [], json_encode(['success' => true, 'result' => [['id' => 'ruleset_id']]])), - ]); - - $response = $client->zones()->rulesets()->get('zone_id'); - - $this->assertTrue($response->successful()); - $this->assertSame('GET', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/rulesets', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldCreateWithArray() - { - $client = $this->mockClient([ - new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'ruleset_id']])), - ]); - - $response = $client->zones()->rulesets()->create('zone_id', [ - 'name' => 'my ruleset', - 'kind' => 'zone', - 'phase' => 'http_request_firewall_custom', - 'rules' => [['action' => 'block', 'expression' => 'true']], - ]); - - $this->assertTrue($response->successful()); - $this->assertSame('POST', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/rulesets', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldCreateWithEmptyRulesArray() - { - $client = $this->mockClient([ - new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'ruleset_id']])), - ]); - - $response = $client->zones()->rulesets()->create('zone_id', [ - 'name' => 'my ruleset', - 'kind' => 'zone', - 'phase' => 'http_request_firewall_custom', - 'rules' => [], - ]); - - $this->assertTrue($response->successful()); - $this->assertSame('POST', $this->lastRequest()->getMethod()); - } - - #[Test] - public function shouldCreateWithoutRulesKey() - { - $client = $this->mockClient([ - new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'ruleset_id']])), - ]); - - $response = $client->zones()->rulesets()->create('zone_id', [ - 'name' => 'my ruleset', - 'kind' => 'zone', - 'phase' => 'http_request_firewall_custom', - ]); - - $this->assertTrue($response->successful()); - $this->assertSame('POST', $this->lastRequest()->getMethod()); - } - - #[Test] - public function shouldCreateWithRulesetObject() - { - $client = $this->mockClient([ - new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'ruleset_id']])), - ]); - - $ruleset = (new Ruleset('my ruleset'))->addRule((new BlockRule(['error' => 'blocked']))->setExpression('true')); - - $response = $client->zones()->rulesets()->create('zone_id', $ruleset); - - $this->assertTrue($response->successful()); - $this->assertSame('POST', $this->lastRequest()->getMethod()); - } - - #[Test] - public function shouldGetDetails() - { - $client = $this->mockClient([ - new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'ruleset_id']])), - ]); - - $response = $client->zones()->rulesets()->details('zone_id', 'ruleset_id'); - - $this->assertTrue($response->successful()); - $this->assertSame('GET', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/rulesets/ruleset_id', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldDelete() - { - $client = $this->mockClient([ - new Response(200, [], json_encode(['success' => true, 'result' => null])), - ]); - - $response = $client->zones()->rulesets()->delete('zone_id', 'ruleset_id'); - - $this->assertTrue($response->successful()); - $this->assertSame('DELETE', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/rulesets/ruleset_id', $this->lastRequest()->getUri()->getPath()); - } -} diff --git a/test/Tests/Endpoints/Zones/SslTest.php b/test/Tests/Endpoints/Zones/SslTest.php deleted file mode 100644 index a4dc4a4..0000000 --- a/test/Tests/Endpoints/Zones/SslTest.php +++ /dev/null @@ -1,103 +0,0 @@ -mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'certificate_status' => 'active', - ], - ])), - ]); - - $response = $client->zones()->ssl()->verification('zone_id'); - - $this->assertTrue($response->successful()); - $this->assertSame('active', $response->json('result.certificate_status')); - - $this->assertSame('GET', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/ssl/verification', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldEditVerification() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'validation_method' => 'txt', - ], - ])), - ]); - - $response = $client->zones()->ssl()->editVerification('zone_id', 'cert_pack_uuid', 'txt'); - - $this->assertTrue($response->successful()); - $this->assertSame('txt', $response->json('result.validation_method')); - - $this->assertSame('PATCH', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/ssl/verification/cert_pack_uuid', $this->lastRequest()->getUri()->getPath()); - $this->assertSame([ - 'validation_method' => 'txt', - ], json_decode((string) $this->lastRequest()->getBody(), true)); - } - - #[Test] - public function shouldGetUniversalSettings() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'enabled' => true, - ], - ])), - ]); - - $response = $client->zones()->ssl()->universalSettings('zone_id'); - - $this->assertTrue($response->successful()); - $this->assertTrue($response->json('result.enabled')); - - $this->assertSame('GET', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/ssl/universal/settings', $this->lastRequest()->getUri()->getPath()); - } - - #[Test] - public function shouldUpdateUniversalSettings() - { - $client = $this->mockClient([ - new Response(200, [], json_encode([ - 'success' => true, - 'result' => [ - 'enabled' => false, - ], - ])), - ]); - - $response = $client->zones()->ssl()->updateUniversalSettings('zone_id', false); - - $this->assertTrue($response->successful()); - $this->assertFalse($response->json('result.enabled')); - - $this->assertSame('PATCH', $this->lastRequest()->getMethod()); - $this->assertSame('/client/v4/zones/zone_id/ssl/universal/settings', $this->lastRequest()->getUri()->getPath()); - $this->assertSame([ - 'enabled' => false, - ], json_decode((string) $this->lastRequest()->getBody(), true)); - } -} diff --git a/test/Tests/Endpoints/ZonesTest.php b/test/Tests/Endpoints/ZonesTest.php index 609e0c4..1dd0c04 100644 --- a/test/Tests/Endpoints/ZonesTest.php +++ b/test/Tests/Endpoints/ZonesTest.php @@ -4,7 +4,6 @@ use Cloudflare\Configurations\Zones\CachePurge; use Cloudflare\Exceptions\MissingArgumentException; -use Cloudflare\Endpoints\Zones\Cache; use Cloudflare\Tests\Concerns\InteractsWithMockClient; use GuzzleHttp\Psr7\Response; use PHPUnit\Framework\Attributes\Test; @@ -55,7 +54,7 @@ public function shouldGetDetails() new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'zone_id']])), ]); - $response = $client->zones()->details('zone_id'); + $response = $client->zones()->get('zone_id'); $this->assertTrue($response->successful()); $this->assertSame('GET', $this->lastRequest()->getMethod()); @@ -77,13 +76,13 @@ public function shouldDelete() } #[Test] - public function shouldUpdateWithoutVanityNameServers() + public function shouldEditWithoutVanityNameServers() { $client = $this->mockClient([ new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'zone_id']])), ]); - $response = $client->zones()->update('zone_id', 'full'); + $response = $client->zones()->edit('zone_id', 'full'); $this->assertTrue($response->successful()); $this->assertSame('PATCH', $this->lastRequest()->getMethod()); @@ -91,13 +90,13 @@ public function shouldUpdateWithoutVanityNameServers() } #[Test] - public function shouldUpdateWithVanityNameServers() + public function shouldEditWithVanityNameServers() { $client = $this->mockClient([ new Response(200, [], json_encode(['success' => true, 'result' => ['id' => 'zone_id']])), ]); - $response = $client->zones()->update('zone_id', 'full', ['ns1.example.com']); + $response = $client->zones()->edit('zone_id', 'full', ['ns1.example.com']); $this->assertTrue($response->successful()); $this->assertSame([ @@ -159,12 +158,4 @@ public function shouldThrowWhenPurgeMissingAnyRequiredParams() $client->zones()->purge('zone_id', []); } - - #[Test] - public function shouldGetCache() - { - $client = $this->mockClient([]); - - $this->assertInstanceOf(Cache::class, $client->zones()->cache()); - } } diff --git a/test/Tests/HttpClient/HttpClientTest.php b/test/Tests/HttpClient/HttpClientTest.php index 26935f7..c73a938 100644 --- a/test/Tests/HttpClient/HttpClientTest.php +++ b/test/Tests/HttpClient/HttpClientTest.php @@ -75,7 +75,7 @@ public function shouldThrowMappedExceptionForStatus(int $status, string $expecte $this->expectException($expectedException); - $client->zones()->details('zone_id'); + $client->zones()->get('zone_id'); } #[Test] @@ -93,6 +93,6 @@ public function shouldWrapConnectExceptionIntoConnectionException() $this->expectException(ConnectionException::class); - $client->zones()->details('zone_id'); + $client->zones()->get('zone_id'); } }