CatNamespace.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. <?php
  2. namespace Elasticsearch\Namespaces;
  3. /**
  4. * Class CatNamespace
  5. *
  6. * @category Elasticsearch
  7. * @package Elasticsearch\Namespaces\CatNamespace
  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 CatNamespace extends AbstractNamespace
  13. {
  14. /**
  15. * $params['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
  16. * ['master_timeout'] = (time) Explicit operation timeout for connection to master node
  17. * ['h'] = (list) Comma-separated list of column names to display
  18. * ['help'] = (bool) Return help information
  19. * ['v'] = (bool) Verbose mode. Display column headers
  20. *
  21. * @param $params array Associative array of parameters
  22. *
  23. * @return array
  24. */
  25. public function aliases($params = array())
  26. {
  27. $name = $this->extractArgument($params, 'name');
  28. /** @var callback $endpointBuilder */
  29. $endpointBuilder = $this->endpoints;
  30. /** @var \Elasticsearch\Endpoints\Cat\Aliases $endpoint */
  31. $endpoint = $endpointBuilder('Cat\Aliases');
  32. $endpoint->setName($name);
  33. $endpoint->setParams($params);
  34. return $this->performRequest($endpoint);
  35. }
  36. /**
  37. * $params['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
  38. * ['master_timeout'] = (time) Explicit operation timeout for connection to master node
  39. * ['h'] = (list) Comma-separated list of column names to display
  40. * ['help'] = (bool) Return help information
  41. * ['v'] = (bool) Verbose mode. Display column headers
  42. * ['bytes'] = (enum) The unit in which to display byte values
  43. *
  44. * @param $params array Associative array of parameters
  45. *
  46. * @return array
  47. */
  48. public function allocation($params = array())
  49. {
  50. $nodeID = $this->extractArgument($params, 'node_id');
  51. /** @var callback $endpointBuilder */
  52. $endpointBuilder = $this->endpoints;
  53. /** @var \Elasticsearch\Endpoints\Cat\Allocation $endpoint */
  54. $endpoint = $endpointBuilder('Cat\Allocation');
  55. $endpoint->setNodeID($nodeID);
  56. $endpoint->setParams($params);
  57. return $this->performRequest($endpoint);
  58. }
  59. /**
  60. * $params['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
  61. * ['master_timeout'] = (time) Explicit operation timeout for connection to master node
  62. * ['h'] = (list) Comma-separated list of column names to display
  63. * ['help'] = (bool) Return help information
  64. * ['v'] = (bool) Verbose mode. Display column headers
  65. *
  66. * @param $params array Associative array of parameters
  67. *
  68. * @return array
  69. */
  70. public function count($params = array())
  71. {
  72. $index = $this->extractArgument($params, 'index');
  73. /** @var callback $endpointBuilder */
  74. $endpointBuilder = $this->endpoints;
  75. /** @var \Elasticsearch\Endpoints\Cat\Count $endpoint */
  76. $endpoint = $endpointBuilder('Cat\Count');
  77. $endpoint->setIndex($index);
  78. $endpoint->setParams($params);
  79. return $this->performRequest($endpoint);
  80. }
  81. /**
  82. * $params['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
  83. * ['master_timeout'] = (time) Explicit operation timeout for connection to master node
  84. * ['h'] = (list) Comma-separated list of column names to display
  85. * ['help'] = (bool) Return help information
  86. * ['v'] = (bool) Verbose mode. Display column headers
  87. * ['ts'] = (bool) Set to false to disable timestamping
  88. *
  89. * @param $params array Associative array of parameters
  90. *
  91. * @return array
  92. */
  93. public function health($params = array())
  94. {
  95. /** @var callback $endpointBuilder */
  96. $endpointBuilder = $this->endpoints;
  97. /** @var \Elasticsearch\Endpoints\Cat\Health $endpoint */
  98. $endpoint = $endpointBuilder('Cat\Health');
  99. $endpoint->setParams($params);
  100. return $this->performRequest($endpoint);
  101. }
  102. /**
  103. * $params['help'] = (bool) Return help information
  104. *
  105. * @param $params array Associative array of parameters
  106. *
  107. * @return array
  108. */
  109. public function help($params = array())
  110. {
  111. /** @var callback $endpointBuilder */
  112. $endpointBuilder = $this->endpoints;
  113. /** @var \Elasticsearch\Endpoints\Cat\Help $endpoint */
  114. $endpoint = $endpointBuilder('Cat\Help');
  115. $endpoint->setParams($params);
  116. return $this->performRequest($endpoint);
  117. }
  118. /**
  119. * $params['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
  120. * ['master_timeout'] = (time) Explicit operation timeout for connection to master node
  121. * ['h'] = (list) Comma-separated list of column names to display
  122. * ['help'] = (bool) Return help information
  123. * ['v'] = (bool) Verbose mode. Display column headers
  124. * ['bytes'] = (enum) The unit in which to display byte values
  125. * ['pri'] = (bool) Set to true to return stats only for primary shards
  126. *
  127. * @param $params array Associative array of parameters
  128. *
  129. * @return array
  130. */
  131. public function indices($params = array())
  132. {
  133. $index = $this->extractArgument($params, 'index');
  134. /** @var callback $endpointBuilder */
  135. $endpointBuilder = $this->endpoints;
  136. /** @var \Elasticsearch\Endpoints\Cat\Indices $endpoint */
  137. $endpoint = $endpointBuilder('Cat\Indices');
  138. $endpoint->setIndex($index);
  139. $endpoint->setParams($params);
  140. return $this->performRequest($endpoint);
  141. }
  142. /**
  143. * $params['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
  144. * ['master_timeout'] = (time) Explicit operation timeout for connection to master node
  145. * ['h'] = (list) Comma-separated list of column names to display
  146. * ['help'] = (bool) Return help information
  147. * ['v'] = (bool) Verbose mode. Display column headers
  148. *
  149. * @param $params array Associative array of parameters
  150. *
  151. * @return array
  152. */
  153. public function master($params = array())
  154. {
  155. /** @var callback $endpointBuilder */
  156. $endpointBuilder = $this->endpoints;
  157. /** @var \Elasticsearch\Endpoints\Cat\Master $endpoint */
  158. $endpoint = $endpointBuilder('Cat\Master');
  159. $endpoint->setParams($params);
  160. return $this->performRequest($endpoint);
  161. }
  162. /**
  163. * $params['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
  164. * ['master_timeout'] = (time) Explicit operation timeout for connection to master node
  165. * ['h'] = (list) Comma-separated list of column names to display
  166. * ['help'] = (bool) Return help information
  167. * ['v'] = (bool) Verbose mode. Display column headers
  168. *
  169. * @param $params array Associative array of parameters
  170. *
  171. * @return array
  172. */
  173. public function nodes($params = array())
  174. {
  175. /** @var callback $endpointBuilder */
  176. $endpointBuilder = $this->endpoints;
  177. /** @var \Elasticsearch\Endpoints\Cat\Nodes $endpoint */
  178. $endpoint = $endpointBuilder('Cat\Nodes');
  179. $endpoint->setParams($params);
  180. return $this->performRequest($endpoint);
  181. }
  182. /**
  183. * $params['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
  184. * ['master_timeout'] = (time) Explicit operation timeout for connection to master node
  185. * ['h'] = (list) Comma-separated list of column names to display
  186. * ['help'] = (bool) Return help information
  187. * ['v'] = (bool) Verbose mode. Display column headers
  188. *
  189. * @param $params array Associative array of parameters
  190. *
  191. * @return array
  192. */
  193. public function nodeAttrs($params = array())
  194. {
  195. /** @var callback $endpointBuilder */
  196. $endpointBuilder = $this->endpoints;
  197. /** @var \Elasticsearch\Endpoints\Cat\NodeAttrs $endpoint */
  198. $endpoint = $endpointBuilder('Cat\NodeAttrs');
  199. $endpoint->setParams($params);
  200. return $this->performRequest($endpoint);
  201. }
  202. /**
  203. * $params['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
  204. * ['master_timeout'] = (time) Explicit operation timeout for connection to master node
  205. * ['h'] = (list) Comma-separated list of column names to display
  206. * ['help'] = (bool) Return help information
  207. * ['v'] = (bool) Verbose mode. Display column headers
  208. *
  209. * @param $params array Associative array of parameters
  210. *
  211. * @return array
  212. */
  213. public function pendingTasks($params = array())
  214. {
  215. /** @var callback $endpointBuilder */
  216. $endpointBuilder = $this->endpoints;
  217. /** @var \Elasticsearch\Endpoints\Cat\PendingTasks $endpoint */
  218. $endpoint = $endpointBuilder('Cat\PendingTasks');
  219. $endpoint->setParams($params);
  220. return $this->performRequest($endpoint);
  221. }
  222. /**
  223. * $params['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
  224. * ['master_timeout'] = (time) Explicit operation timeout for connection to master node
  225. * ['h'] = (list) Comma-separated list of column names to display
  226. * ['help'] = (bool) Return help information
  227. * ['v'] = (bool) Verbose mode. Display column headers
  228. * ['bytes'] = (enum) The unit in which to display byte values
  229. *
  230. * @param $params array Associative array of parameters
  231. *
  232. * @return array
  233. */
  234. public function recovery($params = array())
  235. {
  236. $index = $this->extractArgument($params, 'index');
  237. /** @var callback $endpointBuilder */
  238. $endpointBuilder = $this->endpoints;
  239. /** @var \Elasticsearch\Endpoints\Cat\Recovery $endpoint */
  240. $endpoint = $endpointBuilder('Cat\Recovery');
  241. $endpoint->setIndex($index);
  242. $endpoint->setParams($params);
  243. return $this->performRequest($endpoint);
  244. }
  245. /**
  246. * $params['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
  247. * ['master_timeout'] = (time) Explicit operation timeout for connection to master node
  248. * ['h'] = (list) Comma-separated list of column names to display
  249. * ['help'] = (bool) Return help information
  250. * ['v'] = (bool) Verbose mode. Display column headers
  251. *
  252. * @param $params array Associative array of parameters
  253. *
  254. * @return array
  255. */
  256. public function repositories($params = array())
  257. {
  258. /** @var callback $endpointBuilder */
  259. $endpointBuilder = $this->endpoints;
  260. /** @var \Elasticsearch\Endpoints\Cat\Repositories $endpoint */
  261. $endpoint = $endpointBuilder('Cat\Repositories');
  262. $endpoint->setParams($params);
  263. return $this->performRequest($endpoint);
  264. }
  265. /**
  266. * $params['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
  267. * ['master_timeout'] = (time) Explicit operation timeout for connection to master node
  268. * ['h'] = (list) Comma-separated list of column names to display
  269. * ['help'] = (bool) Return help information
  270. * ['v'] = (bool) Verbose mode. Display column headers
  271. * ['bytes'] = (enum) The unit in which to display byte values
  272. *
  273. * @param $params array Associative array of parameters
  274. *
  275. * @return array
  276. */
  277. public function shards($params = array())
  278. {
  279. $index = $this->extractArgument($params, 'index');
  280. /** @var callback $endpointBuilder */
  281. $endpointBuilder = $this->endpoints;
  282. /** @var \Elasticsearch\Endpoints\Cat\Shards $endpoint */
  283. $endpoint = $endpointBuilder('Cat\Shards');
  284. $endpoint->setIndex($index);
  285. $endpoint->setParams($params);
  286. return $this->performRequest($endpoint);
  287. }
  288. /**
  289. * $params['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
  290. * ['master_timeout'] = (time) Explicit operation timeout for connection to master node
  291. * ['h'] = (list) Comma-separated list of column names to display
  292. * ['help'] = (bool) Return help information
  293. * ['v'] = (bool) Verbose mode. Display column headers
  294. * ['bytes'] = (enum) The unit in which to display byte values
  295. * ['repository'] = (string) Name of repository from which to fetch the snapshot information
  296. *
  297. * @param $params array Associative array of parameters
  298. *
  299. * @return array
  300. */
  301. public function snapshots($params = array())
  302. {
  303. $repository = $this->extractArgument($params, 'repository');
  304. /** @var callback $endpointBuilder */
  305. $endpointBuilder = $this->endpoints;
  306. /** @var \Elasticsearch\Endpoints\Cat\Snapshots $endpoint */
  307. $endpoint = $endpointBuilder('Cat\Snapshots');
  308. $endpoint->setRepository($repository);
  309. $endpoint->setParams($params);
  310. return $this->performRequest($endpoint);
  311. }
  312. /**
  313. * $params['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
  314. * ['master_timeout'] = (time) Explicit operation timeout for connection to master node
  315. * ['h'] = (list) Comma-separated list of column names to display
  316. * ['help'] = (bool) Return help information
  317. * ['v'] = (bool) Verbose mode. Display column headers
  318. * ['full_id'] = (bool) Enables displaying the complete node ids
  319. * ['size'] = (enum) The multiplier in which to display values ([ "", "k", "m", "g", "t", "p" ])
  320. *
  321. * @param $params array Associative array of parameters
  322. *
  323. * @return array
  324. */
  325. public function threadPool($params = array())
  326. {
  327. $index = $this->extractArgument($params, 'index');
  328. /** @var callback $endpointBuilder */
  329. $endpointBuilder = $this->endpoints;
  330. /** @var \Elasticsearch\Endpoints\Cat\ThreadPool $endpoint */
  331. $endpoint = $endpointBuilder('Cat\ThreadPool');
  332. $endpoint->setIndex($index);
  333. $endpoint->setParams($params);
  334. return $this->performRequest($endpoint);
  335. }
  336. /**
  337. * $params['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
  338. * ['master_timeout'] = (time) Explicit operation timeout for connection to master node
  339. * ['h'] = (list) Comma-separated list of column names to display
  340. * ['help'] = (bool) Return help information
  341. * ['v'] = (bool) Verbose mode. Display column headers
  342. * ['bytes'] = (enum) The unit in which to display byte values
  343. * ['fields'] = (list) A comma-separated list of fields to return the fielddata size
  344. *
  345. * @param $params array Associative array of parameters
  346. *
  347. * @return array
  348. */
  349. public function fielddata($params = array())
  350. {
  351. $fields = $this->extractArgument($params, 'fields');
  352. /** @var callback $endpointBuilder */
  353. $endpointBuilder = $this->endpoints;
  354. /** @var \Elasticsearch\Endpoints\Cat\Fielddata $endpoint */
  355. $endpoint = $endpointBuilder('Cat\Fielddata');
  356. $endpoint->setFields($fields);
  357. $endpoint->setParams($params);
  358. return $this->performRequest($endpoint);
  359. }
  360. /**
  361. * $params['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
  362. * ['master_timeout'] = (time) Explicit operation timeout for connection to master node
  363. * ['h'] = (list) Comma-separated list of column names to display
  364. * ['help'] = (bool) Return help information
  365. * ['v'] = (bool) Verbose mode. Display column headers
  366. *
  367. * @param $params array Associative array of parameters
  368. *
  369. * @return array
  370. */
  371. public function plugins($params = array())
  372. {
  373. /** @var callback $endpointBuilder */
  374. $endpointBuilder = $this->endpoints;
  375. /** @var \Elasticsearch\Endpoints\Cat\Plugins $endpoint */
  376. $endpoint = $endpointBuilder('Cat\Plugins');
  377. $endpoint->setParams($params);
  378. return $this->performRequest($endpoint);
  379. }
  380. /**
  381. * $params['h'] = (list) Comma-separated list of column names to display
  382. * ['help'] = (bool) Return help information
  383. * ['v'] = (bool) Verbose mode. Display column headers
  384. *
  385. * @param $params array Associative array of parameters
  386. *
  387. * @return array
  388. */
  389. public function segments($params = array())
  390. {
  391. $index = $this->extractArgument($params, 'index');
  392. /** @var callback $endpointBuilder */
  393. $endpointBuilder = $this->endpoints;
  394. /** @var \Elasticsearch\Endpoints\Cat\Segments $endpoint */
  395. $endpoint = $endpointBuilder('Cat\Segments');
  396. $endpoint->setIndex($index);
  397. $endpoint->setParams($params);
  398. return $this->performRequest($endpoint);
  399. }
  400. /**
  401. * $params['format'] = (string) a short version of the Accept header, e.g. json, yaml
  402. * ['node_id'] = (list) A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
  403. * ['format'] = (string) a short version of the Accept header, e.g. json, yaml
  404. * ['actions'] = (list) A comma-separated list of actions that should be returned. Leave empty to return all.
  405. * ['detailed'] = (boolean) Return detailed task information (default: false)
  406. * ['parent_node'] = (string) Return tasks with specified parent node.
  407. * ['parent_task'] = (number) Return tasks with specified parent task id. Set to -1 to return all.
  408. * ['h'] = (list) Comma-separated list of column names to display
  409. * ['help'] = (bool) Return help information
  410. * ['v'] = (bool) Verbose mode. Display column headers
  411. *
  412. * @param $params array Associative array of parameters
  413. *
  414. * @return array
  415. */
  416. public function tasks($params = array())
  417. {
  418. /** @var callback $endpointBuilder */
  419. $endpointBuilder = $this->endpoints;
  420. /** @var \Elasticsearch\Endpoints\Cat\Tasks $endpoint */
  421. $endpoint = $endpointBuilder('Cat\Tasks');
  422. $endpoint->setParams($params);
  423. return $this->performRequest($endpoint);
  424. }
  425. /**
  426. * $params['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
  427. * ['master_timeout'] = (time) Explicit operation timeout for connection to master node
  428. * ['h'] = (list) Comma-separated list of column names to display
  429. * ['help'] = (bool) Return help information
  430. * ['v'] = (bool) Verbose mode. Display column headers
  431. * ['bytes'] = (enum) The unit in which to display byte values
  432. *
  433. * @param $params array Associative array of parameters
  434. *
  435. * @return array
  436. */
  437. public function templates($params = array())
  438. {
  439. $name = $this->extractArgument($params, 'name');
  440. /** @var callback $endpointBuilder */
  441. $endpointBuilder = $this->endpoints;
  442. /** @var \Elasticsearch\Endpoints\Cat\Templates $endpoint */
  443. $endpoint = $endpointBuilder('Cat\Templates');
  444. $endpoint->setName($name)
  445. ->setParams($params);
  446. return $this->performRequest($endpoint);
  447. }
  448. }