public static void main(String[] args) { final String USAGE = "To run this example, supply an alarm name\n" + "Ex: DeleteAlarm <alarm-name>\n"; if (args.length != 1) { System.out.println(USAGE); System.exit(1); } String alarm_name = args[0]; final AmazonCloudWatch cw = AmazonCloudWatchClientBuilder.defaultClient(); DeleteAlarmsRequest request = new DeleteAlarmsRequest() .withAlarmNames(alarm_name); DeleteAlarmsResult response = cw.deleteAlarms(request); System.out.printf("Successfully deleted alarm %s", alarm_name); }
@Test public void testDeleteAlarm() { final String alarmName = "testAlarmName"; awsHelperService.deleteAlarm(alarmName); final ArgumentCaptor<DeleteAlarmsRequest> argumentCaptor = ArgumentCaptor.forClass(DeleteAlarmsRequest.class); verify(amazonCloudWatch).deleteAlarms(argumentCaptor.capture()); assertThat(argumentCaptor.getValue().getAlarmNames().get(0), equalTo(alarmName)); }
/** * * @param email * @param jobId */ public void removeWatch(String email, String jobId) { String alarmName = getAlarmName(email, jobId); for (MetricAlarm a : asynchCloudWatchClient.describeAlarms().getMetricAlarms()) { if (a.getAlarmName().equalsIgnoreCase(alarmName)) { DeleteAlarmsRequest req = new DeleteAlarmsRequest().withAlarmNames(alarmName); asynchCloudWatchClient.deleteAlarmsAsync(req); } } }
public void deleteAlarms(List<String> alarmNames) { logger.info("delete alarms, alarms={}", alarmNames); cloudWatch.deleteAlarms(new DeleteAlarmsRequest().withAlarmNames(alarmNames)); }