-
Notifications
You must be signed in to change notification settings - Fork 964
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
/Cluster/Nodes endpoints should extend a base, abstract class
All endpoints use a NodeID, extending from an abstract class minimizes code copy/paste
- Loading branch information
1 parent
c386538
commit e60bca2
Showing
5 changed files
with
52 additions
and
87 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
src/Elasticsearch/Endpoints/Cluster/Nodes/AbstractNodesEndpoint.php
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,44 @@ | ||
<?php | ||
/** | ||
* User: zach | ||
* Date: 1/23/14 | ||
* Time: 6:03 PM | ||
*/ | ||
|
||
namespace Elasticsearch\Endpoints\Cluster\Nodes; | ||
|
||
|
||
use Elasticsearch\Common\Exceptions\InvalidArgumentException; | ||
use Elasticsearch\Endpoints\AbstractEndpoint; | ||
|
||
abstract class AbstractNodesEndpoint extends AbstractEndpoint | ||
{ | ||
/** @var string A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes */ | ||
protected $nodeID; | ||
|
||
|
||
/** | ||
* @param $nodeID | ||
* | ||
* @throws \Elasticsearch\Common\Exceptions\InvalidArgumentException | ||
* | ||
* @return $this | ||
*/ | ||
public function setNodeID($nodeID) | ||
{ | ||
if (isset($nodeID) !== true) { | ||
return $this; | ||
} | ||
|
||
if (!(is_array($nodeID) === true || is_string($nodeID) === true)) { | ||
throw new InvalidArgumentException("invalid node_id"); | ||
} | ||
|
||
if (is_array($nodeID) === true) { | ||
$nodeID = implode(',', $nodeID); | ||
} | ||
|
||
$this->nodeID = $nodeID; | ||
return $this; | ||
} | ||
} |
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
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
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
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