Skip to content

Commit

Permalink
Add Remote Namespace and Remote\Info endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
polyfractal committed Jul 19, 2017
1 parent dfdb1a8 commit 82121d9
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Elasticsearch/Client.php
Expand Up @@ -9,12 +9,14 @@
use Elasticsearch\Common\Exceptions\Missing404Exception;
use Elasticsearch\Common\Exceptions\TransportException;
use Elasticsearch\Endpoints\AbstractEndpoint;
use Elasticsearch\Namespaces\AbstractNamespace;
use Elasticsearch\Namespaces\CatNamespace;
use Elasticsearch\Namespaces\ClusterNamespace;
use Elasticsearch\Namespaces\IndicesNamespace;
use Elasticsearch\Namespaces\IngestNamespace;
use Elasticsearch\Namespaces\NamespaceBuilderInterface;
use Elasticsearch\Namespaces\NodesNamespace;
use Elasticsearch\Namespaces\RemoteNamespace;
use Elasticsearch\Namespaces\SnapshotNamespace;
use Elasticsearch\Namespaces\BooleanRequestWrapper;
use Elasticsearch\Namespaces\TasksNamespace;
Expand Down Expand Up @@ -75,6 +77,11 @@ class Client
*/
protected $tasks;

/**
* @var RemoteNamespace
*/
protected $remote;

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

Expand All @@ -99,6 +106,7 @@ public function __construct(Transport $transport, callable $endpoint, array $reg
$this->cat = new CatNamespace($transport, $endpoint);
$this->ingest = new IngestNamespace($transport, $endpoint);
$this->tasks = new TasksNamespace($transport, $endpoint);
$this->remote = new RemoteNamespace($transport, $endpoint);
$this->registeredNamespaces = $registeredNamespaces;
}

Expand Down Expand Up @@ -1430,6 +1438,16 @@ public function tasks()
return $this->tasks;
}

/**
* Operate on the Remote namespace of commands
*
* @return RemoteNamespace
*/
public function remote()
{
return $this->remote;
}

/**
* Catchall for registered namespaces
*
Expand Down
40 changes: 40 additions & 0 deletions src/Elasticsearch/Endpoints/Remote/Info.php
@@ -0,0 +1,40 @@
<?php

namespace Elasticsearch\Endpoints\Remote;
use Elasticsearch\Endpoints\AbstractEndpoint;

/**
* Class Info
*
* @category Elasticsearch
* @package Elasticsearch\Endpoints\Cluster\Nodes
* @author Zachary Tong <zach@elastic.co>
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
* @link http://elastic.co
*/
class Info extends AbstractEndpoint
{
/**
* @return string
*/
public function getURI()
{
return "/_remote/info";
}

/**
* @return string[]
*/
public function getParamWhitelist()
{
return array();
}

/**
* @return string
*/
public function getMethod()
{
return 'GET';
}
}
34 changes: 34 additions & 0 deletions src/Elasticsearch/Namespaces/RemoteNamespace.php
@@ -0,0 +1,34 @@
<?php

namespace Elasticsearch\Namespaces;

use Elasticsearch\Endpoints\Remote\Info;

/**
* Class RemoteNamespace
*
* @category Elasticsearch
* @package Elasticsearch\Namespaces\TasksNamespace
* @author Zachary Tong <zach@elastic.co>
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache2
* @link http://elastic.co
*/
class RemoteNamespace extends AbstractNamespace
{
/**
* @param $params array Associative array of parameters
*
* @return array
*/
public function info($params = array())
{
/** @var callback $endpointBuilder */
$endpointBuilder = $this->endpoints;

/** @var Info $endpoint */
$endpoint = $endpointBuilder('Remote\Info');
$endpoint->setParams($params);

return $this->performRequest($endpoint);
}
}

0 comments on commit 82121d9

Please sign in to comment.