-
Notifications
You must be signed in to change notification settings - Fork 966
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a315e0
commit 1ba8299
Showing
2 changed files
with
138 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 | ||
|
||
namespace Elasticsearch\Endpoints\Indices; | ||
|
||
use Elasticsearch\Endpoints\AbstractEndpoint; | ||
use Elasticsearch\Common\Exceptions; | ||
|
||
/** | ||
* Class Rollover | ||
* | ||
* @category Elasticsearch | ||
* @package Elasticsearch\Endpoints\Indices | ||
* @author Zachary Tong <zach@elastic.co> | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2 | ||
* @link http://elastic.co | ||
*/ | ||
class Rollover extends AbstractEndpoint | ||
{ | ||
private $alias; | ||
private $newIndex; | ||
|
||
/** | ||
* @param string $alias | ||
* | ||
* @return $this | ||
*/ | ||
public function setAlias($alias) | ||
{ | ||
if ($alias === null) { | ||
return $this; | ||
} | ||
|
||
$this->alias = urlencode($alias); | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param string $newIndex | ||
* | ||
* @return $this | ||
*/ | ||
public function setNewIndex($newIndex) | ||
{ | ||
if ($newIndex === null) { | ||
return $this; | ||
} | ||
|
||
$this->newIndex = urlencode($newIndex); | ||
return $this; | ||
} | ||
|
||
/** | ||
* @param array $body | ||
* | ||
* @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException | ||
* @return $this | ||
*/ | ||
public function setBody($body) | ||
{ | ||
if (isset($body) !== true) { | ||
return $this; | ||
} | ||
|
||
$this->body = $body; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @throws \Elasticsearch\Common\Exceptions\RuntimeException | ||
* @return string | ||
*/ | ||
protected function getURI() | ||
{ | ||
if (isset($this->alias) !== true) { | ||
throw new Exceptions\RuntimeException( | ||
'alias name is required for Rollover' | ||
); | ||
} | ||
|
||
$uri = "/{$this->alias}/_rollover"; | ||
|
||
if (isset($this->newIndex) === true) { | ||
$uri .= "/{$this->newIndex}"; | ||
} | ||
|
||
return $uri; | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
protected function getParamWhitelist() | ||
{ | ||
return array( | ||
'timeout', | ||
'master_timeout' | ||
); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
protected function getMethod() | ||
{ | ||
return 'POST'; | ||
} | ||
} |
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