Put.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace Elasticsearch\Endpoints\Script;
  3. use Elasticsearch\Endpoints\AbstractEndpoint;
  4. use Elasticsearch\Common\Exceptions;
  5. /**
  6. * Class Put
  7. *
  8. * @category Elasticsearch
  9. * @package Elasticsearch\Endpoints\Script
  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. * @return $this
  20. */
  21. public function setBody($body)
  22. {
  23. if (isset($body) !== true) {
  24. return $this;
  25. }
  26. $this->body = $body;
  27. return $this;
  28. }
  29. /**
  30. * @throws \Elasticsearch\Common\Exceptions\RuntimeException
  31. * @return string
  32. */
  33. public function getURI()
  34. {
  35. if (isset($this->id) !== true) {
  36. throw new Exceptions\RuntimeException(
  37. 'id is required for put'
  38. );
  39. }
  40. $id = $this->id;
  41. $uri = "/_scripts/$id";
  42. return $uri;
  43. }
  44. /**
  45. * @return string[]
  46. */
  47. public function getParamWhitelist()
  48. {
  49. return array(
  50. 'version_type',
  51. 'version',
  52. 'op_type'
  53. );
  54. }
  55. /**
  56. * @return string
  57. */
  58. public function getMethod()
  59. {
  60. return 'PUT';
  61. }
  62. }