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 Notifiers |
12
|
|
|
* User-level Cloud Traffic Manager Notifier |
13
|
|
|
* |
14
|
|
|
* @author James Bell <[email protected]> |
15
|
|
|
* |
16
|
|
|
* @version 1 |
17
|
|
|
*/ |
18
|
|
View Code Duplication |
class Notifiers extends Api |
|
|
|
|
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* List notifiers |
22
|
|
|
* List configured notifiers for a user |
23
|
|
|
*/ |
24
|
|
|
public function notifiers() |
|
|
|
|
25
|
|
|
{ |
26
|
|
|
return $this->get('/user/load_balancers/notifiers'); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Create a notifier |
31
|
|
|
* Create a configured notifier |
32
|
|
|
* |
33
|
|
|
* @param string $address Notifier address |
34
|
|
|
* @param string|null $type Notifier type |
35
|
|
|
*/ |
36
|
|
|
public function create($address, $type = null) |
37
|
|
|
{ |
38
|
|
|
$data = [ |
39
|
|
|
'address' => $address, |
40
|
|
|
'type' => $type, |
41
|
|
|
]; |
42
|
|
|
|
43
|
|
|
return $this->post('/user/load_balancers/notifiers', $data); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Notifier details |
48
|
|
|
* Fetch a single configured CTM notifier for a user |
49
|
|
|
* |
50
|
|
|
* @param string $identifier |
51
|
|
|
*/ |
52
|
|
|
public function details($identifier) |
53
|
|
|
{ |
54
|
|
|
return $this->get('/user/load_balancers/notifiers/'.$identifier); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Modify a notifier |
59
|
|
|
* Modify a configured notifier |
60
|
|
|
* |
61
|
|
|
* @param string $identifier |
62
|
|
|
* @param string|null $address Notifier address |
63
|
|
|
* @param string|null $type Notifier type |
64
|
|
|
*/ |
65
|
|
|
public function update($identifier, $address = null, $type = null) |
66
|
|
|
{ |
67
|
|
|
$data = [ |
68
|
|
|
'address' => $address, |
69
|
|
|
'type' => $type, |
70
|
|
|
]; |
71
|
|
|
|
72
|
|
|
return $this->patch('/user/load_balancers/notifiers/'.$identifier, $data); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* Delete a notifier |
77
|
|
|
* Delete a configured notifier |
78
|
|
|
* |
79
|
|
|
* @param string $identifier |
80
|
|
|
*/ |
81
|
|
|
public function delete_notifier($identifier) |
82
|
|
|
{ |
83
|
|
|
return $this->delete('/user/load_balancers/notifiers/'.$identifier); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.