public function updateNode(Node $node, ParameterBag $parameters)
{
$allowableParamKeys = array('name', 'accessIPv4', 'accessIPv6');
$requestedParamKeys = $parameters->keys();
if (0 == sizeof($requestedParamKeys)) {
throw new \UnexpectedValueException(sprintf('Expected values for any of the following properties, but got none: "%s".', implode(', ', $allowableParamKeys)));
}
$permittedKeys = array_intersect($requestedParamKeys, $allowableParamKeys);
$prohibitedKeys = array_diff($requestedParamKeys, $permittedKeys);
if (sizeof($prohibitedKeys)) {
throw new \UnexpectedValueException(sprintf('Expected values for any of the following properties "%s". ' . 'The following requested properties are not allowed: "%s".', implode(', ', $allowableParamKeys), implode(', ', $prohibitedKeys)));
}
$updates = array();
foreach ($permittedKeys as $k) {
$updates[$k] = $parameters->get($k);
}
$response = $this->toServer($node)->update($updates);
# It would be nice to have an updateNodeFromServer so that the caller
# gets the updates (which $server now has) for their Node. For now, just
# send some more API requests...
$nodes = $this->listNodes($node->getId());
# and update the few properties that might have changed
$node->setName($nodes[0]->getName());
$node->setPublicIps($nodes[0]->getPublicIps());
$node->setState($nodes[0]->getState());
$node->setExtra($nodes[0]->getExtra());
return $response;
}