1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Cloudflare\Organizations\LoadBalancers; |
4
|
|
|
|
5
|
|
|
use Cloudflare\Api; |
6
|
|
|
use Cloudflare\Organizations; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* CloudFlare API wrapper |
10
|
|
|
* |
11
|
|
|
* CTM Pool |
12
|
|
|
* User-level Cloud Traffic Manager Pool |
13
|
|
|
* |
14
|
|
|
* @author James Bell <[email protected]> |
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
|
|
View Code Duplication |
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
|
|
View Code Duplication |
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
|
|
|
|