Skip to content

Commit

Permalink
Add Snapshot/Status endpoint
Browse files Browse the repository at this point in the history
Also fixes typo in SnapshotNamespace->restore() method, as well
as general formatting corrections

Closes #58
  • Loading branch information
polyfractal committed May 8, 2014
1 parent fd304b1 commit f88d7ca
Showing 1 changed file with 30 additions and 24 deletions.
54 changes: 30 additions & 24 deletions src/Elasticsearch/Namespaces/SnapshotNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,8 @@ class SnapshotNamespace extends AbstractNamespace
public function create($params = array())
{
$repository = $this->extractArgument($params, 'repository');


$snapshot = $this->extractArgument($params, 'snapshot');


$body = $this->extractArgument($params, 'body');

/** @var callback $endpointBuilder */
$endpointBuilder = $this->dicEndpoints;
Expand All @@ -42,7 +39,8 @@ public function create($params = array())
$endpoint = $endpointBuilder('Snapshot\Create');
$endpoint->setRepository($repository)
->setSnapshot($snapshot)
->setParams($params);
->setParams($params)
->setBody($body);
$response = $endpoint->performRequest();
return $response['data'];
}
Expand All @@ -59,12 +57,8 @@ public function create($params = array())
public function createRepository($params = array())
{
$repository = $this->extractArgument($params, 'repository');


$body = $this->extractArgument($params, 'body');



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

Expand All @@ -88,11 +82,7 @@ public function createRepository($params = array())
public function delete($params = array())
{
$repository = $this->extractArgument($params, 'repository');


$snapshot = $this->extractArgument($params, 'snapshot');



/** @var callback $endpointBuilder */
$endpointBuilder = $this->dicEndpoints;
Expand All @@ -118,8 +108,6 @@ public function delete($params = array())
public function deleteRepository($params = array())
{
$repository = $this->extractArgument($params, 'repository');



/** @var callback $endpointBuilder */
$endpointBuilder = $this->dicEndpoints;
Expand All @@ -143,8 +131,6 @@ public function deleteRepository($params = array())
public function get($params = array())
{
$repository = $this->extractArgument($params, 'repository');


$snapshot = $this->extractArgument($params, 'snapshot');


Expand Down Expand Up @@ -173,8 +159,6 @@ public function get($params = array())
public function getRepository($params = array())
{
$repository = $this->extractArgument($params, 'repository');



/** @var callback $endpointBuilder */
$endpointBuilder = $this->dicEndpoints;
Expand All @@ -199,17 +183,39 @@ public function getRepository($params = array())
public function restore($params = array())
{
$repository = $this->extractArgument($params, 'repository');


$snapshot = $this->extractArgument($params, 'snapshot');

$body = $this->extractArgument($params, 'body');

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

/** @var \Elasticsearch\Endpoints\Snapshot\Restore $endpoint */
$endpoint = $endpointBuilder('Snapshot\Restore');
$endpoint->setRepository($repository)
->setSnapshot($snapshot)
->setParams($params)
->setBody($body);
$response = $endpoint->performRequest();
return $response['data'];
}

/**
* $params['master_timeout'] = (time) Explicit operation timeout for connection to master node
*
* @param $params array Associative array of parameters
*
* @return array
*/
public function status($params = array())
{
$repository = $this->extractArgument($params, 'repository');
$snapshot = $this->extractArgument($params, 'snapshot');

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

/** @var \Elasticsearch\Endpoints\Snapshot\Get $endpoint */
$endpoint = $endpointBuilder('Snapshot\Get');
/** @var \Elasticsearch\Endpoints\Snapshot\Status $endpoint */
$endpoint = $endpointBuilder('Snapshot\Status');
$endpoint->setRepository($repository)
->setSnapshot($snapshot)
->setParams($params);
Expand Down

0 comments on commit f88d7ca

Please sign in to comment.