Skip to content

Commit

Permalink
Add Cat\Templates endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
polyfractal committed Jul 19, 2017
1 parent 0acccc6 commit 776c865
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 0 deletions.
70 changes: 70 additions & 0 deletions src/Elasticsearch/Endpoints/Cat/Templates.php
@@ -0,0 +1,70 @@
<?php

namespace Elasticsearch\Endpoints\Cat;

use Elasticsearch\Endpoints\AbstractEndpoint;

/**
* Class Templates
*
* @category Elasticsearch
* @package Elasticsearch\Endpoints\Cat
* @author Zachary Tong <zach@elastic.co>
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
* @link http://elastic.co
*/
class Templates extends AbstractEndpoint
{
private $name;

/**
* @param string $name
* @return Templates
*/
public function setName($name)
{
$this->name = $name;
return $this;
}

/**
* @return string
*/
public function getURI()
{
if (isset($this->name)) {
return "/_cat/templates/{$this->name}";
} else {
return "/_cat/templates";
}
}

/**
* @return string[]
*/
public function getParamWhitelist()
{
return array(
'format',
'node_id',
'actions',
'detailed',
'parent_node',
'parent_task',
'h',
'help',
'v',
's',
'local',
'master_timeout',
);
}

/**
* @return string
*/
public function getMethod()
{
return 'GET';
}
}
27 changes: 27 additions & 0 deletions src/Elasticsearch/Namespaces/CatNamespace.php
Expand Up @@ -490,4 +490,31 @@ public function tasks($params = array())

return $this->performRequest($endpoint);
}

/**
* $params['local'] = (bool) Return local information, do not retrieve the state from master node (default: false)
* ['master_timeout'] = (time) Explicit operation timeout for connection to master node
* ['h'] = (list) Comma-separated list of column names to display
* ['help'] = (bool) Return help information
* ['v'] = (bool) Verbose mode. Display column headers
* ['bytes'] = (enum) The unit in which to display byte values
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function templates($params = array())
{
$name = $this->extractArgument($params, 'name');

/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;

/** @var \Elasticsearch\Endpoints\Cat\Templates $endpoint */
$endpoint = $endpointBuilder('Cat\Templates');
$endpoint->setName($name)
->setParams($params);

return $this->performRequest($endpoint);
}
}

0 comments on commit 776c865

Please sign in to comment.