Example usage for com.amazonaws.services.ec2.model ModifyImageAttributeRequest setLaunchPermission

List of usage examples for com.amazonaws.services.ec2.model ModifyImageAttributeRequest setLaunchPermission

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model ModifyImageAttributeRequest setLaunchPermission.

Prototype


public void setLaunchPermission(LaunchPermissionModifications launchPermission) 

Source Link

Document

A new launch permission for the AMI.

Usage

From source file:com.zotoh.cloudapi.aws.AMImage.java

License:Open Source License

@Override
public void shareMachineImage(String ami, final String acct, boolean allow)
        throws CloudException, InternalException {
    tstEStrArg("image-id", ami);
    LaunchPermissionModifications perms = new LaunchPermissionModifications();
    List<LaunchPermission> lst;
    ModifyImageAttributeRequest req = new ModifyImageAttributeRequest().withImageId(ami);
    LaunchPermission lp = new LaunchPermission();
    lst = toObjList(isEmpty(acct) ? lp.withGroup("all") : lp.withUserId(acct));
    if (allow) {/*from  w  w w .  ja  v  a  2s . co m*/
        perms.setAdd(lst);
    } else {
        perms.setRemove(lst);
    }
    req.setLaunchPermission(perms);
    _svc.getCloud().getEC2().modifyImageAttribute(req);
}