Put.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. namespace Elasticsearch\Endpoints\Template;
  3. use Elasticsearch\Endpoints\AbstractEndpoint;
  4. use Elasticsearch\Common\Exceptions;
  5. /**
  6. * Class Put
  7. *
  8. * @category Elasticsearch
  9. * @package Elasticsearch\Endpoints\Template
  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. $templateId = $this->id;
  41. $uri = "/_search/template/$templateId";
  42. return $uri;
  43. }
  44. /**
  45. * @return string[]
  46. */
  47. public function getParamWhitelist()
  48. {
  49. return array();
  50. }
  51. /**
  52. * @return string
  53. */
  54. public function getMethod()
  55. {
  56. return 'PUT';
  57. }
  58. }