Skip to content

Commit 776c865

Browse files
committed
Add Cat\Templates endpoint
1 parent 0acccc6 commit 776c865

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?php
2+
3+
namespace Elasticsearch\Endpoints\Cat;
4+
5+
use Elasticsearch\Endpoints\AbstractEndpoint;
6+
7+
/**
8+
* Class Templates
9+
*
10+
* @category Elasticsearch
11+
* @package Elasticsearch\Endpoints\Cat
12+
* @author Zachary Tong <[email protected]>
13+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
14+
* @link http://elastic.co
15+
*/
16+
class Templates extends AbstractEndpoint
17+
{
18+
private $name;
19+
20+
/**
21+
* @param string $name
22+
* @return Templates
23+
*/
24+
public function setName($name)
25+
{
26+
$this->name = $name;
27+
return $this;
28+
}
29+
30+
/**
31+
* @return string
32+
*/
33+
public function getURI()
34+
{
35+
if (isset($this->name)) {
36+
return "/_cat/templates/{$this->name}";
37+
} else {
38+
return "/_cat/templates";
39+
}
40+
}
41+
42+
/**
43+
* @return string[]
44+
*/
45+
public function getParamWhitelist()
46+
{
47+
return array(
48+
'format',
49+
'node_id',
50+
'actions',
51+
'detailed',
52+
'parent_node',
53+
'parent_task',
54+
'h',
55+
'help',
56+
'v',
57+
's',
58+
'local',
59+
'master_timeout',
60+
);
61+
}
62+
63+
/**
64+
* @return string
65+
*/
66+
public function getMethod()
67+
{
68+
return 'GET';
69+
}
70+
}

src/Elasticsearch/Namespaces/CatNamespace.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,4 +490,31 @@ public function tasks($params = array())
490490

491491
return $this->performRequest($endpoint);
492492
}
493+
494+
/**
495+
* $params['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
496+
* ['master_timeout'] = (time) Explicit operation timeout for connection to master node
497+
* ['h'] = (list) Comma-separated list of column names to display
498+
* ['help'] = (bool) Return help information
499+
* ['v'] = (bool) Verbose mode. Display column headers
500+
* ['bytes'] = (enum) The unit in which to display byte values
501+
*
502+
* @param $params array Associative array of parameters
503+
*
504+
* @return array
505+
*/
506+
public function templates($params = array())
507+
{
508+
$name = $this->extractArgument($params, 'name');
509+
510+
/** @var callback $endpointBuilder */
511+
$endpointBuilder = $this->endpoints;
512+
513+
/** @var \Elasticsearch\Endpoints\Cat\Templates $endpoint */
514+
$endpoint = $endpointBuilder('Cat\Templates');
515+
$endpoint->setName($name)
516+
->setParams($params);
517+
518+
return $this->performRequest($endpoint);
519+
}
493520
}

0 commit comments

Comments
 (0)