Exists.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace Elasticsearch\Endpoints\Indices\Alias;
  3. use Elasticsearch\Endpoints\AbstractEndpoint;
  4. /**
  5. * Class Exists
  6. *
  7. * @category Elasticsearch
  8. * @package Elasticsearch\Endpoints\Indices\Alias
  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. // A comma-separated list of alias names to return
  16. private $name;
  17. /**
  18. * @param $name
  19. *
  20. * @return $this
  21. */
  22. public function setName($name)
  23. {
  24. if (isset($name) !== true) {
  25. return $this;
  26. }
  27. $this->name = $name;
  28. return $this;
  29. }
  30. /**
  31. * @return string
  32. */
  33. public function getURI()
  34. {
  35. $index = $this->index;
  36. $name = $this->name;
  37. $uri = "/_alias/$name";
  38. if (isset($index) === true && isset($name) === true) {
  39. $uri = "/$index/_alias/$name";
  40. } elseif (isset($index) === true) {
  41. $uri = "/$index/_alias";
  42. } elseif (isset($name) === true) {
  43. $uri = "/_alias/$name";
  44. }
  45. return $uri;
  46. }
  47. /**
  48. * @return string[]
  49. */
  50. public function getParamWhitelist()
  51. {
  52. return array(
  53. 'ignore_unavailable',
  54. 'allow_no_indices',
  55. 'expand_wildcards',
  56. 'local',
  57. );
  58. }
  59. /**
  60. * @return string
  61. */
  62. public function getMethod()
  63. {
  64. return 'HEAD';
  65. }
  66. }