Delete.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace Elasticsearch\Endpoints\Indices\Template;
  3. use Elasticsearch\Endpoints\AbstractEndpoint;
  4. use Elasticsearch\Common\Exceptions;
  5. /**
  6. * Class Delete
  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 Delete 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 Delete'
  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. 'timeout',
  56. 'master_timeout',
  57. );
  58. }
  59. /**
  60. * @return string
  61. */
  62. public function getMethod()
  63. {
  64. return 'DELETE';
  65. }
  66. }