Railguns.php 2.5 KB

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