Get.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. namespace Elasticsearch\Endpoints\Indices;
  3. use Elasticsearch\Endpoints\AbstractEndpoint;
  4. use Elasticsearch\Common\Exceptions;
  5. /**
  6. * Class Get
  7. *
  8. * @category Elasticsearch
  9. * @package Elasticsearch\Endpoints\Get
  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. private $feature;
  17. /**
  18. * @throws \Elasticsearch\Common\Exceptions\RuntimeException
  19. * @return string
  20. */
  21. public function getURI()
  22. {
  23. if (isset($this->index) !== true) {
  24. throw new Exceptions\RuntimeException(
  25. 'index is required for Get'
  26. );
  27. }
  28. $index = $this->index;
  29. $feature = $this->feature;
  30. $uri = "/$index";
  31. if (isset($feature) === true) {
  32. $uri = "/$index/$feature";
  33. }
  34. return $uri;
  35. }
  36. public function setFeature($feature)
  37. {
  38. if (isset($feature) !== true) {
  39. return $this;
  40. }
  41. if (is_array($feature) === true) {
  42. $feature = implode(",", $feature);
  43. }
  44. $this->feature = $feature;
  45. return $this;
  46. }
  47. /**
  48. * @return string[]
  49. */
  50. public function getParamWhitelist()
  51. {
  52. return array(
  53. 'local',
  54. 'ignore_unavailable',
  55. 'allow_no_indices',
  56. 'expand_wildcards',
  57. 'human'
  58. );
  59. }
  60. /**
  61. * @return string
  62. */
  63. public function getMethod()
  64. {
  65. return 'GET';
  66. }
  67. }