本文整理汇总了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);
}
}
示例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.");
}
示例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));
}
示例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"));
}
示例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);
}
}
示例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)));
}
示例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 );
}
示例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");
}
示例9: revokeIngress
import com.amazonaws.services.ec2.model.RevokeSecurityGroupIngressRequest; //导入依赖的package包/类
@Override
public void revokeIngress(RevokeSecurityGroupIngressRequest request) {
revokeIngress(request, null);
}
示例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)));
}
示例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);