Put.php 1.7 KB

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