Delete.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace Elasticsearch\Endpoints\Script;
  3. use Elasticsearch\Endpoints\AbstractEndpoint;
  4. use Elasticsearch\Common\Exceptions;
  5. /**
  6. * Class Delete
  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 Delete extends AbstractEndpoint
  15. {
  16. /** @var String */
  17. private $lang;
  18. /**
  19. * @param $lang
  20. *
  21. * @return $this
  22. */
  23. public function setLang($lang)
  24. {
  25. if (isset($lang) !== true) {
  26. return $this;
  27. }
  28. $this->lang = $lang;
  29. return $this;
  30. }
  31. /**
  32. * @throws \Elasticsearch\Common\Exceptions\RuntimeException
  33. * @return string
  34. */
  35. public function getURI()
  36. {
  37. if (isset($this->lang) !== true) {
  38. throw new Exceptions\RuntimeException(
  39. 'lang is required for Put'
  40. );
  41. }
  42. if (isset($this->id) !== true) {
  43. throw new Exceptions\RuntimeException(
  44. 'id is required for put'
  45. );
  46. }
  47. $id = $this->id;
  48. $lang = $this->lang;
  49. $uri = "/_scripts/$lang/$id";
  50. return $uri;
  51. }
  52. /**
  53. * @return string[]
  54. */
  55. public function getParamWhitelist()
  56. {
  57. return array(
  58. 'version',
  59. 'version_type'
  60. );
  61. }
  62. /**
  63. * @return string
  64. */
  65. public function getMethod()
  66. {
  67. return 'DELETE';
  68. }
  69. }