This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit a64ffef88fa17b7beec01afac3de27ee695c5341 Author: Andrea Cosentino <[email protected]> AuthorDate: Mon Apr 20 12:22:20 2020 +0200 CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-lambda create function --- .../camel/component/aws2/lambda/Lambda2Producer.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/components/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java b/components/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java index 9b6d2bb..edd063c 100644 --- a/components/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java +++ b/components/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java @@ -263,6 +263,21 @@ public class Lambda2Producer extends DefaultProducer { @SuppressWarnings("unchecked") private void createFunction(LambdaClient lambdaClient, Exchange exchange) throws Exception { + if (getConfiguration().isPojoRequest()) { + Object payload = exchange.getIn().getMandatoryBody(); + if (payload instanceof CreateFunctionRequest) { + CreateFunctionResponse result; + try { + result = lambdaClient.createFunction((CreateFunctionRequest) payload); + + } catch (AwsServiceException ase) { + LOG.trace("createFunction command returned the error code {}", ase.awsErrorDetails().errorCode()); + throw ase; + } + + Message message = getMessageForResponse(exchange); + message.setBody(result); + } else { CreateFunctionResponse result; try { @@ -385,6 +400,8 @@ public class Lambda2Producer extends DefaultProducer { Message message = getMessageForResponse(exchange); message.setBody(result); + } + } } private void updateFunction(LambdaClient lambdaClient, Exchange exchange) throws Exception {
