Skip to content

Commit

Permalink
Add Ingest namespace and endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
polyfractal committed Mar 31, 2016
1 parent a76cbf2 commit 66c851f
Show file tree
Hide file tree
Showing 6 changed files with 378 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Elasticsearch/Client.php
Expand Up @@ -8,6 +8,7 @@
use Elasticsearch\Namespaces\CatNamespace;
use Elasticsearch\Namespaces\ClusterNamespace;
use Elasticsearch\Namespaces\IndicesNamespace;
use Elasticsearch\Namespaces\IngestNamespace;
use Elasticsearch\Namespaces\NodesNamespace;
use Elasticsearch\Namespaces\SnapshotNamespace;
use Elasticsearch\Namespaces\BooleanRequestWrapper;
Expand Down Expand Up @@ -58,6 +59,11 @@ class Client
*/
protected $cat;

/**
* @var IngestNamespace
*/
protected $ingest;

/** @var callback */
protected $endpoints;

Expand All @@ -76,6 +82,7 @@ public function __construct(Transport $transport, callable $endpoint)
$this->nodes = new NodesNamespace($transport, $endpoint);
$this->snapshot = new SnapshotNamespace($transport, $endpoint);
$this->cat = new CatNamespace($transport, $endpoint);
$this->ingest = new IngestNamespace($transport, $endpoint);
}

/**
Expand Down Expand Up @@ -1413,6 +1420,16 @@ public function cat()
return $this->cat;
}

/**
* Operate on the Ingest namespace of commands
*
* @return IngestNamespace
*/
public function ingest()
{
return $this->ingest;
}

/**
* @param array $params
* @param string $arg
Expand Down
54 changes: 54 additions & 0 deletions src/Elasticsearch/Endpoints/Ingest/Pipeline/Delete.php
@@ -0,0 +1,54 @@
<?php

namespace Elasticsearch\Endpoints\Ingest\Pipeline;

use Elasticsearch\Common\Exceptions;
use Elasticsearch\Endpoints\AbstractEndpoint;

/**
* Class Delete
*
* @category Elasticsearch
* @package Elasticsearch\Endpoints\Ingest
* @author Zachary Tong <zachary.tong@elasticsearch.com>
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
* @link http://elasticsearch.org
*/
class Delete extends AbstractEndpoint
{
/**
* @throws \Elasticsearch\Common\Exceptions\RuntimeException
* @return string
*/
protected function getURI()
{
if (isset($this->id) !== true) {
throw new Exceptions\RuntimeException(
'id is required for DeletePipeline'
);
}
$id = $this->id;
$uri = "/_ingest/pipeline/$id";

return $uri;
}

/**
* @return string[]
*/
protected function getParamWhitelist()
{
return array(
'master_timeout',
'timeout'
);
}

/**
* @return string
*/
protected function getMethod()
{
return 'DELETE';
}
}
53 changes: 53 additions & 0 deletions src/Elasticsearch/Endpoints/Ingest/Pipeline/Get.php
@@ -0,0 +1,53 @@
<?php

namespace Elasticsearch\Endpoints\Ingest\Pipeline;

use Elasticsearch\Common\Exceptions;
use Elasticsearch\Endpoints\AbstractEndpoint;

/**
* Class Get
*
* @category Elasticsearch
* @package Elasticsearch\Endpoints\Ingest
* @author Zachary Tong <zachary.tong@elasticsearch.com>
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
* @link http://elasticsearch.org
*/
class Get extends AbstractEndpoint
{
/**
* @throws \Elasticsearch\Common\Exceptions\RuntimeException
* @return string
*/
protected function getURI()
{
if (isset($this->id) !== true) {
throw new Exceptions\RuntimeException(
'id is required for GetPipeline'
);
}
$id = $this->id;
$uri = "/_ingest/pipeline/$id";

return $uri;
}

/**
* @return string[]
*/
protected function getParamWhitelist()
{
return array(
'master_timeout'
);
}

/**
* @return string
*/
protected function getMethod()
{
return 'GET';
}
}
71 changes: 71 additions & 0 deletions src/Elasticsearch/Endpoints/Ingest/Pipeline/Put.php
@@ -0,0 +1,71 @@
<?php

namespace Elasticsearch\Endpoints\Ingest\Pipeline;

use Elasticsearch\Common\Exceptions;
use Elasticsearch\Endpoints\AbstractEndpoint;

/**
* Class Put
*
* @category Elasticsearch
* @package Elasticsearch\Endpoints\Ingest
* @author Zachary Tong <zachary.tong@elasticsearch.com>
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
* @link http://elasticsearch.org
*/
class Put extends AbstractEndpoint
{
/**
* @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->id) !== true) {
throw new Exceptions\RuntimeException(
'id is required for PutPipeline'
);
}
$id = $this->id;
$uri = "/_ingest/pipeline/$id";

return $uri;
}

/**
* @return string[]
*/
protected function getParamWhitelist()
{
return array(
'master_timeout',
'timeout'
);
}

/**
* @return string
*/
protected function getMethod()
{
return 'PUT';
}
}
65 changes: 65 additions & 0 deletions src/Elasticsearch/Endpoints/Ingest/Simulate.php
@@ -0,0 +1,65 @@
<?php

namespace Elasticsearch\Endpoints\Ingest;

use Elasticsearch\Common\Exceptions;
use Elasticsearch\Endpoints\AbstractEndpoint;

/**
* Class Simulate
*
* @category Elasticsearch
* @package Elasticsearch\Endpoints\Ingest
* @author Zachary Tong <zachary.tong@elasticsearch.com>
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
* @link http://elasticsearch.org
*/
class Simulate extends AbstractEndpoint
{
/**
* @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->id) === true) {
return "/_ingest/pipeline/{$this->id}/_simulate";
}
return "/_ingest/pipeline/_simulate";
}

/**
* @return string[]
*/
protected function getParamWhitelist()
{
return array(
'verbose',
);
}

/**
* @return string
*/
protected function getMethod()
{
return 'GET';
}
}

0 comments on commit 66c851f

Please sign in to comment.