use of com.amazonaws.services.ec2.model.UnmonitorInstancesResult in project camel by apache.
the class EC2Producer method unmonitorInstances.
private void unmonitorInstances(AmazonEC2Client ec2Client, Exchange exchange) {
Collection instanceIds;
UnmonitorInstancesRequest request = new UnmonitorInstancesRequest();
if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(EC2Constants.INSTANCES_IDS))) {
instanceIds = exchange.getIn().getHeader(EC2Constants.INSTANCES_IDS, Collection.class);
request.withInstanceIds(instanceIds);
} else {
throw new IllegalArgumentException("Instances Ids must be specified");
}
UnmonitorInstancesResult result;
try {
result = ec2Client.unmonitorInstances(request);
} catch (AmazonServiceException ase) {
LOG.trace("Unmonitor Instances command returned the error code {}", ase.getErrorCode());
throw ase;
}
LOG.trace("Stop Monitoring instances with Ids [{}] ", Arrays.toString(instanceIds.toArray()));
Message message = getMessageForResponse(exchange);
message.setBody(result);
}
use of com.amazonaws.services.ec2.model.UnmonitorInstancesResult in project camel by apache.
the class AmazonEC2ClientMock method unmonitorInstances.
@Override
public UnmonitorInstancesResult unmonitorInstances(UnmonitorInstancesRequest unmonitorInstancesRequest) {
UnmonitorInstancesResult result = new UnmonitorInstancesResult();
if (!unmonitorInstancesRequest.getInstanceIds().isEmpty()) {
Collection<InstanceMonitoring> coll = new ArrayList();
Iterator it = unmonitorInstancesRequest.getInstanceIds().iterator();
while (it.hasNext()) {
String id = (String) it.next();
InstanceMonitoring mon = new InstanceMonitoring();
mon.setInstanceId(id);
Monitoring monitoring = new Monitoring();
monitoring.setState(MonitoringState.Disabled);
mon.setMonitoring(monitoring);
coll.add(mon);
}
result.setInstanceMonitorings(coll);
}
return result;
}
use of com.amazonaws.services.ec2.model.UnmonitorInstancesResult in project camel by apache.
the class EC2ProducerTest method ec2UnmonitorInstancesTest.
@Test
public void ec2UnmonitorInstancesTest() throws Exception {
mock.expectedMessageCount(1);
Exchange exchange = template.request("direct:unmonitor", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Collection l = new ArrayList();
l.add("test-1");
exchange.getIn().setHeader(EC2Constants.INSTANCES_IDS, l);
}
});
assertMockEndpointsSatisfied();
UnmonitorInstancesResult resultGet = (UnmonitorInstancesResult) exchange.getIn().getBody();
assertEquals(resultGet.getInstanceMonitorings().size(), 1);
assertEquals(resultGet.getInstanceMonitorings().get(0).getInstanceId(), "test-1");
assertEquals(resultGet.getInstanceMonitorings().get(0).getMonitoring().getState(), MonitoringState.Disabled.toString());
}
use of com.amazonaws.services.ec2.model.UnmonitorInstancesResult in project camel by apache.
the class EC2ComponentSpringTest method ec2UnmonitorInstancesTest.
@Test
public void ec2UnmonitorInstancesTest() throws Exception {
Exchange exchange = template.request("direct:unmonitor", new Processor() {
@Override
public void process(Exchange exchange) throws Exception {
Collection l = new ArrayList();
l.add("test-1");
exchange.getIn().setHeader(EC2Constants.INSTANCES_IDS, l);
}
});
UnmonitorInstancesResult resultGet = (UnmonitorInstancesResult) exchange.getOut().getBody();
assertEquals(resultGet.getInstanceMonitorings().size(), 1);
assertEquals(resultGet.getInstanceMonitorings().get(0).getInstanceId(), "test-1");
assertEquals(resultGet.getInstanceMonitorings().get(0).getMonitoring().getState(), MonitoringState.Disabled.toString());
}
Aggregations