1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Axsor\PhpIPAM\Http\Requests; |
4
|
|
|
|
5
|
|
|
class SubnetRequest extends Connector |
6
|
|
|
{ |
7
|
|
|
public function show($subnet) |
8
|
|
|
{ |
9
|
|
|
$id = get_id_from_variable($subnet); |
10
|
|
|
|
11
|
|
|
return $this->get("subnets/{$id}"); |
12
|
|
|
} |
13
|
|
|
|
14
|
|
|
public function usage($subnet) |
15
|
|
|
{ |
16
|
|
|
$id = get_id_from_variable($subnet); |
17
|
|
|
|
18
|
|
|
return $this->get("subnets/{$id}/usage"); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function freeAddress($subnet) |
22
|
|
|
{ |
23
|
|
|
$id = get_id_from_variable($subnet); |
24
|
|
|
|
25
|
|
|
return $this->get("subnets/{$id}/first_free"); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function slaves($subnet) |
29
|
|
|
{ |
30
|
|
|
$id = get_id_from_variable($subnet); |
31
|
|
|
|
32
|
|
|
return $this->get("subnets/{$id}/slaves"); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
public function slavesRecursive($subnet) |
36
|
|
|
{ |
37
|
|
|
$id = get_id_from_variable($subnet); |
38
|
|
|
|
39
|
|
|
return $this->get("subnets/{$id}/slaves_recursive"); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function addresses($subnet) |
43
|
|
|
{ |
44
|
|
|
$id = get_id_from_variable($subnet); |
45
|
|
|
|
46
|
|
|
return $this->get("subnets/{$id}/addresses"); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function ip($subnet, string $ip) |
50
|
|
|
{ |
51
|
|
|
$id = get_id_from_variable($subnet); |
52
|
|
|
|
53
|
|
|
return $this->get("subnets/{$id}/addresses/{$ip}"); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function freeSubnet($subnet, int $mask) |
57
|
|
|
{ |
58
|
|
|
$id = get_id_from_variable($subnet); |
59
|
|
|
|
60
|
|
|
return $this->get("subnets/{$id}/first_subnet/{$mask}"); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function freeSubnets($subnet, int $mask) |
64
|
|
|
{ |
65
|
|
|
$id = get_id_from_variable($subnet); |
66
|
|
|
|
67
|
|
|
return $this->get("subnets/{$id}/all_subnets/{$mask}"); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function customFields() |
71
|
|
|
{ |
72
|
|
|
return $this->get('subnets/custom_fields'); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function byCidr(string $cidr) |
76
|
|
|
{ |
77
|
|
|
return $this->get("subnets/cidr/{$cidr}"); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function create(array $data) |
81
|
|
|
{ |
82
|
|
|
return $this->post("subnets", $data); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function createInSubnet($subnet, array $data) |
86
|
|
|
{ |
87
|
|
|
$id = get_id_from_variable($subnet); |
88
|
|
|
|
89
|
|
|
return $this->post("subnets/{$id}/first_subnet/{$data['mask']}/", $data); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function update($subnet, array $newData) |
93
|
|
|
{ |
94
|
|
|
$id = get_id_from_variable($subnet); |
95
|
|
|
|
96
|
|
|
return $this->patch("subnets/{$id}/", $newData); |
97
|
|
|
} |
98
|
|
|
|
99
|
|
|
public function resize($subnet, int $mask) |
100
|
|
|
{ |
101
|
|
|
$id = get_id_from_variable($subnet); |
102
|
|
|
|
103
|
|
|
return $this->patch("subnets/{$id}/resize", ['mask' => $mask]); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
public function split($subnet, int $number) |
107
|
|
|
{ |
108
|
|
|
$id = get_id_from_variable($subnet); |
109
|
|
|
|
110
|
|
|
return $this->patch("subnets/{$id}/split", ['number' => $number]); |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
public function drop($subnet) |
114
|
|
|
{ |
115
|
|
|
$id = get_id_from_variable($subnet); |
116
|
|
|
|
117
|
|
|
return $this->delete("subnets/{$id}"); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
public function truncate($subnet) |
121
|
|
|
{ |
122
|
|
|
$id = get_id_from_variable($subnet); |
123
|
|
|
|
124
|
|
|
return $this->delete("subnets/{$id}/truncate"); |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|