You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2021/03/31 09:32:14 UTC
[camel] 07/09: Camel-AWS2-Lambda: Producer operations refactoring -
getAlias
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 941954dc41b50cdda92683d9253ddd0758e81a39
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Mar 31 11:24:32 2021 +0200
Camel-AWS2-Lambda: Producer operations refactoring - getAlias
---
.../component/aws2/lambda/Lambda2Producer.java | 27 ++++++++--------------
1 file changed, 9 insertions(+), 18 deletions(-)
diff --git a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
index 8d4efa1..e960a67 100644
--- a/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
+++ b/components/camel-aws/camel-aws2-lambda/src/main/java/org/apache/camel/component/aws2/lambda/Lambda2Producer.java
@@ -672,36 +672,27 @@ public class Lambda2Producer extends DefaultProducer {
}
private void getAlias(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {
+ GetAliasRequest request = null;
+ GetAliasResponse result;
if (getConfiguration().isPojoRequest()) {
- Object payload = exchange.getIn().getMandatoryBody();
- if (payload instanceof GetAliasRequest) {
- GetAliasResponse result;
- try {
- result = lambdaClient.getAlias((GetAliasRequest) payload);
- } catch (AwsServiceException ase) {
- LOG.trace("getAlias command returned the error code {}", ase.awsErrorDetails().errorCode());
- throw ase;
- }
- Message message = getMessageForResponse(exchange);
- message.setBody(result);
- }
+ request = exchange.getIn().getMandatoryBody(GetAliasRequest.class);
} else {
- GetAliasResponse result;
- try {
- GetAliasRequest.Builder request = GetAliasRequest.builder().functionName(getEndpoint().getFunction());
+ GetAliasRequest.Builder builder = GetAliasRequest.builder();
+ builder.functionName(getEndpoint().getFunction());
String aliasName = exchange.getIn().getHeader(Lambda2Constants.FUNCTION_ALIAS_NAME, String.class);
if (ObjectHelper.isEmpty(aliasName)) {
throw new IllegalArgumentException("Function alias must be specified to get an alias");
}
- request.name(aliasName);
- result = lambdaClient.getAlias(request.build());
+ builder.name(aliasName);
+ }
+ try {
+ result = lambdaClient.getAlias(request);
} catch (AwsServiceException ase) {
LOG.trace("getAlias command returned the error code {}", ase.awsErrorDetails().errorCode());
throw ase;
}
Message message = getMessageForResponse(exchange);
message.setBody(result);
- }
}
private void listAliases(LambdaClient lambdaClient, Exchange exchange) throws InvalidPayloadException {