Info.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. namespace Elasticsearch\Endpoints\Cluster\Nodes;
  3. /**
  4. * Class Info
  5. *
  6. * @category Elasticsearch
  7. * @package Elasticsearch\Endpoints\Cluster\Nodes
  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 Info extends AbstractNodesEndpoint
  13. {
  14. // A comma-separated list of metrics you wish returned. Leave empty to return all.
  15. private $metric;
  16. /**
  17. * @param $metric
  18. *
  19. * @return $this
  20. */
  21. public function setMetric($metric)
  22. {
  23. if (isset($metric) !== true) {
  24. return $this;
  25. }
  26. if (is_array($metric) === true) {
  27. $metric = implode(",", $metric);
  28. }
  29. $this->metric = $metric;
  30. return $this;
  31. }
  32. /**
  33. * @return string
  34. */
  35. public function getURI()
  36. {
  37. $node_id = $this->nodeID;
  38. $metric = $this->metric;
  39. $uri = "/_nodes";
  40. if (isset($node_id) === true && isset($metric) === true) {
  41. $uri = "/_nodes/$node_id/$metric";
  42. } elseif (isset($metric) === true) {
  43. $uri = "/_nodes/$metric";
  44. } elseif (isset($node_id) === true) {
  45. $uri = "/_nodes/$node_id";
  46. }
  47. return $uri;
  48. }
  49. /**
  50. * @return string[]
  51. */
  52. public function getParamWhitelist()
  53. {
  54. return array(
  55. 'flat_settings',
  56. 'human',
  57. );
  58. }
  59. /**
  60. * @return string
  61. */
  62. public function getMethod()
  63. {
  64. return 'GET';
  65. }
  66. }