request.setDevice( avt.getDevice());
return toDetachVolumeResponse( engine.detachVolume( request ));
}
public ModifyImageAttributeResponse modifyImageAttribute(ModifyImageAttribute modifyImageAttribute) {
EC2ModifyImageAttribute EC2request = new EC2ModifyImageAttribute();
ModifyImageAttributeType miat = modifyImageAttribute.getModifyImageAttribute();
ModifyImageAttributeTypeChoice_type0 item = miat.getModifyImageAttributeTypeChoice_type0();
// description is unsupported
AttributeValueType description = item.getDescription();
LaunchPermissionOperationType launchPermission = item.getLaunchPermission();
LaunchPermissionListType launchAdd = launchPermission.getAdd();
LaunchPermissionItemType[] adds = null;
if (launchAdd != null) {
adds = launchAdd.getItem();
}
LaunchPermissionListType launchRemove = launchPermission.getRemove();
LaunchPermissionItemType[] removes = null;
if (launchRemove != null) {
removes = launchRemove.getItem();
}
// we'll silently ignore productcodes for now
// ProductCodeListType productCodes = item.getProductCodes();
// set imageId
EC2request.setImageId(miat.getImageId());
// add users/group
if (adds != null) {
for (LaunchPermissionItemType addItems : adds) {
if (addItems.getUserId() != null) {
EC2request.addAddedUser(addItems.getUserId());
}
// according to api, all is the only legitimate value
if (addItems.getGroup() != null && addItems.getGroup().equalsIgnoreCase("all")) {
EC2request.setIsPublic(true);
}
}
}
// add remove users/group
if (removes != null) {
for (LaunchPermissionItemType removeItems : removes) {
if (removeItems.getUserId() != null) {
EC2request.addRemovedUser(removeItems.getUserId());
}
// according to api, all is the only legitimate value
if (removeItems.getGroup() != null && removeItems.getGroup().equalsIgnoreCase("all")) {
EC2request.setIsPublic(false);
}
}
}
// unsupported description
if (description != null) {
EC2request.setDescription(description.getValue());
}
return toModifyImageAttributeResponse(engine.modifyImageAttribute(EC2request));
}