software.amazon.awssdk.services.lambda.model.ListFunctionsResponse Java Examples
The following examples show how to use
software.amazon.awssdk.services.lambda.model.ListFunctionsResponse.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ListLambdaFunctions.java From aws-doc-sdk-examples with Apache License 2.0 | 6 votes |
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] }
Example #2
Source File: AwsLambdaScannerTest.java From clouditor with Apache License 2.0 | 5 votes |
@BeforeAll static void setUpOnce() { discoverAssets( LambdaClient.class, AwsLambdaScanner::new, api -> { when(api.listFunctions()) .thenReturn( ListFunctionsResponse.builder() .functions( FunctionConfiguration.builder() .functionArn( "arn:aws:lambda:eu-central-1:123456789:function:function-1") .functionName("function-1") .kmsKeyArn("some-key") .build(), FunctionConfiguration.builder() .functionArn( "arn:aws:lambda:eu-central-1:123456789:function:function-2") .functionName("function-2") .build()) .build()); when(api.getPolicy(GetPolicyRequest.builder().functionName("function-1").build())) .thenReturn(GetPolicyResponse.builder().policy("*").build()); when(api.getPolicy(GetPolicyRequest.builder().functionName("function-2").build())) .thenReturn(GetPolicyResponse.builder().policy("no-wildcard").build()); }); }
Example #3
Source File: ServiceIntegrationTest.java From aws-sdk-java-v2 with Apache License 2.0 | 5 votes |
@Test public void testFunctionOperations() throws IOException { // Get function GetFunctionResponse getFunc = lambda.getFunction(r -> r.functionName(FUNCTION_NAME)).join(); checkValid_GetFunctionResponse(getFunc); // Get function configuration GetFunctionConfigurationResponse getConfig = lambda.getFunctionConfiguration(r -> r.functionName(FUNCTION_NAME)).join(); checkValid_GetFunctionConfigurationResponse(getConfig); // List functions ListFunctionsResponse listFunc = lambda.listFunctions(ListFunctionsRequest.builder().build()).join(); Assert.assertFalse(listFunc.functions().isEmpty()); for (FunctionConfiguration funcConfig : listFunc.functions()) { checkValid_FunctionConfiguration(funcConfig); } // Invoke the function InvokeResponse invokeResult = lambda.invoke(InvokeRequest.builder().functionName(FUNCTION_NAME) .invocationType(InvocationType.EVENT).payload(SdkBytes.fromUtf8String("{}")).build()).join(); Assert.assertEquals(202, invokeResult.statusCode().intValue()); Assert.assertNull(invokeResult.logResult()); Assert.assertEquals(0, invokeResult.payload().asByteBuffer().remaining()); invokeResult = lambda.invoke(InvokeRequest.builder().functionName(FUNCTION_NAME) .invocationType(InvocationType.REQUEST_RESPONSE).logType(LogType.TAIL) .payload(SdkBytes.fromUtf8String("{}")).build()).join(); Assert.assertEquals(200, invokeResult.statusCode().intValue()); System.out.println(new String(BinaryUtils.fromBase64(invokeResult.logResult()), StandardCharsets.UTF_8)); Assert.assertEquals("\"Hello World\"", invokeResult.payload().asUtf8String()); }