Delete.php 2.1 KB

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