Skip to content

Commit

Permalink
Added getNodeList() function to zone
Browse files Browse the repository at this point in the history
  • Loading branch information
tfountain committed Nov 3, 2016
1 parent a61886a commit 2fd8fa9
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Requires PHP **5.3.23** or above. The cURL extension is recommended (although no
The best way to install this SDK is with [Composer](http://getcomposer.org). Add the package [`dyninc/dyn-php`](https://packagist.org/packages/dyninc/dyn-php) to the `require` section of your `composer.json`:

"require": {
"dyninc/dyn-php": "0.7.1"
"dyninc/dyn-php": "0.8.0"
}

then run `composer install` to install the SDK along with its dependencies.
Expand Down
22 changes: 22 additions & 0 deletions src/TrafficManagement/Zone.php
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,28 @@ public function deleteService(ServiceInterface $service)
return false;
}

/**
* Returns an array of nodes for the zone
*
* @param string $fqdn Optional FQDN beneath which to return nodes
* @return boolean|array
*/
public function getNodeList($fqdn = null)
{
$path = '/NodeList/'.$this->name;
if ($fqdn) {
$path .= '/'.$fqdn;
}
$path .= '/';

$result = $this->apiClient->get($path);
if ($result && $result->isComplete()) {
return $result->data;
}

return false;
}

/**
* Publish changes made to the zone
*
Expand Down
30 changes: 30 additions & 0 deletions test/DynTest/TrafficManagement/ZoneTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,34 @@ public function testGetAllRecords()
$this->zone->getAllRecords()
);
}

public function testGetNodeList()
{
// simulate the Dyn API response
$this->apiClient->getHttpClient()->getAdapter()->setResponse(
"HTTP/1.1 200 OK" . "\r\n" .
"Content-type: application/json" . "\r\n\r\n" .
'{"status": "success", "data": ["foo.example.com", "bar.example.com"], "job_id": 12345678, "msgs": [{"INFO": "get_node_list: Here is your node list", "SOURCE": "BLL", "ERR_CD": null, "LVL": "INFO"}]}'
);

$this->assertEquals(
array('foo.example.com', 'bar.example.com'),
$this->zone->getNodeList()
);
}

public function testGetNodeListWithFQDN()
{
// simulate the Dyn API response
$this->apiClient->getHttpClient()->getAdapter()->setResponse(
"HTTP/1.1 200 OK" . "\r\n" .
"Content-type: application/json" . "\r\n\r\n" .
'{"status": "success", "data": ["foo.example.com"], "job_id": 12345678, "msgs": [{"INFO": "get_node_list: Here is your node list", "SOURCE": "BLL", "ERR_CD": null, "LVL": "INFO"}]}'
);

$this->assertEquals(
array('foo.example.com'),
$this->zone->getNodeList('foo.example.com')
);
}
}

0 comments on commit 2fd8fa9

Please sign in to comment.