use of com.amazonaws.services.ec2.model.DeleteTagsRequest in project photon-model by vmware.
the class AWSUtils method unTagResources.
/**
* Synchronous UnTagging of one or many AWS resources with the provided tags.
*/
public static void unTagResources(AmazonEC2AsyncClient client, Collection<Tag> tags, String... resourceIds) {
if (isAwsClientMock()) {
return;
}
DeleteTagsRequest req = new DeleteTagsRequest().withTags(tags).withResources(resourceIds);
client.deleteTags(req);
}
use of com.amazonaws.services.ec2.model.DeleteTagsRequest in project camel by apache.
the class EC2Producer method deleteTags.
private void deleteTags(AmazonEC2Client ec2Client, Exchange exchange) {
Collection instanceIds;
Collection tags;
DeleteTagsRequest request = new DeleteTagsRequest();
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCES_IDS))) {
instanceIds = exchange.getIn().getHeader(EC2Constants.INSTANCES_IDS, Collection.class);
request.withResources(instanceIds);
} else {
throw new IllegalArgumentException("Instances Ids must be specified");
}
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCES_TAGS))) {
tags = exchange.getIn().getHeader(EC2Constants.INSTANCES_TAGS, Collection.class);
request.withTags(tags);
} else {
throw new IllegalArgumentException("Tags must be specified");
}
DeleteTagsResult result = new DeleteTagsResult();
try {
result = ec2Client.deleteTags(request);
} catch (AmazonServiceException ase) {
LOG.trace("Delete tags command returned the error code {}", ase.getErrorCode());
throw ase;
}
LOG.trace("Delete tags [{}] on resources with Ids [{}] ", Arrays.toString(tags.toArray()), Arrays.toString(instanceIds.toArray()));
Message message = getMessageForResponse(exchange);
message.setBody(result);
}
Aggregations