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