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 2020/04/22 10:20:52 UTC

[camel] 07/10: CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-iam operations

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 6dd569ee920b7e15eff4e0f7ab6bf1047e2f8f80
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Apr 22 12:11:13 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
---
 .../apache/camel/component/aws2/iam/IAM2Producer.java   | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

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 d7403b8..6819f87 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
@@ -549,7 +549,21 @@ public class IAM2Producer extends DefaultProducer {
         }
     }
 
-    private void removeUserFromGroup(IamClient iamClient, Exchange exchange) {
+    private void removeUserFromGroup(IamClient iamClient, Exchange exchange) throws InvalidPayloadException {
+        if (getConfiguration().isPojoRequest()) {
+            Object payload = exchange.getIn().getMandatoryBody();
+            if (payload instanceof RemoveUserFromGroupRequest) {
+                RemoveUserFromGroupResponse result;
+                try {
+                    result = iamClient.removeUserFromGroup((RemoveUserFromGroupRequest) payload);
+                } catch (AwsServiceException ase) {
+                    LOG.trace("Remove User From Group command returned the error code {}", ase.awsErrorDetails().errorCode());
+                    throw ase;
+                }
+                Message message = getMessageForResponse(exchange);
+                message.setBody(result);
+            }
+        } else {
         RemoveUserFromGroupRequest.Builder builder = RemoveUserFromGroupRequest.builder();
         if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(IAM2Constants.GROUP_NAME))) {
             String groupName = exchange.getIn().getHeader(IAM2Constants.GROUP_NAME, String.class);
@@ -572,6 +586,7 @@ public class IAM2Producer extends DefaultProducer {
         }
         Message message = getMessageForResponse(exchange);
         message.setBody(result);
+        }
     }
 
     public static Message getMessageForResponse(final Exchange exchange) {