-
Notifications
You must be signed in to change notification settings - Fork 964
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Forgot to include this in the last commit :s
- Loading branch information
1 parent
f88d7ca
commit ed85658
Showing
1 changed file
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<?php | ||
/** | ||
* User: zach | ||
* Date: 5/7/14 | ||
* Time: 12:04 PM | ||
*/ | ||
|
||
namespace Elasticsearch\Endpoints\Snapshot; | ||
|
||
use Elasticsearch\Endpoints\AbstractEndpoint; | ||
use Elasticsearch\Common\Exceptions; | ||
|
||
/** | ||
* Class Status | ||
* | ||
* @category Elasticsearch | ||
* @package Elasticsearch\Endpoints\Snapshot | ||
* @author Zachary Tong <[email protected]> | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2 | ||
* @link http://elasticsearch.org | ||
*/ | ||
|
||
class Status extends AbstractEndpoint | ||
{ | ||
// A comma-separated list of repository names | ||
private $repository; | ||
|
||
// A comma-separated list of snapshot names | ||
private $snapshot; | ||
|
||
|
||
/** | ||
* @param $repository | ||
* | ||
* @return $this | ||
*/ | ||
public function setRepository($repository) | ||
{ | ||
if (isset($repository) !== true) { | ||
return $this; | ||
} | ||
|
||
$this->repository = $repository; | ||
return $this; | ||
} | ||
|
||
|
||
/** | ||
* @param $snapshot | ||
* | ||
* @return $this | ||
*/ | ||
public function setSnapshot($snapshot) | ||
{ | ||
if (isset($snapshot) !== true) { | ||
return $this; | ||
} | ||
|
||
$this->snapshot = $snapshot; | ||
return $this; | ||
} | ||
|
||
|
||
/** | ||
* @throws \Elasticsearch\Common\Exceptions\RuntimeException | ||
* @return string | ||
*/ | ||
protected function getURI() | ||
{ | ||
if (isset($this->snapshot) === true && isset($this->repository) !== true) { | ||
throw new Exceptions\RuntimeException( | ||
'Repository param must be provided if snapshot param is set' | ||
); | ||
} | ||
|
||
$repository = $this->repository; | ||
$snapshot = $this->snapshot; | ||
$uri = "/_snapshot/_status"; | ||
|
||
if (isset($repository) === true) { | ||
$uri = "/_snapshot/$repository/_status"; | ||
} elseif (isset($repository) === true && isset($snapshot) === true) { | ||
$uri = "/_snapshot/$repository/$snapshot/_status"; | ||
} | ||
|
||
return $uri; | ||
} | ||
|
||
|
||
/** | ||
* @return string[] | ||
*/ | ||
protected function getParamWhitelist() | ||
{ | ||
return array( | ||
'master_timeout', | ||
); | ||
} | ||
|
||
|
||
/** | ||
* @return string | ||
*/ | ||
protected function getMethod() | ||
{ | ||
return 'GET'; | ||
} | ||
} |