1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Cloudflare\User\LoadBalancers; |
4
|
|
|
|
5
|
|
|
use Cloudflare\Api; |
6
|
|
|
use Cloudflare\User; |
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
|
|
|
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 $notifier 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, $notifier = null) |
46
|
|
|
{ |
47
|
|
|
$data = [ |
48
|
|
|
'name' => $name, |
49
|
|
|
'origins' => $origins, |
50
|
|
|
'description' => $description, |
51
|
|
|
'enabled' => $enabled, |
52
|
|
|
'monitor' => $monitor, |
53
|
|
|
'notifier' => $notifier, |
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|null $name Object name |
76
|
|
|
* @param array|null $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 $notifier 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 = null, $origins = null, $description = null, $enabled = null, $monitor = null, $notifier = null) |
88
|
|
|
{ |
89
|
|
|
$data = [ |
90
|
|
|
'name' => $name, |
91
|
|
|
'origins' => $origins, |
92
|
|
|
'description' => $description, |
93
|
|
|
'enabled' => $enabled, |
94
|
|
|
'monitor' => $monitor, |
95
|
|
|
'notifier' => $notifier, |
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
|
|
|
|