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 Global Policy |
12
|
|
|
* User-level Cloud Traffic Manager Global Policy |
13
|
|
|
* |
14
|
|
|
* @author James Bell <[email protected]> |
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
|
|
|
|