Exists.php 1.5 KB

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