当前位置: 首页>>代码示例>>Java>>正文


Java RevokeSecurityGroupIngressRequest类代码示例

本文整理汇总了Java中com.amazonaws.services.ec2.model.RevokeSecurityGroupIngressRequest的典型用法代码示例。如果您正苦于以下问题:Java RevokeSecurityGroupIngressRequest类的具体用法?Java RevokeSecurityGroupIngressRequest怎么用?Java RevokeSecurityGroupIngressRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RevokeSecurityGroupIngressRequest类属于com.amazonaws.services.ec2.model包,在下文中一共展示了RevokeSecurityGroupIngressRequest类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeIngressRules

import com.amazonaws.services.ec2.model.RevokeSecurityGroupIngressRequest; //导入依赖的package包/类
public DeferredResult<Void> removeIngressRules(String groupId, List<IpPermission> rules) {
    if (CollectionUtils.isNotEmpty(rules)) {
        RevokeSecurityGroupIngressRequest req = new RevokeSecurityGroupIngressRequest()
                .withGroupId(groupId).withIpPermissions(rules);

        String message = "Remove Ingress Rules from AWS Security Group with id [" + groupId +
                "].";

        AWSDeferredResultAsyncHandler<RevokeSecurityGroupIngressRequest,
                RevokeSecurityGroupIngressResult>
                handler = new AWSDeferredResultAsyncHandler<RevokeSecurityGroupIngressRequest,
                RevokeSecurityGroupIngressResult>(this.service, message) {

                    @Override
                    protected Exception consumeError(Exception e) {
                        if (e instanceof AmazonEC2Exception &&
                                ((AmazonEC2Exception)e).getErrorCode().equals
                                        (SECURITY_GROUP_RULE_NOT_FOUND)) {
                            Utils.log(AWSUtils.class, AWSUtils.class.getSimpleName(),
                                    Level.WARNING, () -> String
                                            .format("Ingress rules cannot be removed because "
                                                    + "they do not exist: %s",
                                                    Utils.toString(e)));
                            return null;
                        } else {
                            return e;
                        }
                    }
                };
        this.client.revokeSecurityGroupIngressAsync(req, handler);
        return handler.toDeferredResult()
                .thenApply(r -> (Void)null);
    } else {
        return DeferredResult.completed(null);
    }
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:37,代码来源:AWSSecurityGroupClient.java

示例2: run

import com.amazonaws.services.ec2.model.RevokeSecurityGroupIngressRequest; //导入依赖的package包/类
@Override
public void run(final WhitelistCidrForVpcAccessCommand command) {
    final BaseOutputs baseStackOutputs = configStore.getBaseStackOutputs();

    logger.info("Revoking the previous ingress rules...");
    final DescribeSecurityGroupsResult securityGroupsResult = ec2Client.describeSecurityGroups(
            new DescribeSecurityGroupsRequest().withGroupIds(baseStackOutputs.getToolsIngressSgId()));
    securityGroupsResult.getSecurityGroups().forEach(securityGroup -> {
        if (!securityGroup.getIpPermissions().isEmpty()) {
            RevokeSecurityGroupIngressRequest revokeIngressRequest = new RevokeSecurityGroupIngressRequest()
                    .withGroupId(baseStackOutputs.getToolsIngressSgId())
                    .withIpPermissions(securityGroup.getIpPermissions());
            ec2Client.revokeSecurityGroupIngress(revokeIngressRequest);
        }
    });
    logger.info("Done.");

    logger.info("Authorizing the new ingress rules...");
    final List<IpPermission> ipPermissionList = Lists.newArrayListWithCapacity(command.getPorts().size());
    command.getPorts().forEach(port -> {
        IpPermission ipPermission = new IpPermission()
                .withIpRanges(command.getCidrs())
                .withIpProtocol("tcp")
                .withFromPort(port)
                .withToPort(port);

        ipPermissionList.add(ipPermission);
    });

    AuthorizeSecurityGroupIngressRequest ingressRequest = new AuthorizeSecurityGroupIngressRequest()
            .withGroupId(baseStackOutputs.getToolsIngressSgId())
            .withIpPermissions(ipPermissionList);
    ec2Client.authorizeSecurityGroupIngress(ingressRequest);
    logger.info("Done.");
}
 
开发者ID:Nike-Inc,项目名称:cerberus-lifecycle-cli,代码行数:36,代码来源:WhitelistCidrForVpcAccessOpertaion.java

示例3: deleteSGIngressRules

import com.amazonaws.services.ec2.model.RevokeSecurityGroupIngressRequest; //导入依赖的package包/类
public void deleteSGIngressRules(String securityGroupId, List<IpPermission> rules) {
    logger.info("delete ingress sg rules, sgId={}, rules={}", securityGroupId, rules);

    ec2.revokeSecurityGroupIngress(new RevokeSecurityGroupIngressRequest()
        .withGroupId(securityGroupId)
        .withIpPermissions(rules));
}
 
开发者ID:neowu,项目名称:cmn-project,代码行数:8,代码来源:EC2.java

示例4: revokeIngressRules

import com.amazonaws.services.ec2.model.RevokeSecurityGroupIngressRequest; //导入依赖的package包/类
@Test
public void revokeIngressRules() {
  amazonEc2.setRegion(region);
  amazonEc2.revokeSecurityGroupIngress(new RevokeSecurityGroupIngressRequest(
      "securityGroupName", ImmutableList.of(ipPermission(7000, "4.4.4.4/32"))));
  replayAll();
  service().revokeIngressRules("securityGroupName", "dc1", groupPermission(7000, "4.4.4.4/32"));
}
 
开发者ID:signal,项目名称:agathon,代码行数:9,代码来源:Ec2SecurityGroupServiceTest.java

示例5: revokeIngressRules

import com.amazonaws.services.ec2.model.RevokeSecurityGroupIngressRequest; //导入依赖的package包/类
private void revokeIngressRules(AmazonEC2 client, String groupName, Set<IpPermission> ipPermissions) {
    if (!ipPermissions.isEmpty()) {
        LOG.info(">> Revoking Security Group Ingress Rules: {} for {}", ipPermissions, groupName);

        RevokeSecurityGroupIngressRequest request = new RevokeSecurityGroupIngressRequest()
            .withGroupName(groupName).withIpPermissions(ipPermissions);
        client.revokeSecurityGroupIngress(request);
    }
}
 
开发者ID:apache,项目名称:incubator-provisionr,代码行数:10,代码来源:EnsureSecurityGroupExists.java

示例6: revokeAnyRule

import com.amazonaws.services.ec2.model.RevokeSecurityGroupIngressRequest; //导入依赖的package包/类
private Set<Rule> revokeAnyRule(Set<Rule> ingressRules) {
    List<IpPermission> permissions = newArrayList(transform(ingressRules, ConvertRuleToIpPermission.FUNCTION));
    Collections.shuffle(permissions);

    IpPermission permission = permissions.get(0);
    LOG.info(">> Revoking permission {} on {} for test.", permission, SECURITY_GROUP_NAME);

    client.revokeSecurityGroupIngress(new RevokeSecurityGroupIngressRequest()
        .withGroupName(SECURITY_GROUP_NAME).withIpPermissions(permission));

    return Sets.difference(ingressRules, ImmutableSet.of(ConvertIpPermissionToRule.FUNCTION.apply(permission)));
}
 
开发者ID:apache,项目名称:incubator-provisionr,代码行数:13,代码来源:EnsureSecurityGroupExistsLiveTest.java

示例7: deleteRules

import com.amazonaws.services.ec2.model.RevokeSecurityGroupIngressRequest; //导入依赖的package包/类
@Override
public void deleteRules( final String name, final Collection<IpRule> ipRules ) {
    if( ipRules == null || ipRules.size() == 0 ) {
        return;
    }
    Collection<IpPermission> permissions = new ArrayList<IpPermission>( ipRules.size() );
    for( IpRule rule : ipRules ) {
        permissions.add( toIpPermission( rule ) );
    }

    RevokeSecurityGroupIngressRequest request = new RevokeSecurityGroupIngressRequest();
    request = request.withGroupName( name ).withIpPermissions( permissions );
    client.revokeSecurityGroupIngress( request );
}
 
开发者ID:apache,项目名称:usergrid,代码行数:15,代码来源:AmazonIpRuleManager.java

示例8: revokeSecurityGroupIngress

import com.amazonaws.services.ec2.model.RevokeSecurityGroupIngressRequest; //导入依赖的package包/类
@Override
public void revokeSecurityGroupIngress(RevokeSecurityGroupIngressRequest revokeSecurityGroupIngressRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AmazonEC2Mock.java

示例9: revokeIngress

import com.amazonaws.services.ec2.model.RevokeSecurityGroupIngressRequest; //导入依赖的package包/类
@Override
public void revokeIngress(RevokeSecurityGroupIngressRequest request) {
    revokeIngress(request, null);
}
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:5,代码来源:SecurityGroupImpl.java

示例10: revokeIngressRules

import com.amazonaws.services.ec2.model.RevokeSecurityGroupIngressRequest; //导入依赖的package包/类
@Override
public void revokeIngressRules(String groupName, String dataCenter, SecurityGroupPermission permission) {
  client(dataCenter).revokeSecurityGroupIngress(
      new RevokeSecurityGroupIngressRequest(groupName, toIpPermissions(permission)));
}
 
开发者ID:signal,项目名称:agathon,代码行数:6,代码来源:Ec2SecurityGroupService.java

示例11: revokeIngress

import com.amazonaws.services.ec2.model.RevokeSecurityGroupIngressRequest; //导入依赖的package包/类
/**
 * Performs the <code>RevokeIngress</code> action.
 *
 * <p>
 * The following request parameters will be populated from the data of this
 * <code>SecurityGroup</code> resource, and any conflicting parameter value
 * set in the request will be overridden:
 * <ul>
 *   <li>
 *     <b><code>GroupId</code></b>
 *         - mapped from the <code>Id</code> identifier.
 *   </li>
 * </ul>
 *
 * <p>
 *
 * @see RevokeSecurityGroupIngressRequest
 */
void revokeIngress(RevokeSecurityGroupIngressRequest request);
 
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:20,代码来源:SecurityGroup.java


注:本文中的com.amazonaws.services.ec2.model.RevokeSecurityGroupIngressRequest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。