Java 类com.amazonaws.services.ec2.model.AuthorizeSecurityGroupEgressRequest 实例源码

项目:photon-model    文件:AWSSecurityGroupClient.java   
public DeferredResult<Void> addEgressRules(String groupId, List<IpPermission> rules) {
    if (CollectionUtils.isNotEmpty(rules)) {
        AuthorizeSecurityGroupEgressRequest req = new AuthorizeSecurityGroupEgressRequest()
                .withGroupId(groupId).withIpPermissions(rules);

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

        AWSDeferredResultAsyncHandler<AuthorizeSecurityGroupEgressRequest,
                AuthorizeSecurityGroupEgressResult>
                handler = new AWSDeferredResultAsyncHandler<AuthorizeSecurityGroupEgressRequest,
                AuthorizeSecurityGroupEgressResult>(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("Egress rules already exist: %s",
                                                    Utils.toString(e)));
                            return null;
                        } else {
                            return e;
                        }
                    }
                };
        this.client.authorizeSecurityGroupEgressAsync(req, handler);
        return handler.toDeferredResult()
                .thenApply(r -> (Void)null);
    } else {
        return DeferredResult.completed(null);
    }
}
项目:photon-model    文件:AWSSecurityGroupClient.java   
public DeferredResult<Void> addInnerEgressRule(String securityGroupId) {
    AuthorizeSecurityGroupEgressRequest req = new AuthorizeSecurityGroupEgressRequest()
            .withGroupId(securityGroupId)
            .withIpPermissions(Collections.singletonList(buildInnerRule(securityGroupId)));

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

    AWSDeferredResultAsyncHandler<AuthorizeSecurityGroupEgressRequest,
            AuthorizeSecurityGroupEgressResult>
            handler = new AWSDeferredResultAsyncHandler<AuthorizeSecurityGroupEgressRequest,
            AuthorizeSecurityGroupEgressResult>(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("Egress rule already exists: %s",
                                                Utils.toString(e)));
                        return null;
                    } else {
                        return e;
                    }
                }
            };
    this.client.authorizeSecurityGroupEgressAsync(req, handler);
    return handler.toDeferredResult()
            .thenApply(r -> (Void)null);
}
项目:aws-mock    文件:BaseTest.java   
/**
 * Authorize SecurityGroup Egress.
 * @param groupId the group id
 * @param ipProtocol ipProtocol for Egress.
 * @param port portRange for Egress.
 * @param cidrIp cidr Ip for Egress
 * @return true if deleted, otherwise false.
 */
protected final boolean authorizeSecurityGroupEgress(final String groupId, final String ipProtocol, final Integer port, final String cidrIp) {
    AuthorizeSecurityGroupEgressRequest req = new AuthorizeSecurityGroupEgressRequest();
    req.setGroupId(groupId);
    req.setCidrIp(cidrIp);
    req.setFromPort(port);
    req.setToPort(port);
    req.setIpProtocol(ipProtocol);
    AuthorizeSecurityGroupEgressResult result = amazonEC2Client.authorizeSecurityGroupEgress(req);
    if (result != null) {
        return true;
    }

    return false;
}
项目:elasticsearch_my    文件:AmazonEC2Mock.java   
@Override
public void authorizeSecurityGroupEgress(AuthorizeSecurityGroupEgressRequest authorizeSecurityGroupEgressRequest) throws AmazonServiceException, AmazonClientException {
    throw new UnsupportedOperationException("Not supported in mock");
}
项目:aws-sdk-java-resources    文件:SecurityGroupImpl.java   
@Override
public void authorizeEgress(AuthorizeSecurityGroupEgressRequest request) {
    authorizeEgress(request, null);
}
项目:aws-sdk-java-resources    文件:SecurityGroupImpl.java   
@Override
public void authorizeEgress(AuthorizeSecurityGroupEgressRequest request,
        ResultCapture<Void> extractor) {

    resource.performAction("AuthorizeEgress", request, extractor);
}
项目:aws-sdk-java-resources    文件:SecurityGroup.java   
/**
 * Performs the <code>AuthorizeEgress</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 AuthorizeSecurityGroupEgressRequest
 */
void authorizeEgress(AuthorizeSecurityGroupEgressRequest request);
项目:aws-sdk-java-resources    文件:SecurityGroup.java   
/**
 * Performs the <code>AuthorizeEgress</code> action and use a ResultCapture
 * to retrieve the low-level client response.
 *
 * <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 AuthorizeSecurityGroupEgressRequest
 */
void authorizeEgress(AuthorizeSecurityGroupEgressRequest request,
        ResultCapture<Void> extractor);