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