-
Notifications
You must be signed in to change notification settings - Fork 980
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
3b041f8
commit b6b97a4
Showing
2 changed files
with
128 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,101 @@ | ||
<?php | ||
|
||
namespace Elasticsearch\Endpoints\Indices; | ||
|
||
use Elasticsearch\Endpoints\AbstractEndpoint; | ||
use Elasticsearch\Common\Exceptions; | ||
|
||
/** | ||
* Class Shrink. | ||
* | ||
* @category Elasticsearch | ||
* | ||
* @author Zachary Tong <[email protected]> | ||
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2 | ||
* | ||
* @link http://elastic.co | ||
*/ | ||
class Shrink extends AbstractEndpoint | ||
{ | ||
// The name of the target index to shrink into | ||
private $target; | ||
/** | ||
* @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; | ||
} | ||
|
||
/** | ||
* @param $target | ||
* | ||
* @return $this | ||
*/ | ||
public function setTarget($target) | ||
{ | ||
if (isset($target) !== true) { | ||
return $this; | ||
} | ||
$this->target = $target; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @throws \Elasticsearch\Common\Exceptions\BadMethodCallException | ||
* | ||
* @return string | ||
*/ | ||
protected function getURI() | ||
{ | ||
if (isset($this->index) !== true) { | ||
throw new Exceptions\RuntimeException( | ||
'index is required for Shrink' | ||
); | ||
} | ||
if (isset($this->target) !== true) { | ||
throw new Exceptions\RuntimeException( | ||
'target is required for Shrink' | ||
); | ||
} | ||
$index = $this->index; | ||
$target = $this->target; | ||
$uri = "/$index/_shrink/$target"; | ||
if (isset($index) === true && isset($target) === true) { | ||
$uri = "/$index/_shrink/$target"; | ||
} | ||
|
||
return $uri; | ||
} | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
protected function getParamWhitelist() | ||
{ | ||
return array( | ||
'timeout', | ||
'master_timeout', | ||
); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
protected function getMethod() | ||
{ | ||
//TODO Fix Me! | ||
return 'PUT'; | ||
} | ||
} |
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