Skip to content

Commit 42856dc

Browse files
committed
Add Cat/Tasks endpoint
1 parent d2484c7 commit 42856dc

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
3+
namespace Elasticsearch\Endpoints\Cat;
4+
5+
use Elasticsearch\Endpoints\AbstractEndpoint;
6+
7+
/**
8+
* Class Tasks
9+
*
10+
* @category Elasticsearch
11+
* @package Elasticsearch\Endpoints\Cat
12+
* @author Zachary Tong <zachary.tong@elasticsearch.com>
13+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
14+
* @link http://elasticsearch.org
15+
*/
16+
class Tasks extends AbstractEndpoint
17+
{
18+
/**
19+
* @return string
20+
*/
21+
protected function getURI()
22+
{
23+
return "/_cat/tasks";
24+
}
25+
26+
/**
27+
* @return string[]
28+
*/
29+
protected function getParamWhitelist()
30+
{
31+
return array(
32+
'format',
33+
'node_id',
34+
'actions',
35+
'detailed',
36+
'parent_node',
37+
'parent_task',
38+
'h',
39+
'help',
40+
'v'
41+
);
42+
}
43+
44+
/**
45+
* @return string
46+
*/
47+
protected function getMethod()
48+
{
49+
return 'GET';
50+
}
51+
}

src/Elasticsearch/Namespaces/CatNamespace.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,4 +479,33 @@ public function segments($params = array())
479479

480480
return $endpoint->resultOrFuture($response);
481481
}
482+
483+
/**
484+
* $params['format'] = (string) a short version of the Accept header, e.g. json, yaml
485+
* ['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
486+
* ['format'] = (string) a short version of the Accept header, e.g. json, yaml
487+
* ['actions'] = (list) A comma-separated list of actions that should be returned. Leave empty to return all.
488+
* ['detailed'] = (boolean) Return detailed task information (default: false)
489+
* ['parent_node'] = (string) Return tasks with specified parent node.
490+
* ['parent_task'] = (number) Return tasks with specified parent task id. Set to -1 to return all.
491+
* ['h'] = (list) Comma-separated list of column names to display
492+
* ['help'] = (bool) Return help information
493+
* ['v'] = (bool) Verbose mode. Display column headers
494+
*
495+
* @param $params array Associative array of parameters
496+
*
497+
* @return array
498+
*/
499+
public function tasks($params = array())
500+
{
501+
/** @var callback $endpointBuilder */
502+
$endpointBuilder = $this->endpoints;
503+
504+
/** @var \Elasticsearch\Endpoints\Cat\Tasks $endpoint */
505+
$endpoint = $endpointBuilder('Cat\Tasks');
506+
$endpoint->setParams($params);
507+
$response = $endpoint->performRequest();
508+
509+
return $endpoint->resultOrFuture($response);
510+
}
482511
}

0 commit comments

Comments
 (0)