1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Cloudflare\Zone\WAF; |
4
|
|
|
|
5
|
|
|
use Cloudflare\Api; |
6
|
|
|
use Cloudflare\Zone; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* CloudFlare API wrapper |
10
|
|
|
* |
11
|
|
|
* WAF Rule Packages properties |
12
|
|
|
* |
13
|
|
|
* @author James Bell <[email protected]> |
14
|
|
|
* |
15
|
|
|
* @version 1 |
16
|
|
|
*/ |
17
|
|
|
class Packages extends Api |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* List firewall packages (permission needed: #zone:read) |
21
|
|
|
* Retrieve firewall packages for a zone |
22
|
|
|
* |
23
|
|
|
* @param string $zone_identifier |
24
|
|
|
* @param string|null $name Name of the firewall package |
25
|
|
|
* @param int|null $page Page number of paginated results |
26
|
|
|
* @param int|null $per_page Number of packages per page |
27
|
|
|
* @param string|null $order Field to order packages by |
28
|
|
|
* @param string|null $direction Direction to order packages |
29
|
|
|
* @param string|null $match Whether to match all search requirements or at least one (any) |
30
|
|
|
*/ |
31
|
|
|
public function rules($zone_identifier, $name = null, $page = null, $per_page = null, $order = null, $direction = null, $match = null) |
32
|
|
|
{ |
33
|
|
|
$data = [ |
34
|
|
|
'name' => $name, |
35
|
|
|
'page' => $page, |
36
|
|
|
'per_page' => $per_page, |
37
|
|
|
'order' => $order, |
38
|
|
|
'direction' => $direction, |
39
|
|
|
'match' => $match, |
40
|
|
|
]; |
41
|
|
|
|
42
|
|
|
return $this->get('/zones/'.$zone_identifier.'/firewall/waf/packages', $data); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Firewall package info (permission needed: #zone:read) |
47
|
|
|
* Get information about a single firewall package |
48
|
|
|
* |
49
|
|
|
* @param string $zone_identifier |
50
|
|
|
* @param string $identifier |
51
|
|
|
*/ |
52
|
|
|
public function info($zone_identifier, $identifier) |
53
|
|
|
{ |
54
|
|
|
return $this->get('/zones/'.$zone_identifier.'/firewall/waf/packages/'.$identifier); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Change anomaly-detection web application firewall package settings (permission needed: #zone:edit) |
59
|
|
|
* Change the sensitivity and action for an anomaly detection type WAF rule package |
60
|
|
|
* |
61
|
|
|
* @param string $zone_identifier |
62
|
|
|
* @param string $identifier |
63
|
|
|
* @param string|null $sensitivity The sensitivity of the firewall package. |
64
|
|
|
* @param string|null $action_mode The default action that will be taken for rules under the firewall package. |
65
|
|
|
*/ |
66
|
|
|
public function update($zone_identifier, $identifier, $sensitivity = null, $action_mode = null) |
67
|
|
|
{ |
68
|
|
|
$data = [ |
69
|
|
|
'sensitivity' => $sensitivity, |
70
|
|
|
'action_mode' => $action_mode, |
71
|
|
|
]; |
72
|
|
|
|
73
|
|
|
return $this->patch('/zones/'.$zone_identifier.'/firewall/waf/packages/'.$identifier, $data); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|