Skip to content

Commit

Permalink
Add Indices/Recovery Endpont
Browse files Browse the repository at this point in the history
  • Loading branch information
polyfractal committed Mar 24, 2014
1 parent 1f6822b commit a3a66b7
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
61 changes: 61 additions & 0 deletions src/Elasticsearch/Endpoints/Indices/Recovery.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php
/**
* User: zach
* Date: 3/24/14
* Time: 4:59 PM
*/

namespace Elasticsearch\Endpoints\Indices;

use Elasticsearch\Endpoints\AbstractEndpoint;
use Elasticsearch\Common\Exceptions;

/**
* Class Recovery
*
* @category Elasticsearch
* @package Elasticsearch\Endpoints\Indices
* @author Zachary Tong <[email protected]>
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
* @link http://elasticsearch.org
*/

class Recovery extends AbstractEndpoint
{
/**
* @return string
*/
protected function getURI()
{
$index = $this->index;
$uri = "/_recovery";

if (isset($index) === true) {
$uri = "/$index/_recovery";
}

return $uri;
}


/**
* @return string[]
*/
protected function getParamWhitelist()
{
return array(
'detailed',
'active_only',
'human'
);
}


/**
* @return string
*/
protected function getMethod()
{
return 'GET';
}
}
25 changes: 25 additions & 0 deletions src/Elasticsearch/Namespaces/IndicesNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,31 @@ public function refresh($params = array())
return $response['data'];
}

/**
* $params['index'] = (list) A comma-separated list of index names; use `_all` or empty string for all indices
* ['detailed'] = (bool) Whether to display detailed information about shard recovery
* ['active_only'] = (bool) Display only those recoveries that are currently on-going
* ['human'] = (bool) Whether to return time and byte values in human-readable format.
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function recovery($params = array())
{
$index = $this->extractArgument($params, 'index');

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

/** @var \Elasticsearch\Endpoints\Indices\Flush $endpoint */
$endpoint = $endpointBuilder('Indices\Recovery');
$endpoint->setIndex($index);
$endpoint->setParams($params);
$response = $endpoint->performRequest();
return $response['data'];
}


/**
* $params['index'] = (list) A comma-separated list of index names; use `_all` to check the types across all indices (Required)
Expand Down

0 comments on commit a3a66b7

Please sign in to comment.