Delete.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace Elasticsearch\Endpoints;
  3. use Elasticsearch\Common\Exceptions;
  4. /**
  5. * Class Delete
  6. *
  7. * @category Elasticsearch
  8. * @package Elasticsearch\Endpoints
  9. * @author Zachary Tong <zach@elastic.co>
  10. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
  11. * @link http://elastic.co
  12. */
  13. class Delete extends AbstractEndpoint
  14. {
  15. /**
  16. * @throws \Elasticsearch\Common\Exceptions\RuntimeException
  17. * @return string
  18. */
  19. public function getURI()
  20. {
  21. if (isset($this->id) !== true) {
  22. throw new Exceptions\RuntimeException(
  23. 'id is required for Delete'
  24. );
  25. }
  26. if (isset($this->index) !== true) {
  27. throw new Exceptions\RuntimeException(
  28. 'index is required for Delete'
  29. );
  30. }
  31. if (isset($this->type) !== true) {
  32. throw new Exceptions\RuntimeException(
  33. 'type is required for Delete'
  34. );
  35. }
  36. $id = $this->id;
  37. $index = $this->index;
  38. $type = $this->type;
  39. $uri = "/$index/$type/$id";
  40. if (isset($index) === true && isset($type) === true && isset($id) === true) {
  41. $uri = "/$index/$type/$id";
  42. }
  43. return $uri;
  44. }
  45. /**
  46. * @return string[]
  47. */
  48. public function getParamWhitelist()
  49. {
  50. return array(
  51. 'consistency',
  52. 'parent',
  53. 'refresh',
  54. 'replication',
  55. 'routing',
  56. 'timeout',
  57. 'version',
  58. 'version_type',
  59. );
  60. }
  61. /**
  62. * @return string
  63. */
  64. public function getMethod()
  65. {
  66. return 'DELETE';
  67. }
  68. }