Skip to content

Commit

Permalink
Add Cat/Tasks endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
polyfractal committed May 9, 2016
1 parent d2484c7 commit 42856dc
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/Elasticsearch/Endpoints/Cat/Tasks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace Elasticsearch\Endpoints\Cat;

use Elasticsearch\Endpoints\AbstractEndpoint;

/**
* Class Tasks
*
* @category Elasticsearch
* @package Elasticsearch\Endpoints\Cat
* @author Zachary Tong <zachary.tong@elasticsearch.com>
* @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';
}
}
29 changes: 29 additions & 0 deletions src/Elasticsearch/Namespaces/CatNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 42856dc

Please sign in to comment.