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 Map |
12
|
|
|
* User-level Cloud Traffic Manager Map |
13
|
|
|
* |
14
|
|
|
* @author James Bell <[email protected]> |
15
|
|
|
* |
16
|
|
|
* @version 1 |
17
|
|
|
*/ |
18
|
|
View Code Duplication |
class Maps extends Api |
|
|
|
|
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* List maps |
22
|
|
|
* List configured maps |
23
|
|
|
*/ |
24
|
|
|
public function maps() |
|
|
|
|
25
|
|
|
{ |
26
|
|
|
return $this->get('/user/load_balancers/maps'); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Create a map |
31
|
|
|
* Create a new map |
32
|
|
|
* |
33
|
|
|
* @param array $global_pools Sorted list of pool IDs that will be utilized |
34
|
|
|
* if a CF PoP cannot be assigned to a configured region. |
35
|
|
|
* @param string|null $description Object description. |
36
|
|
|
*/ |
37
|
|
|
public function create($global_pools, $description = null) |
38
|
|
|
{ |
39
|
|
|
$data = [ |
40
|
|
|
'global_pools' => $global_pools, |
41
|
|
|
'description' => $description, |
42
|
|
|
]; |
43
|
|
|
|
44
|
|
|
return $this->post('/user/load_balancers/maps', $data); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Map details |
49
|
|
|
* Fetch a single configured map |
50
|
|
|
* |
51
|
|
|
* @param string $identifier |
52
|
|
|
*/ |
53
|
|
|
public function details($identifier) |
54
|
|
|
{ |
55
|
|
|
return $this->get('/user/load_balancers/maps/'.$identifier); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Modify a map |
60
|
|
|
* Modify a configured map |
61
|
|
|
* |
62
|
|
|
* @param string $identifier |
63
|
|
|
* @param array $global_pools Sorted list of pool IDs that will be utilized |
64
|
|
|
* if a CF PoP cannot be assigned to a configured region. |
65
|
|
|
* @param string|null $description Object description. |
66
|
|
|
*/ |
67
|
|
|
public function update($identifier, $global_pools = null, $description = null) |
68
|
|
|
{ |
69
|
|
|
$data = [ |
70
|
|
|
'global_pools' => $global_pools, |
71
|
|
|
'description' => $description, |
72
|
|
|
]; |
73
|
|
|
|
74
|
|
|
return $this->patch('/user/load_balancers/maps/'.$identifier, $data); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Delete a map |
79
|
|
|
* Delete a configured map |
80
|
|
|
* |
81
|
|
|
* @param string $identifier |
82
|
|
|
*/ |
83
|
|
|
public function delete_map($identifier) |
84
|
|
|
{ |
85
|
|
|
return $this->delete('/user/load_balancers/maps/'.$identifier); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|
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.