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


Java AuthorizeSecurityGroupIngressResult类代码示例

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


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

示例1: addIngressRulesAsync

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

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

        AWSDeferredResultAsyncHandler<AuthorizeSecurityGroupIngressRequest,
                AuthorizeSecurityGroupIngressResult>
                handler = new AWSDeferredResultAsyncHandler<AuthorizeSecurityGroupIngressRequest,
                AuthorizeSecurityGroupIngressResult>(this.service, message) {

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

示例2: addInnerIngressRule

import com.amazonaws.services.ec2.model.AuthorizeSecurityGroupIngressResult; //导入依赖的package包/类
public DeferredResult<Void> addInnerIngressRule(String securityGroupId) {
    AuthorizeSecurityGroupIngressRequest req = new AuthorizeSecurityGroupIngressRequest()
            .withGroupId(securityGroupId)
            .withIpPermissions(Collections.singletonList(buildInnerRule(securityGroupId)));

    String message = "Create internal Ingress Rule on AWS Security Group with id [" +
            securityGroupId + "].";

    AWSDeferredResultAsyncHandler<AuthorizeSecurityGroupIngressRequest,
            AuthorizeSecurityGroupIngressResult>
            handler = new AWSDeferredResultAsyncHandler<AuthorizeSecurityGroupIngressRequest,
            AuthorizeSecurityGroupIngressResult>(this.service, message) {

                @Override
                protected Exception consumeError(Exception e) {
                    if (e instanceof AmazonEC2Exception &&
                            ((AmazonEC2Exception)e).getErrorCode().equals
                                    (SECURITY_GROUP_RULE_DUPLICATE)) {
                        Utils.log(AWSUtils.class, AWSUtils.class.getSimpleName(),
                                Level.WARNING, () -> String
                                        .format("Ingress rule already exists: %s",
                                                Utils.toString(e)));
                        return null;
                    } else {
                        return e;
                    }
                }
            };
    this.client.authorizeSecurityGroupIngressAsync(req, handler);
    return handler.toDeferredResult()
            .thenApply(r -> (Void)null);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:33,代码来源:AWSSecurityGroupClient.java

示例3: authorizeSecurityGroupIngress

import com.amazonaws.services.ec2.model.AuthorizeSecurityGroupIngressResult; //导入依赖的package包/类
/**
 * Authorize SecurityGroup Ingress.
 * @param groupId the group id
 * @param ipProtocol ipProtocol for Ingress.
 * @param port portRange for Ingress.
 * @param cidrIp cidr Ip for Ingress
 * @return true if deleted, otherwise false.
 */
protected final boolean authorizeSecurityGroupIngress(final String groupId, final String ipProtocol, final Integer port, final String cidrIp) {
	AuthorizeSecurityGroupIngressRequest req = new AuthorizeSecurityGroupIngressRequest();
    req.setGroupId(groupId);
    req.setCidrIp(cidrIp);
    req.setFromPort(port);
    req.setToPort(port);
    req.setIpProtocol(ipProtocol);
    AuthorizeSecurityGroupIngressResult result = amazonEC2Client.authorizeSecurityGroupIngress(req);
    if (result != null) {
        return true;
    }

    return false;
}
 
开发者ID:treelogic-swe,项目名称:aws-mock,代码行数:23,代码来源:BaseTest.java

示例4: main

import com.amazonaws.services.ec2.model.AuthorizeSecurityGroupIngressResult; //导入依赖的package包/类
public static void main(String[] args)
{
    final String USAGE =
        "To run this example, supply a group name, group description and vpc id\n" +
        "Ex: CreateSecurityGroup <group-name> <group-description> <vpc-id>\n";

    if (args.length != 3) {
        System.out.println(USAGE);
        System.exit(1);
    }

    String group_name = args[0];
    String group_desc = args[1];
    String vpc_id = args[2];

    final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();

    CreateSecurityGroupRequest create_request = new
        CreateSecurityGroupRequest()
            .withGroupName(group_name)
            .withDescription(group_desc)
            .withVpcId(vpc_id);

    CreateSecurityGroupResult create_response =
        ec2.createSecurityGroup(create_request);

    System.out.printf(
        "Successfully created security group named %s",
        group_name);

    IpRange ip_range = new IpRange()
        .withCidrIp("0.0.0.0/0");

    IpPermission ip_perm = new IpPermission()
        .withIpProtocol("tcp")
        .withToPort(80)
        .withFromPort(80)
        .withIpv4Ranges(ip_range);

    IpPermission ip_perm2 = new IpPermission()
        .withIpProtocol("tcp")
        .withToPort(22)
        .withFromPort(22)
        .withIpv4Ranges(ip_range);

    AuthorizeSecurityGroupIngressRequest auth_request = new
        AuthorizeSecurityGroupIngressRequest()
            .withGroupName(group_name)
            .withIpPermissions(ip_perm, ip_perm2);

    AuthorizeSecurityGroupIngressResult auth_response =
        ec2.authorizeSecurityGroupIngress(auth_request);

    System.out.printf(
        "Successfully added ingress policy to security group %s",
        group_name);
}
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:58,代码来源:CreateSecurityGroup.java


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