diff --git a/src/Elasticsearch/Endpoints/Cat/Tasks.php b/src/Elasticsearch/Endpoints/Cat/Tasks.php new file mode 100644 index 000000000..bb4290346 --- /dev/null +++ b/src/Elasticsearch/Endpoints/Cat/Tasks.php @@ -0,0 +1,51 @@ + + * @license http://www.apache.org/licenses/LICENSE-2.0 Apache2 + * @link http://elasticsearch.org + */ +class Tasks extends AbstractEndpoint +{ + /** + * @return string + */ + protected function getURI() + { + return "/_cat/tasks"; + } + + /** + * @return string[] + */ + protected function getParamWhitelist() + { + return array( + 'format', + 'node_id', + 'actions', + 'detailed', + 'parent_node', + 'parent_task', + 'h', + 'help', + 'v' + ); + } + + /** + * @return string + */ + protected function getMethod() + { + return 'GET'; + } +} diff --git a/src/Elasticsearch/Namespaces/CatNamespace.php b/src/Elasticsearch/Namespaces/CatNamespace.php index aed5ad04f..2a0732727 100644 --- a/src/Elasticsearch/Namespaces/CatNamespace.php +++ b/src/Elasticsearch/Namespaces/CatNamespace.php @@ -479,4 +479,33 @@ public function segments($params = array()) return $endpoint->resultOrFuture($response); } + + /** + * $params['format'] = (string) a short version of the Accept header, e.g. json, yaml + * ['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 + * ['format'] = (string) a short version of the Accept header, e.g. json, yaml + * ['actions'] = (list) A comma-separated list of actions that should be returned. Leave empty to return all. + * ['detailed'] = (boolean) Return detailed task information (default: false) + * ['parent_node'] = (string) Return tasks with specified parent node. + * ['parent_task'] = (number) Return tasks with specified parent task id. Set to -1 to return all. + * ['h'] = (list) Comma-separated list of column names to display + * ['help'] = (bool) Return help information + * ['v'] = (bool) Verbose mode. Display column headers + * + * @param $params array Associative array of parameters + * + * @return array + */ + public function tasks($params = array()) + { + /** @var callback $endpointBuilder */ + $endpointBuilder = $this->endpoints; + + /** @var \Elasticsearch\Endpoints\Cat\Tasks $endpoint */ + $endpoint = $endpointBuilder('Cat\Tasks'); + $endpoint->setParams($params); + $response = $endpoint->performRequest(); + + return $endpoint->resultOrFuture($response); + } }