Skip to content

Commit 66c851f

Browse files
committed
Add Ingest namespace and endpoints
1 parent a76cbf2 commit 66c851f

File tree

6 files changed

+378
-0
lines changed

6 files changed

+378
-0
lines changed

src/Elasticsearch/Client.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Elasticsearch\Namespaces\CatNamespace;
99
use Elasticsearch\Namespaces\ClusterNamespace;
1010
use Elasticsearch\Namespaces\IndicesNamespace;
11+
use Elasticsearch\Namespaces\IngestNamespace;
1112
use Elasticsearch\Namespaces\NodesNamespace;
1213
use Elasticsearch\Namespaces\SnapshotNamespace;
1314
use Elasticsearch\Namespaces\BooleanRequestWrapper;
@@ -58,6 +59,11 @@ class Client
5859
*/
5960
protected $cat;
6061

62+
/**
63+
* @var IngestNamespace
64+
*/
65+
protected $ingest;
66+
6167
/** @var callback */
6268
protected $endpoints;
6369

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

8188
/**
@@ -1413,6 +1420,16 @@ public function cat()
14131420
return $this->cat;
14141421
}
14151422

1423+
/**
1424+
* Operate on the Ingest namespace of commands
1425+
*
1426+
* @return IngestNamespace
1427+
*/
1428+
public function ingest()
1429+
{
1430+
return $this->ingest;
1431+
}
1432+
14161433
/**
14171434
* @param array $params
14181435
* @param string $arg
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
namespace Elasticsearch\Endpoints\Ingest\Pipeline;
4+
5+
use Elasticsearch\Common\Exceptions;
6+
use Elasticsearch\Endpoints\AbstractEndpoint;
7+
8+
/**
9+
* Class Delete
10+
*
11+
* @category Elasticsearch
12+
* @package Elasticsearch\Endpoints\Ingest
13+
* @author Zachary Tong <zachary.tong@elasticsearch.com>
14+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
15+
* @link http://elasticsearch.org
16+
*/
17+
class Delete extends AbstractEndpoint
18+
{
19+
/**
20+
* @throws \Elasticsearch\Common\Exceptions\RuntimeException
21+
* @return string
22+
*/
23+
protected function getURI()
24+
{
25+
if (isset($this->id) !== true) {
26+
throw new Exceptions\RuntimeException(
27+
'id is required for DeletePipeline'
28+
);
29+
}
30+
$id = $this->id;
31+
$uri = "/_ingest/pipeline/$id";
32+
33+
return $uri;
34+
}
35+
36+
/**
37+
* @return string[]
38+
*/
39+
protected function getParamWhitelist()
40+
{
41+
return array(
42+
'master_timeout',
43+
'timeout'
44+
);
45+
}
46+
47+
/**
48+
* @return string
49+
*/
50+
protected function getMethod()
51+
{
52+
return 'DELETE';
53+
}
54+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
namespace Elasticsearch\Endpoints\Ingest\Pipeline;
4+
5+
use Elasticsearch\Common\Exceptions;
6+
use Elasticsearch\Endpoints\AbstractEndpoint;
7+
8+
/**
9+
* Class Get
10+
*
11+
* @category Elasticsearch
12+
* @package Elasticsearch\Endpoints\Ingest
13+
* @author Zachary Tong <zachary.tong@elasticsearch.com>
14+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
15+
* @link http://elasticsearch.org
16+
*/
17+
class Get extends AbstractEndpoint
18+
{
19+
/**
20+
* @throws \Elasticsearch\Common\Exceptions\RuntimeException
21+
* @return string
22+
*/
23+
protected function getURI()
24+
{
25+
if (isset($this->id) !== true) {
26+
throw new Exceptions\RuntimeException(
27+
'id is required for GetPipeline'
28+
);
29+
}
30+
$id = $this->id;
31+
$uri = "/_ingest/pipeline/$id";
32+
33+
return $uri;
34+
}
35+
36+
/**
37+
* @return string[]
38+
*/
39+
protected function getParamWhitelist()
40+
{
41+
return array(
42+
'master_timeout'
43+
);
44+
}
45+
46+
/**
47+
* @return string
48+
*/
49+
protected function getMethod()
50+
{
51+
return 'GET';
52+
}
53+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
3+
namespace Elasticsearch\Endpoints\Ingest\Pipeline;
4+
5+
use Elasticsearch\Common\Exceptions;
6+
use Elasticsearch\Endpoints\AbstractEndpoint;
7+
8+
/**
9+
* Class Put
10+
*
11+
* @category Elasticsearch
12+
* @package Elasticsearch\Endpoints\Ingest
13+
* @author Zachary Tong <zachary.tong@elasticsearch.com>
14+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
15+
* @link http://elasticsearch.org
16+
*/
17+
class Put extends AbstractEndpoint
18+
{
19+
/**
20+
* @param array $body
21+
*
22+
* @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException
23+
* @return $this
24+
*/
25+
public function setBody($body)
26+
{
27+
if (isset($body) !== true) {
28+
return $this;
29+
}
30+
31+
$this->body = $body;
32+
33+
return $this;
34+
}
35+
36+
/**
37+
* @throws \Elasticsearch\Common\Exceptions\RuntimeException
38+
* @return string
39+
*/
40+
protected function getURI()
41+
{
42+
if (isset($this->id) !== true) {
43+
throw new Exceptions\RuntimeException(
44+
'id is required for PutPipeline'
45+
);
46+
}
47+
$id = $this->id;
48+
$uri = "/_ingest/pipeline/$id";
49+
50+
return $uri;
51+
}
52+
53+
/**
54+
* @return string[]
55+
*/
56+
protected function getParamWhitelist()
57+
{
58+
return array(
59+
'master_timeout',
60+
'timeout'
61+
);
62+
}
63+
64+
/**
65+
* @return string
66+
*/
67+
protected function getMethod()
68+
{
69+
return 'PUT';
70+
}
71+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
namespace Elasticsearch\Endpoints\Ingest;
4+
5+
use Elasticsearch\Common\Exceptions;
6+
use Elasticsearch\Endpoints\AbstractEndpoint;
7+
8+
/**
9+
* Class Simulate
10+
*
11+
* @category Elasticsearch
12+
* @package Elasticsearch\Endpoints\Ingest
13+
* @author Zachary Tong <zachary.tong@elasticsearch.com>
14+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
15+
* @link http://elasticsearch.org
16+
*/
17+
class Simulate extends AbstractEndpoint
18+
{
19+
/**
20+
* @param array $body
21+
*
22+
* @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException
23+
* @return $this
24+
*/
25+
public function setBody($body)
26+
{
27+
if (isset($body) !== true) {
28+
return $this;
29+
}
30+
31+
$this->body = $body;
32+
33+
return $this;
34+
}
35+
36+
/**
37+
* @throws \Elasticsearch\Common\Exceptions\RuntimeException
38+
* @return string
39+
*/
40+
protected function getURI()
41+
{
42+
if (isset($this->id) === true) {
43+
return "/_ingest/pipeline/{$this->id}/_simulate";
44+
}
45+
return "/_ingest/pipeline/_simulate";
46+
}
47+
48+
/**
49+
* @return string[]
50+
*/
51+
protected function getParamWhitelist()
52+
{
53+
return array(
54+
'verbose',
55+
);
56+
}
57+
58+
/**
59+
* @return string
60+
*/
61+
protected function getMethod()
62+
{
63+
return 'GET';
64+
}
65+
}

0 commit comments

Comments
 (0)