Skip to content

Commit

Permalink
Allowing entire kv tree to be downloaded
Browse files Browse the repository at this point in the history
  • Loading branch information
dcarbone committed Aug 3, 2016
1 parent db70b83 commit bb8f91e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/KV/KVClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,22 @@ public function get($key, QueryOptions $queryOptions = null)
* @type \DCarbone\PHPConsulAPI\Error|null error, if any
* )
*/
public function valueList($prefix, QueryOptions $queryOptions = null)
public function valueList($prefix = '', QueryOptions $queryOptions = null)
{
if (!is_string($prefix) || '' === $prefix)
if (!is_string($prefix))
{
return [null, null, new Error(sprintf(
'%s::valueList - Prefix expected to be non-empty string, "%s" seen.',
'%s::valueList - Prefix expected to be string, "%s" seen.',
get_class($this),
is_string($prefix) ? $prefix : gettype($prefix)
gettype($prefix)
))];
}

$r = new HttpRequest('get', sprintf('v1/kv/%s', $prefix), $this->_Config);
if ('' === $prefix)
$r = new HttpRequest('get', 'v1/kv', $this->_Config);
else
$r = new HttpRequest('get', sprintf('v1/kv/%s', $prefix), $this->_Config);

$r->setQueryOptions($queryOptions);
$r->params->set('recurse', '');

Expand Down Expand Up @@ -276,7 +280,7 @@ public function release(KVPair $p, WriteOptions $writeOptions = null)
* @type \DCarbone\PHPConsulAPI\Error|null error, if any
* )
*/
public function tree($prefix, QueryOptions $queryOptions = null)
public function tree($prefix = '', QueryOptions $queryOptions = null)
{
list($valueList, $_, $err) = $this->valueList($prefix, $queryOptions);

Expand Down

0 comments on commit bb8f91e

Please sign in to comment.