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 d4ba9216bc7ebd770e0b39b63363ae39874fb700
Author: Andrea Cosentino <anco...@gmail.com>
AuthorDate: Wed Apr 22 12:07:33 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end 
user to pass an AWS Request pojo as body, aws2-iam operations
---
 .../camel/component/aws2/iam/IAM2Producer.java     | 34 ++++++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git 
a/components/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Producer.java
 
b/components/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Producer.java
index 0da861c..e548eb5 100644
--- 
a/components/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Producer.java
+++ 
b/components/camel-aws2-iam/src/main/java/org/apache/camel/component/aws2/iam/IAM2Producer.java
@@ -327,7 +327,21 @@ public class IAM2Producer extends DefaultProducer {
         }
     }
 
-    private void deleteAccessKey(IamClient iamClient, Exchange exchange) {
+    private void deleteAccessKey(IamClient iamClient, Exchange exchange) 
throws InvalidPayloadException {
+        if (getConfiguration().isPojoRequest()) {
+            Object payload = exchange.getIn().getMandatoryBody();
+            if (payload instanceof DeleteAccessKeyRequest) {
+                DeleteAccessKeyResponse result;
+                try {
+                    result = 
iamClient.deleteAccessKey((DeleteAccessKeyRequest) payload);
+                } catch (AwsServiceException ase) {
+                    LOG.trace("Delete Access Key command returned the error 
code {}", ase.awsErrorDetails().errorCode());
+                    throw ase;
+                }
+                Message message = getMessageForResponse(exchange);
+                message.setBody(result);
+            }
+        } else {
         DeleteAccessKeyRequest.Builder builder = 
DeleteAccessKeyRequest.builder();
         if 
(ObjectHelper.isNotEmpty(exchange.getIn().getHeader(IAM2Constants.ACCESS_KEY_ID)))
 {
             String accessKeyId = 
exchange.getIn().getHeader(IAM2Constants.ACCESS_KEY_ID, String.class);
@@ -348,9 +362,24 @@ public class IAM2Producer extends DefaultProducer {
         }
         Message message = getMessageForResponse(exchange);
         message.setBody(result);
+        }
     }
 
-    private void updateAccessKey(IamClient iamClient, Exchange exchange) {
+    private void updateAccessKey(IamClient iamClient, Exchange exchange) 
throws InvalidPayloadException {
+        if (getConfiguration().isPojoRequest()) {
+            Object payload = exchange.getIn().getMandatoryBody();
+            if (payload instanceof UpdateAccessKeyRequest) {
+                UpdateAccessKeyResponse result;
+                try {
+                    result = 
iamClient.updateAccessKey((UpdateAccessKeyRequest) payload);
+                } catch (AwsServiceException ase) {
+                    LOG.trace("Update Access Key command returned the error 
code {}", ase.awsErrorDetails().errorCode());
+                    throw ase;
+                }
+                Message message = getMessageForResponse(exchange);
+                message.setBody(result);
+            }
+        } else {
         UpdateAccessKeyRequest.Builder builder = 
UpdateAccessKeyRequest.builder();
         if 
(ObjectHelper.isNotEmpty(exchange.getIn().getHeader(IAM2Constants.ACCESS_KEY_ID)))
 {
             String accessKeyId = 
exchange.getIn().getHeader(IAM2Constants.ACCESS_KEY_ID, String.class);
@@ -377,6 +406,7 @@ public class IAM2Producer extends DefaultProducer {
         }
         Message message = getMessageForResponse(exchange);
         message.setBody(result);
+        }
     }
 
     private void createGroup(IamClient iamClient, Exchange exchange) {

Reply via email to