public function modifyNetworkInterfaceAttribute($networkInterfaceId, NetworkInterfaceAttributeType $attr, $value)
{
$result = false;
$options = array('NetworkInterfaceId' => (string) $networkInterfaceId);
$action = ucfirst(__FUNCTION__);
$attr = (string) $attr;
if ($attr == NetworkInterfaceAttributeType::ATTR_DESCRIPTION) {
$options['Description.Value'] = (string) $value;
} elseif ($attr == NetworkInterfaceAttributeType::ATTR_GROUP_SET) {
if ($value instanceof GroupList) {
$s = array();
foreach ($value as $v) {
$s[] = $v->groupId;
}
$value = new ListDataType($s);
unset($s);
} elseif (!$value instanceof ListDataType) {
$value = new ListDataType($value);
}
$options = array_merge($options, $value->getQueryArrayBare('SecurityGroupId'));
} elseif ($attr == NetworkInterfaceAttributeType::ATTR_SOURCE_DEST_CHECK) {
$options['SourceDestCheck.Value'] = $value === 'true' || $value === 'false' ? $value : ($value ? true : false);
} elseif ($attr == NetworkInterfaceAttributeType::ATTR_ATTACHMENT) {
if ($value instanceof NetworkInterfaceAttachmentData) {
if ($value->attachmentId !== null) {
$options['Attachment.AttachmentId'] = $value->attachmentId;
}
if ($value->deleteOnTermination !== null) {
$options['Attachment.DeleteOnTermination'] = $value->deleteOnTermination ? 'true' : 'false';
}
} elseif (is_array($value) && (array_key_exists('attachmentId', $value) || array_key_exists('deleteOnTermination', $value))) {
if ($value['attachmentId'] !== null) {
$options['Attachment.AttachmentId'] = $value['attachmentId'];
}
if ($value['deleteOnTermination'] !== null) {
$options['Attachment.DeleteOnTermination'] = $value['deleteOnTermination'] === 'true' || $value['deleteOnTermination'] === 'false' ? $value['deleteOnTermination'] : ($value['deleteOnTermination'] ? true : false);
}
} else {
throw new \BadFunctionCallException(sprintf('Invalid value for the "attachment" attribute in %s call', $action));
}
}
$response = $this->client->call($action, $options);
if ($response->getError() === false) {
$sxml = simplexml_load_string($response->getRawContent());
if ((string) $sxml->return != 'true') {
throw new Ec2Exception(sprintf('Amazon Ec2 could not %s NetworkInterfaceId:"%s" Attribute:"%s". It returned "%s"', $action, $options['NetworkInterfaceId'], $attr, $sxml->return));
}
$result = true;
$entity = $this->ec2->getEntityManagerEnabled() ? $this->ec2->networkInterface->get($options['NetworkInterfaceId']) : null;
//It does not update attribute value stored in the entity manager.
}
return $result;
}