1 | <?php |
||
18 | class Rules extends Api |
||
19 | { |
||
20 | /** |
||
21 | * List access rules (permission needed: #organization:read) |
||
22 | * Search, sort, and filter IP/country access rules |
||
23 | * |
||
24 | * @param string $organization_id |
||
25 | * @param string|null $mode The action to apply to a matched request |
||
26 | * @param string|null $configuration_target The rule configuration target |
||
27 | * @param string|null $configuration_value Search by IP, range, or country code |
||
28 | * @param int|null $page Page number of paginated results |
||
29 | * @param int|null $per_page Number of rules per page |
||
30 | * @param string|null $order Field to order rules by |
||
31 | * @param string|null $direction Direction to order rules |
||
32 | * @param string|null $match Whether to match all search requirements or at least one (any) |
||
33 | */ |
||
34 | public function rules($organization_id, $mode = null, $configuration_target = null, $configuration_value = null, $page = null, $per_page = null, $order = null, $direction = null, $match = null) |
||
35 | { |
||
36 | $data = [ |
||
37 | 'mode' => $mode, |
||
38 | 'configuration_target' => $configuration_target, |
||
39 | 'configuration_value' => $configuration_value, |
||
40 | 'page' => $page, |
||
41 | 'per_page' => $per_page, |
||
42 | 'order' => $order, |
||
43 | 'direction' => $direction, |
||
44 | 'match' => $match, |
||
45 | ]; |
||
46 | |||
47 | return $this->get('organizations/'.$organization_id.'/firewall/access_rules/rules', $data); |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * Create access rule (permission needed: #organization:edit) |
||
52 | * Make a new IP, IP range, or country access rule for all zones owned by the organization. |
||
53 | * Note: If you would like to create an access rule that applies to a specific zone only, use the zone firewall endpoints. |
||
54 | * |
||
55 | * @param string $organization_id |
||
56 | * @param string $mode The action to apply to a matched request |
||
57 | * @param object $configuration Rule configuration |
||
58 | * @param string|null $notes A personal note about the rule. Typically used as a reminder or explanation for the rule. |
||
59 | */ |
||
60 | public function create($organization_id, $mode, $configuration, $notes = null) |
||
70 | |||
71 | /** |
||
72 | * Update access rule (permission needed: #organization:edit) |
||
73 | * Update rule state and/or configuration. This will be applied across all zones owned by the organization. |
||
74 | * |
||
75 | * @param string $organization_id |
||
76 | * @param string $identifier |
||
77 | * @param string|null $mode The action to apply to a matched request |
||
78 | * @param object|null $configuration Rule configuration |
||
79 | * @param string|null $notes A personal note about the rule. Typically used as a reminder or explanation for the rule. |
||
80 | */ |
||
81 | public function update($organization_id, $identifier, $mode = null, $configuration = null, $notes = null) |
||
91 | |||
92 | /** |
||
93 | * Delete access rule (permission needed: #organization:edit) |
||
94 | * Remove an access rule so it is no longer evaluated during requests. This will apply to all zones owned by the organization |
||
95 | * |
||
96 | * @param string $organization_id |
||
97 | * @param string $identifier |
||
98 | */ |
||
99 | public function delete_rule($organization_id, $identifier) |
||
103 | } |
||
104 |
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.