This repository has been archived by the owner on Nov 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated Load Balancer methods to match final API documentation
- Loading branch information
1 parent
0af7a7a
commit 1ed918f
Showing
6 changed files
with
363 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
src/CloudFlare/Organizations/LoadBalancers/Monitors.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
<?php | ||
|
||
namespace Cloudflare\User\LoadBalancers; | ||
|
||
use Cloudflare\Api; | ||
use Cloudflare\Organizations; | ||
|
||
/** | ||
* CloudFlare API wrapper | ||
* | ||
* CTM Monitors | ||
* Cloud Traffic Manager Monitor | ||
* | ||
* @author James Bell <[email protected]> | ||
* | ||
* @version 1 | ||
*/ | ||
class Monitors extends Api | ||
{ | ||
/** | ||
* List monitors | ||
* List configured monitors for a user | ||
* | ||
* @param string $organization_identifier | ||
*/ | ||
public function monitors($organization_identifier) | ||
{ | ||
return $this->get('/organizations/'.$organization_identifier.'/load_balancers/monitors'); | ||
} | ||
|
||
/** | ||
* Create a monitor | ||
* Create a configured monitor | ||
* | ||
* @param string $organization_identifier | ||
* @param string $expected_body A case-insensitive substring to match in the body of the probe | ||
* response to declare an origin as up | ||
* @param string $expected_codes The expected HTTP response code or code range for the probe | ||
* @param string|null $method The HTTP method to use for the health check. | ||
* @param int|null $timeout The timeout (in seconds) before marking the health check as failed | ||
* @param string|null $path The endpoint path to health check against. | ||
* @param int|null $interval The interval between each health check. Shorter intervals may improve failover | ||
* time, but will increase load on the origins as we check from multiple locations. | ||
* @param int|null $retries The number of retries to attempt in case of a timeout before marking the origin | ||
* as unhealthy. Retries are attempted immediately. | ||
* @param array|null $header The HTTP request headers to send in the health check. It is recommended you set | ||
* a Host header by default. The User-Agent header cannot be overridden. | ||
* @param int|null $type The protocol to use for the healthcheck. Currently supported protocols are | ||
* 'HTTP' and 'HTTPS'. | ||
* @param string|null $description Object description | ||
*/ | ||
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) | ||
{ | ||
$data = [ | ||
'expected_body' => $expected_body, | ||
'expected_codes' => $expected_codes, | ||
'method' => $method, | ||
'timeout' => $timeout, | ||
'path' => $path, | ||
'interval' => $interval, | ||
'retries' => $retries, | ||
'header' => $header, | ||
'type' => $type, | ||
'description' => $description, | ||
]; | ||
|
||
return $this->post('/organizations/'.$organization_identifier.'/load_balancers/monitors', $data); | ||
} | ||
|
||
/** | ||
* Monitor details | ||
* List a single configured CTM monitor for a user | ||
* | ||
* @param string $organization_identifier | ||
* @param string $identifier | ||
*/ | ||
public function details($organization_identifier, $identifier) | ||
{ | ||
return $this->get('/organizations/'.$organization_identifier.'/load_balancers/monitors/'.$identifier); | ||
} | ||
|
||
/** | ||
* Modify a monitor | ||
* Modify a configured monitor | ||
* | ||
* @param string $organization_identifier | ||
* @param string $identifier | ||
* @param string $expected_body A case-insensitive substring to match in the body of the probe | ||
* response to declare an origin as up | ||
* @param string $expected_codes The expected HTTP response code or code range for the probe | ||
* @param string|null $method The HTTP method to use for the health check. | ||
* @param int|null $timeout The timeout (in seconds) before marking the health check as failed | ||
* @param string|null $path The endpoint path to health check against. | ||
* @param int|null $interval The interval between each health check. Shorter intervals may improve failover | ||
* time, but will increase load on the origins as we check from multiple locations. | ||
* @param int|null $retries The number of retries to attempt in case of a timeout before marking the origin | ||
* as unhealthy. Retries are attempted immediately. | ||
* @param array|null $header The HTTP request headers to send in the health check. It is recommended you set | ||
* a Host header by default. The User-Agent header cannot be overridden. | ||
* @param int|null $type The protocol to use for the healthcheck. Currently supported protocols are | ||
* 'HTTP' and 'HTTPS'. | ||
* @param string|null $description Object description | ||
*/ | ||
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) | ||
{ | ||
$data = [ | ||
'expected_body' => $expected_body, | ||
'expected_codes' => $expected_codes, | ||
'method' => $method, | ||
'timeout' => $timeout, | ||
'path' => $path, | ||
'interval' => $interval, | ||
'retries' => $retries, | ||
'header' => $header, | ||
'type' => $type, | ||
'description' => $description, | ||
]; | ||
|
||
return $this->patch('/organizations/'.$organization_identifier.'/load_balancers/monitors/'.$identifier, $data); | ||
} | ||
|
||
/** | ||
* Delete a monitor | ||
* Delete a configured monitor | ||
* | ||
* @param string $organization_identifier | ||
* @param string $identifier | ||
*/ | ||
public function delete_monitor($organization_identifier, $identifier) | ||
{ | ||
return $this->delete('/organizations/'.$organization_identifier.'/load_balancers/monitors/'.$identifier); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<?php | ||
|
||
namespace Cloudflare\User\LoadBalancers; | ||
|
||
use Cloudflare\Api; | ||
use Cloudflare\Organizations; | ||
|
||
/** | ||
* CloudFlare API wrapper | ||
* | ||
* CTM Pool | ||
* User-level Cloud Traffic Manager Pool | ||
* | ||
* @author James Bell <[email protected]> | ||
* | ||
* @version 1 | ||
*/ | ||
class Pools extends Api | ||
{ | ||
/** | ||
* List pools | ||
* List configured pools | ||
* | ||
* @param string $organization_identifier | ||
*/ | ||
public function pools($organization_identifier) | ||
{ | ||
return $this->get('/organizations/'.$organization_identifier.'/load_balancers/pools'); | ||
} | ||
|
||
/** | ||
* Create a pool | ||
* Create a new pool | ||
* | ||
* @param string $organization_identifier | ||
* @param string $name Object name | ||
* @param array $origins A list of origins contained in the pool. | ||
* Traffic destined to the pool is balanced across all | ||
* available origins contained in the pool (as long as the pool | ||
* is considered available). | ||
* @param string|null $description Object description | ||
* @param bool|null $enabled Whether this pool is enabled or not. | ||
* @param string|null $monitor ID of the monitor object to use for monitoring the health | ||
* status of origins inside this pool. | ||
* @param string|null $notification_email ID of the notifier object to use for notifications relating | ||
* to the health status of origins inside this pool. | ||
*/ | ||
public function create($organization_identifier, $name, $origins, $description = null, $enabled = null, $monitor = null, $notification_email = null) | ||
{ | ||
$data = [ | ||
'name' => $name, | ||
'origins' => $origins, | ||
'description' => $description, | ||
'enabled' => $enabled, | ||
'monitor' => $monitor, | ||
'notification_email' => $notification_email, | ||
]; | ||
|
||
return $this->post('/organizations/'.$organization_identifier.'/load_balancers/pools', $data); | ||
} | ||
|
||
/** | ||
* Pool details | ||
* Fetch a single configured pool | ||
* | ||
* @param string $organization_identifier | ||
* @param string $identifier | ||
*/ | ||
public function details($organization_identifier, $identifier) | ||
{ | ||
return $this->get('/organizations/'.$organization_identifier.'/load_balancers/pools/'.$identifier); | ||
} | ||
|
||
/** | ||
* Modify a pool | ||
* Modify a configured pool | ||
* | ||
* @param string $organization_identifier | ||
* @param string $identifier | ||
* @param string $name Object name | ||
* @param array $origins A list of origins contained in the pool. | ||
* Traffic destined to the pool is balanced across all | ||
* available origins contained in the pool (as long as the pool | ||
* is considered available). | ||
* @param string|null $description Object description | ||
* @param bool|null $enabled Whether this pool is enabled or not. | ||
* @param string|null $monitor ID of the monitor object to use for monitoring the health | ||
* status of origins inside this pool. | ||
* @param string|null $notification_email ID of the notifier object to use for notifications relating | ||
* to the health status of origins inside this pool. | ||
*/ | ||
public function update($organization_identifier, $identifier, $name, $origins, $description = null, $enabled = null, $monitor = null, $notification_email = null) | ||
{ | ||
$data = [ | ||
'name' => $name, | ||
'origins' => $origins, | ||
'description' => $description, | ||
'enabled' => $enabled, | ||
'monitor' => $monitor, | ||
'notification_email' => $notification_email, | ||
]; | ||
|
||
return $this->patch('/organizations/'.$organization_identifier.'/load_balancers/pools/'.$identifier, $data); | ||
} | ||
|
||
/** | ||
* Delete a pool | ||
* Delete a configured pool | ||
* | ||
* @param string $identifier | ||
*/ | ||
public function delete_pool($organization_identifier, $identifier) | ||
{ | ||
return $this->delete('/organizations/'.$organization_identifier.'/load_balancers/pools/'.$identifier); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.