Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
77 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
namespace SensioLabs\Consul\Services; | ||
|
||
use SensioLabs\Consul\Client; | ||
use SensioLabs\Consul\OptionsResolver; | ||
|
||
class Catalog | ||
{ | ||
private $client; | ||
|
||
public function __construct(Client $client = null) | ||
{ | ||
$this->client = $client ?: new Client(); | ||
} | ||
|
||
public function register($node) | ||
{ | ||
$params = array( | ||
'body' => (string) $node, | ||
); | ||
|
||
return $this->client->get('/v1/catalog/register', $params); | ||
} | ||
|
||
public function deregister($node) | ||
{ | ||
$params = array( | ||
'body' => (string) $node, | ||
); | ||
|
||
return $this->client->get('/v1/catalog/deregister', $params); | ||
} | ||
|
||
public function datacenters() | ||
{ | ||
return $this->client->get('/v1/catalog/datacenters'); | ||
} | ||
|
||
public function nodes(array $options = array()) | ||
{ | ||
$params = array( | ||
'query' => OptionsResolver::resolve($options, array('dc')), | ||
); | ||
|
||
return $this->client->get('/v1/catalog/nodes', $params); | ||
} | ||
|
||
public function node($node, array $options = array()) | ||
{ | ||
$params = array( | ||
'query' => OptionsResolver::resolve($options, array('dc')), | ||
); | ||
|
||
return $this->client->get('/v1/catalog/node/'.$node, $params); | ||
} | ||
|
||
public function services(array $options = array()) | ||
{ | ||
$params = array( | ||
'query' => OptionsResolver::resolve($options, array('dc')), | ||
); | ||
|
||
return $this->client->get('/v1/catalog/services', $params); | ||
} | ||
|
||
public function service($service, array $options = array()) | ||
{ | ||
$params = array( | ||
'query' => OptionsResolver::resolve($options, array('dc', 'tag')), | ||
); | ||
|
||
return $this->client->get('/v1/catalog/service/'.$service, $params); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -59,6 +59,7 @@ Available services | |
------------------ | ||
|
||
* agent | ||
* catalog | ||
* health | ||
* kv | ||
* session |