Delete.php 1.6 KB

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