Get.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace Elasticsearch\Endpoints\Source;
  3. use Elasticsearch\Endpoints\AbstractEndpoint;
  4. use Elasticsearch\Common\Exceptions;
  5. /**
  6. * Class Get
  7. *
  8. * @category Elasticsearch
  9. * @package Elasticsearch\Endpoints\Source
  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 Get extends AbstractEndpoint
  15. {
  16. /**
  17. * @throws \Elasticsearch\Common\Exceptions\RuntimeException
  18. * @return string
  19. */
  20. public function getURI()
  21. {
  22. if (isset($this->id) !== true) {
  23. throw new Exceptions\RuntimeException(
  24. 'id is required for Get'
  25. );
  26. }
  27. if (isset($this->index) !== true) {
  28. throw new Exceptions\RuntimeException(
  29. 'index is required for Get'
  30. );
  31. }
  32. if (isset($this->type) !== true) {
  33. throw new Exceptions\RuntimeException(
  34. 'type is required for Get'
  35. );
  36. }
  37. $id = $this->id;
  38. $index = $this->index;
  39. $type = $this->type;
  40. $uri = "/$index/$type/$id/_source";
  41. if (isset($index) === true && isset($type) === true && isset($id) === true) {
  42. $uri = "/$index/$type/$id/_source";
  43. }
  44. return $uri;
  45. }
  46. /**
  47. * @return string[]
  48. */
  49. public function getParamWhitelist()
  50. {
  51. return array(
  52. 'parent',
  53. 'preference',
  54. 'realtime',
  55. 'refresh',
  56. 'routing',
  57. '_source',
  58. '_source_exclude',
  59. '_source_include',
  60. 'version',
  61. 'version_type',
  62. );
  63. }
  64. /**
  65. * @return string
  66. */
  67. public function getMethod()
  68. {
  69. return 'GET';
  70. }
  71. }