1: <?php
2:
3: namespace Cloudflare;
4:
5: /**
6: * CloudFlare API wrapper
7: *
8: * Railguns
9: * CloudFlare Railgun
10: *
11: * @author James Bell <[email protected]>
12: *
13: * @version 1
14: */
15: class Railguns extends Api
16: {
17: /**
18: * Default permissions level
19: *
20: * @var array
21: */
22: protected $permission_level = ['read' => '#railgun:read', 'edit' => '#railgun:edit'];
23:
24: /**
25: * Create Railgun (permission needed: #railgun:edit)
26: *
27: * @param string $name Readable identifier of the railgun
28: */
29: public function create($name)
30: {
31: $data = [
32: 'name' => $name,
33: ];
34:
35: return $this->post('railguns', $data);
36: }
37:
38: /**
39: * List Railguns (permission needed: #railgun:read)
40: * List, search, sort and filter your Railguns
41: *
42: * @param int|null $page Page number of paginated results
43: * @param int|null $per_page Number of items per page
44: * @param string|null $direction Direction to order Railguns (asc, desc)
45: */
46: public function railguns($page = null, $per_page = null, $direction = null)
47: {
48: $data = [
49: 'page' => $page,
50: 'per_page' => $per_page,
51: 'direction' => $direction,
52: ];
53:
54: return $this->get('railguns', $data);
55: }
56:
57: /**
58: * Railgun details (permission needed: #railgun:read)
59: *
60: * @param string $identifier API item identifier tag
61: */
62: public function details($identifier)
63: {
64: return $this->get('railguns/'.$identifier);
65: }
66:
67: /**
68: * Get zones connected to a Railgun (permission needed: #railgun:read)
69: * The zones that are currently using this Railgun
70: *
71: * @param string $identifier API item identifier tag
72: */
73: public function zones($identifier)
74: {
75: return $this->get('railguns/'.$identifier.'/zones');
76: }
77:
78: /**
79: * Enable or disable a Railgun (permission needed: #railgun:edit)
80: * Enable or disable a Railgun for all zones connected to it
81: *
82: * @param string $zone_identifier API item identifier tag
83: * @param bool|null $enabled Flag to determine if the Railgun is accepting connections
84: */
85: public function enabled($zone_identifier, $enabled = null)
86: {
87: $data = [
88: 'enabled' => $enabled,
89: ];
90:
91: return $this->patch('railguns/'.$identifier, $data);
92: }
93:
94: /**
95: * Delete Railgun (permission needed: #railgun:edit)
96: * Disable and delete a Railgun. This will immediately disable the Railgun for any connected zones
97: *
98: * @param string $identifier API item identifier tag
99: */
100: public function delete_railgun($identifier)
101: {
102: return $this->delete('railguns/'.$identifier);
103: }
104: }
105: