Skip to content

Commit 82121d9

Browse files
committed
Add Remote Namespace and Remote\Info endpoint
1 parent dfdb1a8 commit 82121d9

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed

src/Elasticsearch/Client.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
use Elasticsearch\Common\Exceptions\Missing404Exception;
1010
use Elasticsearch\Common\Exceptions\TransportException;
1111
use Elasticsearch\Endpoints\AbstractEndpoint;
12+
use Elasticsearch\Namespaces\AbstractNamespace;
1213
use Elasticsearch\Namespaces\CatNamespace;
1314
use Elasticsearch\Namespaces\ClusterNamespace;
1415
use Elasticsearch\Namespaces\IndicesNamespace;
1516
use Elasticsearch\Namespaces\IngestNamespace;
1617
use Elasticsearch\Namespaces\NamespaceBuilderInterface;
1718
use Elasticsearch\Namespaces\NodesNamespace;
19+
use Elasticsearch\Namespaces\RemoteNamespace;
1820
use Elasticsearch\Namespaces\SnapshotNamespace;
1921
use Elasticsearch\Namespaces\BooleanRequestWrapper;
2022
use Elasticsearch\Namespaces\TasksNamespace;
@@ -75,6 +77,11 @@ class Client
7577
*/
7678
protected $tasks;
7779

80+
/**
81+
* @var RemoteNamespace
82+
*/
83+
protected $remote;
84+
7885
/** @var callback */
7986
protected $endpoints;
8087

@@ -99,6 +106,7 @@ public function __construct(Transport $transport, callable $endpoint, array $reg
99106
$this->cat = new CatNamespace($transport, $endpoint);
100107
$this->ingest = new IngestNamespace($transport, $endpoint);
101108
$this->tasks = new TasksNamespace($transport, $endpoint);
109+
$this->remote = new RemoteNamespace($transport, $endpoint);
102110
$this->registeredNamespaces = $registeredNamespaces;
103111
}
104112

@@ -1430,6 +1438,16 @@ public function tasks()
14301438
return $this->tasks;
14311439
}
14321440

1441+
/**
1442+
* Operate on the Remote namespace of commands
1443+
*
1444+
* @return RemoteNamespace
1445+
*/
1446+
public function remote()
1447+
{
1448+
return $this->remote;
1449+
}
1450+
14331451
/**
14341452
* Catchall for registered namespaces
14351453
*
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace Elasticsearch\Endpoints\Remote;
4+
use Elasticsearch\Endpoints\AbstractEndpoint;
5+
6+
/**
7+
* Class Info
8+
*
9+
* @category Elasticsearch
10+
* @package Elasticsearch\Endpoints\Cluster\Nodes
11+
* @author Zachary Tong <[email protected]>
12+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
13+
* @link http://elastic.co
14+
*/
15+
class Info extends AbstractEndpoint
16+
{
17+
/**
18+
* @return string
19+
*/
20+
public function getURI()
21+
{
22+
return "/_remote/info";
23+
}
24+
25+
/**
26+
* @return string[]
27+
*/
28+
public function getParamWhitelist()
29+
{
30+
return array();
31+
}
32+
33+
/**
34+
* @return string
35+
*/
36+
public function getMethod()
37+
{
38+
return 'GET';
39+
}
40+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Elasticsearch\Namespaces;
4+
5+
use Elasticsearch\Endpoints\Remote\Info;
6+
7+
/**
8+
* Class RemoteNamespace
9+
*
10+
* @category Elasticsearch
11+
* @package Elasticsearch\Namespaces\TasksNamespace
12+
* @author Zachary Tong <[email protected]>
13+
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
14+
* @link http://elastic.co
15+
*/
16+
class RemoteNamespace extends AbstractNamespace
17+
{
18+
/**
19+
* @param $params array Associative array of parameters
20+
*
21+
* @return array
22+
*/
23+
public function info($params = array())
24+
{
25+
/** @var callback $endpointBuilder */
26+
$endpointBuilder = $this->endpoints;
27+
28+
/** @var Info $endpoint */
29+
$endpoint = $endpointBuilder('Remote\Info');
30+
$endpoint->setParams($params);
31+
32+
return $this->performRequest($endpoint);
33+
}
34+
}

0 commit comments

Comments
 (0)