SnapshotNamespace.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <?php
  2. namespace Elasticsearch\Namespaces;
  3. /**
  4. * Class SnapshotNamespace
  5. *
  6. * @category Elasticsearch
  7. * @package Elasticsearch\Namespaces\SnapshotNamespace
  8. * @author Zachary Tong <zach@elastic.co>
  9. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
  10. * @link http://elastic.co
  11. */
  12. class SnapshotNamespace extends AbstractNamespace
  13. {
  14. /**
  15. * $params['master_timeout'] = (time) Explicit operation timeout for connection to master node
  16. * ['wait_for_completion'] = (bool) Should this request wait until the operation has completed before returning
  17. *
  18. * @param $params array Associative array of parameters
  19. *
  20. * @return array
  21. */
  22. public function create($params = array())
  23. {
  24. $repository = $this->extractArgument($params, 'repository');
  25. $snapshot = $this->extractArgument($params, 'snapshot');
  26. $body = $this->extractArgument($params, 'body');
  27. /** @var callback $endpointBuilder */
  28. $endpointBuilder = $this->endpoints;
  29. /** @var \Elasticsearch\Endpoints\Snapshot\Create $endpoint */
  30. $endpoint = $endpointBuilder('Snapshot\Create');
  31. $endpoint->setRepository($repository)
  32. ->setSnapshot($snapshot)
  33. ->setParams($params)
  34. ->setBody($body);
  35. return $this->performRequest($endpoint);
  36. }
  37. /**
  38. * $params['master_timeout'] = (time) Explicit operation timeout for connection to master node
  39. * ['timeout'] = (time) Explicit operation timeout
  40. *
  41. * @param $params array Associative array of parameters
  42. *
  43. * @return array
  44. */
  45. public function createRepository($params = array())
  46. {
  47. $repository = $this->extractArgument($params, 'repository');
  48. $body = $this->extractArgument($params, 'body');
  49. /** @var callback $endpointBuilder */
  50. $endpointBuilder = $this->endpoints;
  51. /** @var \Elasticsearch\Endpoints\Snapshot\Repository\Create $endpoint */
  52. $endpoint = $endpointBuilder('Snapshot\Repository\Create');
  53. $endpoint->setRepository($repository)
  54. ->setBody($body)
  55. ->setParams($params);
  56. return $this->performRequest($endpoint);
  57. }
  58. /**
  59. * $params['master_timeout'] = (time) Explicit operation timeout for connection to master node
  60. *
  61. * @param $params array Associative array of parameters
  62. *
  63. * @return array
  64. */
  65. public function delete($params = array())
  66. {
  67. $repository = $this->extractArgument($params, 'repository');
  68. $snapshot = $this->extractArgument($params, 'snapshot');
  69. /** @var callback $endpointBuilder */
  70. $endpointBuilder = $this->endpoints;
  71. /** @var \Elasticsearch\Endpoints\Snapshot\Delete $endpoint */
  72. $endpoint = $endpointBuilder('Snapshot\Delete');
  73. $endpoint->setRepository($repository)
  74. ->setSnapshot($snapshot)
  75. ->setParams($params);
  76. return $this->performRequest($endpoint);
  77. }
  78. /**
  79. * $params['master_timeout'] = (time) Explicit operation timeout for connection to master node
  80. * ['timeout'] = (time) Explicit operation timeout
  81. *
  82. * @param $params array Associative array of parameters
  83. *
  84. * @return array
  85. */
  86. public function deleteRepository($params = array())
  87. {
  88. $repository = $this->extractArgument($params, 'repository');
  89. /** @var callback $endpointBuilder */
  90. $endpointBuilder = $this->endpoints;
  91. /** @var \Elasticsearch\Endpoints\Snapshot\Repository\Delete $endpoint */
  92. $endpoint = $endpointBuilder('Snapshot\Repository\Delete');
  93. $endpoint->setRepository($repository)
  94. ->setParams($params);
  95. return $this->performRequest($endpoint);
  96. }
  97. /**
  98. * $params['master_timeout'] = (time) Explicit operation timeout for connection to master node
  99. *
  100. * @param $params array Associative array of parameters
  101. *
  102. * @return array
  103. */
  104. public function get($params = array())
  105. {
  106. $repository = $this->extractArgument($params, 'repository');
  107. $snapshot = $this->extractArgument($params, 'snapshot');
  108. /** @var callback $endpointBuilder */
  109. $endpointBuilder = $this->endpoints;
  110. /** @var \Elasticsearch\Endpoints\Snapshot\Get $endpoint */
  111. $endpoint = $endpointBuilder('Snapshot\Get');
  112. $endpoint->setRepository($repository)
  113. ->setSnapshot($snapshot)
  114. ->setParams($params);
  115. return $this->performRequest($endpoint);
  116. }
  117. /**
  118. * $params['master_timeout'] = (time) Explicit operation timeout for connection to master node
  119. * ['timeout'] = (time) Explicit operation timeout
  120. *
  121. * @param $params array Associative array of parameters
  122. *
  123. * @return array
  124. */
  125. public function getRepository($params = array())
  126. {
  127. $repository = $this->extractArgument($params, 'repository');
  128. /** @var callback $endpointBuilder */
  129. $endpointBuilder = $this->endpoints;
  130. /** @var \Elasticsearch\Endpoints\Snapshot\Repository\Get $endpoint */
  131. $endpoint = $endpointBuilder('Snapshot\Repository\Get');
  132. $endpoint->setRepository($repository)
  133. ->setParams($params);
  134. return $this->performRequest($endpoint);
  135. }
  136. /**
  137. * $params['master_timeout'] = (time) Explicit operation timeout for connection to master node
  138. * ['wait_for_completion'] = (bool) Should this request wait until the operation has completed before returning
  139. *
  140. * @param $params array Associative array of parameters
  141. *
  142. * @return array
  143. */
  144. public function restore($params = array())
  145. {
  146. $repository = $this->extractArgument($params, 'repository');
  147. $snapshot = $this->extractArgument($params, 'snapshot');
  148. $body = $this->extractArgument($params, 'body');
  149. /** @var callback $endpointBuilder */
  150. $endpointBuilder = $this->endpoints;
  151. /** @var \Elasticsearch\Endpoints\Snapshot\Restore $endpoint */
  152. $endpoint = $endpointBuilder('Snapshot\Restore');
  153. $endpoint->setRepository($repository)
  154. ->setSnapshot($snapshot)
  155. ->setParams($params)
  156. ->setBody($body);
  157. return $this->performRequest($endpoint);
  158. }
  159. /**
  160. * $params['master_timeout'] = (time) Explicit operation timeout for connection to master node
  161. *
  162. * @param $params array Associative array of parameters
  163. *
  164. * @return array
  165. */
  166. public function status($params = array())
  167. {
  168. $repository = $this->extractArgument($params, 'repository');
  169. $snapshot = $this->extractArgument($params, 'snapshot');
  170. /** @var callback $endpointBuilder */
  171. $endpointBuilder = $this->endpoints;
  172. /** @var \Elasticsearch\Endpoints\Snapshot\Status $endpoint */
  173. $endpoint = $endpointBuilder('Snapshot\Status');
  174. $endpoint->setRepository($repository)
  175. ->setSnapshot($snapshot)
  176. ->setParams($params);
  177. return $this->performRequest($endpoint);
  178. }
  179. /**
  180. * $params['master_timeout'] = (time) Explicit operation timeout for connection to master node
  181. * ['timeout'] = (time) Explicit operation timeout
  182. *
  183. * @param $params array Associative array of parameters
  184. *
  185. * @return array
  186. */
  187. public function verifyRepository($params = array())
  188. {
  189. $repository = $this->extractArgument($params, 'repository');
  190. /** @var callback $endpointBuilder */
  191. $endpointBuilder = $this->endpoints;
  192. /** @var \Elasticsearch\Endpoints\Snapshot\Repository\Verify $endpoint */
  193. $endpoint = $endpointBuilder('Snapshot\Repository\Verify');
  194. $endpoint->setRepository($repository)
  195. ->setParams($params);
  196. return $this->performRequest($endpoint);
  197. }
  198. }