public DeferredResult<Void> removeEgressRules(String groupId, List<IpPermission> rules) { if (CollectionUtils.isNotEmpty(rules)) { RevokeSecurityGroupEgressRequest req = new RevokeSecurityGroupEgressRequest() .withGroupId(groupId).withIpPermissions(rules); String message = "Remove Egress Rules from AWS Security Group with id [" + groupId + "]."; AWSDeferredResultAsyncHandler<RevokeSecurityGroupEgressRequest, RevokeSecurityGroupEgressResult> handler = new AWSDeferredResultAsyncHandler<RevokeSecurityGroupEgressRequest, RevokeSecurityGroupEgressResult>(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("Egress rules cannot be removed because " + "they do not exist: %s", Utils.toString(e))); return null; } else { return e; } } }; this.client.revokeSecurityGroupEgressAsync(req, handler); return handler.toDeferredResult() .thenApply(r -> (Void)null); } else { return DeferredResult.completed(null); } }
@Override public void revokeSecurityGroupEgress(RevokeSecurityGroupEgressRequest revokeSecurityGroupEgressRequest) throws AmazonServiceException, AmazonClientException { throw new UnsupportedOperationException("Not supported in mock"); }
@Override public void revokeEgress(RevokeSecurityGroupEgressRequest request) { revokeEgress(request, null); }
@Override public void revokeEgress(RevokeSecurityGroupEgressRequest request, ResultCapture<Void> extractor) { resource.performAction("RevokeEgress", request, extractor); }
/** * Performs the <code>RevokeEgress</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 RevokeSecurityGroupEgressRequest */ void revokeEgress(RevokeSecurityGroupEgressRequest request);
/** * Performs the <code>RevokeEgress</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 RevokeSecurityGroupEgressRequest */ void revokeEgress(RevokeSecurityGroupEgressRequest request, ResultCapture<Void> extractor);