//snippet-sourcedescription:[DeleteAlarm.java demonstrates how to delete a CloudWatch alarm.]
//snippet-keyword:[SDK for Java 2.0]
//snippet-keyword:[Code Sample]
//snippet-service:[cloudwatch]
//snippet-sourcetype:[full-example]
//snippet-sourcedate:[]
//snippet-sourceauthor:[soo-aws]
// snippet-start:[cloudwatch.java2.delete_metrics.complete]
/*
 * Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License").
 * You may not use this file except in compliance with the License.
 * A copy of the License is located at
 *
 *  http://aws.amazon.com/apache2.0
 *
 * or in the "license" file accompanying this file. This file is distributed
 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied. See the License for the specific language governing
 * permissions and limitations under the License.
 */
package com.example.cloudwatch;
// snippet-start:[cloudwatch.java2.delete_metrics.import]
import software.amazon.awssdk.services.cloudwatch.CloudWatchClient;
import software.amazon.awssdk.services.cloudwatch.model.DeleteAlarmsRequest;
import software.amazon.awssdk.services.cloudwatch.model.DeleteAlarmsResponse;
// snippet-end:[cloudwatch.java2.delete_metrics.import]

/**
 * Deletes a CloudWatch alarm
 */
public class DeleteAlarm {
    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];

        // snippet-start:[cloudwatch.java2.delete_metrics.main]
        CloudWatchClient cw = CloudWatchClient.builder().build();


        DeleteAlarmsRequest request = DeleteAlarmsRequest.builder()
            .alarmNames(alarm_name).build();

        DeleteAlarmsResponse response = cw.deleteAlarms(request);

        System.out.printf("Successfully deleted alarm %s", alarm_name);
        // snippet-end:[cloudwatch.java2.delete_metrics.main]
    }
}
// snippet-end:[cloudwatch.java2.delete_metrics.complete]
@@ -250,16 +250,26 @@
 cedate:%5B
+12/12/2020
 %5D%0D%0A//sni
@@ -292,74 +292,15 @@
 r:%5Bs
-oo-aws%5D%0A// snippet-start:%5Bcloudwatch.java2.delete_metrics.complete
+cmacdon
 %5D%0D%0A/
@@ -326,10 +326,10 @@
 0-20
-19
+20
  Ama
@@ -895,16 +895,78 @@
 se.%0D%0A */
+%0D%0A// snippet-start:%5Bcloudwatch.java2.delete_metrics.complete%5D%0D
 %0Apackage
@@ -1115,24 +1115,102 @@
 tchClient;%0D%0A
+import software.amazon.awssdk.services.cloudwatch.model.CloudWatchException;%0D%0A
 import softw
@@ -1452,16 +1452,17 @@
 arm%0D%0A */
+%0D
 %0Apublic 
@@ -1572,16 +1572,20 @@
         
+    
 %22To run 
@@ -1625,16 +1625,28 @@
 e%5Cn%22 +%0D%0A
+            
         
@@ -1805,48 +1805,8 @@
 %0D%0A%0D%0A
-        String alarm_name = args%5B0%5D;%0D%0A%0D%0A
     
@@ -1862,24 +1862,80 @@
 rics.main%5D%0D%0A
+        String alarmName = args%5B0%5D;%0D%0A        try %7B%0D%0A    
         Clou
@@ -1991,18 +1991,20 @@
 d();%0D%0A%0D%0A
-%0D%0A
+    
         
@@ -2076,16 +2076,20 @@
         
+    
 .alarmNa
@@ -2093,26 +2093,25 @@
 mNames(alarm
-_n
+N
 ame).build()
@@ -2107,32 +2107,36 @@
 me).build();%0D%0A%0D%0A
+    
         DeleteAl
@@ -2182,26 +2182,28 @@
 (request);%0D%0A
-%0D%0A
+    
         Syst
@@ -2258,15 +2258,168 @@
 larm
-_name);
+Name);%0D%0A%0D%0A        %7D catch (CloudWatchException e) %7B%0D%0A            System.err.println(e.awsErrorDetails().errorMessage());%0D%0A            System.exit(1);%0D%0A        %7D
 %0D%0A  
@@ -2526,28 +2526,30 @@
 va2.delete_metrics.complete%5D
+%0D%0A

Update DeleteAlarm.java