use of com.amazonaws.services.ec2.model.RevokeSecurityGroupEgressResult in project photon-model by vmware.
the class AWSSecurityGroupClient method removeEgressRules.
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);
}
}
Aggregations