| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- <?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
- */
- public 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[]
- */
- public function getParamWhitelist()
- {
- return array(
- 'timeout',
- 'master_timeout',
- 'wait_for_active_shards',
- );
- }
- /**
- * @return string
- */
- public function getMethod()
- {
- return 'POST';
- }
- }
|