/**
 * 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:[ListLambdaFunctions.java demonstrates how to list all functions specific to the account 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.ListLambdaFunctions.complete]
package com.example.lambda;

// snippet-start:[lambda.java2.list.import]
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.lambda.LambdaClient;
import software.amazon.awssdk.services.lambda.model.ListFunctionsResponse;
import software.amazon.awssdk.services.lambda.model.FunctionConfiguration;
import software.amazon.awssdk.services.lambda.model.ServiceException;
import java.util.Iterator;
import java.util.List;
// snippet-end:[lambda.java2.list.import]


public class ListLambdaFunctions {

    public static void main(String[] args) {

        // snippet-start:[lambda.java2.list.main]
        ListFunctionsResponse functionResult = null ;
        try {
            Region region = Region.US_WEST_2;
            LambdaClient awsLambda = LambdaClient.builder().region(region).build();

            //Get a list of all functions
            functionResult = awsLambda.listFunctions();

            List<FunctionConfiguration> list = functionResult.functions();

            for (Iterator iter = list.iterator(); iter.hasNext(); ) {
                FunctionConfiguration config = (FunctionConfiguration)iter.next();
                System.out.println("The function name is "+config.functionName());
            }
        } catch(ServiceException e) {
            e.getStackTrace();
        }
        // snippet-end:[lambda.java2.list.main]
    }
}
// snippet-end:[lambda.java2.ListLambdaFunctions.complete]

@@ -1,8 +1,485 @@
+// snippet-comment:%5BThese are tags for the AWS doc team's sample catalog. Do not remove.%5D%0A// snippet-sourcedescription:%5BListLambdaFunctions.java demonstrates how to list all functions specific to the account 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
@@ -491,18 +491,8 @@
 ght 
-2010-2020 
 Amaz
@@ -1007,492 +1007,13 @@
 se.%0A
- *%0A
  */%0A%0A
-// snippet-comment:%5BThese are tags for the AWS doc team's sample catalog. Do not remove.%5D%0A// snippet-sourcedescription:%5BListLambdaFunctions.java demonstrates how to list all functions specific to the account 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
 // s
@@ -1248,16 +1248,85 @@
 Client;%0A
+import software.amazon.awssdk.services.lambda.model.LambdaException;%0A
 import s
@@ -1471,78 +1471,8 @@
 on;%0A
-import software.amazon.awssdk.services.lambda.model.ServiceException;%0A
 impo
@@ -1647,130 +1647,8 @@
  %7B%0A%0A
-        // snippet-start:%5Blambda.java2.list.main%5D%0A        ListFunctionsResponse functionResult = null ;%0A        try %7B%0A    
     
@@ -1685,20 +1685,16 @@
 WEST_2;%0A
-    
         
@@ -1744,48 +1744,248 @@
 er()
-.region(region).build();%0A%0A            //
+%0A                .region(region)%0A                .build();%0A%0A        listFunctions(awsLambda);%0A    %7D%0A%0A    // snippet-start:%5Blambda.java2.list.main%5D%0A    public static void listFunctions(LambdaClient awsLambda) %7B%0A%0A        try %7B%0A            // 
 Get 
@@ -2020,16 +2020,38 @@
         
+ListFunctionsResponse 
 function
@@ -2078,33 +2078,32 @@
 istFunctions();%0A
-%0A
             List
@@ -2183,143 +2183,45 @@
 or (
-Iterator iter = list.iterator(); iter.hasNext(); ) %7B%0A                FunctionConfiguration config = (FunctionConfiguration)iter.next();
+FunctionConfiguration config: list) %7B
 %0A   
@@ -2306,32 +2306,33 @@
 ;%0A            %7D%0A
+%0A
         %7D catch(
@@ -2335,15 +2335,14 @@
 tch(
-Service
+Lambda
 Exce
@@ -2368,24 +2368,69 @@
     
-e.getStackTrace(
+System.err.println(e.getMessage());%0A            System.exit(1
 );%0A 

Update ListLambdaFunctions.java