Delete.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. namespace Elasticsearch\Endpoints\Indices\Alias;
  3. use Elasticsearch\Endpoints\AbstractEndpoint;
  4. use Elasticsearch\Common\Exceptions;
  5. /**
  6. * Class Delete
  7. *
  8. * @category Elasticsearch
  9. * @package Elasticsearch\Endpoints\Indices\Alias
  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. // A comma-separated list of aliases to delete (supports wildcards); use `_all` to delete all aliases for the specified indices.
  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->index) !== true) {
  38. throw new Exceptions\RuntimeException(
  39. 'index is required for Delete'
  40. );
  41. }
  42. if (isset($this->name) !== true) {
  43. throw new Exceptions\RuntimeException(
  44. 'name is required for Delete'
  45. );
  46. }
  47. $index = $this->index;
  48. $name = $this->name;
  49. $uri = "/$index/_alias/$name";
  50. if (isset($index) === true && isset($name) === true) {
  51. $uri = "/$index/_alias/$name";
  52. }
  53. return $uri;
  54. }
  55. /**
  56. * @return string[]
  57. */
  58. public function getParamWhitelist()
  59. {
  60. return array(
  61. 'timeout',
  62. 'master_timeout',
  63. );
  64. }
  65. /**
  66. * @return string
  67. */
  68. public function getMethod()
  69. {
  70. return 'DELETE';
  71. }
  72. }