diff --git a/src/Elasticsearch/Endpoints/Cluster/AllocationExplain.php b/src/Elasticsearch/Endpoints/Cluster/AllocationExplain.php new file mode 100644 index 000000000..007011bac --- /dev/null +++ b/src/Elasticsearch/Endpoints/Cluster/AllocationExplain.php @@ -0,0 +1,61 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 Apache2 + * @link http://elasticsearch.org + */ +class AllocationExplain extends AbstractEndpoint +{ + + /** + * @param array $body + * + * @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException + * @return $this + */ + public function setBody($body) + { + if (isset($body) !== true) { + return $this; + } + + $this->body = $body; + + return $this; + } + + /** + * @return string + */ + protected function getURI() + { + return "/_cluster/allocation/explain"; + } + + /** + * @return string[] + */ + protected function getParamWhitelist() + { + return array( + 'include_yes_decisions' + ); + } + + /** + * @return string + */ + protected function getMethod() + { + return 'GET'; + } +} diff --git a/src/Elasticsearch/Namespaces/ClusterNamespace.php b/src/Elasticsearch/Namespaces/ClusterNamespace.php index a035aade9..1ec6f8481 100644 --- a/src/Elasticsearch/Namespaces/ClusterNamespace.php +++ b/src/Elasticsearch/Namespaces/ClusterNamespace.php @@ -187,4 +187,27 @@ public function pendingTasks($params = array()) return $endpoint->resultOrFuture($response); } + + /** + * $params['include_yes_decisions'] = (bool) Return 'YES' decisions in explanation (default: false) + * + * @param $params array Associative array of parameters + * + * @return array + */ + public function allocationExplain($params = array()) + { + $body = $this->extractArgument($params, 'body'); + + /** @var callback $endpointBuilder */ + $endpointBuilder = $this->endpoints; + + /** @var \Elasticsearch\Endpoints\Cluster\AllocationExplain $endpoint */ + $endpoint = $endpointBuilder('Cluster\AllocationExplain'); + $endpoint->setBody($body) + ->setParams($params); + $response = $endpoint->performRequest(); + + return $endpoint->resultOrFuture($response); + } }