Exists.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. namespace Elasticsearch\Endpoints;
  3. use Elasticsearch\Common\Exceptions;
  4. /**
  5. * Class Exists
  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 Exists 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 Exists'
  24. );
  25. }
  26. if (isset($this->index) !== true) {
  27. throw new Exceptions\RuntimeException(
  28. 'index is required for Exists'
  29. );
  30. }
  31. if (isset($this->type) !== true) {
  32. throw new Exceptions\RuntimeException(
  33. 'type is required for Exists'
  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. 'parent',
  52. 'preference',
  53. 'realtime',
  54. 'refresh',
  55. 'routing',
  56. 'version',
  57. 'stored_fields'
  58. );
  59. }
  60. /**
  61. * @return string
  62. */
  63. public function getMethod()
  64. {
  65. return 'HEAD';
  66. }
  67. }