From 776c8650818ffa549376fb2731afbfc68a22372a Mon Sep 17 00:00:00 2001 From: Zachary Tong Date: Wed, 19 Jul 2017 14:31:09 -0400 Subject: [PATCH] Add Cat\Templates endpoint --- src/Elasticsearch/Endpoints/Cat/Templates.php | 70 +++++++++++++++++++ src/Elasticsearch/Namespaces/CatNamespace.php | 27 +++++++ 2 files changed, 97 insertions(+) create mode 100644 src/Elasticsearch/Endpoints/Cat/Templates.php diff --git a/src/Elasticsearch/Endpoints/Cat/Templates.php b/src/Elasticsearch/Endpoints/Cat/Templates.php new file mode 100644 index 000000000..aee9e61fb --- /dev/null +++ b/src/Elasticsearch/Endpoints/Cat/Templates.php @@ -0,0 +1,70 @@ + + * @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'; + } +} diff --git a/src/Elasticsearch/Namespaces/CatNamespace.php b/src/Elasticsearch/Namespaces/CatNamespace.php index dac0ff6e1..942983813 100644 --- a/src/Elasticsearch/Namespaces/CatNamespace.php +++ b/src/Elasticsearch/Namespaces/CatNamespace.php @@ -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); + } }