Split.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <?php
  2. declare(strict_types = 1);
  3. namespace Elasticsearch\Endpoints\Indices;
  4. use Elasticsearch\Endpoints\AbstractEndpoint;
  5. use Elasticsearch\Common\Exceptions;
  6. /**
  7. * Class Split
  8. *
  9. * @category Elasticsearch
  10. * @package Elasticsearch\Endpoints\Indices
  11. * @author Zachary Tong <zach@elastic.co>
  12. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
  13. * @link http://elastic.co
  14. */
  15. class Split extends AbstractEndpoint
  16. {
  17. private $target;
  18. /**
  19. * @param array|object $body
  20. *
  21. * @return $this
  22. */
  23. public function setBody($body)
  24. {
  25. if (isset($body) !== true) {
  26. return $this;
  27. }
  28. $this->body = $body;
  29. return $this;
  30. }
  31. /**
  32. * @param string $target
  33. *
  34. * @return $this
  35. */
  36. public function setTarget($target)
  37. {
  38. if ($target === null) {
  39. return $this;
  40. }
  41. $this->target = $target;
  42. return $this;
  43. }
  44. /**
  45. * @throws \Elasticsearch\Common\Exceptions\RuntimeException
  46. * @return string
  47. */
  48. public function getURI()
  49. {
  50. if (isset($this->index) !== true) {
  51. throw new Exceptions\RuntimeException(
  52. 'index is required for Split'
  53. );
  54. }
  55. if (isset($this->target) !== true) {
  56. throw new Exceptions\RuntimeException(
  57. 'target is required for Split'
  58. );
  59. }
  60. $uri = "/{$this->index}/_split/{$this->target}";
  61. return $uri;
  62. }
  63. /**
  64. * @return string[]
  65. */
  66. public function getParamWhitelist()
  67. {
  68. return array(
  69. 'copy_settings',
  70. 'timeout',
  71. 'master_timeout',
  72. 'wait_for_active_shards'
  73. );
  74. }
  75. /**
  76. * @return string
  77. */
  78. public function getMethod()
  79. {
  80. return 'PUT';
  81. }
  82. }