/**
 * Copyright 2010-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
 *
 * This file is 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/
 *
 * 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.
 *
 */

// snippet-comment:[These are tags for the AWS doc team's sample catalog. Do not remove.]
// snippet-sourcedescription:[DeleteFunction.java demonstrates how to delete an AWS Lambda function by using the LambdaClient object]
// snippet-service:[Lambda]
// snippet-keyword:[Java]
// snippet-keyword:[Amazon Lambda]
// snippet-keyword:[Code Sample]
// snippet-sourcetype:[full-example]
// snippet-sourcedate:[2019-11-19]
// snippet-sourceauthor:[AWS-scmacdon]


// snippet-start:[lambda.java2.DeleteFunction.complete]
package com.example.lambda;

// snippet-start:[lambda.java2.delete.import]
import software.amazon.awssdk.services.lambda.LambdaClient;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.lambda.model.DeleteFunctionRequest;
import software.amazon.awssdk.services.lambda.model.ServiceException;
// snippet-end:[lambda.java2.delete.import]

public class DeleteFunction {

    public static void main(String[] args) {

        if (args.length < 1) {
            System.out.println("Please specify a function name");
            System.exit(1);
        }

        // snippet-start:[lambda.java2.delete.main]
        String functionName = args[0];
        try {
            Region region = Region.US_WEST_2;
            LambdaClient awsLambda = LambdaClient.builder().region(region).build();

            //Setup an DeleteFunctionRequest
            DeleteFunctionRequest request = DeleteFunctionRequest.builder()
                    .functionName(functionName)
                    .build();

            //Invoke the Lambda deleteFunction method
            awsLambda.deleteFunction(request);
            System.out.println("Done");
        } catch(ServiceException e) {
            e.getStackTrace();
        }

        // snippet-end:[lambda.java2.delete.main]
    }
}
// snippet-end:[lambda.java2.DeleteFunction.complete]

@@ -1,8 +1,466 @@
+// snippet-comment:%5BThese are tags for the AWS doc team's sample catalog. Do not remove.%5D%0A// snippet-sourcedescription:%5BDeleteFunction.java demonstrates how to delete an AWS Lambda function by using the LambdaClient object%5D%0A// snippet-service:%5BLambda%5D%0A// snippet-keyword:%5BJava%5D%0A// snippet-keyword:%5BAmazon Lambda%5D%0A// snippet-keyword:%5BCode Sample%5D%0A// snippet-sourcetype:%5Bfull-example%5D%0A// snippet-sourcedate:%5B2020-10-02%5D%0A// snippet-sourceauthor:%5BAWS-scmacdon%5D%0A%0A
 /**%0A * C
@@ -472,18 +472,8 @@
 ght 
-2010-2020 
 Amaz
@@ -996,467 +996,8 @@
 */%0A%0A
-// snippet-comment:%5BThese are tags for the AWS doc team's sample catalog. Do not remove.%5D%0A// snippet-sourcedescription:%5BDeleteFunction.java demonstrates how to delete an AWS Lambda function by using the LambdaClient object%5D%0A// snippet-service:%5BLambda%5D%0A// snippet-keyword:%5BJava%5D%0A// snippet-keyword:%5BAmazon Lambda%5D%0A// snippet-keyword:%5BCode Sample%5D%0A// snippet-sourcetype:%5Bfull-example%5D%0A// snippet-sourcedate:%5B2019-11-19%5D%0A// snippet-sourceauthor:%5BAWS-scmacdon%5D%0A%0A%0A
 // s
@@ -1356,23 +1356,22 @@
 a.model.
-Service
+Lambda
 Exceptio
@@ -1491,24 +1491,251 @@
 %5B%5D args) %7B%0A%0A
+        final String USAGE = %22%5Cn%22 +%0A                %22Usage:%5Cn%22 +%0A                %22    DeleteFunction %3CfunctionName%3E %5Cn%5Cn%22 +%0A                %22Where:%5Cn%22 +%0A                %22    functionName - the name of the Lambda function %5Cn%22;%0A%0A
         if (
@@ -1788,40 +1788,13 @@
 tln(
-%22Please specify a function name%22
+USAGE
 );%0A 
@@ -1844,50 +1844,43 @@
    /
-/ snippet-start:%5Blambda.java2.delete.main%5D
+* Read the name from command args*/
 %0A   
@@ -1919,32 +1919,17 @@
 0%5D;%0A
-        try %7B%0A  
+%0A
         
   Re
@@ -1924,18 +1924,16 @@
         
-  
 Region r
@@ -1954,20 +1954,16 @@
 .US_
-W
 E
+A
 ST_
-2
+1
 ;%0A
-    
     
@@ -2017,33 +2017,283 @@
 er()
-.region(region).build();%0A
+%0A                .region(region)%0A                .build();%0A%0A        deleteLambdaFunction(awsLambda, functionName);%0A    %7D%0A%0A    // snippet-start:%5Blambda.java2.delete.main%5D%0A    public static void deleteLambdaFunction(LambdaClient awsLambda, String functionName ) %7B%0A        try %7B
 %0A   
@@ -2626,16 +2626,55 @@
 ln(%22
-Done
+The %22+functionName +%22 function was deleted
 %22);%0A
+%0A
     
@@ -2689,15 +2689,14 @@
 tch(
-Service
+Lambda
 Exce
@@ -2722,24 +2722,69 @@
     
-e.getStackTrace(
+System.err.println(e.getMessage());%0A            System.exit(1
 );%0A 
@@ -2784,33 +2784,32 @@
 t(1);%0A        %7D%0A
-%0A
         // snipp

Update DeleteFunction.java