├── src └── CloudFlare │ ├── Exception │ ├── UnauthorizedException.php │ └── AuthenticationException.php │ ├── IPs.php │ ├── Zone │ ├── SSL │ │ ├── CertificatePacks.php │ │ └── Analyze.php │ ├── Aml.php │ ├── Plan.php │ ├── CustomPages.php │ ├── Cache.php │ ├── Railgun.php │ ├── WAF │ │ ├── Packages.php │ │ └── Packages │ │ │ ├── Rules.php │ │ │ └── Groups.php │ ├── SSL.php │ ├── KeylessSSL.php │ ├── Analytics.php │ ├── Firewall │ │ └── AccessRules.php │ ├── CustomSSL.php │ ├── Dns.php │ ├── Pagerules.php │ ├── LoadBalancers.php │ └── Settings.php │ ├── Organizations.php │ ├── Organizations │ ├── Roles.php │ ├── Members.php │ ├── Invites.php │ ├── Railguns.php │ ├── VirtualDns.php │ ├── Firewall │ │ └── AccessRules │ │ │ └── Rules.php │ └── LoadBalancers │ │ ├── Pools.php │ │ └── Monitors.php │ ├── User │ ├── Invites.php │ ├── Billing.php │ ├── Organizations.php │ ├── LoadBalancers │ │ ├── Notifiers.php │ │ ├── Maps.php │ │ ├── GlobalPolicies.php │ │ ├── Origins.php │ │ ├── Pools.php │ │ └── Monitors.php │ ├── Billing │ │ └── Subscriptions │ │ │ ├── Apps.php │ │ │ └── Zones.php │ ├── VirtualDns.php │ └── Firewall │ │ └── AccessRules.php │ ├── Railguns.php │ ├── Certificates.php │ ├── User.php │ ├── Zone.php │ └── Api.php └── composer.json /src/CloudFlare/Exception/UnauthorizedException.php: -------------------------------------------------------------------------------- 1 | 12 | * 13 | * @version 1 14 | */ 15 | class IPs extends Api 16 | { 17 | /** 18 | * CloudFlare IPs 19 | * Get CloudFlare IPs 20 | */ 21 | public function ips() 22 | { 23 | return $this->get('/ips'); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jamesryanbell/cloudflare", 3 | "description": "CloudFlare API - PHP", 4 | "license": "MIT", 5 | "keywords": ["cloudflare", "api"], 6 | "authors": [ 7 | { 8 | "name": "James Bell", 9 | "email": "james@james-bell.co.uk" 10 | } 11 | ], 12 | "require": {}, 13 | "require-dev": { 14 | "phpunit/phpunit": "< 6", 15 | "satooshi/php-coveralls": "dev-master" 16 | }, 17 | "autoload": { 18 | "psr-4": { 19 | "Cloudflare\\": "src/CloudFlare" 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/CloudFlare/Zone/SSL/CertificatePacks.php: -------------------------------------------------------------------------------- 1 | 14 | * 15 | * @version 1 16 | */ 17 | class CertificatePacks extends Api 18 | { 19 | /** 20 | * List all certificate packs (permission needed: #ssl:read) 21 | * For a given zone, list all certificate packs 22 | * 23 | * @param string $identifier 24 | */ 25 | public function certificate_packs($identifier) 26 | { 27 | return $this->get('/zones/'.$identifier.'/ssl/certificate_packs'); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/CloudFlare/Organizations.php: -------------------------------------------------------------------------------- 1 | 11 | * 12 | * @version 1 13 | */ 14 | class Organizations extends Api 15 | { 16 | /** 17 | * Organization details (permission needed: #organization:read) 18 | * Get information about a specific organization that you are a member of 19 | * 20 | * @param string $identifier 21 | */ 22 | public function organization($identifier) 23 | { 24 | return $this->get('/organizations/'.$identifier); 25 | } 26 | 27 | /** 28 | * Update organization (permission needed: #organization:edit) 29 | * Update an existing Organization 30 | * 31 | * @param string|null $identifier 32 | * @param string|null $name Organization Name 33 | */ 34 | public function update($identifier = null, $name = null) 35 | { 36 | $data = [ 37 | 'name' => $name, 38 | ]; 39 | 40 | return $this->get('/organizations/'.$identifier, $data); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/CloudFlare/Organizations/Roles.php: -------------------------------------------------------------------------------- 1 | 13 | * 14 | * @version 1 15 | */ 16 | class Roles extends Api 17 | { 18 | /** 19 | * List roles (permission needed: #organization:read) 20 | * Get all available roles for an organization 21 | * 22 | * @param string $organization_identifier 23 | */ 24 | public function roles($organization_identifier) 25 | { 26 | return $this->get('/organizations/'.$organization_identifier.'/roles'); 27 | } 28 | 29 | /** 30 | * Role details (permission needed: #organization:read) 31 | * Get information about a specific role for an organization 32 | * 33 | * @param string $organization_identifier 34 | * @param string $identifier 35 | */ 36 | public function details($organization_identifier, $identifier) 37 | { 38 | return $this->get('/organizations/'.$organization_identifier.'/roles/'.$identifier); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/CloudFlare/User/Invites.php: -------------------------------------------------------------------------------- 1 | 13 | * 14 | * @version 1 15 | */ 16 | class Invites extends Api 17 | { 18 | /** 19 | * List invitations (permission needed: #invites:read) 20 | * List all invitations associated with my user 21 | */ 22 | public function invites() 23 | { 24 | return $this->get('/user/invites'); 25 | } 26 | 27 | /** 28 | * Invitation details (permission needed: #invites:read) 29 | * Get the details of an invitation 30 | * 31 | * @param string $identifier 32 | */ 33 | public function details($identifier) 34 | { 35 | return $this->get('/user/invites/'.$identifier); 36 | } 37 | 38 | /** 39 | * Respond to Invitation (permission needed: #invites:edit) 40 | * Respond to an invitation 41 | * 42 | * @param string $identifier 43 | * @param string $status Status of your response to the invitation (rejected or accepted) 44 | */ 45 | public function respond($identifier, $status) 46 | { 47 | $data = [ 48 | 'status' => $status, 49 | ]; 50 | 51 | return $this->patch('/user/invites/'.$identifier, $data); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/CloudFlare/Zone/Aml.php: -------------------------------------------------------------------------------- 1 | 13 | * 14 | * @version 1 15 | */ 16 | class Aml extends Api 17 | { 18 | /** 19 | * Get AML Settings (permission needed: #zone_settings:edit) 20 | * Fetch AML configuration for a zone 21 | * 22 | * @param string $zone_identifier 23 | */ 24 | public function viewer($zone_identifier) 25 | { 26 | return $this->get('zones/'.$zone_identifier.'/amp/viewer'); 27 | } 28 | 29 | /** 30 | * Update AML Settings (permission needed: #zone_settings:edit) 31 | * Update AML configuration for a zone 32 | * 33 | * @param bool|null $enabled Enable Accelerated Mobile Links on mobile browsers. 34 | * @param array|null $subdomains Your contact email address, repeated 35 | * @param string|null $prepend_links_with Your current password 36 | */ 37 | public function change_email($enabled = null, $subdomains = null, $prepend_links_with = null) 38 | { 39 | $data = [ 40 | 'enabled' => $enabled, 41 | 'subdomains' => $subdomains, 42 | 'prepend_links_with' => $prepend_links_with, 43 | ]; 44 | 45 | return $this->put('zones/'.$zone_identifier.'/amp/viewer', $data); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/CloudFlare/Zone/Plan.php: -------------------------------------------------------------------------------- 1 | 13 | * 14 | * @version 1 15 | */ 16 | class Plan extends Api 17 | { 18 | /** 19 | * Available plans (permission needed: #billing:read) 20 | * List all plans the zone can subscribe to. 21 | * 22 | * @param string $zone_identifier 23 | */ 24 | public function available($zone_identifier) 25 | { 26 | return $this->get('zones/'.$zone_identifier.'/available_rate_plans'); 27 | } 28 | 29 | /** 30 | * Available plans (permission needed: #billing:read) 31 | * 32 | * @param string $zone_identifier 33 | * @param string $identifier API item identifier tag 34 | */ 35 | public function details($zone_identifier, $identifier) 36 | { 37 | return $this->get('zones/'.$zone_identifier.'/plans/'.$identifier); 38 | } 39 | 40 | /** 41 | * Change plan (permission needed: #billing:edit) 42 | * Change the plan level for the zone. This will cancel any previous subscriptions and subscribe the zone to the new plan. 43 | * 44 | * @param string $zone_identifier 45 | * @param string $identifier API item identifier tag 46 | */ 47 | public function change($zone_identifier, $identifier) 48 | { 49 | return $this->put('zones/'.$zone_identifier.'/plans/'.$identifier.'/subscribe'); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/CloudFlare/Zone/SSL/Analyze.php: -------------------------------------------------------------------------------- 1 | 14 | * 15 | * @version 1 16 | */ 17 | class Analyze extends Api 18 | { 19 | /** 20 | * Analyze Certificate (permission needed: #ssl:read) 21 | * Returns the set of hostnames, the signature algorithm, and the expiration date of the certificate. 22 | * 23 | * @param string $identifier 24 | * @param string $certificate The zone's SSL certificate or certificate and the intermediate(s) 25 | * @param string|null $bundle_method A ubiquitous bundle is a bundle that has a higher probability of 26 | * being verified everywhere, even by clients using outdated or unusual 27 | * trust stores. An optimal bundle is a bundle with the shortest chain and 28 | * newest intermediates. A forced method attempt to use the certificate/chain 29 | * as defined by the input 30 | */ 31 | public function analyze($identifier, $certificate, $bundle_method = null) 32 | { 33 | $data = [ 34 | 'certificate' => $certificate, 35 | 'bundle_method' => $bundle_method, 36 | ]; 37 | 38 | return $this->post('/zones/'.$identifier.'/ssl/analyze', $data); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/CloudFlare/User/Billing.php: -------------------------------------------------------------------------------- 1 | 13 | * 14 | * @version 1 15 | */ 16 | class Billing extends Api 17 | { 18 | /** 19 | * Billing Profile (permission needed: #billing:read) 20 | * Access your billing profile object 21 | */ 22 | public function billing() 23 | { 24 | return $this->get('/user/billing/profile'); 25 | } 26 | 27 | /** 28 | * Billing History (permission needed: #billing:read) 29 | * Access your billing profile object 30 | * 31 | * @param int|null $page Page number of paginated results 32 | * @param int|null $per_page Number of items per page 33 | * @param string|null $order Field to order billing history by 34 | * @param string|null $type The billing item type 35 | * @param string|null $occured_at When the billing item was created 36 | * @param string|null $action The billing item action 37 | */ 38 | public function history($page = null, $per_page = null, $order = null, $type = null, $occured_at = null, $action = null) 39 | { 40 | $data = [ 41 | 'page' => $page, 42 | 'per_page' => $per_page, 43 | 'order' => $order, 44 | 'type' => $type, 45 | 'occured_at' => $occured_at, 46 | 'action' => $action, 47 | ]; 48 | 49 | return $this->get('/user/billing/history', $data); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/CloudFlare/Zone/CustomPages.php: -------------------------------------------------------------------------------- 1 | 13 | * 14 | * @version 1 15 | */ 16 | class CustomPages extends Api 17 | { 18 | /** 19 | * Available Custom Pages (permission needed: #zone_settings:read) 20 | * 21 | * @param string $zone_identifier API item identifier tag 22 | */ 23 | public function custom_pages($zone_identifier) 24 | { 25 | return $this->get('zones/'.$zone_identifier.'/custom_pages'); 26 | } 27 | 28 | /** 29 | * Custom Page details (permission needed: #zone_settings:read) 30 | * Details about a specific Custom page details 31 | * 32 | * @param string $zone_identifier API item identifier tag 33 | * @param string $identifier 34 | */ 35 | public function details($zone_identifier, $identifier) 36 | { 37 | return $this->get('zones/'.$zone_identifier.'/custom_pages/'.$identifier); 38 | } 39 | 40 | /** 41 | * Update Custom page URL (permission needed: #zone_settings:edit) 42 | * Update Custom page URL 43 | * 44 | * @param string $zone_identifier API item identifier tag 45 | * @param string $identifier 46 | * @param string $url A URL that is associated with the Custom Page. 47 | * @param string $state The Custom Page state 48 | */ 49 | public function update($zone_identifier, $identifier, $url, $state) 50 | { 51 | $data = [ 52 | 'url' => $url, 53 | 'state' => $state, 54 | ]; 55 | 56 | return $this->patch('zones/'.$zone_identifier.'/custom_pages/'.$identifier, $data); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/CloudFlare/Zone/Cache.php: -------------------------------------------------------------------------------- 1 | 13 | * 14 | * @version 1 15 | */ 16 | class Cache extends Api 17 | { 18 | /** 19 | * Purge all files (permission needed: #zone:edit) 20 | * Remove ALL files from CloudFlare's cache 21 | * 22 | * @param string $identifier API item identifier tag 23 | * @param bool|null $purge_everything A flag that indicates all resources in CloudFlare's cache should be removed. 24 | * Note: This may have dramatic affects on your origin server load after performing this action. (true) 25 | */ 26 | public function purge($identifier, $purge_everything = null) 27 | { 28 | $data = [ 29 | 'purge_everything' => $purge_everything, 30 | ]; 31 | 32 | return $this->delete('zones/'.$identifier.'/purge_cache', $data); 33 | } 34 | 35 | /** 36 | * Purge individual files (permission needed: #zone:edit) 37 | * Remove one or more files from CloudFlare's cache 38 | * 39 | * @param string $identifier API item identifier tag 40 | * @param array|null $files An array of URLs that should be removed from cache 41 | * @param array|null $tags Any assets served with a Cache-Tag header that matches one of the provided values will be purged from the CloudFlare cache 42 | */ 43 | public function purge_files($identifier, array $files = null, array $tags = null) 44 | { 45 | $data = [ 46 | 'files' => $files, 47 | 'tags' => $tags, 48 | ]; 49 | 50 | return $this->delete('zones/'.$identifier.'/purge_cache', $data); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/CloudFlare/Organizations/Members.php: -------------------------------------------------------------------------------- 1 | 13 | * 14 | * @version 1 15 | */ 16 | class Members extends Api 17 | { 18 | /** 19 | * List members (permission needed: #organization:read) 20 | * List all members of a organization 21 | * 22 | * @param string $organization_identifier 23 | */ 24 | public function members($organization_identifier) 25 | { 26 | return $this->get('/organizations/'.$organization_identifier.'/members'); 27 | } 28 | 29 | /** 30 | * Member details (permission needed: #organization:read) 31 | * Get information about a specific member of an organization 32 | * 33 | * @param string $organization_identifier 34 | * @param string $identifier 35 | */ 36 | public function details($organization_identifier, $identifier) 37 | { 38 | return $this->get('/organizations/'.$organization_identifier.'/members/'.$identifier); 39 | } 40 | 41 | /** 42 | * Update member roles (permission needed: #organization:edit) 43 | * Change the Roles of an Organization's Member 44 | * 45 | * @param string $organization_identifier 46 | * @param string $identifier 47 | * @param array|null $roles Array of Roles associated with this Member 48 | */ 49 | public function update($organization_identifier, $identifier, array $roles = null) 50 | { 51 | $data = [ 52 | 'roles' => $roles, 53 | ]; 54 | 55 | return $this->patch('/organizations/'.$organization_identifier.'/members/'.$identifier, $data); 56 | } 57 | 58 | /** 59 | * Remove member (permission needed: #organization:edit) 60 | * Remove a member from an organization 61 | * 62 | * @param string $organization_identifier 63 | * @param string $identifier 64 | */ 65 | public function delete_member($organization_identifier, $identifier) 66 | { 67 | return $this->delete('/organizations/'.$organization_identifier.'/members/'.$identifier); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/CloudFlare/Zone/Railgun.php: -------------------------------------------------------------------------------- 1 | 13 | * 14 | * @version 1 15 | */ 16 | class Railgun extends Api 17 | { 18 | /** 19 | * Get available Railguns (permission needed: #zone_settings:read) 20 | * A list of available Railguns the zone can use 21 | * 22 | * @param string $zone_identifier API item identifier tag 23 | */ 24 | public function railguns($zone_identifier) 25 | { 26 | return $this->get('zones/'.$zone_identifier.'/railguns'); 27 | } 28 | 29 | /** 30 | * Get Railgun details (permission needed: #zone_settings:read) 31 | * Details about a specific Railgun 32 | * 33 | * @param string $zone_identifier API item identifier tag 34 | * @param string $identifier 35 | */ 36 | public function details($zone_identifier, $identifier) 37 | { 38 | return $this->get('zones/'.$zone_identifier.'/railguns/'.$identifier); 39 | } 40 | 41 | /** 42 | * Test Railgun connection (permission needed: #zone_settings:read) 43 | * Test Railgun connection to the Zone 44 | * 45 | * @param string $zone_identifier API item identifier tag 46 | * @param string $identifier 47 | */ 48 | public function diagnose($zone_identifier, $identifier) 49 | { 50 | return $this->get('zones/'.$zone_identifier.'/railguns/'.$identifier.'/diagnose'); 51 | } 52 | 53 | /** 54 | * Connect or disconnect a Railgun (permission needed: #zone_settings:edit) 55 | * Connect or disconnect a Railgun 56 | * 57 | * @param string $zone_identifier 58 | * @param string $identifier API item identifier tag 59 | * @param bool $connected A flag indicating whether the given zone is connected to the Railgun [valid values: (true,false)] 60 | */ 61 | public function connected($zone_identifier, $identifier, $connected) 62 | { 63 | $data = [ 64 | 'connected' => $connected, 65 | ]; 66 | 67 | return $this->get('zones/'.$zone_identifier.'/railguns/'.$identifier, $data); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/CloudFlare/User/Organizations.php: -------------------------------------------------------------------------------- 1 | 13 | * 14 | * @version 1 15 | */ 16 | class Organizations extends Api 17 | { 18 | /** 19 | * List organizations (permission needed: #organizations:read) 20 | * List organizations the user is associated with 21 | * 22 | * @param string|null $status Whether or not the user is a member of the organization or has an inivitation pending 23 | * @param string|null $name Organization Name 24 | * @param int|null $page Page number of paginated results 25 | * @param int|null $per_page Number of organizations per page 26 | * @param string|null $order Field to order organizations by 27 | * @param string|null $direction Direction to order organizations 28 | * @param string|null $match Whether to match all search requirements or at least one (any) 29 | */ 30 | public function organizations($status = null, $name = null, $page = null, $per_page = null, $order = null, $direction = null, $match = null) 31 | { 32 | $data = [ 33 | 'status' => $status, 34 | 'name' => $name, 35 | 'page' => $page, 36 | 'per_page' => $per_page, 37 | 'order' => $order, 38 | 'direction' => $direction, 39 | 'match' => $match, 40 | ]; 41 | 42 | return $this->get('/user/organizations', $data); 43 | } 44 | 45 | /** 46 | * Organization details (permission needed: #organizations:read) 47 | * Get a specific organization the user is associated with 48 | * 49 | * @param string $identifier 50 | */ 51 | public function details($identifier) 52 | { 53 | return $this->get('/user/organizations/'.$identifier); 54 | } 55 | 56 | /** 57 | * Leave organization (permission needed: #organizations:edit) 58 | * Remove association to an organization 59 | * 60 | * @param string $identifier 61 | */ 62 | public function leave($identifier) 63 | { 64 | return $this->delete('/user/organizations/'.$identifier); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/CloudFlare/User/LoadBalancers/Notifiers.php: -------------------------------------------------------------------------------- 1 | 15 | * 16 | * @version 1 17 | */ 18 | class Notifiers extends Api 19 | { 20 | /** 21 | * List notifiers 22 | * List configured notifiers for a user 23 | */ 24 | public function notifiers() 25 | { 26 | return $this->get('/user/load_balancers/notifiers'); 27 | } 28 | 29 | /** 30 | * Create a notifier 31 | * Create a configured notifier 32 | * 33 | * @param string $address Notifier address 34 | * @param string|null $type Notifier type 35 | */ 36 | public function create($address, $type = null) 37 | { 38 | $data = [ 39 | 'address' => $address, 40 | 'type' => $type, 41 | ]; 42 | 43 | return $this->post('/user/load_balancers/notifiers', $data); 44 | } 45 | 46 | /** 47 | * Notifier details 48 | * Fetch a single configured CTM notifier for a user 49 | * 50 | * @param string $identifier 51 | */ 52 | public function details($identifier) 53 | { 54 | return $this->get('/user/load_balancers/notifiers/'.$identifier); 55 | } 56 | 57 | /** 58 | * Modify a notifier 59 | * Modify a configured notifier 60 | * 61 | * @param string $identifier 62 | * @param string|null $address Notifier address 63 | * @param string|null $type Notifier type 64 | */ 65 | public function update($identifier, $address = null, $type = null) 66 | { 67 | $data = [ 68 | 'address' => $address, 69 | 'type' => $type, 70 | ]; 71 | 72 | return $this->patch('/user/load_balancers/notifiers/'.$identifier, $data); 73 | } 74 | 75 | /** 76 | * Delete a notifier 77 | * Delete a configured notifier 78 | * 79 | * @param string $identifier 80 | */ 81 | public function delete_notifier($identifier) 82 | { 83 | return $this->delete('/user/load_balancers/notifiers/'.$identifier); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/CloudFlare/User/LoadBalancers/Maps.php: -------------------------------------------------------------------------------- 1 | 15 | * 16 | * @version 1 17 | */ 18 | class Maps extends Api 19 | { 20 | /** 21 | * List maps 22 | * List configured maps 23 | */ 24 | public function maps() 25 | { 26 | return $this->get('/user/load_balancers/maps'); 27 | } 28 | 29 | /** 30 | * Create a map 31 | * Create a new map 32 | * 33 | * @param array $global_pools Sorted list of pool IDs that will be utilized 34 | * if a CF PoP cannot be assigned to a configured region. 35 | * @param string|null $description Object description. 36 | */ 37 | public function create($global_pools, $description = null) 38 | { 39 | $data = [ 40 | 'global_pools' => $global_pools, 41 | 'description' => $description, 42 | ]; 43 | 44 | return $this->post('/user/load_balancers/maps', $data); 45 | } 46 | 47 | /** 48 | * Map details 49 | * Fetch a single configured map 50 | * 51 | * @param string $identifier 52 | */ 53 | public function details($identifier) 54 | { 55 | return $this->get('/user/load_balancers/maps/'.$identifier); 56 | } 57 | 58 | /** 59 | * Modify a map 60 | * Modify a configured map 61 | * 62 | * @param string $identifier 63 | * @param array $global_pools Sorted list of pool IDs that will be utilized 64 | * if a CF PoP cannot be assigned to a configured region. 65 | * @param string|null $description Object description. 66 | */ 67 | public function update($identifier, $global_pools = null, $description = null) 68 | { 69 | $data = [ 70 | 'global_pools' => $global_pools, 71 | 'description' => $description, 72 | ]; 73 | 74 | return $this->patch('/user/load_balancers/maps/'.$identifier, $data); 75 | } 76 | 77 | /** 78 | * Delete a map 79 | * Delete a configured map 80 | * 81 | * @param string $identifier 82 | */ 83 | public function delete_map($identifier) 84 | { 85 | return $this->delete('/user/load_balancers/maps/'.$identifier); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/CloudFlare/User/LoadBalancers/GlobalPolicies.php: -------------------------------------------------------------------------------- 1 | 15 | * 16 | * @version 1 17 | */ 18 | class GlobalPolicies extends Api 19 | { 20 | /** 21 | * List global policies 22 | * List configured global policies 23 | */ 24 | public function global_policies() 25 | { 26 | return $this->get('/user/load_balancers/global_policies'); 27 | } 28 | 29 | /** 30 | * Create a global policy 31 | * Create a new global policy 32 | * 33 | * @param string $fallback_pool ID for a fallback pool to use when all pools are down. 34 | * @param string $location_mapping ID of the location map object. 35 | * @param string|null $description Object description. 36 | */ 37 | public function create($fallback_pool, $location_mapping, $description = null) 38 | { 39 | $data = [ 40 | 'fallback_pool' => $fallback_pool, 41 | 'location_mapping' => $location_mapping, 42 | 'description' => $description, 43 | ]; 44 | 45 | return $this->post('/user/load_balancers/global_policies', $data); 46 | } 47 | 48 | /** 49 | * Global policy details 50 | * Fetch a single configured global policy 51 | * 52 | * @param string $identifier 53 | */ 54 | public function details($identifier) 55 | { 56 | return $this->get('/user/load_balancers/global_policies/'.$identifier); 57 | } 58 | 59 | /** 60 | * Modify a global policy 61 | * Modify a configured global policy 62 | * 63 | * @param string $identifier 64 | * @param string|null $fallback_pool ID for a fallback pool to use when all pools are down. 65 | * @param string|null $location_mapping ID of the location map object. 66 | * @param string|null $description Object description. 67 | */ 68 | public function update($identifier, $fallback_pool = null, $location_mapping = null, $description = null) 69 | { 70 | $data = [ 71 | 'fallback_pool' => $fallback_pool, 72 | 'location_mapping' => $location_mapping, 73 | 'description' => $description, 74 | ]; 75 | 76 | return $this->patch('/user/load_balancers/global_policies/'.$identifier, $data); 77 | } 78 | 79 | /** 80 | * Delete a global policy 81 | * Delete a configured global policy 82 | * 83 | * @param string $identifier 84 | */ 85 | public function delete_global_policy($identifier) 86 | { 87 | return $this->delete('/user/load_balancers/global_policies/'.$identifier); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/CloudFlare/Zone/WAF/Packages.php: -------------------------------------------------------------------------------- 1 | 14 | * 15 | * @version 1 16 | */ 17 | class Packages extends Api 18 | { 19 | /** 20 | * List firewall packages (permission needed: #zone:read) 21 | * Retrieve firewall packages for a zone 22 | * 23 | * @param string $zone_identifier 24 | * @param string|null $name Name of the firewall package 25 | * @param int|null $page Page number of paginated results 26 | * @param int|null $per_page Number of packages per page 27 | * @param string|null $order Field to order packages by 28 | * @param string|null $direction Direction to order packages 29 | * @param string|null $match Whether to match all search requirements or at least one (any) 30 | */ 31 | public function rules($zone_identifier, $name = null, $page = null, $per_page = null, $order = null, $direction = null, $match = null) 32 | { 33 | $data = [ 34 | 'name' => $name, 35 | 'page' => $page, 36 | 'per_page' => $per_page, 37 | 'order' => $order, 38 | 'direction' => $direction, 39 | 'match' => $match, 40 | ]; 41 | 42 | return $this->get('/zones/'.$zone_identifier.'/firewall/waf/packages', $data); 43 | } 44 | 45 | /** 46 | * Firewall package info (permission needed: #zone:read) 47 | * Get information about a single firewall package 48 | * 49 | * @param string $zone_identifier 50 | * @param string $identifier 51 | */ 52 | public function info($zone_identifier, $identifier) 53 | { 54 | return $this->get('/zones/'.$zone_identifier.'/firewall/waf/packages/'.$identifier); 55 | } 56 | 57 | /** 58 | * Change anomaly-detection web application firewall package settings (permission needed: #zone:edit) 59 | * Change the sensitivity and action for an anomaly detection type WAF rule package 60 | * 61 | * @param string $zone_identifier 62 | * @param string $identifier 63 | * @param string|null $sensitivity The sensitivity of the firewall package. 64 | * @param string|null $action_mode The default action that will be taken for rules under the firewall package. 65 | */ 66 | public function update($zone_identifier, $identifier, $sensitivity = null, $action_mode = null) 67 | { 68 | $data = [ 69 | 'sensitivity' => $sensitivity, 70 | 'action_mode' => $action_mode, 71 | ]; 72 | 73 | return $this->patch('/zones/'.$zone_identifier.'/firewall/waf/packages/'.$identifier, $data); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/CloudFlare/Railguns.php: -------------------------------------------------------------------------------- 1 | 12 | * 13 | * @version 1 14 | */ 15 | class Railguns extends Api 16 | { 17 | /** 18 | * Create Railgun (permission needed: #railgun:edit) 19 | * 20 | * @param string $name Readable identifier of the railgun 21 | */ 22 | public function create($name) 23 | { 24 | $data = [ 25 | 'name' => $name, 26 | ]; 27 | 28 | return $this->post('railguns', $data); 29 | } 30 | 31 | /** 32 | * List Railguns (permission needed: #railgun:read) 33 | * List, search, sort and filter your Railguns 34 | * 35 | * @param int|null $page Page number of paginated results 36 | * @param int|null $per_page Number of items per page 37 | * @param string|null $direction Direction to order Railguns (asc, desc) 38 | */ 39 | public function railguns($page = null, $per_page = null, $direction = null) 40 | { 41 | $data = [ 42 | 'page' => $page, 43 | 'per_page' => $per_page, 44 | 'direction' => $direction, 45 | ]; 46 | 47 | return $this->get('railguns', $data); 48 | } 49 | 50 | /** 51 | * Railgun details (permission needed: #railgun:read) 52 | * 53 | * @param string $identifier API item identifier tag 54 | */ 55 | public function details($identifier) 56 | { 57 | return $this->get('railguns/'.$identifier); 58 | } 59 | 60 | /** 61 | * Get zones connected to a Railgun (permission needed: #railgun:read) 62 | * The zones that are currently using this Railgun 63 | * 64 | * @param string $identifier API item identifier tag 65 | */ 66 | public function zones($identifier) 67 | { 68 | return $this->get('railguns/'.$identifier.'/zones'); 69 | } 70 | 71 | /** 72 | * Enable or disable a Railgun (permission needed: #railgun:edit) 73 | * Enable or disable a Railgun for all zones connected to it 74 | * 75 | * @param string $identifier API item identifier tag 76 | * @param bool|null $enabled Flag to determine if the Railgun is accepting connections 77 | */ 78 | public function enabled($identifier, $enabled = null) 79 | { 80 | $data = [ 81 | 'enabled' => $enabled, 82 | ]; 83 | 84 | return $this->patch('railguns/'.$identifier, $data); 85 | } 86 | 87 | /** 88 | * Delete Railgun (permission needed: #railgun:edit) 89 | * Disable and delete a Railgun. This will immediately disable the Railgun for any connected zones 90 | * 91 | * @param string $identifier API item identifier tag 92 | */ 93 | public function delete_railgun($identifier) 94 | { 95 | return $this->delete('railguns/'.$identifier); 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /src/CloudFlare/User/Billing/Subscriptions/Apps.php: -------------------------------------------------------------------------------- 1 | 15 | * 16 | * @version 1 17 | */ 18 | class Apps extends Api 19 | { 20 | /** 21 | * List (permission needed: #billing:read) 22 | * List all of your app subscriptions 23 | */ 24 | public function list_apps() 25 | { 26 | return $this->get('/user/billing/subscriptions/apps'); 27 | } 28 | 29 | /** 30 | * Search, sort, and paginate (permission needed: #billing:read) 31 | * Search, sort, and paginate your subscriptions 32 | * 33 | * @param int|null $page Page number of paginated results 34 | * @param int|null $per_page Number of items per page 35 | * @param string|null $order Field to order subscriptions by 36 | * @param string|null $status The state of the subscription 37 | * @param string|null $price The price of the subscription that will be billed, in US dollars 38 | * @param string|null $activated_on When the subscription was activated 39 | * @param string|null $expires_on When the subscription will expire 40 | * @param string|null $expired_on When the subscription expired 41 | * @param string|null $cancelled_on When the subscription was cancelled 42 | * @param string|null $renewed_on When the subscription was renewed 43 | * @param string|null $direction Direction to order subscriptions 44 | * @param string|null $match Whether to match all search requirements or at least one (any) 45 | */ 46 | public function search_sort_paginate($page = null, $per_page = null, $order = null, $status = null, $price = null, $activated_on = null, $expires_on = null, $expired_on = null, $cancelled_on = null, $renewed_on = null, $direction = null, $match = null) 47 | { 48 | $data = [ 49 | 'page' => $page, 50 | 'per_page' => $per_page, 51 | 'order' => $order, 52 | 'status' => $status, 53 | 'price' => $price, 54 | 'activated_on' => $activated_on, 55 | 'expires_on' => $expires_on, 56 | 'expired_on' => $expired_on, 57 | 'cancelled_on' => $cancelled_on, 58 | 'renewed_on' => $renewed_on, 59 | 'direction' => $direction, 60 | 'match' => $match, 61 | ]; 62 | 63 | return $this->get('/user/billing/subscriptions/apps', $data); 64 | } 65 | 66 | /** 67 | * Info (permission needed: #billing:read) 68 | * Billing subscription details 69 | * 70 | * @param string $identifier 71 | */ 72 | public function info($identifier) 73 | { 74 | return $this->get('/user/billing/subscriptions/apps/'.$identifier); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/CloudFlare/Organizations/Invites.php: -------------------------------------------------------------------------------- 1 | 13 | * 14 | * @version 1 15 | */ 16 | class Invites extends Api 17 | { 18 | /** 19 | * Create invitation (permission needed: #organization:read) 20 | * Invite a User to become a Member of an Organization 21 | * 22 | * @param string $organization_identifier 23 | * @param string $invited_member_email Email address of the user to be added to the Organization 24 | * @param array $roles Array of Roles associated with the invited user 25 | */ 26 | public function create($organization_identifier, $invited_member_email, array $roles) 27 | { 28 | $data = [ 29 | 'invited_member_email' => $invited_member_email, 30 | 'roles' => $roles, 31 | ]; 32 | 33 | return $this->post('/organizations/'.$organization_identifier.'/members', $data); 34 | } 35 | 36 | /** 37 | * List invitations (permission needed: #organization:read) 38 | * List all invitations associated with an organization 39 | * 40 | * @param string $organization_identifier 41 | */ 42 | public function invitations($organization_identifier) 43 | { 44 | return $this->get('/organizations/'.$organization_identifier.'/invites'); 45 | } 46 | 47 | /** 48 | * Invitation details (permission needed: #organization:read) 49 | * Get the details of an invitation 50 | * 51 | * @param string $organization_identifier 52 | * @param string $identifier 53 | */ 54 | public function details($organization_identifier, $identifier) 55 | { 56 | return $this->get('/organizations/'.$organization_identifier.'/invites/'.$identifier); 57 | } 58 | 59 | /** 60 | * Update invitation roles (permission needed: #organization:edit) 61 | * Change the Roles of a Pending Invite 62 | * 63 | * @param string $organization_identifier 64 | * @param string $identifier 65 | * @param array|null $roles Array of Roles associated with the invited user 66 | */ 67 | public function update($organization_identifier, $identifier, array $roles = null) 68 | { 69 | $data = [ 70 | 'roles' => $roles, 71 | ]; 72 | 73 | return $this->patch('/organizations/'.$organization_identifier.'/invites/'.$identifier, $data); 74 | } 75 | 76 | /** 77 | * Cancel Invitation (permission needed: #organization:edit) 78 | * Cancel an existing invitation 79 | * 80 | * @param string $organization_identifier 81 | * @param string $identifier 82 | */ 83 | public function delete_invitation($organization_identifier, $identifier) 84 | { 85 | return $this->delete('/organizations/'.$organization_identifier.'/invites/'.$identifier); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/CloudFlare/User/LoadBalancers/Origins.php: -------------------------------------------------------------------------------- 1 | 15 | * 16 | * @version 1 17 | */ 18 | class Origins extends Api 19 | { 20 | /** 21 | * List origins 22 | * List configured origins for a user 23 | */ 24 | public function origins() 25 | { 26 | return $this->get('/user/load_balancers/origins'); 27 | } 28 | 29 | /** 30 | * Create a origin 31 | * Create a new origin 32 | * 33 | * @param string $name Object name 34 | * @param string $address Origin server IPv4 or IPv6 address 35 | * @param bool|null $enabled Whether this origin is enabled or not 36 | * @param string|null $notifier The ID of the notifier object to use for 37 | * notifications relating to the health status of this origin. 38 | */ 39 | public function create($name, $address, $enabled = null, $notifier = null) 40 | { 41 | $data = [ 42 | 'name' => $name, 43 | 'address' => $address, 44 | 'enabled' => $enabled, 45 | 'notifier' => $notifier, 46 | ]; 47 | 48 | return $this->post('/user/load_balancers/origins', $data); 49 | } 50 | 51 | /** 52 | * Origin details 53 | * Fetch a single configured CTM origin for a user 54 | * 55 | * @param string $identifier 56 | */ 57 | public function details($identifier) 58 | { 59 | return $this->get('/user/load_balancers/origins/'.$identifier); 60 | } 61 | 62 | /** 63 | * Modify an origin 64 | * Modify a configured origin 65 | * 66 | * @param string $identifier 67 | * @param string|null $name Object name 68 | * @param string|null $address Origin server IPv4 or IPv6 address 69 | * @param bool|null $enabled Whether this origin is enabled or not 70 | * @param string|null $notifier The ID of the notifier object to use for 71 | * notifications relating to the health status of this origin. 72 | */ 73 | public function update($identifier, $name = null, $address = null, $enabled = null, $notifier = null) 74 | { 75 | $data = [ 76 | 'name' => $name, 77 | 'address' => $address, 78 | 'enabled' => $enabled, 79 | 'notifier' => $notifier, 80 | ]; 81 | 82 | return $this->patch('/user/load_balancers/origins/'.$identifier, $data); 83 | } 84 | 85 | /** 86 | * Delete an origin 87 | * Delete a configured origin 88 | * 89 | * @param string $identifier 90 | */ 91 | public function delete_origin($identifier) 92 | { 93 | return $this->delete('/user/load_balancers/origins/'.$identifier); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/CloudFlare/Certificates.php: -------------------------------------------------------------------------------- 1 | 14 | * 15 | * @version 1 16 | */ 17 | class Certificates extends Api 18 | { 19 | /** 20 | * List Certificates 21 | * List all existing CloudFlare-issued Certificates for a given zone. Use your Certificates API Key as your 22 | * User Service Key when calling this endpoint 23 | */ 24 | public function certificates($page = null, $per_page = null, $direction = null) 25 | { 26 | $data = [ 27 | 'page' => $page, 28 | 'per_page' => $per_page, 29 | 'direction' => $direction, 30 | ]; 31 | 32 | return $this->get('certificates', $data); 33 | } 34 | 35 | /** 36 | * Create Certificate 37 | * Create a CloudFlare-signed certificate. Use your Certificates API Key as your User Service Key when 38 | * calling this endpoint 39 | * 40 | * @param array $hostnames Array of hostnames or wildcard names (e.g., *.example.com) bound to the certificate 41 | * @param string $request_type Signature type desired on certificate ("origin-rsa" (rsa), "origin-ecc" (ecdsa), or "keyless-certificate" (for Keyless SSL servers) 42 | * @param string $csr The Certificate Signing Request (CSR). Must be newline-encoded. 43 | * @param int|null $requested_validity The number of days for which the certificate should be valid 44 | */ 45 | public function create($hostnames, $request_type, $csr, $requested_validity = null) 46 | { 47 | $data = [ 48 | 'hostnames' => $hostnames, 49 | 'request_type' => $request_type, 50 | 'csr' => $csr, 51 | 'requested_validity' => $requested_validity, 52 | ]; 53 | 54 | return $this->post('certificates', $data); 55 | } 56 | 57 | /** 58 | * Certificate Details 59 | * Get an existing certificate by its serial number. Use your Certificates API Key as your User Service Key 60 | * when calling this endpoint 61 | * 62 | * @param string $identifier API item identifier tag 63 | */ 64 | public function details($identifier) 65 | { 66 | return $this->get('certificates/'.$identifier); 67 | } 68 | 69 | /** 70 | * Revoke certificate 71 | * Revoke a created certificate for a zone. Use your Certificates API Key as your User Service Key when 72 | * calling this endpoint 73 | * 74 | * @param string $identifier API item identifier tag 75 | */ 76 | public function revoke($identifier) 77 | { 78 | return $this->delete('certificates/'.$identifier); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/CloudFlare/User/Billing/Subscriptions/Zones.php: -------------------------------------------------------------------------------- 1 | 15 | * 16 | * @version 1 17 | */ 18 | class Zones extends Api 19 | { 20 | /** 21 | * List (permission needed: #billing:read) 22 | * List all of your zone plan subscriptions 23 | */ 24 | public function list_zones() 25 | { 26 | return $this->get('/user/billing/subscriptions/zones'); 27 | } 28 | 29 | /** 30 | * Search, sort, and paginate (permission needed: #billing:read) 31 | * Search, sort, and paginate your subscriptions 32 | * 33 | * @param int|null $page Page number of paginated results 34 | * @param int|null $per_page Number of items per page 35 | * @param string|null $order Field to order subscriptions by 36 | * @param string|null $status The state of the subscription 37 | * @param string|null $price The price of the subscription that will be billed, in US dollars 38 | * @param string|null $activated_on When the subscription was activated 39 | * @param string|null $expires_on When the subscription will expire 40 | * @param string|null $expired_on When the subscription expired 41 | * @param string|null $cancelled_on When the subscription was cancelled 42 | * @param string|null $renewed_on When the subscription was renewed 43 | * @param string|null $direction Direction to order subscriptions 44 | * @param string|null $match Whether to match all search requirements or at least one (any) 45 | */ 46 | public function search_sort_paginate($page = null, $per_page = null, $order = null, $status = null, $price = null, $activated_on = null, $expires_on = null, $expired_on = null, $cancelled_on = null, $renewed_on = null, $direction = null, $match = null) 47 | { 48 | $data = [ 49 | 'page' => $page, 50 | 'per_page' => $per_page, 51 | 'order' => $order, 52 | 'status' => $status, 53 | 'price' => $price, 54 | 'activated_on' => $activated_on, 55 | 'expires_on' => $expires_on, 56 | 'expired_on' => $expired_on, 57 | 'cancelled_on' => $cancelled_on, 58 | 'renewed_on' => $renewed_on, 59 | 'direction' => $direction, 60 | 'match' => $match, 61 | ]; 62 | 63 | return $this->get('/user/billing/subscriptions/zones', $data); 64 | } 65 | 66 | /** 67 | * Info (permission needed: #billing:read) 68 | * Billing subscription details 69 | * 70 | * @param string $identifier API item identifier tag 71 | */ 72 | public function info($identifier) 73 | { 74 | return $this->get('/user/billing/subscriptions/zones/'.$identifier); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/CloudFlare/Zone/WAF/Packages/Rules.php: -------------------------------------------------------------------------------- 1 | 15 | * 16 | * @version 1 17 | */ 18 | class Rules extends Api 19 | { 20 | /** 21 | * List rule (permission needed: #zone:read) 22 | * Search, list, and filter rules within a package 23 | * 24 | * @param string $zone_id 25 | * @param string $package_id 26 | * @param string|null $description Public description of the rule 27 | * @param object|null $mode The rule mode 28 | * @param int|null $priority The order in which the individual rule is executed within the related group 29 | * @param string|null $group_id WAF group identifier tag 30 | * @param int|null $page Page number of paginated results 31 | * @param int|null $per_page Number of rules per page 32 | * @param string|null $order Field to order rules by 33 | * @param string|null $direction Direction to order rules 34 | * @param string|null $match Whether to match all search requirements or at least one (any) 35 | */ 36 | public function rules($zone_id, $package_id, $description = null, $mode = null, $priority = null, $group_id = null, $page = null, $per_page = null, $order = null, $direction = null, $match = null) 37 | { 38 | $data = [ 39 | 'description' => $description, 40 | 'mode' => $mode, 41 | 'priority' => $priority, 42 | 'group_id' => $group_id, 43 | 'page' => $page, 44 | 'per_page' => $per_page, 45 | 'order' => $order, 46 | 'direction' => $direction, 47 | 'match' => $match, 48 | ]; 49 | 50 | return $this->get('/zones/'.$zone_id.'/firewall/waf/packages/'.$package_id.'/rules', $data); 51 | } 52 | 53 | /** 54 | * Rule info (permission needed: #zone:read) 55 | * Individual information about a rule 56 | * 57 | * @param string $zone_id 58 | * @param string $package_id 59 | * @param string $identifier 60 | */ 61 | public function info($zone_id, $package_id, $identifier) 62 | { 63 | return $this->get('/zones/'.$zone_id.'/firewall/waf/packages/'.$package_id.'/rules/'.$identifier); 64 | } 65 | 66 | /** 67 | * Update Rule group (permission needed: #zone:edit) 68 | * Update the state of a rule group 69 | * 70 | * @param string $zone_id 71 | * @param string $package_id 72 | * @param string $identifier 73 | * @param string|null $mode The mode to use when the rule is triggered. Value is restricted based on the allowed_modes of the rule 74 | */ 75 | public function update($zone_id, $package_id, $identifier, $mode = null) 76 | { 77 | $data = [ 78 | 'mode' => $mode, 79 | ]; 80 | 81 | return $this->patch('/zones/'.$zone_id.'/firewall/waf/packages/'.$package_id.'/rules/'.$identifier, $data); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/CloudFlare/Zone/WAF/Packages/Groups.php: -------------------------------------------------------------------------------- 1 | 15 | * 16 | * @version 1 17 | */ 18 | class Groups extends Api 19 | { 20 | /** 21 | * List rule groups (permission needed: #zone:read) 22 | * Search, list, and sort rule groups contained within a package 23 | * 24 | * @param string $zone_identifier 25 | * @param string $package_identifier 26 | * @param string|null $name Name of the firewall rule group 27 | * @param string|null $mode Whether or not the rules contained within this group are configurable/usable 28 | * @param int|null $rules_count How many rules are contained within this group 29 | * @param int|null $page Page number of paginated results 30 | * @param int|null $per_page Number of groups per page 31 | * @param string|null $order Field to order groups by 32 | * @param string|null $direction Direction to order groups 33 | * @param string|null $match Whether to match all search requirements or at least one (any) 34 | */ 35 | public function groups($zone_identifier, $package_identifier, $name = null, $mode = null, $rules_count = null, $page = null, $per_page = null, $order = null, $direction = null, $match = null) 36 | { 37 | $data = [ 38 | 'name' => $name, 39 | 'mode' => $mode, 40 | 'rules_count' => $rules_count, 41 | 'page' => $page, 42 | 'per_page' => $per_page, 43 | 'order' => $order, 44 | 'direction' => $direction, 45 | 'match' => $match, 46 | ]; 47 | 48 | return $this->get('/zones/'.$zone_identifier.'/firewall/waf/packages/'.$package_identifier.'/groups', $data); 49 | } 50 | 51 | /** 52 | * Rule group info (permission needed: #zone:read) 53 | * Get a single rule group 54 | * 55 | * @param string $zone_identifier 56 | * @param string $package_identifier 57 | * @param string $identifier 58 | */ 59 | public function info($zone_identifier, $package_identifier, $identifier) 60 | { 61 | return $this->get('/zones/'.$zone_identifier.'/firewall/waf/packages/'.$package_identifier.'/groups/'.$identifier); 62 | } 63 | 64 | /** 65 | * Update Rule group (permission needed: #zone:edit) 66 | * Update the state of a rule group 67 | * 68 | * @param string $zone_identifier 69 | * @param string $package_identifier 70 | * @param string $identifier 71 | * @param string|null $mode Whether or not the rules contained within this group are configurable/usable 72 | */ 73 | public function update($zone_identifier, $package_identifier, $identifier, $mode = null) 74 | { 75 | $data = [ 76 | 'mode' => $mode, 77 | ]; 78 | 79 | return $this->patch('/zones/'.$zone_identifier.'/firewall/waf/packages/'.$package_identifier.'/groups/'.$identifier, $data); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/CloudFlare/Zone/SSL.php: -------------------------------------------------------------------------------- 1 | 13 | * 14 | * @version 1 15 | */ 16 | class SSL extends Api 17 | { 18 | /** 19 | * List SSL configurations (permission needed: #ssl:read) 20 | * 21 | * @param string $zone_identifier API item identifier tag 22 | */ 23 | public function certificates($zone_identifier) 24 | { 25 | return $this->get('zones/'.$zone_identifier.'/custom_certificates'); 26 | } 27 | 28 | /** 29 | * List SSL configuration details (permission needed: #ssl:read) 30 | * 31 | * @param string $zone_identifier API item identifier tag 32 | * @param string $identifier 33 | */ 34 | public function details($zone_identifier, $identifier) 35 | { 36 | return $this->get('zones/'.$zone_identifier.'/custom_certificates/'.$identifier); 37 | } 38 | 39 | /** 40 | * Create SSL configuration (permission needed: #ssl:edit) 41 | * 42 | * @param string $zone_identifier API item identifier tag 43 | * @param string $certificate The zone's SSL certificate or certificate and the intermediate(s) 44 | * @param string $private_key The zone's private key 45 | */ 46 | public function create($zone_identifier, $certificate, $private_key) 47 | { 48 | $data = [ 49 | 'certificate' => $certificate, 50 | 'private_key' => $private_key, 51 | ]; 52 | 53 | return $this->post('zones/'.$zone_identifier.'/custom_certificates', $data); 54 | } 55 | 56 | /** 57 | * Update SSL configuration (permission needed: #ssl:edit) 58 | * 59 | * @param string $zone_identifier API item identifier tag 60 | * @param string $identifier 61 | * @param string $certificate The zone's SSL certificate or certificate and the intermediate(s) 62 | * @param string $private_key The zone's private key 63 | */ 64 | public function update($zone_identifier, $identifier, $certificate, $private_key) 65 | { 66 | $data = [ 67 | 'certificate' => $certificate, 68 | 'private_key' => $private_key, 69 | ]; 70 | 71 | return $this->patch('zones/'.$zone_identifier.'/custom_certificates/'.$identifier, $data); 72 | } 73 | 74 | /** 75 | * Re-prioritize SSL certificates (permission needed: #ssl:edit) 76 | * 77 | * @param string $zone_identifier API item identifier tag 78 | * @param array $certificates Array of ordered certificates 79 | */ 80 | public function prioritize($zone_identifier, array $certificates) 81 | { 82 | $data = [ 83 | 'certificates' => $certificates, 84 | ]; 85 | 86 | return $this->patch('zones/'.$zone_identifier.'/custom_certificates/prioritize', $data); 87 | } 88 | 89 | /** 90 | * Delete an SSL certificate (permission needed: #ssl:edit) 91 | * 92 | * @param string $zone_identifier API item identifier tag 93 | * @param string $identifier 94 | */ 95 | public function delete_ssl($zone_identifier, $identifier) 96 | { 97 | return $this->delete('zones/'.$zone_identifier.'/custom_certificates/'.$identifier); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/CloudFlare/User/VirtualDns.php: -------------------------------------------------------------------------------- 1 | 14 | * 15 | * @version 1 16 | */ 17 | class Virtual_Dns extends Api 18 | { 19 | /** 20 | * Get Virtual DNS Clusters (permission needed: #dns_records:read) 21 | * List configured Virtual DNS clusters for a user 22 | */ 23 | public function clusters() 24 | { 25 | return $this->get('/user/virtual_dns'); 26 | } 27 | 28 | /** 29 | * Create a Virtual DNS Cluster (permission needed: #dns_records:edit) 30 | * Create a configured Virtual DNS Cluster 31 | * 32 | * @param string $name Virtual DNS Cluster Name 33 | * @param array $origin_ips 34 | * @param int|null $minimum_cache_ttl Minimum DNS Cache TTL 35 | * @param int|null $maximum_cache_ttl Maximum DNS Cache TTL 36 | * @param bool|null $deprecate_any_request Deprecate the response to ANY requests 37 | */ 38 | public function create($name, $origin_ips, $minimum_cache_ttl = null, $maximum_cache_ttl = null, $deprecate_any_request = null) 39 | { 40 | $data = [ 41 | 'name' => $name, 42 | 'origin_ips' => $origin_ips, 43 | 'minimum_cache_ttl' => $minimum_cache_ttl, 44 | 'maximum_cache_ttl' => $maximum_cache_ttl, 45 | 'deprecate_any_request' => $deprecate_any_request, 46 | ]; 47 | 48 | return $this->post('/user/virtual_dns', $data); 49 | } 50 | 51 | /** 52 | * Get a Virtual DNS Cluster (permission needed: #dns_records:read) 53 | * List a single configured Virtual DNS clusters for a user 54 | * 55 | * @param string $identifier Identifier tag 56 | */ 57 | public function cluster($identifier) 58 | { 59 | return $this->get('/user/virtual_dns/'.$identifier); 60 | } 61 | 62 | /** 63 | * Modify a Virtual DNS Cluster 64 | * Modify a Virtual DNS Cluster configuration (permission needed: #dns_records:edit) 65 | * 66 | * @param string $identifier Identifier tag 67 | * @param string $name Virtual DNS Cluster Name 68 | * @param array $origin_ips 69 | * @param int $minimum_cache_ttl Minimum DNS Cache TTL 70 | * @param int $maximum_cache_ttl Maximum DNS Cache TTL 71 | * @param bool $deprecate_any_request Deprecate the response to ANY requests 72 | */ 73 | public function modify($identifier, $name, $origin_ips, $minimum_cache_ttl, $maximum_cache_ttl, $deprecate_any_request) 74 | { 75 | $data = [ 76 | 'name' => $name, 77 | 'origin_ips' => $origin_ips, 78 | 'minimum_cache_ttl' => $minimum_cache_ttl, 79 | 'maximum_cache_ttl' => $maximum_cache_ttl, 80 | 'deprecate_any_request' => $deprecate_any_request, 81 | ]; 82 | 83 | return $this->patch('/user/virtual_dns/'.$identifier, $data); 84 | } 85 | 86 | /** 87 | * Delete a Virtual DNS Cluster (permission needed: #dns_records:edit) 88 | * Delete a configured Virtual DNS cluster 89 | * 90 | * @param string $identifier Identifier tag 91 | */ 92 | public function delete_cluster($identifier) 93 | { 94 | return $this->delete('/user/virtual_dns/'.$identifier); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/CloudFlare/Zone/KeylessSSL.php: -------------------------------------------------------------------------------- 1 | 13 | * 14 | * @version 1 15 | */ 16 | class KeylessSSL extends Api 17 | { 18 | /** 19 | * Create a Keyless SSL configuration (permission needed: #ssl:edit) 20 | * 21 | * @param string $zone_identifier API item identifier tag 22 | * @param string $host The keyless SSL host 23 | * @param int $port The keyless SSL port used to commmunicate between CloudFlare and the client's Keyless SSL server 24 | * @param string $name The keyless SSL name 25 | * @param string $certificate The zone's SSL certificate or SSL certificate and intermediate(s) 26 | * @param string|null $bundle_method A ubiquitous bundle is a bundle that has a higher probability of being verified everywhere, even by clients using outdated or unusual trust stores. 27 | * An optimal bundle is a bundle with the shortest chain and newest intermediates. A forced method attempt to use the certificate/chain as defined by the input 28 | */ 29 | public function create($zone_identifier, $host, $port, $name, $certificate, $bundle_method = null) 30 | { 31 | $data = [ 32 | 'host' => $host, 33 | 'port' => $port, 34 | 'name' => $name, 35 | 'certificate' => $certificate, 36 | 'bundle_method' => $bundle_method, 37 | ]; 38 | 39 | return $this->post('zones/'.$zone_identifier.'/keyless_certificates', $data); 40 | } 41 | 42 | /** 43 | * List Keyless SSLs (permission needed: #ssl:read) 44 | * 45 | * @param string $zone_identifier API item identifier tag 46 | */ 47 | public function certificates($zone_identifier) 48 | { 49 | return $this->get('zones/'.$zone_identifier.'/keyless_certificates'); 50 | } 51 | 52 | /** 53 | * Keyless SSL details (permission needed: #ssl:read) 54 | * 55 | * @param string $zone_identifier API item identifier tag 56 | * @param string $identifier 57 | */ 58 | public function details($zone_identifier, $identifier) 59 | { 60 | return $this->get('zones/'.$zone_identifier.'/keyless_certificates/'.$identifier); 61 | } 62 | 63 | /** 64 | * Update SSL configuration (permission needed: #ssl:edit) 65 | * 66 | * @param string $zone_identifier API item identifier tag 67 | * @param string $identifier 68 | * @param string $host The keyless SSL hostname 69 | * @param string $name The keyless SSL name 70 | * @param int $port The keyless SSL port used to commmunicate between CloudFlare and the client's Keyless SSL server 71 | * @param bool|null $enabled Whether or not the Keyless SSL is on or off 72 | */ 73 | public function update($zone_identifier, $identifier, $host, $name, $port, $enabled = null) 74 | { 75 | $data = [ 76 | 'host' => $host, 77 | 'port' => $port, 78 | 'name' => $name, 79 | 'enabled' => $enabled, 80 | ]; 81 | 82 | return $this->patch('zones/'.$zone_identifier.'/keyless_certificates/'.$identifier, $data); 83 | } 84 | 85 | /** 86 | * Delete an SSL certificate (permission needed: #ssl:edit) 87 | * 88 | * @param string $zone_identifier API item identifier tag 89 | * @param string $identifier 90 | */ 91 | public function delete_ssl($zone_identifier, $identifier) 92 | { 93 | return $this->delete('zones/'.$zone_identifier.'/keyless_certificates/'.$identifier); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/CloudFlare/Organizations/Railguns.php: -------------------------------------------------------------------------------- 1 | 14 | * 15 | * @version 1 16 | */ 17 | class Railguns extends Api 18 | { 19 | /** 20 | * Create Railgun (permission needed: #organization:edit) 21 | * 22 | * @param string $organization_identifier Organization identifier tag 23 | * @param string $name Readable identifier of the railgun 24 | */ 25 | public function create($organization_identifier, $name) 26 | { 27 | $data = [ 28 | 'name' => $name, 29 | ]; 30 | 31 | return $this->post('/organizations/'.$organization_identifier.'/railguns', $data); 32 | } 33 | 34 | /** 35 | * List Railguns (permission needed: #organization:read) 36 | * List, search, sort and filter your Railguns 37 | * 38 | * @param string $organization_identifier Organization identifier tag 39 | * @param int|null $page Page number of paginated results 40 | * @param int|null $per_page Number of items per page 41 | * @param string|null $direction Direction to order Railguns (asc, desc) 42 | */ 43 | public function railguns($organization_identifier, $page = null, $per_page = null, $direction = null) 44 | { 45 | $data = [ 46 | 'page' => $page, 47 | 'per_page' => $per_page, 48 | 'direction' => $direction, 49 | ]; 50 | 51 | return $this->get('/organizations/'.$organization_identifier.'/railguns', $data); 52 | } 53 | 54 | /** 55 | * Railgun details (permission needed: #organization:read) 56 | * 57 | * @param string $organization_identifier Organization identifier tag 58 | * @param string $identifier API item identifier tag 59 | */ 60 | public function details($organization_identifier, $identifier) 61 | { 62 | return $this->get('/organizations/'.$organization_identifier.'/railguns/'.$identifier); 63 | } 64 | 65 | /** 66 | * Get zones connected to a Railgun (permission needed: #organization:read) 67 | * The zones that are currently using this Railgun 68 | * 69 | * @param string $organization_identifier Organization identifier tag 70 | * @param string $identifier API item identifier tag 71 | */ 72 | public function zones($organization_identifier, $identifier) 73 | { 74 | return $this->get('/organizations/'.$organization_identifier.'/railguns/'.$identifier.'/zones'); 75 | } 76 | 77 | /** 78 | * Enable or disable a Railgun (permission needed: #organization:edit) 79 | * Enable or disable a Railgun for all zones connected to it 80 | * 81 | * @param string $organization_identifier Organization identifier tag 82 | * @param string $identifier API item identifier tag 83 | * @param bool|null $enabled Flag to determine if the Railgun is accepting connections 84 | */ 85 | public function enabled($organization_identifier, $identifier, $enabled = null) 86 | { 87 | $data = [ 88 | 'enabled' => $enabled, 89 | ]; 90 | 91 | return $this->patch('/organizations/'.$organization_identifier.'/railguns/'.$identifier, $data); 92 | } 93 | 94 | /** 95 | * Delete Railgun (permission needed: #organization:edit) 96 | * Disable and delete a Railgun. This will immediately disable the Railgun for any connected zones 97 | * 98 | * @param string $organization_identifier Organization identifier tag 99 | * @param string $identifier API item identifier tag 100 | */ 101 | public function delete_railgun($organization_identifier, $identifier) 102 | { 103 | return $this->delete('/organizations/'.$organization_identifier.'/railguns/'.$identifier); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/CloudFlare/User/Firewall/AccessRules.php: -------------------------------------------------------------------------------- 1 | 14 | * 15 | * @version 1 16 | */ 17 | class AccessRules extends Api 18 | { 19 | /** 20 | * List access rules (permission needed: #billing:read) 21 | * Search, sort, and filter IP/country access rules 22 | * 23 | * @param string|null $mode The action to apply to a matched request 24 | * @param string|null $configuration_target The rule configuration target 25 | * @param string|null $configuration_value Search by IP, range, or country code 26 | * @param int|null $page Page number of paginated results 27 | * @param int|null $per_page Number of items per page 28 | * @param string|null $order Field to order rules by 29 | * @param string|null $direction Direction to order rules 30 | * @param string|null $match Whether to match all search requirements or at least one (any) 31 | */ 32 | public function rules($mode = null, $configuration_target = null, $configuration_value = null, $page = null, $per_page = null, $order = null, $direction = null, $match = null) 33 | { 34 | $data = [ 35 | 'mode' => $mode, 36 | 'configuration_target' => $configuration_target, 37 | 'configuration_value' => $configuration_value, 38 | 'page' => $page, 39 | 'per_page' => $per_page, 40 | 'order' => $order, 41 | 'direction' => $direction, 42 | 'match' => $match, 43 | ]; 44 | 45 | return $this->get('/user/firewall/access_rules/rules', $data); 46 | } 47 | 48 | /** 49 | * Create access rule (permission needed: #billing:edit) 50 | * Make a new IP, IP range, or country access rule for all zones owned by the user. 51 | * Note: If you would like to create an access rule that applies to a specific zone only, use the zone firewall endpoints. 52 | * 53 | * @param string $mode The action to apply to a matched request 54 | * @param object $configuration Rule configuration 55 | * @param string|null $notes A personal note about the rule. Typically used as a reminder or explanation for the rule. 56 | */ 57 | public function create($mode, $configuration, $notes = null) 58 | { 59 | $data = [ 60 | 'mode' => $mode, 61 | 'configuration' => $configuration, 62 | 'notes' => $notes, 63 | ]; 64 | 65 | return $this->post('/user/firewall/access_rules/rules', $data); 66 | } 67 | 68 | /** 69 | * Update access rule (permission needed: #billing:edit) 70 | * Update rule state and/or configuration. This will be applied across all zones owned by the user. 71 | * 72 | * @param string $identifier 73 | * @param string|null $mode The action to apply to a matched request 74 | * @param object|null $configuration Rule configuration 75 | * @param string|null $notes A personal note about the rule. Typically used as a reminder or explanation for the rule. 76 | */ 77 | public function update($identifier, $mode = null, $configuration = null, $notes = null) 78 | { 79 | $data = [ 80 | 'mode' => $mode, 81 | 'configuration' => $configuration, 82 | 'notes' => $notes, 83 | ]; 84 | 85 | return $this->patch('/user/firewall/access_rules/rules/'.$identifier, $data); 86 | } 87 | 88 | /** 89 | * Delete access rule (permission needed: #billing:edit) 90 | * Remove an access rule so it is no longer evaluated during requests. This will apply to all zones owned by the user 91 | * 92 | * @param string $identifier 93 | */ 94 | public function delete_rule($identifier) 95 | { 96 | return $this->delete('/user/firewall/access_rules/rules/'.$identifier); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/CloudFlare/Zone/Analytics.php: -------------------------------------------------------------------------------- 1 | 14 | * 15 | * @version 1 16 | */ 17 | class Analytics extends Api 18 | { 19 | /** 20 | * Dashboard (permission needed: #analytics:read) 21 | * The dashboard view provides both totals and timeseries data for the given zone and time period across the entire CloudFlare network. 22 | * 23 | * @param string $zone_identifier 24 | * @param string|int|null $since The (inclusive) beginning of the requested time frame. This value can be a negative integer representing the number of minutes in the past relative to time the request is made, 25 | * or can be an absolute timestamp that conforms to RFC 3339. At this point in time, it cannot exceed a time in the past greater than one year. 26 | * @param string|int|null $until The (exclusive) end of the requested time frame. This value can be a negative integer representing the number of minutes in the past relative to time the request is made, 27 | * or can be an absolute timestamp that conforms to RFC 3339. If omitted, the time of the request is used. 28 | * @param bool $continuous When set to true, the range returned by the response acts like a sliding window to provide a contiguous time-window. 29 | * Analytics data is processed and aggregated asynchronously and can sometimes lead to recent data points being incomplete if this value is set to false. 30 | * If a start date provided is earlier than a date for which data is available, the API will return 0's for those dates until the first available date with data 31 | */ 32 | public function dashboard($zone_identifier, $since = null, $until = null, $continuous = null) 33 | { 34 | $data = [ 35 | 'since' => $since, 36 | 'until' => $until, 37 | 'continuous' => $continuous, 38 | ]; 39 | 40 | return $this->get('zones/'.$zone_identifier.'/analytics/dashboard', $data); 41 | } 42 | 43 | /** 44 | * Analytics by Co-locations (permission needed: #analytics:read) 45 | * This view provides a breakdown of analytics data by datacenter. Note: This is available to Enterprise customers only. 46 | * 47 | * @param string $zone_identifier 48 | * @param string|int|null $since The (inclusive) beginning of the requested time frame. This value can be a negative integer representing the number of minutes in the past relative to time the request is made, 49 | * or can be an absolute timestamp that conforms to RFC 3339. At this point in time, it cannot exceed a time in the past greater than one year. 50 | * @param string|int|null $until The (exclusive) end of the requested time frame. This value can be a negative integer representing the number of minutes in the past relative to time the request is made, 51 | * or can be an absolute timestamp that conforms to RFC 3339. If omitted, the time of the request is used. 52 | * @param bool $continuous When set to true, the range returned by the response acts like a sliding window to provide a contiguous time-window. 53 | * Analytics data is processed and aggregated asynchronously and can sometimes lead to recent data points being incomplete if this value is set to false. 54 | * If a start date provided is earlier than a date for which data is available, the API will return 0's for those dates until the first available date with data 55 | */ 56 | public function colos($zone_identifier, $since = null, $until = null, $continuous = null) 57 | { 58 | $data = [ 59 | 'since' => $since, 60 | 'until' => $until, 61 | 'continuous' => $continuous, 62 | ]; 63 | 64 | return $this->get('zones/'.$zone_identifier.'/analytics/colos', $data); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/CloudFlare/Organizations/VirtualDns.php: -------------------------------------------------------------------------------- 1 | 14 | * 15 | * @version 1 16 | */ 17 | class Virtual_Dns extends Api 18 | { 19 | /** 20 | * Get Virtual DNS Clusters (permission needed: #dns_records:read) 21 | * List configured Virtual DNS clusters for an organization 22 | * 23 | * @param string $organization_identifier organization_identifier tag 24 | */ 25 | public function clusters($organization_identifier) 26 | { 27 | return $this->get('/organizations/'.$organization_identifier.'/virtual_dns'); 28 | } 29 | 30 | /** 31 | * Create a Virtual DNS Cluster (permission needed: #dns_records:edit) 32 | * Create a configured Virtual DNS Cluster 33 | * 34 | * @param string $organization_identifier organization_identifier tag 35 | * @param string $name Virtual DNS Cluster Name 36 | * @param array $origin_ips 37 | * @param int|null $minimum_cache_ttl Minimum DNS Cache TTL 38 | * @param int|null $maximum_cache_ttl Maximum DNS Cache TTL 39 | * @param bool|null $deprecate_any_request Deprecate the response to ANY requests 40 | */ 41 | public function create($organization_identifier, $name, $origin_ips, $minimum_cache_ttl = null, $maximum_cache_ttl = null, $deprecate_any_request = null) 42 | { 43 | $data = [ 44 | 'name' => $name, 45 | 'origin_ips' => $origin_ips, 46 | 'minimum_cache_ttl' => $minimum_cache_ttl, 47 | 'maximum_cache_ttl' => $maximum_cache_ttl, 48 | 'deprecate_any_request' => $deprecate_any_request, 49 | ]; 50 | 51 | return $this->post('/organizations/'.$organization_identifier.'/virtual_dns', $data); 52 | } 53 | 54 | /** 55 | * Get a Virtual DNS Cluster (permission needed: #dns_records:read) 56 | * List a single configured Virtual DNS clusters for an organization 57 | * 58 | * @param string $organization_identifier organization_identifier tag 59 | * @param string $identifier identifier tag 60 | */ 61 | public function cluster($organization_identifier, $identifier) 62 | { 63 | return $this->get('/organizations/'.$organization_identifier.'/virtual_dns/'.$identifier); 64 | } 65 | 66 | /** 67 | * Modify a Virtual DNS Cluster 68 | * Modify a Virtual DNS Cluster configuration (permission needed: #dns_records:edit) 69 | * 70 | * @param string $organization_identifier organization_identifier tag 71 | * @param string $identifier identifier tag 72 | * @param string $name Virtual DNS Cluster Name 73 | * @param array $origin_ips 74 | * @param int $minimum_cache_ttl Minimum DNS Cache TTL 75 | * @param int $maximum_cache_ttl Maximum DNS Cache TTL 76 | * @param bool $deprecate_any_request Deprecate the response to ANY requests 77 | */ 78 | public function modify($organization_identifier, $identifier, $name, $origin_ips, $minimum_cache_ttl, $maximum_cache_ttl, $deprecate_any_request) 79 | { 80 | $data = [ 81 | 'name' => $name, 82 | 'origin_ips' => $origin_ips, 83 | 'minimum_cache_ttl' => $minimum_cache_ttl, 84 | 'maximum_cache_ttl' => $maximum_cache_ttl, 85 | 'deprecate_any_request' => $deprecate_any_request, 86 | ]; 87 | 88 | return $this->patch('/organizations/'.$organization_identifier.'/virtual_dns/'.$identifier, $data); 89 | } 90 | 91 | /** 92 | * Delete a Virtual DNS Cluster (permission needed: #dns_records:edit) 93 | * Delete a configured Virtual DNS cluster 94 | * 95 | * @param string $organization_identifier organization_identifier tag 96 | * @param string $identifier identifier tag 97 | */ 98 | public function delete_cluster($organization_identifier, $identifier) 99 | { 100 | return $this->delete('/organizations/'.$organization_identifier.'/virtual_dns/'.$identifier); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/CloudFlare/User/LoadBalancers/Pools.php: -------------------------------------------------------------------------------- 1 | 15 | * 16 | * @version 1 17 | */ 18 | class Pools extends Api 19 | { 20 | /** 21 | * List pools 22 | * List configured pools 23 | */ 24 | public function pools() 25 | { 26 | return $this->get('/user/load_balancers/pools'); 27 | } 28 | 29 | /** 30 | * Create a pool 31 | * Create a new pool 32 | * 33 | * @param string $name Object name 34 | * @param array $origins A list of origins contained in the pool. 35 | * Traffic destined to the pool is balanced across all 36 | * available origins contained in the pool (as long as the pool 37 | * is considered available). 38 | * @param string|null $description Object description 39 | * @param bool|null $enabled Whether this pool is enabled or not. 40 | * @param string|null $monitor ID of the monitor object to use for monitoring the health 41 | * status of origins inside this pool. 42 | * @param string|null $notification_email ID of the notifier object to use for notifications relating 43 | * to the health status of origins inside this pool. 44 | */ 45 | public function create($name, $origins, $description = null, $enabled = null, $monitor = null, $notification_email = null) 46 | { 47 | $data = [ 48 | 'name' => $name, 49 | 'origins' => $origins, 50 | 'description' => $description, 51 | 'enabled' => $enabled, 52 | 'monitor' => $monitor, 53 | 'notification_email' => $notification_email, 54 | ]; 55 | 56 | return $this->post('/user/load_balancers/pools', $data); 57 | } 58 | 59 | /** 60 | * Pool details 61 | * Fetch a single configured pool 62 | * 63 | * @param string $identifier 64 | */ 65 | public function details($identifier) 66 | { 67 | return $this->get('/user/load_balancers/pools/'.$identifier); 68 | } 69 | 70 | /** 71 | * Modify a pool 72 | * Modify a configured pool 73 | * 74 | * @param string $identifier 75 | * @param string $name Object name 76 | * @param array $origins A list of origins contained in the pool. 77 | * Traffic destined to the pool is balanced across all 78 | * available origins contained in the pool (as long as the pool 79 | * is considered available). 80 | * @param string|null $description Object description 81 | * @param bool|null $enabled Whether this pool is enabled or not. 82 | * @param string|null $monitor ID of the monitor object to use for monitoring the health 83 | * status of origins inside this pool. 84 | * @param string|null $notification_email ID of the notifier object to use for notifications relating 85 | * to the health status of origins inside this pool. 86 | */ 87 | public function update($identifier, $name, $origins, $description = null, $enabled = null, $monitor = null, $notification_email = null) 88 | { 89 | $data = [ 90 | 'name' => $name, 91 | 'origins' => $origins, 92 | 'description' => $description, 93 | 'enabled' => $enabled, 94 | 'monitor' => $monitor, 95 | 'notification_email' => $notification_email, 96 | ]; 97 | 98 | return $this->patch('/user/load_balancers/pools/'.$identifier, $data); 99 | } 100 | 101 | /** 102 | * Delete a pool 103 | * Delete a configured pool 104 | * 105 | * @param string $identifier 106 | */ 107 | public function delete_pool($identifier) 108 | { 109 | return $this->delete('/user/load_balancers/pools/'.$identifier); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /src/CloudFlare/Organizations/Firewall/AccessRules/Rules.php: -------------------------------------------------------------------------------- 1 | 15 | * 16 | * @version 1 17 | */ 18 | class Rules extends Api 19 | { 20 | /** 21 | * List access rules (permission needed: #organization:read) 22 | * Search, sort, and filter IP/country access rules 23 | * 24 | * @param string $organization_id 25 | * @param string|null $mode The action to apply to a matched request 26 | * @param string|null $configuration_target The rule configuration target 27 | * @param string|null $configuration_value Search by IP, range, or country code 28 | * @param int|null $page Page number of paginated results 29 | * @param int|null $per_page Number of rules per page 30 | * @param string|null $order Field to order rules by 31 | * @param string|null $direction Direction to order rules 32 | * @param string|null $match Whether to match all search requirements or at least one (any) 33 | */ 34 | public function rules($organization_id, $mode = null, $configuration_target = null, $configuration_value = null, $page = null, $per_page = null, $order = null, $direction = null, $match = null) 35 | { 36 | $data = [ 37 | 'mode' => $mode, 38 | 'configuration_target' => $configuration_target, 39 | 'configuration_value' => $configuration_value, 40 | 'page' => $page, 41 | 'per_page' => $per_page, 42 | 'order' => $order, 43 | 'direction' => $direction, 44 | 'match' => $match, 45 | ]; 46 | 47 | return $this->get('organizations/'.$organization_id.'/firewall/access_rules/rules', $data); 48 | } 49 | 50 | /** 51 | * Create access rule (permission needed: #organization:edit) 52 | * Make a new IP, IP range, or country access rule for all zones owned by the organization. 53 | * Note: If you would like to create an access rule that applies to a specific zone only, use the zone firewall endpoints. 54 | * 55 | * @param string $organization_id 56 | * @param string $mode The action to apply to a matched request 57 | * @param object $configuration Rule configuration 58 | * @param string|null $notes A personal note about the rule. Typically used as a reminder or explanation for the rule. 59 | */ 60 | public function create($organization_id, $mode, $configuration, $notes = null) 61 | { 62 | $data = [ 63 | 'mode' => $mode, 64 | 'configuration' => $configuration, 65 | 'notes' => $notes, 66 | ]; 67 | 68 | return $this->post('organizations/'.$organization_id.'/firewall/access_rules/rules', $data); 69 | } 70 | 71 | /** 72 | * Update access rule (permission needed: #organization:edit) 73 | * Update rule state and/or configuration. This will be applied across all zones owned by the organization. 74 | * 75 | * @param string $organization_id 76 | * @param string $identifier 77 | * @param string|null $mode The action to apply to a matched request 78 | * @param object|null $configuration Rule configuration 79 | * @param string|null $notes A personal note about the rule. Typically used as a reminder or explanation for the rule. 80 | */ 81 | public function update($organization_id, $identifier, $mode = null, $configuration = null, $notes = null) 82 | { 83 | $data = [ 84 | 'mode' => $mode, 85 | 'configuration' => $configuration, 86 | 'notes' => $notes, 87 | ]; 88 | 89 | return $this->patch('organizations/'.$organization_id.'/firewall/access_rules/rules/'.$identifier, $data); 90 | } 91 | 92 | /** 93 | * Delete access rule (permission needed: #organization:edit) 94 | * Remove an access rule so it is no longer evaluated during requests. This will apply to all zones owned by the organization 95 | * 96 | * @param string $organization_id 97 | * @param string $identifier 98 | */ 99 | public function delete_rule($organization_id, $identifier) 100 | { 101 | return $this->delete('organizations/'.$organization_id.'/firewall/access_rules/rules/'.$identifier); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/CloudFlare/User.php: -------------------------------------------------------------------------------- 1 | 12 | * 13 | * @version 1 14 | */ 15 | class User extends Api 16 | { 17 | /** 18 | * User details 19 | */ 20 | public function user() 21 | { 22 | return $this->get('user'); 23 | } 24 | 25 | /** 26 | * Update user 27 | * Update part of your user details 28 | * 29 | * @param string|null $first_name User's first name 30 | * @param string|null $last_name User's last name 31 | * @param string|null $telephone User's telephone number 32 | * @param string|null $country The country in which the user lives. (Full list is here: http://en.wikipedia.org/wiki/List_of_country_calling_codes) 33 | * @param string|null $zipcode The zipcode or postal code where the user lives. 34 | */ 35 | public function update($first_name = null, $last_name = null, $telephone = null, $country = null, $zipcode = null) 36 | { 37 | $data = [ 38 | 'first_name' => $first_name, 39 | 'last_name' => $last_name, 40 | 'telephone' => $telephone, 41 | 'country' => $country, 42 | 'zipcode' => $zipcode, 43 | ]; 44 | 45 | return $this->patch('user', $data); 46 | } 47 | 48 | /** 49 | * Change your email address. Note: You must provide your current password. 50 | * 51 | * @param string $email Your contact email address 52 | * @param string $confirm_email Your contact email address, repeated 53 | * @param string $password Your current password 54 | */ 55 | public function change_email($email, $confirm_email, $password) 56 | { 57 | $data = [ 58 | 'email' => $email, 59 | 'confirm_email' => $confirm_email, 60 | 'password' => $password, 61 | ]; 62 | 63 | return $this->put('user/email', $data); 64 | } 65 | 66 | /** 67 | * Change your password 68 | * 69 | * @param string $old_password Your current password 70 | * @param string $new_password Your new password 71 | * @param string $new_password_confirm Your new password, repeated 72 | */ 73 | public function change_password($old_password, $new_password, $new_password_confirm) 74 | { 75 | $data = [ 76 | 'old_password' => $old_password, 77 | 'new_password' => $new_password, 78 | 'new_password_confirm' => $new_password_confirm, 79 | ]; 80 | 81 | return $this->put('user/password', $data); 82 | } 83 | 84 | /** 85 | * Change your username. Note: You must provide your current password. 86 | * 87 | * @param string $username A username used to access other cloudflare services, like support 88 | * @param string $password Your current password 89 | */ 90 | public function change_username($username, $password) 91 | { 92 | $data = [ 93 | 'username' => $username, 94 | 'password' => $password, 95 | ]; 96 | 97 | return $this->put('user/username', $data); 98 | } 99 | 100 | /** 101 | * Begin setting up CloudFlare two-factor authentication with a given telephone number 102 | * 103 | * @param int $country_code The country code of your mobile phone number 104 | * @param string $mobile_phone_number Your mobile phone number 105 | * @param string $current_password Your current CloudFlare password 106 | */ 107 | public function initialize_two_factor_authentication($country_code, $mobile_phone_number, $current_password) 108 | { 109 | $data = [ 110 | 'country_code' => $country_code, 111 | 'mobile_phone_number' => $mobile_phone_number, 112 | 'current_password' => $current_password, 113 | ]; 114 | 115 | return $this->post('/user/two_factor_authentication', $data); 116 | } 117 | 118 | /** 119 | * Finish setting up CloudFlare two-factor authentication with a given telephone number 120 | * 121 | * @param int $auth_token The token provided by the two-factor authenticator 122 | */ 123 | public function finalize_two_factor_authentication($auth_token) 124 | { 125 | $data = [ 126 | 'auth_token' => $auth_token, 127 | ]; 128 | 129 | return $this->put('user/two_factor_authentication', $data); 130 | } 131 | 132 | /** 133 | * Disable two-factor authentication for your CloudFlare user account 134 | * 135 | * @param int The token provided by the two-factor authenticator 136 | */ 137 | public function disable_two_factor_authentication($auth_token) 138 | { 139 | $data = [ 140 | 'auth_token' => $auth_token, 141 | ]; 142 | 143 | return $this->delete('user/two_factor_authentication', $data); 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /src/CloudFlare/Organizations/LoadBalancers/Pools.php: -------------------------------------------------------------------------------- 1 | 15 | * 16 | * @version 1 17 | */ 18 | class Pools extends Api 19 | { 20 | /** 21 | * List pools 22 | * List configured pools 23 | * 24 | * @param string $organization_identifier 25 | */ 26 | public function pools($organization_identifier) 27 | { 28 | return $this->get('/organizations/'.$organization_identifier.'/load_balancers/pools'); 29 | } 30 | 31 | /** 32 | * Create a pool 33 | * Create a new pool 34 | * 35 | * @param string $organization_identifier 36 | * @param string $name Object name 37 | * @param array $origins A list of origins contained in the pool. 38 | * Traffic destined to the pool is balanced across all 39 | * available origins contained in the pool (as long as the pool 40 | * is considered available). 41 | * @param string|null $description Object description 42 | * @param bool|null $enabled Whether this pool is enabled or not. 43 | * @param string|null $monitor ID of the monitor object to use for monitoring the health 44 | * status of origins inside this pool. 45 | * @param string|null $notification_email ID of the notifier object to use for notifications relating 46 | * to the health status of origins inside this pool. 47 | */ 48 | public function create($organization_identifier, $name, $origins, $description = null, $enabled = null, $monitor = null, $notification_email = null) 49 | { 50 | $data = [ 51 | 'name' => $name, 52 | 'origins' => $origins, 53 | 'description' => $description, 54 | 'enabled' => $enabled, 55 | 'monitor' => $monitor, 56 | 'notification_email' => $notification_email, 57 | ]; 58 | 59 | return $this->post('/organizations/'.$organization_identifier.'/load_balancers/pools', $data); 60 | } 61 | 62 | /** 63 | * Pool details 64 | * Fetch a single configured pool 65 | * 66 | * @param string $organization_identifier 67 | * @param string $identifier 68 | */ 69 | public function details($organization_identifier, $identifier) 70 | { 71 | return $this->get('/organizations/'.$organization_identifier.'/load_balancers/pools/'.$identifier); 72 | } 73 | 74 | /** 75 | * Modify a pool 76 | * Modify a configured pool 77 | * 78 | * @param string $organization_identifier 79 | * @param string $identifier 80 | * @param string $name Object name 81 | * @param array $origins A list of origins contained in the pool. 82 | * Traffic destined to the pool is balanced across all 83 | * available origins contained in the pool (as long as the pool 84 | * is considered available). 85 | * @param string|null $description Object description 86 | * @param bool|null $enabled Whether this pool is enabled or not. 87 | * @param string|null $monitor ID of the monitor object to use for monitoring the health 88 | * status of origins inside this pool. 89 | * @param string|null $notification_email ID of the notifier object to use for notifications relating 90 | * to the health status of origins inside this pool. 91 | */ 92 | public function update($organization_identifier, $identifier, $name, $origins, $description = null, $enabled = null, $monitor = null, $notification_email = null) 93 | { 94 | $data = [ 95 | 'name' => $name, 96 | 'origins' => $origins, 97 | 'description' => $description, 98 | 'enabled' => $enabled, 99 | 'monitor' => $monitor, 100 | 'notification_email' => $notification_email, 101 | ]; 102 | 103 | return $this->patch('/organizations/'.$organization_identifier.'/load_balancers/pools/'.$identifier, $data); 104 | } 105 | 106 | /** 107 | * Delete a pool 108 | * Delete a configured pool 109 | * 110 | * @param string $identifier 111 | */ 112 | public function delete_pool($organization_identifier, $identifier) 113 | { 114 | return $this->delete('/organizations/'.$organization_identifier.'/load_balancers/pools/'.$identifier); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/CloudFlare/Zone/Firewall/AccessRules.php: -------------------------------------------------------------------------------- 1 | 14 | * 15 | * @version 1 16 | */ 17 | class AccessRules extends Api 18 | { 19 | /** 20 | * List access rules (permission needed: #zone:read) 21 | * Search, sort, and filter IP/country access rule 22 | * 23 | * @param string $zone_id 24 | * @param string|null $scope_type The scope of the rules 25 | * @param string|null $mode The action to apply to a matched request 26 | * @param string|null $configuration_target The rule configuration target 27 | * @param string|null $configuration_value Search by IP, range, or country code 28 | * @param int|null $page Page number of paginated results 29 | * @param int|null $per_page Number of rules per page 30 | * @param string|null $order Field to order rules by 31 | * @param string|null $direction Direction to order rules 32 | * @param string|null $match Whether to match all search requirements or at least one (any) 33 | * @param string|null $notes Search in the access rules by notes. 34 | */ 35 | public function rules($zone_id, $scope_type = null, $mode = null, $configuration_target = null, $configuration_value = null, $page = null, $per_page = null, $order = null, $direction = null, $match = null, $notes = null) 36 | { 37 | $data = [ 38 | 'scope_type' => $scope_type, 39 | 'mode' => $mode, 40 | 'configuration_target' => $configuration_target, 41 | 'configuration_value' => $configuration_value, 42 | 'page' => $page, 43 | 'per_page' => $per_page, 44 | 'order' => $order, 45 | 'direction' => $direction, 46 | 'match' => $match, 47 | 'notes' => $notes, 48 | ]; 49 | 50 | return $this->get('/zones/'.$zone_id.'/firewall/access_rules/rules', $data); 51 | } 52 | 53 | /** 54 | * Create access rule (permission needed: #zone:edit) 55 | * Make a new IP, IP range, or country access rule for the zone. 56 | * Note: If you would like to create an access rule that applies across all of your owned zones, use the user or organization firewall endpoints as appropriate. 57 | * 58 | * @param string $zone_id 59 | * @param string $mode The action to apply to a matched request 60 | * @param object $configuration Rule configuration 61 | * @param string|null $notes A personal note about the rule. Typically used as a reminder or explanation for the rule. 62 | */ 63 | public function create($zone_id, $mode, $configuration, $notes = null) 64 | { 65 | $data = [ 66 | 'mode' => $mode, 67 | 'configuration' => $configuration, 68 | 'notes' => $notes, 69 | ]; 70 | 71 | return $this->post('/zones/'.$zone_id.'/firewall/access_rules/rules', $data); 72 | } 73 | 74 | /** 75 | * Update access rule (permission needed: #zone:edit) 76 | * Update rule state and/or configuration for the zone. 77 | * Note: you can only edit rules in the 'zone' group via this endpoint. Use the appropriate owner rules endpoint if trying to manage owner-level rules 78 | * 79 | * @param string $zone_id 80 | * @param string $identifier 81 | * @param string|null $mode The action to apply to a matched request 82 | * @param string|null $notes A personal note about the rule. Typically used as a reminder or explanation for the rule. 83 | */ 84 | public function update($zone_id, $identifier, $mode = null, $notes = null) 85 | { 86 | $data = [ 87 | 'mode' => $mode, 88 | 'notes' => $notes, 89 | ]; 90 | 91 | return $this->patch('/zones/'.$zone_id.'/firewall/access_rules/rules/'.$identifier, $data); 92 | } 93 | 94 | /** 95 | * Delete access rule (permission needed: #zone:edit) 96 | * Remove an access rule so it is no longer evaluated during requests. 97 | * Optionally, specify how to delete rules that match the mode and configuration across all other zones that this zone owner manages. 98 | * 'none' is the default, and will only delete this rule. 99 | * 'basic' will delete rules that match the same mode and configuration. 100 | * 'aggressive' will delete rules that match the same configuration. 101 | * 102 | * @param string $zone_id 103 | * @param string $identifier 104 | * @param string|null $cascade The level to attempt to delete rules defined on other zones that are similar to this rule 105 | */ 106 | public function delete_rule($zone_id, $identifier, $cascade = null) 107 | { 108 | $data = [ 109 | 'cascade' => $cascade, 110 | ]; 111 | 112 | return $this->delete('/zones/'.$zone_id.'/firewall/access_rules/rules/'.$identifier, $data); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/CloudFlare/Zone.php: -------------------------------------------------------------------------------- 1 | 12 | * 13 | * @version 1 14 | */ 15 | class Zone extends Api 16 | { 17 | /** 18 | * Create a zone (permission needed: #zone:edit) 19 | * 20 | * @param string $name The domain name 21 | * @param bool|null $jump_start Automatically attempt to fetch existing DNS records 22 | * @param int|null $organization To create a zone owned by an organization, specify the organization parameter. Organization objects can be found in the User or User's Organizations endpoints. You must pass at least the ID of the organization. 23 | */ 24 | public function create($name, $jump_start = null, $organization = null) 25 | { 26 | $data = [ 27 | 'name' => $name, 28 | 'jump_start' => $jump_start, 29 | 'organization' => $organization, 30 | ]; 31 | 32 | return $this->post('zones', $data); 33 | } 34 | 35 | /** 36 | * Initiate another zone activation check (permission needed: #zone:edit) 37 | * 38 | * @param string $identifier API item identifier tag 39 | */ 40 | public function activation_check($identifier) 41 | { 42 | return $this->put('zones/'.$identifier.'/activation_check'); 43 | } 44 | 45 | /** 46 | * List zones (permission needed: #zone:read) 47 | * List, search, sort, and filter your zones 48 | * 49 | * @param string|null $name A domain name 50 | * @param string|null $status Status of the zone (active, pending, initializing, moved, deleted) 51 | * @param int|null $page Page number of paginated results 52 | * @param int|null $per_page Number of zones per page 53 | * @param string|null $order Field to order zones by (name, status, email) 54 | * @param string|null $direction Direction to order zones (asc, desc) 55 | * @param string|null $match Whether to match all search requirements or at least one (any) (any, all) 56 | */ 57 | public function zones($name = null, $status = null, $page = null, $per_page = null, $order = null, $direction = null, $match = null) 58 | { 59 | $data = [ 60 | 'name' => $name, 61 | 'status' => $status, 62 | 'page' => $page, 63 | 'per_page' => $per_page, 64 | 'order' => $order, 65 | 'direction' => $direction, 66 | 'match' => $match, 67 | ]; 68 | 69 | return $this->get('zones', $data); 70 | } 71 | 72 | /** 73 | * Zone details (permission needed: #zone:read) 74 | * 75 | * @param string $zone_identifier API item identifier tag 76 | */ 77 | public function zone($zone_identifier) 78 | { 79 | return $this->get('zones/'.$zone_identifier); 80 | } 81 | 82 | /** 83 | * Edit Vanity Name Servers (permission needed: #zone:edit) 84 | * 85 | * @param string $zone_identifier API item identifier tag 86 | * @param array $vanity_name_servers An array of domains used for custom name servers. This is only available for Business 87 | * and Enterprise plans. 88 | */ 89 | public function edit_vanity_name_servers($zone_identifier, $vanity_name_servers) 90 | { 91 | $data = [ 92 | 'vanity_name_servers' => $vanity_name_servers, 93 | ]; 94 | 95 | return $this->patch('zones/'.$zone_identifier, $data); 96 | } 97 | 98 | /** 99 | * Edit the desired plan for the zone (permission needed: #zone:edit) 100 | * 101 | * @param string $zone_identifier API item identifier tag 102 | * @param object $plan The desired plan for the zone. Changing this value will create/cancel associated 103 | * subscriptions. To view available plans for this zone, see Zone Plans 104 | */ 105 | public function edit_plan($zone_identifier, $plan) 106 | { 107 | $data = [ 108 | 'plan' => $plan, 109 | ]; 110 | 111 | return $this->patch('zones/'.$zone_identifier, $data); 112 | } 113 | 114 | /** 115 | * Pause all CloudFlare features (permission needed: #zone:edit) 116 | * This will pause all features and settings for the zone. DNS will still resolve 117 | * 118 | * @param string $zone_identifier API item identifier tag 119 | */ 120 | public function pause($zone_identifier) 121 | { 122 | $data = [ 123 | 'paused' => true, 124 | ]; 125 | 126 | return $this->patch('zones/'.$zone_identifier, $data); 127 | } 128 | 129 | /** 130 | * Re-enable all CloudFlare features (permission needed: #zone:edit) 131 | * This will restore all features and settings for the zone 132 | * 133 | * @param string $zone_identifier API item identifier tag 134 | */ 135 | public function unpause($zone_identifier) 136 | { 137 | $data = [ 138 | 'paused' => false, 139 | ]; 140 | 141 | return $this->patch('zones/'.$zone_identifier, $data); 142 | } 143 | 144 | /** 145 | * Delete a zone (permission needed: #zone:edit) 146 | * 147 | * @param string $zone_identifier API item identifier tag 148 | */ 149 | public function delete_zone($zone_identifier) 150 | { 151 | return $this->delete('zones/'.$zone_identifier); 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /src/CloudFlare/Zone/CustomSSL.php: -------------------------------------------------------------------------------- 1 | 13 | * 14 | * @version 1 15 | */ 16 | class CustomSSL extends Api 17 | { 18 | /** 19 | * List SSL configurations (permission needed: #ssl:edit) 20 | * List, search, sort, and filter all of your custom SSL certificates 21 | * 22 | * @param string $zone_identifier API item identifier tag 23 | * @param string|null $status Status of the zone's custom SSL 24 | * @param int|null $page Page number of paginated results 25 | * @param int|null $per_page Number of zones per page 26 | * @param string|null $order Field to order certificates by (status, issuer, priority, expires_on) 27 | * @param string|null $direction Direction to order domains (asc, desc) 28 | * @param string|null $match Whether to match all search requirements or at least one (any) (any, all) 29 | */ 30 | public function list_certificates($zone_identifier, $status = null, $page = null, $per_page = null, $order = null, $direction = null, $match = null) 31 | { 32 | $data = [ 33 | 'status' => $status, 34 | 'page' => $page, 35 | 'per_page' => $per_page, 36 | 'order' => $order, 37 | 'direction' => $direction, 38 | 'match' => $match, 39 | ]; 40 | 41 | return $this->get('zones/'.$zone_identifier.'/custom_certificates', $data); 42 | } 43 | 44 | /** 45 | * Create SSL configuration (permission needed: #ssl:edit) 46 | * Upload a new SSL certificate for a zone 47 | * 48 | * @param string $zone_identifier API item identifier tag 49 | * @param string $certificate The zone's private key 50 | * @param string $private_key The zone's SSL certificate or certificate and the intermediate(s) 51 | * @param string|null $bundle_method A ubiquitous bundle is a bundle that has a higher probability of being verified everywhere, 52 | * even by clients using outdated or unusual trust stores. An optimal bundle is a bundle with the shortest chain and newest 53 | * intermediates. A forced method attempt to use the certificate/chain as defined by the input "ubiquitous" 54 | */ 55 | public function create($zone_identifier, $certificate, $private_key, $bundle_method = null) 56 | { 57 | $data = [ 58 | 'certificate' => $certificate, 59 | 'private_key' => $private_key, 60 | 'bundle_method' => $bundle_method, 61 | ]; 62 | 63 | return $this->post('zones/'.$zone_identifier.'/custom_certificates', $data); 64 | } 65 | 66 | /** 67 | * SSL configuration details (permission needed: #ssl:read) 68 | * 69 | * @param string $zone_identifier API item identifier tag 70 | * @param string $identifier 71 | */ 72 | public function details($zone_identifier, $identifier) 73 | { 74 | return $this->get('zones/'.$zone_identifier.'/custom_certificates/'.$identifier); 75 | } 76 | 77 | /** 78 | * Create a Keyless SSL configuration (permission needed: #ssl:edit) 79 | * 80 | * @param string $zone_identifier API item identifier tag 81 | * @param string $identifier 82 | * @param string $private_key The zone's SSL certificate or certificate and the intermediate(s) 83 | * @param string $certificate The zone's private key 84 | * @param string|null $bundle_method A ubiquitous bundle is a bundle that has a higher probability of being verified everywhere, 85 | * even by clients using outdated or unusual trust stores. An optimal bundle is a bundle with the shortest chain and newest 86 | * intermediates. A forced method attempt to use the certificate/chain as defined by the input "ubiquitous" 87 | */ 88 | public function update($zone_identifier, $identifier, $private_key, $certificate, $bundle_method = null) 89 | { 90 | $data = [ 91 | 'certificate' => $certificate, 92 | 'private_key' => $private_key, 93 | 'bundle_method' => $bundle_method, 94 | ]; 95 | 96 | return $this->patch('zones/'.$zone_identifier.'/custom_certificates/'.$identifier, $data); 97 | } 98 | 99 | /** 100 | * Re-prioritize SSL certificates (permission needed: #ssl:edit) 101 | * If a zone has multiple SSL certificates, you can set the order in which they should be used during a request. 102 | * 103 | * @param string $zone_identifier API item identifier tag 104 | * @param array $certificates Array of ordered certificates. 105 | */ 106 | public function prioritize($zone_identifier, array $certificates) 107 | { 108 | $data = [ 109 | 'certificates' => $certificates, 110 | ]; 111 | 112 | return $this->put('zones/'.$zone_identifier.'/custom_certificates/prioritize', $data); 113 | } 114 | 115 | /** 116 | * Delete an SSL certificate (permission needed: #ssl:edit) 117 | * 118 | * @param string $zone_identifier API item identifier tag 119 | * @param string $identifier 120 | */ 121 | public function delete_ssl($zone_identifier, $identifier) 122 | { 123 | return $this->delete('zones/'.$zone_identifier.'/custom_certificates/'.$identifier); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/CloudFlare/Zone/Dns.php: -------------------------------------------------------------------------------- 1 | 14 | * 15 | * @version 1 16 | */ 17 | class Dns extends Api 18 | { 19 | /** 20 | * Create DNS record (permission needed: #dns_records:edit) 21 | * Create a new DNS record for a zone. See the record object definitions for required attributes for each record type 22 | * 23 | * @param string $zone_identifier 24 | * @param string $type DNS record type (A, AAAA, CNAME, TXT, SRV, LOC, MX, NS, SPF) 25 | * @param string $name DNS record name 26 | * @param string $content DNS record content 27 | * @param int|null $ttl Time to live for DNS record. Value of 1 is 'automatic' 28 | * @param bool|null $proxied Whether to proxy the domain through CloudFlare or not 29 | * @param int|null $priority MX record priority value 30 | * @param array|null $data Additional data required for SRV record 31 | */ 32 | public function create($zone_identifier, $type, $name, $content, $ttl = null, $proxied = null, $priority = null, $data = null) 33 | { 34 | $data = [ 35 | 'type' => strtoupper($type), 36 | 'name' => $name, 37 | 'content' => $content, 38 | 'ttl' => $ttl, 39 | 'proxied' => $proxied, 40 | 'priority' => $priority, 41 | 'data' => $data, 42 | ]; 43 | 44 | return $this->post('zones/'.$zone_identifier.'/dns_records', $data); 45 | } 46 | 47 | /** 48 | * List DNS Records (permission needed: #dns_records:read) 49 | * List, search, sort, and filter a zones' DNS records. 50 | * 51 | * @param string $zone_identifier 52 | * @param string|null $type DNS record type (A, AAAA, CNAME, TXT, SRV, LOC, MX, NS, SPF) 53 | * @param string|null $name DNS record name 54 | * @param string|null $content DNS record content 55 | * @param string|null $vanity_name_server_record Flag for records that were created for the vanity name server feature (true, false) 56 | * @param int|null $page Page number of paginated results 57 | * @param int|null $per_page Number of DNS records per page 58 | * @param string|null $order Field to order records by (type, name, content, ttl, proxied) 59 | * @param string|null $direction Direction to order domains (asc, desc) 60 | * @param string|null $match Whether to match all search requirements or at least one (any) (any, all) 61 | */ 62 | public function list_records($zone_identifier, $type = null, $name = null, $content = null, $vanity_name_server_record = null, $page = null, $per_page = null, $order = null, $direction = null, $match = null) 63 | { 64 | $data = [ 65 | 'type' => $type, 66 | 'name' => $name, 67 | 'content' => $content, 68 | 'vanity_name_server_record' => $vanity_name_server_record, 69 | 'page' => $page, 70 | 'per_page' => $per_page, 71 | 'order' => $order, 72 | 'direction' => $direction, 73 | 'match' => $match, 74 | ]; 75 | 76 | return $this->get('zones/'.$zone_identifier.'/dns_records', $data); 77 | } 78 | 79 | /** 80 | * DNS record details (permission needed: #dns_records:read) 81 | * 82 | * @param string $zone_identifier 83 | * @param string $identifier API item identifier tag 84 | */ 85 | public function details($zone_identifier, $identifier) 86 | { 87 | return $this->get('zones/'.$zone_identifier.'/dns_records/'.$identifier); 88 | } 89 | 90 | /** 91 | * Update DNS record (permission needed: #dns_records:edit) 92 | * 93 | * @param string $zone_identifier 94 | * @param string $identifier API item identifier tag 95 | * @param string|null $type DNS record type (A, AAAA, CNAME, TXT, SRV, LOC, MX, NS, SPF) 96 | * @param string|null $name DNS record name 97 | * @param string|null $content DNS record content 98 | * @param string|null $ttl Time to live for DNS record. Value of 1 is 'automatic' 99 | * @param bool|null $proxied Whether to proxy the domain through CloudFlare or not 100 | * @param array|null $data Additional data required for SRV record 101 | * @param int|null $priority MX record priority value 102 | */ 103 | public function update($zone_identifier, $identifier, $type = null, $name = null, $content = null, $ttl = null, $proxied = null, $data = null, $priority = null) 104 | { 105 | $data = [ 106 | 'type' => $type, 107 | 'name' => $name, 108 | 'content' => $content, 109 | 'ttl' => $ttl, 110 | 'proxied' => $proxied, 111 | 'priority' => $priority, 112 | 'data' => $data, 113 | ]; 114 | 115 | return $this->put('zones/'.$zone_identifier.'/dns_records/'.$identifier, $data); 116 | } 117 | 118 | /** 119 | * Update DNS record (permission needed: #dns_records:edit) 120 | * 121 | * @param string $zone_identifier 122 | * @param string $identifier API item identifier tag 123 | */ 124 | public function delete_record($zone_identifier, $identifier) 125 | { 126 | return $this->delete('zones/'.$zone_identifier.'/dns_records/'.$identifier); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /src/CloudFlare/User/LoadBalancers/Monitors.php: -------------------------------------------------------------------------------- 1 | 15 | * 16 | * @version 1 17 | */ 18 | class Monitors extends Api 19 | { 20 | /** 21 | * List monitors 22 | * List configured monitors for a user 23 | */ 24 | public function monitors() 25 | { 26 | return $this->get('/user/load_balancers/monitors'); 27 | } 28 | 29 | /** 30 | * Create a monitor 31 | * Create a configured monitor 32 | * 33 | * @param string $expected_body A case-insensitive substring to match in the body of the probe 34 | * response to declare an origin as up 35 | * @param string $expected_codes The expected HTTP response code or code range for the probe 36 | * @param string|null $method The HTTP method to use for the health check. 37 | * @param int|null $timeout The timeout (in seconds) before marking the health check as failed 38 | * @param string|null $path The endpoint path to health check against. 39 | * @param int|null $interval The interval between each health check. Shorter intervals may improve failover 40 | * time, but will increase load on the origins as we check from multiple locations. 41 | * @param int|null $retries The number of retries to attempt in case of a timeout before marking the origin 42 | * as unhealthy. Retries are attempted immediately. 43 | * @param array|null $header The HTTP request headers to send in the health check. It is recommended you set 44 | * a Host header by default. The User-Agent header cannot be overridden. 45 | * @param int|null $type The protocol to use for the healthcheck. Currently supported protocols are 46 | * 'HTTP' and 'HTTPS'. 47 | * @param string|null $description Object description 48 | */ 49 | public function create($expected_body, $expected_codes, $method = null, $timeout = null, $path = null, $interval = null, $retries = null, $header = null, $type = null, $description = null) 50 | { 51 | $data = [ 52 | 'expected_body' => $expected_body, 53 | 'expected_codes' => $expected_codes, 54 | 'method' => $method, 55 | 'timeout' => $timeout, 56 | 'path' => $path, 57 | 'interval' => $interval, 58 | 'retries' => $retries, 59 | 'header' => $header, 60 | 'type' => $type, 61 | 'description' => $description, 62 | ]; 63 | 64 | return $this->post('/user/load_balancers/monitors', $data); 65 | } 66 | 67 | /** 68 | * Monitor details 69 | * List a single configured CTM monitor for a user 70 | * 71 | * @param string $identifier 72 | */ 73 | public function details($identifier) 74 | { 75 | return $this->get('/user/load_balancers/monitors/'.$identifier); 76 | } 77 | 78 | /** 79 | * Modify a monitor 80 | * Modify a configured monitor 81 | * 82 | * @param string $identifier 83 | * @param string $expected_body A case-insensitive substring to match in the body of the probe 84 | * response to declare an origin as up 85 | * @param string $expected_codes The expected HTTP response code or code range for the probe 86 | * @param string|null $method The HTTP method to use for the health check. 87 | * @param int|null $timeout The timeout (in seconds) before marking the health check as failed 88 | * @param string|null $path The endpoint path to health check against. 89 | * @param int|null $interval The interval between each health check. Shorter intervals may improve failover 90 | * time, but will increase load on the origins as we check from multiple locations. 91 | * @param int|null $retries The number of retries to attempt in case of a timeout before marking the origin 92 | * as unhealthy. Retries are attempted immediately. 93 | * @param array|null $header The HTTP request headers to send in the health check. It is recommended you set 94 | * a Host header by default. The User-Agent header cannot be overridden. 95 | * @param int|null $type The protocol to use for the healthcheck. Currently supported protocols are 96 | * 'HTTP' and 'HTTPS'. 97 | * @param string|null $description Object description 98 | */ 99 | public function update($identifier, $expected_body, $expected_codes, $method = null, $timeout = null, $path = null, $interval = null, $retries = null, $header = null, $type = null, $description = null) 100 | { 101 | $data = [ 102 | 'expected_body' => $expected_body, 103 | 'expected_codes' => $expected_codes, 104 | 'method' => $method, 105 | 'timeout' => $timeout, 106 | 'path' => $path, 107 | 'interval' => $interval, 108 | 'retries' => $retries, 109 | 'header' => $header, 110 | 'type' => $type, 111 | 'description' => $description, 112 | ]; 113 | 114 | return $this->patch('/user/load_balancers/monitors/'.$identifier, $data); 115 | } 116 | 117 | /** 118 | * Delete a monitor 119 | * Delete a configured monitor 120 | * 121 | * @param string $identifier 122 | */ 123 | public function delete_monitor($identifier) 124 | { 125 | return $this->delete('/user/load_balancers/monitors/'.$identifier); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /src/CloudFlare/Zone/Pagerules.php: -------------------------------------------------------------------------------- 1 | 14 | * 15 | * @version 1 16 | */ 17 | class Pagerules extends Api 18 | { 19 | /** 20 | * Create a page rule [BETA] (permission needed: #zone:edit) 21 | * 22 | * @param string $zone_identifier API item identifier tag 23 | * @param array $targets Targets to evaluate on a request 24 | * @param array $actions The set of actions to perform if the targets of this rule match the request. 25 | * Actions can redirect the url to another url or override settings (but not both) 26 | * @param int|null $priority A number that indicates the preference for a page rule over another. In the case where 27 | * you may have a catch-all page rule (e.g., #1: '/images/') but want a rule that is more 28 | * specific to take precedence (e.g., #2: '/images/special/'), you'll want to specify a 29 | * higher priority on the latter (#2) so it will override the first. 30 | * @param string|null $status Status of the page rule 31 | */ 32 | public function create($zone_identifier, $targets, $actions, $priority = null, $status = 'active') 33 | { 34 | $data = [ 35 | 'targets' => $targets, 36 | 'actions' => $actions, 37 | 'priority' => $priority, 38 | 'status' => $status, 39 | ]; 40 | 41 | return $this->post('zones/'.$zone_identifier.'/pagerules', $data); 42 | } 43 | 44 | /** 45 | * List page rules [BETA] (permission needed: #zone:read) 46 | * 47 | * @param string $zone_identifier API item identifier tag 48 | * @param string|null $status Status of the page rule 49 | * @param string|null $order Field to order page rules by (status, priority) 50 | * @param string|null $direction Direction to order page rules (asc, desc) 51 | * @param string|null $match Whether to match all search requirements or at least one (any) (any, all) 52 | */ 53 | public function list_pagerules($zone_identifier, $status = null, $order = null, $direction = null, $match = null) 54 | { 55 | $data = [ 56 | 'status' => $status, 57 | 'order' => $order, 58 | 'direction' => $direction, 59 | 'match' => $match, 60 | ]; 61 | 62 | return $this->get('zones/'.$zone_identifier.'/pagerules', $data); 63 | } 64 | 65 | /** 66 | * Page rule details [BETA] (permission needed: #zone:read) 67 | * 68 | * @param string $zone_identifier API item identifier tag 69 | * @param string $identifier 70 | */ 71 | public function details($zone_identifier, $identifier) 72 | { 73 | return $this->get('zones/'.$zone_identifier.'/pagerules/'.$identifier); 74 | } 75 | 76 | /** 77 | * Change a page rule [BETA] (permission needed: #zone:edit) 78 | * 79 | * @param string $zone_identifier API item identifier tag 80 | * @param string $identifier 81 | * @param array|null $targets Targets to evaluate on a request 82 | * @param array|null $actions The set of actions to perform if the targets of this rule match the request. 83 | * Actions can redirect the url to another url or override settings (but not both) 84 | * @param int|null $priority A number that indicates the preference for a page rule over another. In the case where 85 | * you may have a catch-all page rule (e.g., #1: '/images/') but want a rule that is more 86 | * specific to take precedence (e.g., #2: '/images/special/'), you'll want to specify a 87 | * higher priority on the latter (#2) so it will override the first. 88 | * @param string|null $status Status of the page rule 89 | */ 90 | public function change($zone_identifier, $identifier, $targets = null, $actions = null, $priority = null, $status = null) 91 | { 92 | $data = [ 93 | 'targets' => $targets, 94 | 'actions' => $actions, 95 | 'priority' => $priority, 96 | 'status' => $status, 97 | ]; 98 | 99 | return $this->patch('zones/'.$zone_identifier.'/pagerules/'.$identifier, $data); 100 | } 101 | 102 | /** 103 | * Update a page rule [BETA] (permission needed: #zone:edit) 104 | * Replace a page rule. The final rule will exactly match the data passed with this request. 105 | * 106 | * @param string $zone_identifier API item identifier tag 107 | * @param string $identifier 108 | * @param array $targets Targets to evaluate on a request 109 | * @param array $actions The set of actions to perform if the targets of this rule match the request. 110 | * Actions can redirect the url to another url or override settings (but not both) 111 | * @param int|null $priority A number that indicates the preference for a page rule over another. In the case where 112 | * you may have a catch-all page rule (e.g., #1: '/images/') but want a rule that is more 113 | * specific to take precedence (e.g., #2: '/images/special/'), you'll want to specify a 114 | * higher priority on the latter (#2) so it will override the first. 115 | * @param string|null $status Status of the page rule 116 | */ 117 | public function update($zone_identifier, $identifier, $targets, $actions, $priority = null, $status = null) 118 | { 119 | $data = [ 120 | 'targets' => $targets, 121 | 'actions' => $actions, 122 | 'priority' => $priority, 123 | 'status' => $status, 124 | ]; 125 | 126 | return $this->put('zones/'.$zone_identifier.'/pagerules/'.$identifier, $data); 127 | } 128 | 129 | /** 130 | * Delete a page rule [BETA] (permission needed: #zone:edit) 131 | * 132 | * @param string $zone_identifier API item identifier tag 133 | * @param string $identifier 134 | */ 135 | public function delete_pagerule($zone_identifier, $identifier) 136 | { 137 | return $this->delete('zones/'.$zone_identifier.'/pagerules/'.$identifier); 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /src/CloudFlare/Organizations/LoadBalancers/Monitors.php: -------------------------------------------------------------------------------- 1 | 15 | * 16 | * @version 1 17 | */ 18 | class Monitors extends Api 19 | { 20 | /** 21 | * List monitors 22 | * List configured monitors for a user 23 | * 24 | * @param string $organization_identifier 25 | */ 26 | public function monitors($organization_identifier) 27 | { 28 | return $this->get('/organizations/'.$organization_identifier.'/load_balancers/monitors'); 29 | } 30 | 31 | /** 32 | * Create a monitor 33 | * Create a configured monitor 34 | * 35 | * @param string $organization_identifier 36 | * @param string $expected_body A case-insensitive substring to match in the body of the probe 37 | * response to declare an origin as up 38 | * @param string $expected_codes The expected HTTP response code or code range for the probe 39 | * @param string|null $method The HTTP method to use for the health check. 40 | * @param int|null $timeout The timeout (in seconds) before marking the health check as failed 41 | * @param string|null $path The endpoint path to health check against. 42 | * @param int|null $interval The interval between each health check. Shorter intervals may improve failover 43 | * time, but will increase load on the origins as we check from multiple locations. 44 | * @param int|null $retries The number of retries to attempt in case of a timeout before marking the origin 45 | * as unhealthy. Retries are attempted immediately. 46 | * @param array|null $header The HTTP request headers to send in the health check. It is recommended you set 47 | * a Host header by default. The User-Agent header cannot be overridden. 48 | * @param int|null $type The protocol to use for the healthcheck. Currently supported protocols are 49 | * 'HTTP' and 'HTTPS'. 50 | * @param string|null $description Object description 51 | */ 52 | public function create($organization_identifier, $expected_body, $expected_codes, $method = null, $timeout = null, $path = null, $interval = null, $retries = null, $header = null, $type = null, $description = null) 53 | { 54 | $data = [ 55 | 'expected_body' => $expected_body, 56 | 'expected_codes' => $expected_codes, 57 | 'method' => $method, 58 | 'timeout' => $timeout, 59 | 'path' => $path, 60 | 'interval' => $interval, 61 | 'retries' => $retries, 62 | 'header' => $header, 63 | 'type' => $type, 64 | 'description' => $description, 65 | ]; 66 | 67 | return $this->post('/organizations/'.$organization_identifier.'/load_balancers/monitors', $data); 68 | } 69 | 70 | /** 71 | * Monitor details 72 | * List a single configured CTM monitor for a user 73 | * 74 | * @param string $organization_identifier 75 | * @param string $identifier 76 | */ 77 | public function details($organization_identifier, $identifier) 78 | { 79 | return $this->get('/organizations/'.$organization_identifier.'/load_balancers/monitors/'.$identifier); 80 | } 81 | 82 | /** 83 | * Modify a monitor 84 | * Modify a configured monitor 85 | * 86 | * @param string $organization_identifier 87 | * @param string $identifier 88 | * @param string $expected_body A case-insensitive substring to match in the body of the probe 89 | * response to declare an origin as up 90 | * @param string $expected_codes The expected HTTP response code or code range for the probe 91 | * @param string|null $method The HTTP method to use for the health check. 92 | * @param int|null $timeout The timeout (in seconds) before marking the health check as failed 93 | * @param string|null $path The endpoint path to health check against. 94 | * @param int|null $interval The interval between each health check. Shorter intervals may improve failover 95 | * time, but will increase load on the origins as we check from multiple locations. 96 | * @param int|null $retries The number of retries to attempt in case of a timeout before marking the origin 97 | * as unhealthy. Retries are attempted immediately. 98 | * @param array|null $header The HTTP request headers to send in the health check. It is recommended you set 99 | * a Host header by default. The User-Agent header cannot be overridden. 100 | * @param int|null $type The protocol to use for the healthcheck. Currently supported protocols are 101 | * 'HTTP' and 'HTTPS'. 102 | * @param string|null $description Object description 103 | */ 104 | public function update($organization_identifier, $identifier, $expected_body, $expected_codes, $method = null, $timeout = null, $path = null, $interval = null, $retries = null, $header = null, $type = null, $description = null) 105 | { 106 | $data = [ 107 | 'expected_body' => $expected_body, 108 | 'expected_codes' => $expected_codes, 109 | 'method' => $method, 110 | 'timeout' => $timeout, 111 | 'path' => $path, 112 | 'interval' => $interval, 113 | 'retries' => $retries, 114 | 'header' => $header, 115 | 'type' => $type, 116 | 'description' => $description, 117 | ]; 118 | 119 | return $this->patch('/organizations/'.$organization_identifier.'/load_balancers/monitors/'.$identifier, $data); 120 | } 121 | 122 | /** 123 | * Delete a monitor 124 | * Delete a configured monitor 125 | * 126 | * @param string $organization_identifier 127 | * @param string $identifier 128 | */ 129 | public function delete_monitor($organization_identifier, $identifier) 130 | { 131 | return $this->delete('/organizations/'.$organization_identifier.'/load_balancers/monitors/'.$identifier); 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /src/CloudFlare/Zone/LoadBalancers.php: -------------------------------------------------------------------------------- 1 | 14 | * 15 | * @version 1 16 | */ 17 | class LoadBalancers extends Api 18 | { 19 | /** 20 | * List load balancers 21 | * List configured load balancers 22 | * 23 | * @param string $zone_identifier 24 | */ 25 | public function load_balancers($zone_identifier) 26 | { 27 | return $this->get('/zones/'.$zone_identifier.'/load_balancers'); 28 | } 29 | 30 | /** 31 | * Create a load balancer 32 | * Create a new load balancer 33 | * 34 | * @param string $zone_identifier 35 | * @param string $name The DNS hostname to associate with your Load Balancer. If this hostname already 36 | * exists as a DNS record in Cloudflare's DNS, the Load Balancer will take 37 | * precedence and the DNS record will not be used. 38 | * @param string $fallback_pool The pool ID to use when all other pools are detected as unhealthy. 39 | * @param array $default_pools A list of pool IDs ordered by their failover priority. Pools defined here are 40 | * used by default, or when region_pools are not configured for a given region. 41 | * @param string|null $description Object description. 42 | * @param int|null $ttl Time to live (TTL) of the DNS entry for the IP address returned by this load 43 | * balancer. This only applies to gray-clouded (unproxied) load balancers. 44 | * @param object|null $region_pools A mapping of region/country codes to a list of pool IDs (ordered by their 45 | * failover priority) for the given region. Any regions not explicitly defined 46 | * will fall back to using default_pools. 47 | * @param int|null $pop_pools (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs 48 | * (ordered by their failover priority) for the PoP (datacenter). Any PoPs not 49 | * explicitly defined will fall back to using default_pools. 50 | * balancer. This only applies to gray-clouded (unproxied) load balancers. 51 | * @param bool|null $proxied Whether the hostname should be gray clouded (false) or orange clouded (true). 52 | */ 53 | public function create($zone_identifier, $name, $fallback_pool, $default_pools, $description = null, $ttl = null, $region_pools = null, $pop_pools = null, $proxied = null) 54 | { 55 | $data = [ 56 | 'name' => $name, 57 | 'fallback_pool' => $fallback_pool, 58 | 'default_pools' => $default_pools, 59 | 'description' => $description, 60 | 'ttl' => $ttl, 61 | 'region_pools' => $region_pools, 62 | 'pop_pools' => $pop_pools, 63 | 'proxied' => $proxied, 64 | ]; 65 | 66 | return $this->post('/zones/'.$zone_identifier.'/load_balancers', $data); 67 | } 68 | 69 | /** 70 | * Load balancer details 71 | * Fetch a single configured load balancer 72 | * 73 | * @param string $zone_identifier 74 | * @param string $identifier 75 | */ 76 | public function details($zone_identifier, $identifier) 77 | { 78 | return $this->get('/zones/'.$zone_identifier.'/load_balancers/'.$identifier); 79 | } 80 | 81 | /** 82 | * Modify a load balancer 83 | * Modify a configured load balancer 84 | * 85 | * @param string $zone_identifier 86 | * @param string $identifier 87 | * @param string $name The DNS hostname to associate with your Load Balancer. If this hostname already 88 | * exists as a DNS record in Cloudflare's DNS, the Load Balancer will take 89 | * precedence and the DNS record will not be used. 90 | * @param string $fallback_pool The pool ID to use when all other pools are detected as unhealthy. 91 | * @param array $default_pools A list of pool IDs ordered by their failover priority. Pools defined here are 92 | * used by default, or when region_pools are not configured for a given region. 93 | * @param string|null $description Object description. 94 | * @param int|null $ttl Time to live (TTL) of the DNS entry for the IP address returned by this load 95 | * balancer. This only applies to gray-clouded (unproxied) load balancers. 96 | * @param object|null $region_pools A mapping of region/country codes to a list of pool IDs (ordered by their 97 | * failover priority) for the given region. Any regions not explicitly defined 98 | * will fall back to using default_pools. 99 | * @param int|null $pop_pools (Enterprise only): A mapping of Cloudflare PoP identifiers to a list of pool IDs 100 | * (ordered by their failover priority) for the PoP (datacenter). Any PoPs not 101 | * explicitly defined will fall back to using default_pools. 102 | * balancer. This only applies to gray-clouded (unproxied) load balancers. 103 | * @param bool|null $proxied Whether the hostname should be gray clouded (false) or orange clouded (true). 104 | */ 105 | public function update($zone_identifier, $identifier, $name, $fallback_pool, $default_pools, $description = null, $ttl = null, $region_pools = null, $pop_pools = null, $proxied = null) 106 | { 107 | $data = [ 108 | 'name' => $name, 109 | 'fallback_pool' => $fallback_pool, 110 | 'default_pools' => $default_pools, 111 | 'description' => $description, 112 | 'ttl' => $ttl, 113 | 'region_pools' => $region_pools, 114 | 'pop_pools' => $pop_pools, 115 | 'proxied' => $proxied, 116 | ]; 117 | 118 | return $this->patch('/zones/'.$zone_identifier.'/load_balancers/'.$identifier, $data); 119 | } 120 | 121 | /** 122 | * Delete a load balancer 123 | * Delete a configured load balancer 124 | * 125 | * @param string $zone_identifier 126 | * @param string $identifier 127 | */ 128 | public function delete_load_balancer($zone_identifier, $identifier) 129 | { 130 | return $this->delete('/zones/'.$zone_identifier.'/load_balancers/'.$identifier); 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /src/CloudFlare/Api.php: -------------------------------------------------------------------------------- 1 | 14 | * 15 | * @version 1 16 | */ 17 | class Api 18 | { 19 | /** 20 | * Holds the provided email address for API authentication 21 | * 22 | * @var string 23 | */ 24 | public $email; 25 | 26 | /** 27 | * Holds the provided auth_key for API authentication 28 | * 29 | * @var string 30 | */ 31 | public $auth_key; 32 | 33 | /** 34 | * Holds the curl options 35 | * 36 | * @var array 37 | */ 38 | public $curl_options; 39 | 40 | /** 41 | * Make a new instance of the API client 42 | * This can be done via providing the email address and api key as seperate parameters 43 | * or by passing in an already instantiated object from which the details will be extracted 44 | */ 45 | public function __construct() 46 | { 47 | $num_args = func_num_args(); 48 | if ($num_args === 1) { 49 | $parameters = func_get_args(); 50 | $client = $parameters[0]; 51 | $this->email = $client->email; 52 | $this->auth_key = $client->auth_key; 53 | $this->curl_options = $client->curl_options; 54 | } elseif ($num_args === 2) { 55 | $parameters = func_get_args(); 56 | $this->email = $parameters[0]; 57 | $this->auth_key = $parameters[1]; 58 | } 59 | } 60 | 61 | /** 62 | * Setter to allow the setting of the email address 63 | * 64 | * @param string $email The email address associated with the Cloudflare account 65 | */ 66 | public function setEmail($email) 67 | { 68 | $this->email = $email; 69 | } 70 | 71 | /** 72 | * Setter to allow the setting of the Authentication Key 73 | * 74 | * @param string $token Authentication key, this can be retrieve from the 'My Account' section of the Cloudflare account 75 | */ 76 | public function setAuthKey($token) 77 | { 78 | $this->auth_key = $token; 79 | } 80 | 81 | /** 82 | * Setter to allow the adding / changing of the Curl options that will be used within the HTTP requests 83 | * 84 | * @param int $key The CURLOPT_XXX option to set e.g. CURLOPT_TIMEOUT 85 | * @param mixed $value The value to be set on option e.g. 10 86 | */ 87 | public function setCurlOption($key, $value) 88 | { 89 | $this->curl_options[$key] = $value; 90 | } 91 | 92 | /** 93 | * API call method for sending requests using GET 94 | * 95 | * @param string $path Path of the endpoint 96 | * @param array $data Data to be sent along with the request 97 | * 98 | * @return mixed 99 | */ 100 | public function get($path, array $data = []) 101 | { 102 | return $this->request($path, $data, 'get'); 103 | } 104 | 105 | /** 106 | * API call method for sending requests using POST 107 | * 108 | * @param string $path Path of the endpoint 109 | * @param array $data Data to be sent along with the request 110 | * 111 | * @return mixed 112 | */ 113 | public function post($path, array $data = []) 114 | { 115 | return $this->request($path, $data, 'post'); 116 | } 117 | 118 | /** 119 | * API call method for sending requests using PUT 120 | * 121 | * @param string $path Path of the endpoint 122 | * @param array $data Data to be sent along with the request 123 | * 124 | * @return mixed 125 | */ 126 | public function put($path, array $data = []) 127 | { 128 | return $this->request($path, $data, 'put'); 129 | } 130 | 131 | /** 132 | * API call method for sending requests using DELETE 133 | * 134 | * @param string $path Path of the endpoint 135 | * @param array $data Data to be sent along with the request 136 | * 137 | * @return mixed 138 | */ 139 | public function delete($path, array $data = []) 140 | { 141 | return $this->request($path, $data, 'delete'); 142 | } 143 | 144 | /** 145 | * API call method for sending requests using PATCH 146 | * 147 | * @param string $path Path of the endpoint 148 | * @param array $data Data to be sent along with the request 149 | * 150 | * @return mixed 151 | */ 152 | public function patch($path, array $data = []) 153 | { 154 | return $this->request($path, $data, 'patch'); 155 | } 156 | 157 | /** 158 | * @codeCoverageIgnore 159 | * 160 | * API call method for sending requests using GET, POST, PUT, DELETE OR PATCH 161 | * 162 | * @param string $path Path of the endpoint 163 | * @param array $data Data to be sent along with the request 164 | * @param string $method Type of method that should be used ('GET', 'POST', 'PUT', 'DELETE', 'PATCH') 165 | * 166 | * @return mixed 167 | */ 168 | protected function request($path, array $data = [], $method = 'get') 169 | { 170 | if (!isset($this->email, $this->auth_key) || false === filter_var($this->email, FILTER_VALIDATE_EMAIL)) { 171 | throw new AuthenticationException('Authentication information must be provided'); 172 | } 173 | 174 | //Removes null entries 175 | $data = array_filter($data, function ($val) { 176 | return !is_null($val); 177 | }); 178 | 179 | $url = 'https://api.cloudflare.com/client/v4/'.$path; 180 | 181 | $default_curl_options = [ 182 | CURLOPT_VERBOSE => false, 183 | CURLOPT_FORBID_REUSE => true, 184 | CURLOPT_RETURNTRANSFER => 1, 185 | CURLOPT_HEADER => false, 186 | CURLOPT_TIMEOUT => 30, 187 | CURLOPT_SSL_VERIFYPEER => true, 188 | ]; 189 | 190 | $curl_options = $default_curl_options; 191 | if (isset($this->curl_options) && is_array($this->curl_options)) { 192 | $curl_options = array_replace($default_curl_options, $this->curl_options); 193 | } 194 | 195 | $user_agent = __FILE__; 196 | $headers = [ 197 | "X-Auth-Email: {$this->email}", 198 | "X-Auth-Key: {$this->auth_key}", 199 | "User-Agent: {$user_agent}", 200 | 'Content-type: application/json', 201 | ]; 202 | 203 | $ch = curl_init(); 204 | curl_setopt_array($ch, $curl_options); 205 | 206 | $json_data = json_encode($data); 207 | 208 | if ($method === 'post') { 209 | curl_setopt($ch, CURLOPT_POST, true); 210 | curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); 211 | } elseif ($method === 'put') { 212 | curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); 213 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); 214 | } elseif ($method === 'delete') { 215 | curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); 216 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); 217 | } elseif ($method === 'patch') { 218 | curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); 219 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH'); 220 | } else { 221 | $url .= '?'.http_build_query($data); 222 | } 223 | 224 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 225 | curl_setopt($ch, CURLOPT_URL, $url); 226 | 227 | $http_result = curl_exec($ch); 228 | $error = curl_error($ch); 229 | $information = curl_getinfo($ch); 230 | $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 231 | 232 | if (in_array($http_code, [401, 403])) { 233 | throw new UnauthorizedException('You do not have permission to perform this request'); 234 | } 235 | 236 | $response = json_decode($http_result); 237 | if (!$response) { 238 | $response = new \stdClass(); 239 | $response->success = false; 240 | } 241 | 242 | curl_close($ch); 243 | if ($response->success !== true) { 244 | $response->error = $error; 245 | $response->http_code = $http_code; 246 | $response->method = $method; 247 | $response->information = $information; 248 | } 249 | 250 | return $response; 251 | } 252 | } 253 | -------------------------------------------------------------------------------- /src/CloudFlare/Zone/Settings.php: -------------------------------------------------------------------------------- 1 | 13 | * 14 | * @version 1 15 | */ 16 | class Settings extends Api 17 | { 18 | /** 19 | * Zone settings (permission needed: #zone_settings:read) 20 | * Available settings for your user in relation to a zone 21 | * 22 | * @param string $zone_identifier API item identifier tag 23 | */ 24 | public function settings($zone_identifier) 25 | { 26 | return $this->get('zones/'.$zone_identifier.'/settings'); 27 | } 28 | 29 | /** 30 | * Advanced DDOS setting (permission needed: #zone_settings:read) 31 | * Advanced protection from Distributed Denial of Service (DDoS) attacks on your website. 32 | * This is an uneditable value that is 'on' in the case of Business and Enterprise zones 33 | * 34 | * @param string $zone_identifier API item identifier tag 35 | */ 36 | public function advanced_ddos($zone_identifier) 37 | { 38 | return $this->get('zones/'.$zone_identifier.'/settings/advanced_ddos'); 39 | } 40 | 41 | /** 42 | * Get Automatic HTTPS Rewrites setting (permission needed: #zone_settings:edit) 43 | * Enable the Automatic HTTPS Rewrites feature for this zone. 44 | * 45 | * @param string $zone_identifier API item identifier tag 46 | */ 47 | public function automatic_https_rewrites($zone_identifier) 48 | { 49 | return $this->get('zones/'.$zone_identifier.'/settings/automatic_https_rewrites'); 50 | } 51 | 52 | /** 53 | * Get Always Online setting (permission needed: #zone_settings:read) 54 | * When enabled, Always Online will serve pages from our cache if your server is offline 55 | * (https://support.cloudflare.com/hc/en-us/articles/200168006) 56 | * 57 | * @param string $zone_identifier API item identifier tag 58 | */ 59 | public function always_online($zone_identifier) 60 | { 61 | return $this->get('zones/'.$zone_identifier.'/settings/always_online'); 62 | } 63 | 64 | /** 65 | * Get Always Use HTTPS setting permission needed: #zone_settings:read 66 | * 67 | * Reply to all requests for URLs that use "http" with a 301 redirect to the equivalent "https" URL. If you only want to redirect for a subset of requests, consider creating an "Always use HTTPS" page rule. 68 | * 69 | * @link https://api.cloudflare.com/#zone-settings-get-always-use-https-setting 70 | * 71 | * @param string $zone_identifier API item identifier tag 72 | * 73 | * @return \stdClass | false 74 | */ 75 | public function always_use_https($zone_identifier) 76 | { 77 | return $this->get('zones/' . $zone_identifier . '/settings/always_use_https'); 78 | } 79 | 80 | /** 81 | * Get Browser Cache TTL setting (permission needed: #zone_settings:read) 82 | * Browser Cache TTL (in seconds) specifies how long CloudFlare-cached resources will remain on your visitors' computers. 83 | * CloudFlare will honor any larger times specified by your server. 84 | * (https://support.cloudflare.com/hc/en-us/articles/200168276) 85 | * 86 | * @param string $zone_identifier API item identifier tag 87 | */ 88 | public function browser_cache_ttl($zone_identifier) 89 | { 90 | return $this->get('zones/'.$zone_identifier.'/settings/browser_cache_ttl'); 91 | } 92 | 93 | /** 94 | * Get Browser Check setting (permission needed: #zone_settings:read) 95 | * Browser Integrity Check is similar to Bad Behavior and looks for common HTTP headers abused most commonly by spammers and denies access to your page. 96 | * It will also challenge visitors that do not have a user agent or a non standard user agent (also commonly used by abuse bots, crawlers or visitors). 97 | * (https://support.cloudflare.com/hc/en-us/articles/200170086) 98 | * 99 | * @param string $zone_identifier API item identifier tag 100 | */ 101 | public function browser_check($zone_identifier) 102 | { 103 | return $this->get('zones/'.$zone_identifier.'/settings/browser_check'); 104 | } 105 | 106 | /** 107 | * Get Cache Level setting (permission needed: #zone_settings:read) 108 | * Cache Level functions based off the setting level. The basic setting will cache most static resources (i.e., css, images, and JavaScript). 109 | * The simplified setting will ignore the query string when delivering a cached resource. The aggressive setting will cache all static resources, including ones with a query string. 110 | * (https://support.cloudflare.com/hc/en-us/articles/200168256) 111 | * 112 | * @param string $zone_identifier API item identifier tag 113 | */ 114 | public function cache_level($zone_identifier) 115 | { 116 | return $this->get('zones/'.$zone_identifier.'/settings/cache_level'); 117 | } 118 | 119 | /** 120 | * Get Challenge TTL setting (permission needed: #zone_settings:read) 121 | * Specify how long a visitor is allowed access to your site after successfully completing a challenge (such as a CAPTCHA). After the TTL has expired the visitor will have to complete a new challenge. 122 | * We recommend a 15 - 45 minute setting and will attempt to honor any setting above 45 minutes. 123 | * (https://support.cloudflare.com/hc/en-us/articles/200170136) 124 | * 125 | * @param string $zone_identifier API item identifier tag 126 | */ 127 | public function challenge_ttl($zone_identifier) 128 | { 129 | return $this->get('zones/'.$zone_identifier.'/settings/challenge_ttl'); 130 | } 131 | 132 | /** 133 | * Get Development Mode setting (permission needed: #zone_settings:read) 134 | * Development Mode temporarily allows you to enter development mode for your websites if you need to make changes to your site. 135 | * This will bypass CloudFlare's accelerated cache and slow down your site, but is useful if you are making changes to cacheable content (like images, css, or JavaScript) and would like to see those changes right away. 136 | * Once entered, development mode will last for 3 hours and then automatically toggle off. 137 | * 138 | * @param string $zone_identifier API item identifier tag 139 | */ 140 | public function development_mode($zone_identifier) 141 | { 142 | return $this->get('zones/'.$zone_identifier.'/settings/development_mode'); 143 | } 144 | 145 | /** 146 | * Get Email Obfuscation setting (permission needed: #zone_settings:read) 147 | * Encrypt email adresses on your web page from bots, while keeping them visible to humans. 148 | * (https://support.cloudflare.com/hc/en-us/articles/200170016) 149 | * 150 | * @param string $zone_identifier API item identifier tag 151 | */ 152 | public function email_obfuscation($zone_identifier) 153 | { 154 | return $this->get('zones/'.$zone_identifier.'/settings/email_obfuscation'); 155 | } 156 | 157 | /** 158 | * Get Hotlink Protection setting (permission needed: #zone_settings:read) 159 | * When enabled, the Hotlink Protection option ensures that other sites cannot suck up your bandwidth by building pages that use images hosted on your site. 160 | * Anytime a request for an image on your site hits CloudFlare, we check to ensure that it's not another site requesting them. 161 | * People will still be able to download and view images from your page, but other sites won't be able to steal them for use on their own pages. 162 | * (https://support.cloudflare.com/hc/en-us/articles/200170026) 163 | * 164 | * @param string $zone_identifier API item identifier tag 165 | */ 166 | public function hotlink_protection($zone_identifier) 167 | { 168 | return $this->get('zones/'.$zone_identifier.'/settings/hotlink_protection'); 169 | } 170 | 171 | /** 172 | * Get IP Geolocation setting (permission needed: #zone_settings:read) 173 | * Enable IP Geolocation to have CloudFlare geolocate visitors to your website and pass the country code to you. 174 | * (https://support.cloudflare.com/hc/en-us/articles/200168236) 175 | * 176 | * @param string $zone_identifier API item identifier tag 177 | */ 178 | public function ip_geolocation($zone_identifier) 179 | { 180 | return $this->get('zones/'.$zone_identifier.'/settings/ip_geolocation'); 181 | } 182 | 183 | /** 184 | * Get IP IPv6 setting (permission needed: #zone_settings:read) 185 | * Enable IPv6 on all subdomains that are CloudFlare enabled. 186 | * (https://support.cloudflare.com/hc/en-us/articles/200168586) 187 | * 188 | * @param string $zone_identifier API item identifier tag 189 | */ 190 | public function ipv6($zone_identifier) 191 | { 192 | return $this->get('zones/'.$zone_identifier.'/settings/ipv6'); 193 | } 194 | 195 | /** 196 | * Get IP Minify setting (permission needed: #zone_settings:read) 197 | * Automatically minify certain assets for your website (https://support.cloudflare.com/hc/en-us/articles/200168196). 198 | * 199 | * @param string $zone_identifier API item identifier tag 200 | */ 201 | public function minify($zone_identifier) 202 | { 203 | return $this->get('zones/'.$zone_identifier.'/settings/minify'); 204 | } 205 | 206 | /** 207 | * Get Mobile Redirect setting (permission needed: #zone_settings:read) 208 | * Automatically redirect visitors on mobile devices to a mobile-optimized subdomain (https://support.cloudflare.com/hc/en-us/articles/200168336). 209 | * 210 | * @param string $zone_identifier API item identifier tag 211 | */ 212 | public function mobile_redirect($zone_identifier) 213 | { 214 | return $this->get('zones/'.$zone_identifier.'/settings/mobile_redirect'); 215 | } 216 | 217 | /** 218 | * Get Mirage setting (permission needed: #zone_settings:read) 219 | * Automatically optimize image loading for website visitors on mobile devices (http://blog.cloudflare.com/mirage2-solving-mobile-speed). 220 | * 221 | * @param string $zone_identifier API item identifier tag 222 | */ 223 | public function mirage($zone_identifier) 224 | { 225 | return $this->get('zones/'.$zone_identifier.'/settings/mirage'); 226 | } 227 | 228 | /** 229 | * Get Enable Error Pages On setting (permission needed: #zone_settings:read) 230 | * CloudFlare will proxy customer error pages on any 502,504 errors on origin server instead of showing a default CloudFlare error page. 231 | * This does not apply to 522 errors and is limited to Enterprise Zones. 232 | * 233 | * @param string $zone_identifier API item identifier tag 234 | */ 235 | public function origin_error_page_pass_thru($zone_identifier) 236 | { 237 | return $this->get('zones/'.$zone_identifier.'/settings/origin_error_page_pass_thru'); 238 | } 239 | 240 | /** 241 | * Get Polish setting (permission needed: #zone_settings:read) 242 | * Strips metadata and compresses your images for faster page load times. Basic (Lossless): Reduce the size of PNG, JPEG, and GIF files - no impact on visual quality. 243 | * Basic + JPEG (Lossy): Further reduce the size of JPEG files for faster image loading. 244 | * Larger JPEGs are converted to progressive images, loading a lower-resolution image first and ending in a higher-resolution version. Not recommended for hi-res photography sites. 245 | * 246 | * @param string $zone_identifier API item identifier tag 247 | */ 248 | public function polish($zone_identifier) 249 | { 250 | return $this->get('zones/'.$zone_identifier.'/settings/polish'); 251 | } 252 | 253 | /** 254 | * Get Prefetch Preload setting (permission needed: #zone_settings:read) 255 | * CloudFlare will prefetch any URLs that are included in the response headers. This is limited to Enterprise Zones. 256 | * 257 | * @param string $zone_identifier API item identifier tag 258 | */ 259 | public function prefetch_preload($zone_identifier) 260 | { 261 | return $this->get('zones/'.$zone_identifier.'/settings/prefetch_preload'); 262 | } 263 | 264 | /** 265 | * Get Response Buffering setting (permission needed: #zone_settings:read) 266 | * Enables or disables buffering of responses from the proxied server. CloudFlare may buffer the whole payload to deliver it at once to the client versus allowing it to be delivered in chunks. 267 | * By default, the proxied server streams directly and is not buffered by CloudFlare. This is limited to Enterprise Zones. 268 | * 269 | * @param string $zone_identifier API item identifier tag 270 | */ 271 | public function response_buffering($zone_identifier) 272 | { 273 | return $this->get('zones/'.$zone_identifier.'/settings/response_buffering'); 274 | } 275 | 276 | /** 277 | * Get Rocket Loader setting (permission needed: #zone_settings:read) 278 | * Rocket Loader is a general-purpose asynchronous JavaScript loader coupled with a lightweight virtual browser which can safely run any JavaScript code after window.onload. 279 | * Turning on Rocket Loader will immediately improve a web page's window.onload time (assuming there is JavaScript on the page), which can have a positive impact on your Google search ranking. 280 | * Automatic Mode: Rocket Loader will automatically run on the JavaScript resources on your site, with no configuration required after turning on automatic mode. Manual Mode: In order to have Rocket Loader execute for a particular script, you must add the following attribute to the script tag: "data-cfasync='true'". 281 | * As your page passes through CloudFlare, we'll enable Rocket Loader for that particular script. All other JavaScript will continue to execute without CloudFlare touching the script. (https://support.cloudflare.com/hc/en-us/articles/200168056) 282 | * 283 | * @param string $zone_identifier API item identifier tag 284 | */ 285 | public function rocket_loader($zone_identifier) 286 | { 287 | return $this->get('zones/'.$zone_identifier.'/settings/rocket_loader'); 288 | } 289 | 290 | /** 291 | * Get Security Header (HSTS) setting (permission needed: #zone_settings:read) 292 | * CloudFlare security header for a zone. 293 | * 294 | * @param string $zone_identifier API item identifier tag 295 | */ 296 | public function security_header($zone_identifier) 297 | { 298 | return $this->get('zones/'.$zone_identifier.'/settings/security_header'); 299 | } 300 | 301 | /** 302 | * Get Security Level setting (permission needed: #zone_settings:read) 303 | * Choose the appropriate security profile for your website, which will automatically adjust each of the security settings. If you choose to customize an individual security setting, the profile will become Custom. 304 | * (https://support.cloudflare.com/hc/en-us/articles/200170056) 305 | * 306 | * @param string $zone_identifier API item identifier tag 307 | */ 308 | public function security_level($zone_identifier) 309 | { 310 | return $this->get('zones/'.$zone_identifier.'/settings/security_level'); 311 | } 312 | 313 | /** 314 | * Get Server Side Exclude setting (permission needed: #zone_settings:read) 315 | * If there is sensitive content on your website that you want visible to real visitors, but that you want to hide from suspicious visitors, all you have to do is wrap the content with CloudFlare SSE tags. Wrap any content that you want to be excluded from suspicious visitors in the following SSE tags: . 316 | * For example: Bad visitors won't see my phone number, 555-555-5555 . Note: SSE only will work with HTML. If you have HTML minification enabled, you won't see the SSE tags in your HTML source when it's served through CloudFlare. 317 | * SSE will still function in this case, as CloudFlare's HTML minification and SSE functionality occur on-the-fly as the resource moves through our network to the visitor's computer. 318 | * (https://support.cloudflare.com/hc/en-us/articles/200170036) 319 | * 320 | * @param string $zone_identifier API item identifier tag 321 | */ 322 | public function server_side_exclude($zone_identifier) 323 | { 324 | return $this->get('zones/'.$zone_identifier.'/settings/server_side_exclude'); 325 | } 326 | 327 | /** 328 | * Get Enable Query String Sort setting (permission needed: #zone_settings:read) 329 | * CloudFlare will treat files with the same query strings as the same file in cache, regardless of the order of the query strings. This is limited to Enterprise Zones. 330 | * 331 | * @param string $zone_identifier API item identifier tag 332 | */ 333 | public function sort_query_string_for_cache($zone_identifier) 334 | { 335 | return $this->get('zones/'.$zone_identifier.'/settings/sort_query_string_for_cache'); 336 | } 337 | 338 | /** 339 | * Get SSL setting (permission needed: #zone_settings:read) 340 | * SSL encrypts your visitor's connection and safeguards credit card numbers and other personal data to and from your website. SSL can take up to 5 minutes to fully activate. Requires CloudFlare active on your root domain or www domain. 341 | * Off: no SSL between the visitor and CloudFlare, and no SSL between CloudFlare and your web server (all HTTP traffic). 342 | * Flexible: SSL between the visitor and CloudFlare -- visitor sees HTTPS on your site, but no SSL between CloudFlare and your web server. You don't need to have an SSL cert on your web server, but your vistors will still see the site as being HTTPS enabled. 343 | * Full: SSL between the visitor and CloudFlare -- visitor sees HTTPS on your site, and SSL between CloudFlare and your web server. You'll need to have your own SSL cert or self-signed cert at the very least. 344 | * Full (Strict): SSL between the visitor and CloudFlare -- visitor sees HTTPS on your site, and SSL between CloudFlare and your web server. You'll need to have a valid SSL certificate installed on your web server. This certificate must be signed by a certificate authority, have an expiration date in the future, and respond for the request domain name (hostname). 345 | * (https://support.cloudflare.com/hc/en-us/articles/200170416) 346 | * 347 | * @param string $zone_identifier API item identifier tag 348 | */ 349 | public function ssl($zone_identifier) 350 | { 351 | return $this->get('zones/'.$zone_identifier.'/settings/ssl'); 352 | } 353 | 354 | /** 355 | * Get Zone Enable TLS 1.2 setting (permission needed: #zone_settings:read) 356 | * Enable Crypto TLS 1.2 feature for this zone and prevent use of previous versions. This is limited to Enterprise or Business Zones. 357 | * 358 | * @param string $zone_identifier API item identifier tag 359 | */ 360 | public function tls_1_2_only($zone_identifier) 361 | { 362 | return $this->get('zones/'.$zone_identifier.'/settings/tls_1_2_only'); 363 | } 364 | 365 | /** 366 | * Get TLS Client Auth setting (permission needed: #zone_settings:read) 367 | * TLS Client Auth requires CloudFlare to connect to your origin server using a client certificate (Enterprise Only) 368 | * 369 | * @param string $zone_identifier API item identifier tag 370 | */ 371 | public function tls_client_auth($zone_identifier) 372 | { 373 | return $this->get('zones/'.$zone_identifier.'/settings/tls_client_auth'); 374 | } 375 | 376 | /** 377 | * Get True Client IP setting (permission needed: #zone_settings:edit) 378 | * Allows customer to continue to use True Client IP (Akamai feature) in the headers we send to the origin. This is limited to Enterprise Zones. 379 | * 380 | * @param string $zone_identifier API item identifier tag 381 | */ 382 | public function true_client_ip_header($zone_identifier) 383 | { 384 | return $this->get('zones/'.$zone_identifier.'/settings/true_client_ip_header'); 385 | } 386 | 387 | /** 388 | * Get Web Application Firewall (WAF) setting (permission needed: #zone_settings:read) 389 | * The WAF examines HTTP requests to your website. It inspects both GET and POST requests and applies rules to help filter out illegitimate traffic from legitimate website visitors. The CloudFlare WAF inspects website addresses or URLs to detect anything out of the ordinary. If the CloudFlare WAF determines suspicious user behavior, then the WAF will ‘challenge’ the web visitor with a page that asks them to submit a CAPTCHA successfully to continue their action. If the challenge is failed, the action will be stopped. What this means is that CloudFlare’s WAF will block any traffic identified as illegitimate before it reaches your origin web server. 390 | * (https://support.cloudflare.com/hc/en-us/articles/200172016) 391 | * 392 | * @param string $zone_identifier API item identifier tag 393 | */ 394 | public function waf($zone_identifier) 395 | { 396 | return $this->get('zones/'.$zone_identifier.'/settings/waf'); 397 | } 398 | 399 | /** 400 | * Get Web Application Firewall (WAF) setting (permission needed: #zone_settings:edit) 401 | * Edit settings for a zone 402 | * 403 | * @param string $zone_identifier API item identifier tag 404 | * @param array $items One or more zone setting objects. Must contain an ID and a value. 405 | */ 406 | public function edit($zone_identifier, array $items) 407 | { 408 | $data = [ 409 | 'items' => $items, 410 | ]; 411 | 412 | return $this->patch('zones/'.$zone_identifier.'/settings', $data); 413 | } 414 | 415 | /** 416 | * Change Automatic HTTPS Rewrites setting (permission needed: #zone_settings:edit) 417 | * Enable the Automatic HTTPS Rewrites feature for this zone. 418 | * 419 | * @param string $zone_identifier API item identifier tag 420 | * @param string|null $value Value of the zone setting (default: off) 421 | */ 422 | public function change_automatic_https_rewrites($zone_identifier, $value = null) 423 | { 424 | $data = [ 425 | 'value' => $value, 426 | ]; 427 | 428 | return $this->patch('zones/'.$zone_identifier.'/settings/automatic_https_rewrites', $data); 429 | } 430 | 431 | /** 432 | * Change Always Online setting (permission needed: #zone_settings:edit) 433 | * When enabled, Always Online will serve pages from our cache if your server is offline (https://support.cloudflare.com/hc/en-us/articles/200168006) 434 | * 435 | * @param string $zone_identifier API item identifier tag 436 | * @param string|null $value Value of the zone setting (default: on) 437 | */ 438 | public function change_always_on($zone_identifier, $value = null) 439 | { 440 | $data = [ 441 | 'value' => $value, 442 | ]; 443 | 444 | return $this->patch('zones/'.$zone_identifier.'/settings/always_online', $data); 445 | } 446 | 447 | /** 448 | * Change Always Use HTTPS setting (permission needed: #zone_settings:edit) 449 | * 450 | * Reply to all requests for URLs that use "http" with a 301 redirect to the equivalent "https" URL. If you only want to redirect for a subset of requests, consider creating an "Always use HTTPS" page rule. 451 | * 452 | * @link https://api.cloudflare.com/#zone-settings-change-always-use-https-setting 453 | * 454 | * @param string $zone_identifier API item identifier tag 455 | * @param string|null $value Value of the zone setting (default: off) 456 | * 457 | * @return \stdClass | false 458 | */ 459 | public function change_always_use_https($zone_identifier, $value = null) 460 | { 461 | $data = array( 462 | 'value' => $value 463 | ); 464 | return $this->patch('zones/' . $zone_identifier . '/settings/always_use_https', $data); 465 | } 466 | 467 | /** 468 | * Change Browser Cache TTL setting (permission needed: #zone_settings:edit) 469 | * Browser Cache TTL (in seconds) specifies how long CloudFlare-cached resources will remain on your visitors' computers. CloudFlare will honor any larger times specified by your server. 470 | * (https://support.cloudflare.com/hc/en-us/articles/200168276) 471 | * 472 | * @param string $zone_identifier API item identifier tag 473 | * @param int|null $value Value of the zone setting (default: 14400) 474 | */ 475 | public function change_browser_cache_ttl($zone_identifier, $value = null) 476 | { 477 | $data = [ 478 | 'value' => $value, 479 | ]; 480 | 481 | return $this->patch('zones/'.$zone_identifier.'/settings/browser_cache_ttl', $data); 482 | } 483 | 484 | /** 485 | * Change Browser Check setting (permission needed: #zone_settings:edit) 486 | * Browser Integrity Check is similar to Bad Behavior and looks for common HTTP headers abused most commonly by spammers and denies access to your page. 487 | * It will also challenge visitors that do not have a user agent or a non standard user agent (also commonly used by abuse bots, crawlers or visitors). 488 | * (https://support.cloudflare.com/hc/en-us/articles/200170086) 489 | * 490 | * @param string $zone_identifier API item identifier tag 491 | * @param string|null $value Value of the zone setting (default: on) 492 | */ 493 | public function change_browser_check($zone_identifier, $value = null) 494 | { 495 | $data = [ 496 | 'value' => $value, 497 | ]; 498 | 499 | return $this->patch('zones/'.$zone_identifier.'/settings/browser_check', $data); 500 | } 501 | 502 | /** 503 | * Change Cache Level setting (permission needed: #zone_settings:edit) 504 | * Cache Level functions based off the setting level. The basic setting will cache most static resources (i.e., css, images, and JavaScript). 505 | * The simplified setting will ignore the query string when delivering a cached resource. The aggressive setting will cache all static resources, including ones with a query string. 506 | * (https://support.cloudflare.com/hc/en-us/articles/200168256) 507 | * 508 | * @param string $zone_identifier API item identifier tag 509 | * @param string|null $value Value of the zone setting (default: on) 510 | */ 511 | public function change_cache_level($zone_identifier, $value = null) 512 | { 513 | $data = [ 514 | 'value' => $value, 515 | ]; 516 | 517 | return $this->patch('zones/'.$zone_identifier.'/settings/cache_level', $data); 518 | } 519 | 520 | /** 521 | * Change Challenge TTL setting (permission needed: #zone_settings:edit) 522 | * Specify how long a visitor is allowed access to your site after successfully completing a challenge (such as a CAPTCHA). After the TTL has expired the visitor will have to complete a new challenge. 523 | * We recommend a 15 - 45 minute setting and will attempt to honor any setting above 45 minutes. 524 | * (https://support.cloudflare.com/hc/en-us/articles/200170136) 525 | * 526 | * @param string $zone_identifier API item identifier tag 527 | * @param int|null $value Value of the zone setting (default: on) 528 | */ 529 | public function change_challenge_ttl($zone_identifier, $value = null) 530 | { 531 | $data = [ 532 | 'value' => $value, 533 | ]; 534 | 535 | return $this->patch('zones/'.$zone_identifier.'/settings/challenge_ttl', $data); 536 | } 537 | 538 | /** 539 | * Change Development Mode setting (permission needed: #zone_settings:edit) 540 | * Development Mode temporarily allows you to enter development mode for your websites if you need to make changes to your site. 541 | * This will bypass CloudFlare's accelerated cache and slow down your site, but is useful if you are making changes to cacheable content (like images, css, or JavaScript) and would like to see those changes right away. Once entered, development mode will last for 3 hours and then automatically toggle off. 542 | * 543 | * @param string $zone_identifier API item identifier tag 544 | * @param string|null $value Value of the zone setting (default: on) 545 | */ 546 | public function change_development_mode($zone_identifier, $value = null) 547 | { 548 | $data = [ 549 | 'value' => $value, 550 | ]; 551 | 552 | return $this->patch('zones/'.$zone_identifier.'/settings/development_mode', $data); 553 | } 554 | 555 | /** 556 | * Change Enable Error Pages On setting (permission needed: #zone_settings:edit) 557 | * CloudFlare will proxy customer error pages on any 502,504 errors on origin server instead of showing a default CloudFlare error page. This does not apply to 522 errors and is limited to Enterprise Zones. 558 | * 559 | * @param string $zone_identifier API item identifier tag 560 | * @param string|null $value Value of the zone setting (default: on) 561 | */ 562 | public function change_origin_error_page_pass_thru($zone_identifier, $value = null) 563 | { 564 | $data = [ 565 | 'value' => $value, 566 | ]; 567 | 568 | return $this->patch('zones/'.$zone_identifier.'/settings/origin_error_page_pass_thru', $data); 569 | } 570 | 571 | /** 572 | * Change Enable Query String Sort setting (permission needed: #zone_settings:edit) 573 | * CloudFlare will treat files with the same query strings as the same file in cache, regardless of the order of the query strings. This is limited to Enterprise Zones. 574 | * 575 | * @param string $zone_identifier API item identifier tag 576 | * @param string|null $value Value of the zone setting (default: on) 577 | */ 578 | public function change_sort_query_string_for_cache($zone_identifier, $value = null) 579 | { 580 | $data = [ 581 | 'value' => $value, 582 | ]; 583 | 584 | return $this->patch('zones/'.$zone_identifier.'/settings/sort_query_string_for_cache', $data); 585 | } 586 | 587 | /** 588 | * Change Hotlink Protection setting (permission needed: #zone_settings:edit) 589 | * When enabled, the Hotlink Protection option ensures that other sites cannot suck up your bandwidth by building pages that use images hosted on your site. Anytime a request for an image on your site hits CloudFlare, we check to ensure that it's not another site requesting them. 590 | * People will still be able to download and view images from your page, but other sites won't be able to steal them for use on their own pages. 591 | * (https://support.cloudflare.com/hc/en-us/articles/200170026) 592 | * 593 | * @param string $zone_identifier API item identifier tag 594 | * @param string|null $value Value of the zone setting (default: on) 595 | */ 596 | public function change_hotlink_protection($zone_identifier, $value = null) 597 | { 598 | $data = [ 599 | 'value' => $value, 600 | ]; 601 | 602 | return $this->patch('zones/'.$zone_identifier.'/settings/hotlink_protection', $data); 603 | } 604 | 605 | /** 606 | * Change IP Geolocation setting (permission needed: #zone_settings:edit) 607 | * Enable IP Geolocation to have CloudFlare geolocate visitors to your website and pass the country code to you. (https://support.cloudflare.com/hc/en-us/articles/200168236) 608 | * 609 | * @param string $zone_identifier API item identifier tag 610 | * @param string|null $value Value of the zone setting (default: on) 611 | */ 612 | public function change_ip_geolocation($zone_identifier, $value = null) 613 | { 614 | $data = [ 615 | 'value' => $value, 616 | ]; 617 | 618 | return $this->patch('zones/'.$zone_identifier.'/settings/ip_geolocation', $data); 619 | } 620 | 621 | /** 622 | * Change IPv6 setting (permission needed: #zone_settings:edit) 623 | * Enable IPv6 on all subdomains that are CloudFlare enabled. (https://support.cloudflare.com/hc/en-us/articles/200168586) 624 | * 625 | * @param string $zone_identifier API item identifier tag 626 | * @param string|null $value Value of the zone setting (default: on) 627 | */ 628 | public function change_ipv6($zone_identifier, $value = null) 629 | { 630 | $data = [ 631 | 'value' => $value, 632 | ]; 633 | 634 | return $this->patch('zones/'.$zone_identifier.'/settings/ipv6', $data); 635 | } 636 | 637 | /** 638 | * Change Minify setting (permission needed: #zone_settings:edit) 639 | * Automatically minify certain assets for your website (https://support.cloudflare.com/hc/en-us/articles/200168196). 640 | * 641 | * @param string $zone_identifier API item identifier tag 642 | * @param string|null $value Value of the zone setting 643 | */ 644 | public function change_minify($zone_identifier, $value) 645 | { 646 | $data = [ 647 | 'value' => $value, 648 | ]; 649 | 650 | return $this->patch('zones/'.$zone_identifier.'/settings/minify', $data); 651 | } 652 | 653 | /** 654 | * Change Mobile Redirect setting (permission needed: #zone_settings:edit) 655 | * Automatically redirect visitors on mobile devices to a mobile-optimized subdomain (https://support.cloudflare.com/hc/en-us/articles/200168336). 656 | * 657 | * @param string $zone_identifier API item identifier tag 658 | * @param string|null $value Value of the zone setting (default: on) 659 | */ 660 | public function change_mobile_redirect($zone_identifier, $value) 661 | { 662 | $data = [ 663 | 'value' => $value, 664 | ]; 665 | 666 | return $this->patch('zones/'.$zone_identifier.'/settings/mobile_redirect', $data); 667 | } 668 | 669 | /** 670 | * Change Mirage setting (permission needed: #zone_settings:edit) 671 | * Automatically optimize image loading for website visitors on mobile devices (http://blog.cloudflare.com/mirage2-solving-mobile-speed). 672 | * 673 | * @param string $zone_identifier API item identifier tag 674 | * @param string|null $value Value of the zone setting (default: off) 675 | */ 676 | public function change_mirage($zone_identifier, $value = null) 677 | { 678 | $data = [ 679 | 'value' => $value, 680 | ]; 681 | 682 | return $this->patch('zones/'.$zone_identifier.'/settings/mirage', $data); 683 | } 684 | 685 | /** 686 | * Change Polish setting (permission needed: #zone_settings:edit) 687 | * Strips metadata and compresses your images for faster page load times. Basic (Lossless): Reduce the size of PNG, JPEG, and GIF files - no impact on visual quality. Basic + JPEG (Lossy): Further reduce the size of JPEG files for faster image loading. 688 | * Larger JPEGs are converted to progressive images, loading a lower-resolution image first and ending in a higher-resolution version. Not recommended for hi-res photography sites. 689 | * 690 | * @param string $zone_identifier API item identifier tag 691 | * @param string|null $value Value of the zone setting (default: off) 692 | */ 693 | public function change_polish($zone_identifier, $value = null) 694 | { 695 | $data = [ 696 | 'value' => $value, 697 | ]; 698 | 699 | return $this->patch('zones/'.$zone_identifier.'/settings/polish', $data); 700 | } 701 | 702 | /** 703 | * Change Prefetch Preload setting (permission needed: #zone_settings:edit) 704 | * CloudFlare will prefetch any URLs that are included in the response headers. This is limited to Enterprise Zones. 705 | * 706 | * @param string $zone_identifier API item identifier tag 707 | * @param string|null $value Value of the zone setting (default: off) 708 | */ 709 | public function change_prefetch_preload($zone_identifier, $value = null) 710 | { 711 | $data = [ 712 | 'value' => $value, 713 | ]; 714 | 715 | return $this->patch('zones/'.$zone_identifier.'/settings/prefetch_preload', $data); 716 | } 717 | 718 | /** 719 | * Change Response Buffering setting (permission needed: #zone_settings:edit) 720 | * Enables or disables buffering of responses from the proxied server. CloudFlare may buffer the whole payload to deliver it at once to the client versus allowing it to be delivered in chunks. 721 | * By default, the proxied server streams directly and is not buffered by CloudFlare. This is limited to Enterprise Zones. 722 | * 723 | * @param string $zone_identifier API item identifier tag 724 | * @param string|null $value Value of the zone setting (default: off) 725 | */ 726 | public function change_response_buffering($zone_identifier, $value = null) 727 | { 728 | $data = [ 729 | 'value' => $value, 730 | ]; 731 | 732 | return $this->patch('zones/'.$zone_identifier.'/settings/response_buffering', $data); 733 | } 734 | 735 | /** 736 | * Change Rocket Loader setting (permission needed: #zone_settings:edit) 737 | * Rocket Loader is a general-purpose asynchronous JavaScript loader coupled with a lightweight virtual browser which can safely run any JavaScript code after window.onload. Turning on Rocket Loader will immediately improve a web page's window.onload time (assuming there is JavaScript on the page), which can have a positive impact on your Google search ranking. 738 | * Automatic Mode: Rocket Loader will automatically run on the JavaScript resources on your site, with no configuration required after turning on automatic mode. 739 | * Manual Mode: In order to have Rocket Loader execute for a particular script, you must add the following attribute to the script tag: "data-cfasync='true'". As your page passes through CloudFlare, we'll enable Rocket Loader for that particular script. 740 | * All other JavaScript will continue to execute without CloudFlare touching the script. (https://support.cloudflare.com/hc/en-us/articles/200168056) 741 | * 742 | * @param string $zone_identifier API item identifier tag 743 | * @param string|null $value Value of the zone setting (default: off) 744 | */ 745 | public function change_rocket_loader($zone_identifier, $value = null) 746 | { 747 | $data = [ 748 | 'value' => $value, 749 | ]; 750 | 751 | return $this->patch('zones/'.$zone_identifier.'/settings/rocket_loader', $data); 752 | } 753 | 754 | /** 755 | * Change Security Header (HSTS) setting (permission needed: #zone_settings:edit) 756 | * CloudFlare security header for a zone. 757 | * 758 | * @param string $zone_identifier API item identifier tag 759 | * @param string|null $value Value of the zone setting (default: off) 760 | */ 761 | public function change_security_header($zone_identifier, $value) 762 | { 763 | $data = [ 764 | 'value' => $value, 765 | ]; 766 | 767 | return $this->patch('zones/'.$zone_identifier.'/settings/security_header', $data); 768 | } 769 | 770 | /** 771 | * Change Security Level setting (permission needed: #zone_settings:edit) 772 | * Choose the appropriate security profile for your website, which will automatically adjust each of the security settings. If you choose to customize an individual security setting, the profile will become Custom. 773 | * (https://support.cloudflare.com/hc/en-us/articles/200170056) 774 | * 775 | * @param string $zone_identifier API item identifier tag 776 | * @param string|null $value Value of the zone setting (default: medium) 777 | */ 778 | public function change_security_level($zone_identifier, $value = null) 779 | { 780 | $data = [ 781 | 'value' => $value, 782 | ]; 783 | 784 | return $this->patch('zones/'.$zone_identifier.'/settings/security_level', $data); 785 | } 786 | 787 | /** 788 | * Change Server Side Exclude setting (permission needed: #zone_settings:edit) 789 | * If there is sensitive content on your website that you want visible to real visitors, but that you want to hide from suspicious visitors, all you have to do is wrap the content with CloudFlare SSE tags. 790 | * Wrap any content that you want to be excluded from suspicious visitors in the following SSE tags: . For example: Bad visitors won't see my phone number, 555-555-5555 . Note: SSE only will work with HTML. 791 | * If you have HTML minification enabled, you won't see the SSE tags in your HTML source when it's served through CloudFlare. SSE will still function in this case, as CloudFlare's HTML minification and SSE functionality occur on-the-fly as the resource moves through our network to the visitor's computer. 792 | * (https://support.cloudflare.com/hc/en-us/articles/200170036) 793 | * 794 | * @param string $zone_identifier API item identifier tag 795 | * @param string|null $value Value of the zone setting (default: on) 796 | */ 797 | public function change_server_side_exclude($zone_identifier, $value = null) 798 | { 799 | $data = [ 800 | 'value' => $value, 801 | ]; 802 | 803 | return $this->patch('zones/'.$zone_identifier.'/settings/server_side_exclude', $data); 804 | } 805 | 806 | /** 807 | * Change SSL setting (permission needed: #zone_settings:edit) 808 | * SSL encrypts your visitor's connection and safeguards credit card numbers and other personal data to and from your website. SSL can take up to 5 minutes to fully activate. 809 | * Requires CloudFlare active on your root domain or www domain. 810 | * Off: no SSL between the visitor and CloudFlare, and no SSL between CloudFlare and your web server (all HTTP traffic). 811 | * Flexible: SSL between the visitor and CloudFlare -- visitor sees HTTPS on your site, but no SSL between CloudFlare and your web server. You don't need to have an SSL cert on your web server, but your vistors will still see the site as being HTTPS enabled. 812 | * Full: SSL between the visitor and CloudFlare -- visitor sees HTTPS on your site, and SSL between CloudFlare and your web server. You'll need to have your own SSL cert or self-signed cert at the very least. 813 | * Full (Strict): SSL between the visitor and CloudFlare -- visitor sees HTTPS on your site, and SSL between CloudFlare and your web server. You'll need to have a valid SSL certificate installed on your web server. This certificate must be signed by a certificate authority, have an expiration date in the future, and respond for the request domain name (hostname). 814 | * (https://support.cloudflare.com/hc/en-us/articles/200170416) 815 | * 816 | * @param string $zone_identifier API item identifier tag 817 | * @param string|null $value Value of the zone setting (default: off) 818 | */ 819 | public function change_ssl($zone_identifier, $value = null) 820 | { 821 | $data = [ 822 | 'value' => $value, 823 | ]; 824 | 825 | return $this->patch('zones/'.$zone_identifier.'/settings/ssl', $data); 826 | } 827 | 828 | /** 829 | * Change TLS Client Auth setting (permission needed: #zone_settings:edit) 830 | * TLS Client Auth requires CloudFlare to connect to your origin server using a client certificate (Enterprise Only) 831 | * 832 | * @param string $zone_identifier API item identifier tag 833 | * @param string|null $value Value of the zone setting (default: off) 834 | */ 835 | public function change_tls_client_auth($zone_identifier, $value = null) 836 | { 837 | $data = [ 838 | 'value' => $value, 839 | ]; 840 | 841 | return $this->patch('zones/'.$zone_identifier.'/settings/tls_client_auth', $data); 842 | } 843 | 844 | /** 845 | * Change True Client IP setting (permission needed: #zone_settings:edit) 846 | * Allows customer to continue to use True Client IP (Akamai feature) in the headers we send to the origin. This is limited to Enterprise Zones. 847 | * 848 | * @param string $zone_identifier API item identifier tag 849 | * @param string|null $value Value of the zone setting (default: off) 850 | */ 851 | public function change_true_client_ip_header($zone_identifier, $value = null) 852 | { 853 | $data = [ 854 | 'value' => $value, 855 | ]; 856 | 857 | return $this->patch('zones/'.$zone_identifier.'/settings/true_client_ip_header', $data); 858 | } 859 | 860 | /** 861 | * Change TLS 1.2 setting (permission needed: #zone_settings:edit) 862 | * Enable Crypto TLS 1.2 feature for this zone and prevent use of previous versions. This is limited to Enterprise or Business Zones. 863 | * 864 | * @param string $zone_identifier API item identifier tag 865 | * @param string|null $value Value of the zone setting (default: off) 866 | */ 867 | public function change_tls_1_2_only($zone_identifier, $value = null) 868 | { 869 | $data = [ 870 | 'value' => $value, 871 | ]; 872 | 873 | return $this->patch('zones/'.$zone_identifier.'/settings/true_client_ip_header', $data); 874 | } 875 | 876 | /** 877 | * Change Web Application Firewall (WAF) (permission needed: #zone_settings:edit) 878 | * The WAF examines HTTP requests to your website. It inspects both GET and POST requests and applies rules to help filter out illegitimate traffic from legitimate website visitors. 879 | * The CloudFlare WAF inspects website addresses or URLs to detect anything out of the ordinary. If the CloudFlare WAF determines suspicious user behavior, then the WAF will "challenge" the web visitor with a page that asks them to submit a CAPTCHA successfully to continue their action. 880 | * If the challenge is failed, the action will be stopped. What this means is that CloudFlare’s WAF will block any traffic identified as illegitimate before it reaches your origin web server. 881 | * (https://support.cloudflare.com/hc/en-us/articles/200172016) 882 | * 883 | * @param string $zone_identifier API item identifier tag 884 | * @param string|null $value Value of the zone setting (default: off) 885 | */ 886 | public function change_waf($zone_identifier, $value = null) 887 | { 888 | $data = [ 889 | 'value' => $value, 890 | ]; 891 | 892 | return $this->patch('zones/'.$zone_identifier.'/settings/waf', $data); 893 | } 894 | } 895 | --------------------------------------------------------------------------------