1<?php 2 3declare(strict_types = 1); 4 5namespace Elasticsearch\Namespaces; 6 7/** 8 * Class ClusterNamespace 9 * 10 * @category Elasticsearch 11 * @package Elasticsearch\Namespaces\ClusterNamespace 12 * @author Zachary Tong <zach@elastic.co> 13 * @license http://www.apache.org/licenses/LICENSE-2.0 Apache2 14 * @link http://elastic.co 15 */ 16class ClusterNamespace extends AbstractNamespace 17{ 18 /** 19 * $params['index'] = (string) Limit the information returned to a specific index 20 * ['level'] = (enum) Specify the level of detail for returned information 21 * ['local'] = (boolean) Return local information, do not retrieve the state from master node (default: false) 22 * ['master_timeout'] = (time) Explicit operation timeout for connection to master node 23 * ['timeout'] = (time) Explicit operation timeout 24 * ['wait_for_active_shards'] = (number) Wait until the specified number of shards is active 25 * ['wait_for_nodes'] = (number) Wait until the specified number of nodes is available 26 * ['wait_for_relocating_shards'] = (number) Wait until the specified number of relocating shards is finished 27 * ['wait_for_status'] = (enum) Wait until cluster is in a specific state 28 * 29 * @return callable|array 30 */ 31 public function health(array $params = []) 32 { 33 $index = $this->extractArgument($params, 'index'); 34 35 /** 36 * @var callable $endpointBuilder 37*/ 38 $endpointBuilder = $this->endpoints; 39 40 /** 41 * @var \Elasticsearch\Endpoints\Cluster\Health $endpoint 42*/ 43 $endpoint = $endpointBuilder('Cluster\Health'); 44 $endpoint->setIndex($index); 45 $endpoint->setParams($params); 46 47 return $this->performRequest($endpoint); 48 } 49 50 /** 51 * $params['dry_run'] = (boolean) Simulate the operation only and return the resulting state 52 * ['filter_metadata'] = (boolean) Don't return cluster state metadata (default: false) 53 * ['body'] = (boolean) Don't return cluster state metadata (default: false) 54 * ['explain'] = (boolean) Return an explanation of why the commands can or cannot be executed 55 * 56 * @return callable|array 57 */ 58 public function reroute(array $params = []) 59 { 60 $body = $this->extractArgument($params, 'body'); 61 62 /** 63 * @var callable $endpointBuilder 64*/ 65 $endpointBuilder = $this->endpoints; 66 67 /** 68 * @var \Elasticsearch\Endpoints\Cluster\Reroute $endpoint 69*/ 70 $endpoint = $endpointBuilder('Cluster\Reroute'); 71 $endpoint->setBody($body); 72 $endpoint->setParams($params); 73 74 return $this->performRequest($endpoint); 75 } 76 77 /** 78 * $params['filter_blocks'] = (boolean) Do not return information about blocks 79 * ['filter_index_templates'] = (boolean) Do not return information about index templates 80 * ['filter_indices'] = (list) Limit returned metadata information to specific indices 81 * ['filter_metadata'] = (boolean) Do not return information about indices metadata 82 * ['filter_nodes'] = (boolean) Do not return information about nodes 83 * ['filter_routing_table'] = (boolean) Do not return information about shard allocation (`routing_table` and `routing_nodes`) 84 * ['local'] = (boolean) Return local information, do not retrieve the state from master node (default: false) 85 * ['master_timeout'] = (time) Specify timeout for connection to master 86 * 87 * @return callable|array 88 */ 89 public function state(array $params = []) 90 { 91 $index = $this->extractArgument($params, 'index'); 92 $metric = $this->extractArgument($params, 'metric'); 93 94 /** 95 * @var callable $endpointBuilder 96*/ 97 $endpointBuilder = $this->endpoints; 98 99 /** 100 * @var \Elasticsearch\Endpoints\Cluster\State $endpoint 101*/ 102 $endpoint = $endpointBuilder('Cluster\State'); 103 $endpoint->setParams($params) 104 ->setIndex($index) 105 ->setMetric($metric); 106 107 return $this->performRequest($endpoint); 108 } 109 110 /** 111 * $params['flat_settings'] = (boolean) Return settings in flat format (default: false) 112 * ['human'] = (boolean) Whether to return time and byte values in human-readable format. 113 * 114 * @return callable|array 115 */ 116 public function stats(array $params = []) 117 { 118 $nodeID = $this->extractArgument($params, 'node_id'); 119 120 /** 121 * @var callable $endpointBuilder 122*/ 123 $endpointBuilder = $this->endpoints; 124 125 /** 126 * @var \Elasticsearch\Endpoints\Cluster\Stats $endpoint 127*/ 128 $endpoint = $endpointBuilder('Cluster\Stats'); 129 $endpoint->setNodeID($nodeID) 130 ->setParams($params); 131 132 return $this->performRequest($endpoint); 133 } 134 135 /** 136 * $params['body'] = () 137 * 138 * @return callable|array 139 */ 140 public function putSettings(array $params = []) 141 { 142 $body = $this->extractArgument($params, 'body'); 143 144 /** 145 * @var callable $endpointBuilder 146*/ 147 $endpointBuilder = $this->endpoints; 148 149 /** 150 * @var \Elasticsearch\Endpoints\Cluster\Settings\Put $endpoint 151*/ 152 $endpoint = $endpointBuilder('Cluster\Settings\Put'); 153 $endpoint->setBody($body); 154 $endpoint->setParams($params); 155 156 return $this->performRequest($endpoint); 157 } 158 159 /** 160 * @return callable|array 161 */ 162 public function getSettings(array $params = []) 163 { 164 /** 165 * @var callable $endpointBuilder 166*/ 167 $endpointBuilder = $this->endpoints; 168 169 /** 170 * @var \Elasticsearch\Endpoints\Cluster\Settings\Put $endpoint 171*/ 172 $endpoint = $endpointBuilder('Cluster\Settings\Get'); 173 $endpoint->setParams($params); 174 175 return $this->performRequest($endpoint); 176 } 177 178 /** 179 * $params['local'] = (bool) Return local information, do not retrieve the state from master node (default: false) 180 * ['master_timeout'] = (time) Specify timeout for connection to master 181 * 182 * @return callable|array 183 */ 184 public function pendingTasks(array $params = []) 185 { 186 /** 187 * @var callable $endpointBuilder 188*/ 189 $endpointBuilder = $this->endpoints; 190 191 /** 192 * @var \Elasticsearch\Endpoints\Cluster\PendingTasks $endpoint 193*/ 194 $endpoint = $endpointBuilder('Cluster\PendingTasks'); 195 $endpoint->setParams($params); 196 197 return $this->performRequest($endpoint); 198 } 199 200 /** 201 * $params['include_yes_decisions'] = (bool) Return 'YES' decisions in explanation (default: false) 202 * 203 * @return callable|array 204 */ 205 public function allocationExplain(array $params = []) 206 { 207 $body = $this->extractArgument($params, 'body'); 208 209 /** 210 * @var callable $endpointBuilder 211*/ 212 $endpointBuilder = $this->endpoints; 213 214 /** 215 * @var \Elasticsearch\Endpoints\Cluster\AllocationExplain $endpoint 216*/ 217 $endpoint = $endpointBuilder('Cluster\AllocationExplain'); 218 $endpoint->setBody($body) 219 ->setParams($params); 220 221 return $this->performRequest($endpoint); 222 } 223 224 /** 225 * @return callable|array 226 */ 227 public function remoteInfo(array $params = []) 228 { 229 /** 230 * @var callable $endpointBuilder 231*/ 232 $endpointBuilder = $this->endpoints; 233 234 /** 235 * @var \Elasticsearch\Endpoints\Cluster\RemoteInfo $endpoint 236*/ 237 $endpoint = $endpointBuilder('Cluster\RemoteInfo'); 238 239 return $this->performRequest($endpoint); 240 } 241} 242