State.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace Elasticsearch\Endpoints\Cluster;
  3. use Elasticsearch\Endpoints\AbstractEndpoint;
  4. /**
  5. * Class State
  6. *
  7. * @category Elasticsearch
  8. * @package Elasticsearch\Endpoints\Cluster
  9. * @author Zachary Tong <zach@elastic.co>
  10. * @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
  11. * @link http://elastic.co
  12. */
  13. class State extends AbstractEndpoint
  14. {
  15. // Limit the information returned to the specified metrics
  16. private $metric;
  17. /**
  18. * @param $metric
  19. *
  20. * @return $this
  21. */
  22. public function setMetric($metric)
  23. {
  24. if (isset($metric) !== true) {
  25. return $this;
  26. }
  27. if (is_array($metric) === true) {
  28. $metric = implode(",", $metric);
  29. }
  30. $this->metric = $metric;
  31. return $this;
  32. }
  33. /**
  34. * @return string
  35. */
  36. public function getURI()
  37. {
  38. $index = $this->index;
  39. $metric = $this->metric;
  40. $uri = "/_cluster/state";
  41. if (isset($metric) === true && isset($index) === true) {
  42. $uri = "/_cluster/state/$metric/$index";
  43. } elseif (isset($metric) === true) {
  44. $uri = "/_cluster/state/$metric";
  45. }
  46. return $uri;
  47. }
  48. /**
  49. * @return string[]
  50. */
  51. public function getParamWhitelist()
  52. {
  53. return array(
  54. 'local',
  55. 'master_timeout',
  56. 'flat_settings',
  57. 'index_templates',
  58. 'expand_wildcards',
  59. 'ignore_unavailable',
  60. 'allow_no_indices'
  61. );
  62. }
  63. /**
  64. * @return string
  65. */
  66. public function getMethod()
  67. {
  68. return 'GET';
  69. }
  70. }