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/14 09:35:45 UTC

[camel] branch master updated (21054c0 -> 248b998)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from 21054c0  Upgrade jslt to version 0.1.9
     new 9dc925b  CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms list keys
     new aec81b8  CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms create key
     new fac900a  CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms disable key
     new 65b4653  CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms scheduled key deletion
     new b28d4da  CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms describe key
     new 971c691  CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms enable key
     new 104165f  CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms fixed CS
     new 4e13df1  CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms regen
     new 6acf9e5  CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms added a little test
     new 248b998  CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms added spring test too

The 10 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../aws2/kms/KMS2ComponentConfigurer.java          |   5 +
 .../component/aws2/kms/KMS2EndpointConfigurer.java |   5 +
 .../apache/camel/component/aws2/kms/aws2-kms.json  |   2 +
 .../src/main/docs/aws2-kms-component.adoc          |   6 +-
 .../component/aws2/kms/KMS2Configuration.java      |  13 +
 .../camel/component/aws2/kms/KMS2Producer.java     | 275 ++++++++++++++-------
 .../component/aws2/kms/KMSProducerSpringTest.java  |  20 ++
 .../camel/component/aws2/kms/KMSProducerTest.java  |  21 ++
 .../aws2/kms/KMSComponentSpringTest-context.xml    |   5 +
 .../dsl/Aws2KmsComponentBuilderFactory.java        |  13 +
 .../src/generated/resources/metadata.json          |   2 +-
 .../endpoint/dsl/KMS2EndpointBuilderFactory.java   |  24 ++
 12 files changed, 296 insertions(+), 95 deletions(-)


[camel] 10/10: CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms added spring test too

Posted by ac...@apache.org.
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 248b998e09326f0e99c98246db0cd3fdfe03e51a
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Apr 14 11:31:45 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms added spring test too
---
 .../component/aws2/kms/KMSProducerSpringTest.java    | 20 ++++++++++++++++++++
 .../aws2/kms/KMSComponentSpringTest-context.xml      |  5 +++++
 2 files changed, 25 insertions(+)

diff --git a/components/camel-aws2-kms/src/test/java/org/apache/camel/component/aws2/kms/KMSProducerSpringTest.java b/components/camel-aws2-kms/src/test/java/org/apache/camel/component/aws2/kms/KMSProducerSpringTest.java
index 241d107..d2c895d 100644
--- a/components/camel-aws2-kms/src/test/java/org/apache/camel/component/aws2/kms/KMSProducerSpringTest.java
+++ b/components/camel-aws2-kms/src/test/java/org/apache/camel/component/aws2/kms/KMSProducerSpringTest.java
@@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 import software.amazon.awssdk.services.kms.model.CreateKeyResponse;
 import software.amazon.awssdk.services.kms.model.DescribeKeyResponse;
+import software.amazon.awssdk.services.kms.model.ListKeysRequest;
 import software.amazon.awssdk.services.kms.model.ListKeysResponse;
 import software.amazon.awssdk.services.kms.model.ScheduleKeyDeletionResponse;
 
@@ -141,6 +142,25 @@ public class KMSProducerSpringTest extends CamelSpringTestSupport {
         assertEquals("MyCamelKey", resultGet.keyMetadata().description());
         assertFalse(resultGet.keyMetadata().enabled());
     }
+    
+    @Test
+    public void kmsListKeysPojoTest() throws Exception {
+
+        mock.expectedMessageCount(1);
+        Exchange exchange = template.request("direct:listKeysPojo", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(KMS2Constants.OPERATION, KMS2Operations.listKeys);
+                exchange.getIn().setBody(ListKeysRequest.builder().limit(10).build());
+            }
+        });
+
+        assertMockEndpointsSatisfied();
+
+        ListKeysResponse resultGet = (ListKeysResponse)exchange.getIn().getBody();
+        assertEquals(1, resultGet.keys().size());
+        assertEquals("keyId", resultGet.keys().get(0).keyId());
+    }
 
     @Override
     protected ClassPathXmlApplicationContext createApplicationContext() {
diff --git a/components/camel-aws2-kms/src/test/resources/org/apache/camel/component/aws2/kms/KMSComponentSpringTest-context.xml b/components/camel-aws2-kms/src/test/resources/org/apache/camel/component/aws2/kms/KMSComponentSpringTest-context.xml
index 4a8a0f7..1b65cb2 100644
--- a/components/camel-aws2-kms/src/test/resources/org/apache/camel/component/aws2/kms/KMSComponentSpringTest-context.xml
+++ b/components/camel-aws2-kms/src/test/resources/org/apache/camel/component/aws2/kms/KMSComponentSpringTest-context.xml
@@ -30,6 +30,11 @@
             <to uri="mock:result"/>
         </route>
         <route>
+            <from uri="direct:listKeysPojo"/>
+            <to uri="aws2-kms://Test?kmsClient=#amazonKmsClient&amp;operation=listKeys&amp;pojoRequest=true"/>
+            <to uri="mock:result"/>
+        </route>
+        <route>
             <from uri="direct:createKey"/>
             <to uri="aws2-kms://Test?kmsClient=#amazonKmsClient&amp;operation=createKey"/>
             <to uri="mock:result"/>


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

Posted by ac...@apache.org.
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 4e13df19a705646ca24a97f026157e84572083ff
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Apr 14 11:17:32 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms regen
---
 .../aws2/kms/KMS2ComponentConfigurer.java          |  5 +++++
 .../component/aws2/kms/KMS2EndpointConfigurer.java |  5 +++++
 .../apache/camel/component/aws2/kms/aws2-kms.json  |  2 ++
 .../src/main/docs/aws2-kms-component.adoc          |  6 ++++--
 .../dsl/Aws2KmsComponentBuilderFactory.java        | 13 ++++++++++++
 .../src/generated/resources/metadata.json          |  2 +-
 .../endpoint/dsl/KMS2EndpointBuilderFactory.java   | 24 ++++++++++++++++++++++
 7 files changed, 54 insertions(+), 3 deletions(-)

diff --git a/components/camel-aws2-kms/src/generated/java/org/apache/camel/component/aws2/kms/KMS2ComponentConfigurer.java b/components/camel-aws2-kms/src/generated/java/org/apache/camel/component/aws2/kms/KMS2ComponentConfigurer.java
index c5e6c99..9589773 100644
--- a/components/camel-aws2-kms/src/generated/java/org/apache/camel/component/aws2/kms/KMS2ComponentConfigurer.java
+++ b/components/camel-aws2-kms/src/generated/java/org/apache/camel/component/aws2/kms/KMS2ComponentConfigurer.java
@@ -36,6 +36,8 @@ public class KMS2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "lazystartproducer":
         case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
         case "operation": getOrCreateConfiguration(target).setOperation(property(camelContext, org.apache.camel.component.aws2.kms.KMS2Operations.class, value)); return true;
+        case "pojorequest":
+        case "pojoRequest": getOrCreateConfiguration(target).setPojoRequest(property(camelContext, boolean.class, value)); return true;
         case "proxyhost":
         case "proxyHost": getOrCreateConfiguration(target).setProxyHost(property(camelContext, java.lang.String.class, value)); return true;
         case "proxyport":
@@ -58,6 +60,7 @@ public class KMS2ComponentConfigurer extends PropertyConfigurerSupport implement
         answer.put("kmsClient", software.amazon.awssdk.services.kms.KmsClient.class);
         answer.put("lazyStartProducer", boolean.class);
         answer.put("operation", org.apache.camel.component.aws2.kms.KMS2Operations.class);
+        answer.put("pojoRequest", boolean.class);
         answer.put("proxyHost", java.lang.String.class);
         answer.put("proxyPort", java.lang.Integer.class);
         answer.put("proxyProtocol", software.amazon.awssdk.core.Protocol.class);
@@ -80,6 +83,8 @@ public class KMS2ComponentConfigurer extends PropertyConfigurerSupport implement
         case "lazystartproducer":
         case "lazyStartProducer": return target.isLazyStartProducer();
         case "operation": return getOrCreateConfiguration(target).getOperation();
+        case "pojorequest":
+        case "pojoRequest": return getOrCreateConfiguration(target).isPojoRequest();
         case "proxyhost":
         case "proxyHost": return getOrCreateConfiguration(target).getProxyHost();
         case "proxyport":
diff --git a/components/camel-aws2-kms/src/generated/java/org/apache/camel/component/aws2/kms/KMS2EndpointConfigurer.java b/components/camel-aws2-kms/src/generated/java/org/apache/camel/component/aws2/kms/KMS2EndpointConfigurer.java
index a04572a..39889ed 100644
--- a/components/camel-aws2-kms/src/generated/java/org/apache/camel/component/aws2/kms/KMS2EndpointConfigurer.java
+++ b/components/camel-aws2-kms/src/generated/java/org/apache/camel/component/aws2/kms/KMS2EndpointConfigurer.java
@@ -28,6 +28,8 @@ public class KMS2EndpointConfigurer extends PropertyConfigurerSupport implements
         case "lazystartproducer":
         case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
         case "operation": target.getConfiguration().setOperation(property(camelContext, org.apache.camel.component.aws2.kms.KMS2Operations.class, value)); return true;
+        case "pojorequest":
+        case "pojoRequest": target.getConfiguration().setPojoRequest(property(camelContext, boolean.class, value)); return true;
         case "proxyhost":
         case "proxyHost": target.getConfiguration().setProxyHost(property(camelContext, java.lang.String.class, value)); return true;
         case "proxyport":
@@ -50,6 +52,7 @@ public class KMS2EndpointConfigurer extends PropertyConfigurerSupport implements
         answer.put("kmsClient", software.amazon.awssdk.services.kms.KmsClient.class);
         answer.put("lazyStartProducer", boolean.class);
         answer.put("operation", org.apache.camel.component.aws2.kms.KMS2Operations.class);
+        answer.put("pojoRequest", boolean.class);
         answer.put("proxyHost", java.lang.String.class);
         answer.put("proxyPort", java.lang.Integer.class);
         answer.put("proxyProtocol", software.amazon.awssdk.core.Protocol.class);
@@ -72,6 +75,8 @@ public class KMS2EndpointConfigurer extends PropertyConfigurerSupport implements
         case "lazystartproducer":
         case "lazyStartProducer": return target.isLazyStartProducer();
         case "operation": return target.getConfiguration().getOperation();
+        case "pojorequest":
+        case "pojoRequest": return target.getConfiguration().isPojoRequest();
         case "proxyhost":
         case "proxyHost": return target.getConfiguration().getProxyHost();
         case "proxyport":
diff --git a/components/camel-aws2-kms/src/generated/resources/org/apache/camel/component/aws2/kms/aws2-kms.json b/components/camel-aws2-kms/src/generated/resources/org/apache/camel/component/aws2/kms/aws2-kms.json
index 851c01b..6cd296b 100644
--- a/components/camel-aws2-kms/src/generated/resources/org/apache/camel/component/aws2/kms/aws2-kms.json
+++ b/components/camel-aws2-kms/src/generated/resources/org/apache/camel/component/aws2/kms/aws2-kms.json
@@ -25,6 +25,7 @@
     "kmsClient": { "kind": "property", "displayName": "Kms Client", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.kms.KmsClient", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.kms.KMS2Configuration", "configurationField": "configuration", "description": "To use a existing configured AWS KMS as client" },
     "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the r [...]
     "operation": { "kind": "property", "displayName": "Operation", "group": "producer", "label": "", "required": true, "type": "object", "javaType": "org.apache.camel.component.aws2.kms.KMS2Operations", "enum": [ "listKeys", "createKey", "disableKey", "scheduleKeyDeletion", "describeKey", "enableKey" ], "deprecated": false, "deprecationNote": "", "secret": false, "configurationClass": "org.apache.camel.component.aws2.kms.KMS2Configuration", "configurationField": "configuration", "descrip [...]
+    "pojoRequest": { "kind": "property", "displayName": "Pojo Request", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "false", "configurationClass": "org.apache.camel.component.aws2.kms.KMS2Configuration", "configurationField": "configuration", "description": "If we want to use a POJO request as body or not" },
     "proxyHost": { "kind": "property", "displayName": "Proxy Host", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.kms.KMS2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the KMS client" },
     "proxyPort": { "kind": "property", "displayName": "Proxy Port", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.kms.KMS2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the KMS client" },
     "proxyProtocol": { "kind": "property", "displayName": "Proxy Protocol", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.kms.KMS2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the KMS client" },
@@ -38,6 +39,7 @@
     "kmsClient": { "kind": "parameter", "displayName": "Kms Client", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.services.kms.KmsClient", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.kms.KMS2Configuration", "configurationField": "configuration", "description": "To use a existing configured AWS KMS as client" },
     "lazyStartProducer": { "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the  [...]
     "operation": { "kind": "parameter", "displayName": "Operation", "group": "producer", "label": "", "required": true, "type": "object", "javaType": "org.apache.camel.component.aws2.kms.KMS2Operations", "enum": [ "listKeys", "createKey", "disableKey", "scheduleKeyDeletion", "describeKey", "enableKey" ], "deprecated": false, "deprecationNote": "", "secret": false, "configurationClass": "org.apache.camel.component.aws2.kms.KMS2Configuration", "configurationField": "configuration", "descri [...]
+    "pojoRequest": { "kind": "parameter", "displayName": "Pojo Request", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": "false", "configurationClass": "org.apache.camel.component.aws2.kms.KMS2Configuration", "configurationField": "configuration", "description": "If we want to use a POJO request as body or not" },
     "proxyHost": { "kind": "parameter", "displayName": "Proxy Host", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.kms.KMS2Configuration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the KMS client" },
     "proxyPort": { "kind": "parameter", "displayName": "Proxy Port", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.kms.KMS2Configuration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the KMS client" },
     "proxyProtocol": { "kind": "parameter", "displayName": "Proxy Protocol", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "software.amazon.awssdk.core.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws2.kms.KMS2Configuration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the KMS client" },
diff --git a/components/camel-aws2-kms/src/main/docs/aws2-kms-component.adoc b/components/camel-aws2-kms/src/main/docs/aws2-kms-component.adoc
index 457bdb5..19d6f3b 100644
--- a/components/camel-aws2-kms/src/main/docs/aws2-kms-component.adoc
+++ b/components/camel-aws2-kms/src/main/docs/aws2-kms-component.adoc
@@ -38,7 +38,7 @@ You can append query options to the URI in the following format,
 
 
 // component options: START
-The AWS 2 KMS component supports 11 options, which are listed below.
+The AWS 2 KMS component supports 12 options, which are listed below.
 
 
 
@@ -49,6 +49,7 @@ The AWS 2 KMS component supports 11 options, which are listed below.
 | *kmsClient* (producer) | To use a existing configured AWS KMS as client |  | KmsClient
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
 | *operation* (producer) | *Required* The operation to perform. The value can be one of: listKeys, createKey, disableKey, scheduleKeyDeletion, describeKey, enableKey |  | KMS2Operations
+| *pojoRequest* (producer) | If we want to use a POJO request as body or not | false | boolean
 | *proxyHost* (producer) | To define a proxy host when instantiating the KMS client |  | String
 | *proxyPort* (producer) | To define a proxy port when instantiating the KMS client |  | Integer
 | *proxyProtocol* (producer) | To define a proxy protocol when instantiating the KMS client. The value can be one of: HTTP, HTTPS | HTTPS | Protocol
@@ -81,7 +82,7 @@ with the following path and query parameters:
 |===
 
 
-=== Query Parameters (11 parameters):
+=== Query Parameters (12 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -90,6 +91,7 @@ with the following path and query parameters:
 | *kmsClient* (producer) | To use a existing configured AWS KMS as client |  | KmsClient
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
 | *operation* (producer) | *Required* The operation to perform. The value can be one of: listKeys, createKey, disableKey, scheduleKeyDeletion, describeKey, enableKey |  | KMS2Operations
+| *pojoRequest* (producer) | If we want to use a POJO request as body or not | false | boolean
 | *proxyHost* (producer) | To define a proxy host when instantiating the KMS client |  | String
 | *proxyPort* (producer) | To define a proxy port when instantiating the KMS client |  | Integer
 | *proxyProtocol* (producer) | To define a proxy protocol when instantiating the KMS client. The value can be one of: HTTP, HTTPS | HTTPS | Protocol
diff --git a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2KmsComponentBuilderFactory.java b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2KmsComponentBuilderFactory.java
index 518c944..bdeda3a 100644
--- a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2KmsComponentBuilderFactory.java
+++ b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2KmsComponentBuilderFactory.java
@@ -108,6 +108,18 @@ public interface Aws2KmsComponentBuilderFactory {
             return this;
         }
         /**
+         * If we want to use a POJO request as body or not.
+         * 
+         * The option is a: <code>boolean</code> type.
+         * 
+         * Default: false
+         * Group: producer
+         */
+        default Aws2KmsComponentBuilder pojoRequest(boolean pojoRequest) {
+            doSetProperty("pojoRequest", pojoRequest);
+            return this;
+        }
+        /**
          * To define a proxy host when instantiating the KMS client.
          * 
          * The option is a: <code>java.lang.String</code> type.
@@ -221,6 +233,7 @@ public interface Aws2KmsComponentBuilderFactory {
             case "kmsClient": getOrCreateConfiguration((KMS2Component) component).setKmsClient((software.amazon.awssdk.services.kms.KmsClient) value); return true;
             case "lazyStartProducer": ((KMS2Component) component).setLazyStartProducer((boolean) value); return true;
             case "operation": getOrCreateConfiguration((KMS2Component) component).setOperation((org.apache.camel.component.aws2.kms.KMS2Operations) value); return true;
+            case "pojoRequest": getOrCreateConfiguration((KMS2Component) component).setPojoRequest((boolean) value); return true;
             case "proxyHost": getOrCreateConfiguration((KMS2Component) component).setProxyHost((java.lang.String) value); return true;
             case "proxyPort": getOrCreateConfiguration((KMS2Component) component).setProxyPort((java.lang.Integer) value); return true;
             case "proxyProtocol": getOrCreateConfiguration((KMS2Component) component).setProxyProtocol((software.amazon.awssdk.core.Protocol) value); return true;
diff --git a/core/camel-componentdsl/src/generated/resources/metadata.json b/core/camel-componentdsl/src/generated/resources/metadata.json
index 7bc5774..33e30cb 100644
--- a/core/camel-componentdsl/src/generated/resources/metadata.json
+++ b/core/camel-componentdsl/src/generated/resources/metadata.json
@@ -612,7 +612,6 @@
     "lenientProperties": false,
     "javaType": "org.apache.camel.component.aws2.kms.KMS2Component",
     "firstVersion": "3.1.0",
-    "supportLevel": "Stable",
     "groupId": "org.apache.camel",
     "artifactId": "camel-aws2-kms",
     "version": "3.3.0-SNAPSHOT"
@@ -2270,6 +2269,7 @@
     "lenientProperties": false,
     "javaType": "org.apache.camel.component.djl.DJLComponent",
     "firstVersion": "3.3.0",
+    "supportLevel": "Stable",
     "groupId": "org.apache.camel",
     "artifactId": "camel-djl",
     "version": "3.3.0-SNAPSHOT"
diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/KMS2EndpointBuilderFactory.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/KMS2EndpointBuilderFactory.java
index bf6bcdf..b6d44bc 100644
--- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/KMS2EndpointBuilderFactory.java
+++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/KMS2EndpointBuilderFactory.java
@@ -128,6 +128,30 @@ public interface KMS2EndpointBuilderFactory {
             return this;
         }
         /**
+         * If we want to use a POJO request as body or not.
+         * 
+         * The option is a: <code>boolean</code> type.
+         * 
+         * Default: false
+         * Group: producer
+         */
+        default KMS2EndpointBuilder pojoRequest(boolean pojoRequest) {
+            doSetProperty("pojoRequest", pojoRequest);
+            return this;
+        }
+        /**
+         * If we want to use a POJO request as body or not.
+         * 
+         * The option will be converted to a <code>boolean</code> type.
+         * 
+         * Default: false
+         * Group: producer
+         */
+        default KMS2EndpointBuilder pojoRequest(String pojoRequest) {
+            doSetProperty("pojoRequest", pojoRequest);
+            return this;
+        }
+        /**
          * To define a proxy host when instantiating the KMS client.
          * 
          * The option is a: <code>java.lang.String</code> type.


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

Posted by ac...@apache.org.
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 aec81b8a41a50e6df1db15d98612c30d57e5034f
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Apr 14 10:41:31 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms create key
---
 .../camel/component/aws2/kms/KMS2Producer.java       | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java b/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
index 46069e0..e107a00 100644
--- a/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
+++ b/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.aws2.kms;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
+import org.apache.camel.InvalidPayloadException;
 import org.apache.camel.Message;
 import org.apache.camel.support.DefaultProducer;
 import org.apache.camel.util.ObjectHelper;
@@ -110,7 +111,7 @@ public class KMS2Producer extends DefaultProducer {
         return (KMS2Endpoint)super.getEndpoint();
     }
 
-    private void listKeys(KmsClient kmsClient, Exchange exchange) {
+    private void listKeys(KmsClient kmsClient, Exchange exchange) throws InvalidPayloadException {
         if (getConfiguration().isPojoRequest()) {
             Object payload = exchange.getIn().getMandatoryBody();
             if (payload instanceof ListKeysRequest) {
@@ -142,7 +143,21 @@ public class KMS2Producer extends DefaultProducer {
         }
     }
 
-    private void createKey(KmsClient kmsClient, Exchange exchange) {
+    private void createKey(KmsClient kmsClient, Exchange exchange) throws InvalidPayloadException {
+        if (getConfiguration().isPojoRequest()) {
+            Object payload = exchange.getIn().getMandatoryBody();
+            if (payload instanceof CreateKeyRequest) {
+                CreateKeyResponse result;
+                try {
+                    result = kmsClient.createKey((CreateKeyRequest) payload);
+                } catch (AwsServiceException ase) {
+                    LOG.trace("Create Key command returned the error code {}", ase.awsErrorDetails().errorCode());
+                    throw ase;
+                }
+                Message message = getMessageForResponse(exchange);
+                message.setBody(result);
+            }
+        } else {
         CreateKeyRequest.Builder builder = CreateKeyRequest.builder();
         if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(KMS2Constants.DESCRIPTION))) {
             String description = exchange.getIn().getHeader(KMS2Constants.DESCRIPTION, String.class);
@@ -157,6 +172,7 @@ public class KMS2Producer extends DefaultProducer {
         }
         Message message = getMessageForResponse(exchange);
         message.setBody(result);
+        }
     }
 
     private void disableKey(KmsClient kmsClient, Exchange exchange) {


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

Posted by ac...@apache.org.
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 b28d4da30f13b242e1381f101b32db550357b535
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Apr 14 11:12:37 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms describe key
---
 .../apache/camel/component/aws2/kms/KMS2Producer.java | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java b/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
index 0d04235..8bf4631 100644
--- a/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
+++ b/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
@@ -209,7 +209,7 @@ public class KMS2Producer extends DefaultProducer {
         }
     }
 
-    private void scheduleKeyDeletion(KmsClient kmsClient, Exchange exchange) {
+    private void scheduleKeyDeletion(KmsClient kmsClient, Exchange exchange) throws InvalidPayloadException {
         if (getConfiguration().isPojoRequest()) {
             Object payload = exchange.getIn().getMandatoryBody();
             if (payload instanceof ScheduleKeyDeletionRequest) {
@@ -247,7 +247,21 @@ public class KMS2Producer extends DefaultProducer {
         }
     }
 
-    private void describeKey(KmsClient kmsClient, Exchange exchange) {
+    private void describeKey(KmsClient kmsClient, Exchange exchange) throws InvalidPayloadException {
+        if (getConfiguration().isPojoRequest()) {
+            Object payload = exchange.getIn().getMandatoryBody();
+            if (payload instanceof DescribeKeyRequest) {
+                DescribeKeyResponse result;
+                try {
+                    result = kmsClient.describeKey((DescribeKeyRequest) payload);
+                } catch (AwsServiceException ase) {
+                    LOG.trace("Describe Key command returned the error code {}", ase.awsErrorDetails().errorCode());
+                    throw ase;
+                }
+                Message message = getMessageForResponse(exchange);
+                message.setBody(result);
+            }
+        } else {
         DescribeKeyRequest.Builder builder = DescribeKeyRequest.builder();
         if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(KMS2Constants.KEY_ID))) {
             String keyId = exchange.getIn().getHeader(KMS2Constants.KEY_ID, String.class);
@@ -264,6 +278,7 @@ public class KMS2Producer extends DefaultProducer {
         }
         Message message = getMessageForResponse(exchange);
         message.setBody(result);
+        }
     }
 
     private void enableKey(KmsClient kmsClient, Exchange exchange) {


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

Posted by ac...@apache.org.
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 9dc925b59d008140eb9e4e4a80e6277b6992132c
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Apr 14 10:39:19 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms list keys
---
 .../camel/component/aws2/kms/KMS2Configuration.java     | 13 +++++++++++++
 .../apache/camel/component/aws2/kms/KMS2Producer.java   | 17 +++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Configuration.java b/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Configuration.java
index a8b7e4c6..b3cde67 100644
--- a/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Configuration.java
+++ b/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Configuration.java
@@ -47,6 +47,8 @@ public class KMS2Configuration implements Cloneable {
     private Integer proxyPort;
     @UriParam
     private String region;
+    @UriParam(defaultValue = "false")
+    private boolean pojoRequest;
 
     public KmsClient getKmsClient() {
         return kmsClient;
@@ -137,6 +139,17 @@ public class KMS2Configuration implements Cloneable {
     public void setRegion(String region) {
         this.region = region;
     }
+    
+    public boolean isPojoRequest() {
+        return pojoRequest;
+    }
+
+    /**
+     * If we want to use a POJO request as body or not
+     */
+    public void setPojoRequest(boolean pojoRequest) {
+        this.pojoRequest = pojoRequest;
+    }
 
     // *************************************************
     //
diff --git a/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java b/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
index 74ab670..46069e0 100644
--- a/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
+++ b/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
@@ -25,6 +25,8 @@ import org.apache.camel.util.URISupport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import software.amazon.awssdk.awscore.exception.AwsServiceException;
+import software.amazon.awssdk.services.ec2.model.RunInstancesRequest;
+import software.amazon.awssdk.services.ec2.model.RunInstancesResponse;
 import software.amazon.awssdk.services.kms.KmsClient;
 import software.amazon.awssdk.services.kms.model.CreateKeyRequest;
 import software.amazon.awssdk.services.kms.model.CreateKeyResponse;
@@ -109,6 +111,20 @@ public class KMS2Producer extends DefaultProducer {
     }
 
     private void listKeys(KmsClient kmsClient, Exchange exchange) {
+        if (getConfiguration().isPojoRequest()) {
+            Object payload = exchange.getIn().getMandatoryBody();
+            if (payload instanceof ListKeysRequest) {
+                ListKeysResponse result;
+                try {
+                    result = kmsClient.listKeys((ListKeysRequest) payload);
+                } catch (AwsServiceException ase) {
+                    LOG.trace("List Keys command returned the error code {}", ase.awsErrorDetails().errorCode());
+                    throw ase;
+                }
+                Message message = getMessageForResponse(exchange);
+                message.setBody(result);
+            }
+        } else {
         ListKeysRequest.Builder builder = ListKeysRequest.builder();
         if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(KMS2Constants.LIMIT))) {
             int limit = exchange.getIn().getHeader(KMS2Constants.LIMIT, Integer.class);
@@ -123,6 +139,7 @@ public class KMS2Producer extends DefaultProducer {
         }
         Message message = getMessageForResponse(exchange);
         message.setBody(result);
+        }
     }
 
     private void createKey(KmsClient kmsClient, Exchange exchange) {


[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-kms fixed CS

Posted by ac...@apache.org.
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 104165fe8fae95f76c5916a03ebaf95646798855
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Apr 14 11:16:14 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms fixed CS
---
 .../camel/component/aws2/kms/KMS2Producer.java     | 204 ++++++++++-----------
 1 file changed, 102 insertions(+), 102 deletions(-)

diff --git a/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java b/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
index e768187..b98ba85 100644
--- a/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
+++ b/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
@@ -115,7 +115,7 @@ public class KMS2Producer extends DefaultProducer {
             if (payload instanceof ListKeysRequest) {
                 ListKeysResponse result;
                 try {
-                    result = kmsClient.listKeys((ListKeysRequest) payload);
+                    result = kmsClient.listKeys((ListKeysRequest)payload);
                 } catch (AwsServiceException ase) {
                     LOG.trace("List Keys command returned the error code {}", ase.awsErrorDetails().errorCode());
                     throw ase;
@@ -124,20 +124,20 @@ public class KMS2Producer extends DefaultProducer {
                 message.setBody(result);
             }
         } else {
-        ListKeysRequest.Builder builder = ListKeysRequest.builder();
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(KMS2Constants.LIMIT))) {
-            int limit = exchange.getIn().getHeader(KMS2Constants.LIMIT, Integer.class);
-            builder.limit(limit);
-        }
-        ListKeysResponse result;
-        try {
-            result = kmsClient.listKeys(builder.build());
-        } catch (AwsServiceException ase) {
-            LOG.trace("List Keys command returned the error code {}", ase.awsErrorDetails().errorCode());
-            throw ase;
-        }
-        Message message = getMessageForResponse(exchange);
-        message.setBody(result);
+            ListKeysRequest.Builder builder = ListKeysRequest.builder();
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(KMS2Constants.LIMIT))) {
+                int limit = exchange.getIn().getHeader(KMS2Constants.LIMIT, Integer.class);
+                builder.limit(limit);
+            }
+            ListKeysResponse result;
+            try {
+                result = kmsClient.listKeys(builder.build());
+            } catch (AwsServiceException ase) {
+                LOG.trace("List Keys command returned the error code {}", ase.awsErrorDetails().errorCode());
+                throw ase;
+            }
+            Message message = getMessageForResponse(exchange);
+            message.setBody(result);
         }
     }
 
@@ -147,7 +147,7 @@ public class KMS2Producer extends DefaultProducer {
             if (payload instanceof CreateKeyRequest) {
                 CreateKeyResponse result;
                 try {
-                    result = kmsClient.createKey((CreateKeyRequest) payload);
+                    result = kmsClient.createKey((CreateKeyRequest)payload);
                 } catch (AwsServiceException ase) {
                     LOG.trace("Create Key command returned the error code {}", ase.awsErrorDetails().errorCode());
                     throw ase;
@@ -156,20 +156,20 @@ public class KMS2Producer extends DefaultProducer {
                 message.setBody(result);
             }
         } else {
-        CreateKeyRequest.Builder builder = CreateKeyRequest.builder();
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(KMS2Constants.DESCRIPTION))) {
-            String description = exchange.getIn().getHeader(KMS2Constants.DESCRIPTION, String.class);
-            builder.description(description);
-        }
-        CreateKeyResponse result;
-        try {
-            result = kmsClient.createKey(builder.build());
-        } catch (AwsServiceException ase) {
-            LOG.trace("Create Key command returned the error code {}", ase.awsErrorDetails().errorCode());
-            throw ase;
-        }
-        Message message = getMessageForResponse(exchange);
-        message.setBody(result);
+            CreateKeyRequest.Builder builder = CreateKeyRequest.builder();
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(KMS2Constants.DESCRIPTION))) {
+                String description = exchange.getIn().getHeader(KMS2Constants.DESCRIPTION, String.class);
+                builder.description(description);
+            }
+            CreateKeyResponse result;
+            try {
+                result = kmsClient.createKey(builder.build());
+            } catch (AwsServiceException ase) {
+                LOG.trace("Create Key command returned the error code {}", ase.awsErrorDetails().errorCode());
+                throw ase;
+            }
+            Message message = getMessageForResponse(exchange);
+            message.setBody(result);
         }
     }
 
@@ -179,7 +179,7 @@ public class KMS2Producer extends DefaultProducer {
             if (payload instanceof DisableKeyRequest) {
                 DisableKeyResponse result;
                 try {
-                    result = kmsClient.disableKey((DisableKeyRequest) payload);
+                    result = kmsClient.disableKey((DisableKeyRequest)payload);
                 } catch (AwsServiceException ase) {
                     LOG.trace("Disable Key command returned the error code {}", ase.awsErrorDetails().errorCode());
                     throw ase;
@@ -188,22 +188,22 @@ public class KMS2Producer extends DefaultProducer {
                 message.setBody(result);
             }
         } else {
-        DisableKeyRequest.Builder builder = DisableKeyRequest.builder();
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(KMS2Constants.KEY_ID))) {
-            String keyId = exchange.getIn().getHeader(KMS2Constants.KEY_ID, String.class);
-            builder.keyId(keyId);
-        } else {
-            throw new IllegalArgumentException("Key Id must be specified");
-        }
-        DisableKeyResponse result;
-        try {
-            result = kmsClient.disableKey(builder.build());
-        } catch (AwsServiceException ase) {
-            LOG.trace("Disable Key command returned the error code {}", ase.awsErrorDetails().errorCode());
-            throw ase;
-        }
-        Message message = getMessageForResponse(exchange);
-        message.setBody(result);
+            DisableKeyRequest.Builder builder = DisableKeyRequest.builder();
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(KMS2Constants.KEY_ID))) {
+                String keyId = exchange.getIn().getHeader(KMS2Constants.KEY_ID, String.class);
+                builder.keyId(keyId);
+            } else {
+                throw new IllegalArgumentException("Key Id must be specified");
+            }
+            DisableKeyResponse result;
+            try {
+                result = kmsClient.disableKey(builder.build());
+            } catch (AwsServiceException ase) {
+                LOG.trace("Disable Key command returned the error code {}", ase.awsErrorDetails().errorCode());
+                throw ase;
+            }
+            Message message = getMessageForResponse(exchange);
+            message.setBody(result);
         }
     }
 
@@ -213,7 +213,7 @@ public class KMS2Producer extends DefaultProducer {
             if (payload instanceof ScheduleKeyDeletionRequest) {
                 ScheduleKeyDeletionResponse result;
                 try {
-                    result = kmsClient.scheduleKeyDeletion((ScheduleKeyDeletionRequest) payload);
+                    result = kmsClient.scheduleKeyDeletion((ScheduleKeyDeletionRequest)payload);
                 } catch (AwsServiceException ase) {
                     LOG.trace("Schedule Key Deletion command returned the error code {}", ase.awsErrorDetails().errorCode());
                     throw ase;
@@ -222,26 +222,26 @@ public class KMS2Producer extends DefaultProducer {
                 message.setBody(result);
             }
         } else {
-        ScheduleKeyDeletionRequest.Builder builder = ScheduleKeyDeletionRequest.builder();
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(KMS2Constants.KEY_ID))) {
-            String keyId = exchange.getIn().getHeader(KMS2Constants.KEY_ID, String.class);
-            builder.keyId(keyId);
-        } else {
-            throw new IllegalArgumentException("Key Id must be specified");
-        }
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(KMS2Constants.PENDING_WINDOW_IN_DAYS))) {
-            int pendingWindows = exchange.getIn().getHeader(KMS2Constants.PENDING_WINDOW_IN_DAYS, Integer.class);
-            builder.pendingWindowInDays(pendingWindows);
-        }
-        ScheduleKeyDeletionResponse result;
-        try {
-            result = kmsClient.scheduleKeyDeletion(builder.build());
-        } catch (AwsServiceException ase) {
-            LOG.trace("Schedule Key Deletion command returned the error code {}", ase.awsErrorDetails().errorCode());
-            throw ase;
-        }
-        Message message = getMessageForResponse(exchange);
-        message.setBody(result);
+            ScheduleKeyDeletionRequest.Builder builder = ScheduleKeyDeletionRequest.builder();
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(KMS2Constants.KEY_ID))) {
+                String keyId = exchange.getIn().getHeader(KMS2Constants.KEY_ID, String.class);
+                builder.keyId(keyId);
+            } else {
+                throw new IllegalArgumentException("Key Id must be specified");
+            }
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(KMS2Constants.PENDING_WINDOW_IN_DAYS))) {
+                int pendingWindows = exchange.getIn().getHeader(KMS2Constants.PENDING_WINDOW_IN_DAYS, Integer.class);
+                builder.pendingWindowInDays(pendingWindows);
+            }
+            ScheduleKeyDeletionResponse result;
+            try {
+                result = kmsClient.scheduleKeyDeletion(builder.build());
+            } catch (AwsServiceException ase) {
+                LOG.trace("Schedule Key Deletion command returned the error code {}", ase.awsErrorDetails().errorCode());
+                throw ase;
+            }
+            Message message = getMessageForResponse(exchange);
+            message.setBody(result);
         }
     }
 
@@ -251,7 +251,7 @@ public class KMS2Producer extends DefaultProducer {
             if (payload instanceof DescribeKeyRequest) {
                 DescribeKeyResponse result;
                 try {
-                    result = kmsClient.describeKey((DescribeKeyRequest) payload);
+                    result = kmsClient.describeKey((DescribeKeyRequest)payload);
                 } catch (AwsServiceException ase) {
                     LOG.trace("Describe Key command returned the error code {}", ase.awsErrorDetails().errorCode());
                     throw ase;
@@ -260,22 +260,22 @@ public class KMS2Producer extends DefaultProducer {
                 message.setBody(result);
             }
         } else {
-        DescribeKeyRequest.Builder builder = DescribeKeyRequest.builder();
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(KMS2Constants.KEY_ID))) {
-            String keyId = exchange.getIn().getHeader(KMS2Constants.KEY_ID, String.class);
-            builder.keyId(keyId);
-        } else {
-            throw new IllegalArgumentException("Key Id must be specified");
-        }
-        DescribeKeyResponse result;
-        try {
-            result = kmsClient.describeKey(builder.build());
-        } catch (AwsServiceException ase) {
-            LOG.trace("Describe Key command returned the error code {}", ase.awsErrorDetails().errorCode());
-            throw ase;
-        }
-        Message message = getMessageForResponse(exchange);
-        message.setBody(result);
+            DescribeKeyRequest.Builder builder = DescribeKeyRequest.builder();
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(KMS2Constants.KEY_ID))) {
+                String keyId = exchange.getIn().getHeader(KMS2Constants.KEY_ID, String.class);
+                builder.keyId(keyId);
+            } else {
+                throw new IllegalArgumentException("Key Id must be specified");
+            }
+            DescribeKeyResponse result;
+            try {
+                result = kmsClient.describeKey(builder.build());
+            } catch (AwsServiceException ase) {
+                LOG.trace("Describe Key command returned the error code {}", ase.awsErrorDetails().errorCode());
+                throw ase;
+            }
+            Message message = getMessageForResponse(exchange);
+            message.setBody(result);
         }
     }
 
@@ -285,7 +285,7 @@ public class KMS2Producer extends DefaultProducer {
             if (payload instanceof EnableKeyRequest) {
                 EnableKeyResponse result;
                 try {
-                    result = kmsClient.enableKey((EnableKeyRequest) payload);
+                    result = kmsClient.enableKey((EnableKeyRequest)payload);
                 } catch (AwsServiceException ase) {
                     LOG.trace("Enable Key command returned the error code {}", ase.awsErrorDetails().errorCode());
                     throw ase;
@@ -294,22 +294,22 @@ public class KMS2Producer extends DefaultProducer {
                 message.setBody(result);
             }
         } else {
-        EnableKeyRequest.Builder builder = EnableKeyRequest.builder();
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(KMS2Constants.KEY_ID))) {
-            String keyId = exchange.getIn().getHeader(KMS2Constants.KEY_ID, String.class);
-            builder.keyId(keyId);
-        } else {
-            throw new IllegalArgumentException("Key Id must be specified");
-        }
-        EnableKeyResponse result;
-        try {
-            result = kmsClient.enableKey(builder.build());
-        } catch (AwsServiceException ase) {
-            LOG.trace("Enable Key command returned the error code {}", ase.awsErrorDetails().errorCode());
-            throw ase;
-        }
-        Message message = getMessageForResponse(exchange);
-        message.setBody(result);
+            EnableKeyRequest.Builder builder = EnableKeyRequest.builder();
+            if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(KMS2Constants.KEY_ID))) {
+                String keyId = exchange.getIn().getHeader(KMS2Constants.KEY_ID, String.class);
+                builder.keyId(keyId);
+            } else {
+                throw new IllegalArgumentException("Key Id must be specified");
+            }
+            EnableKeyResponse result;
+            try {
+                result = kmsClient.enableKey(builder.build());
+            } catch (AwsServiceException ase) {
+                LOG.trace("Enable Key command returned the error code {}", ase.awsErrorDetails().errorCode());
+                throw ase;
+            }
+            Message message = getMessageForResponse(exchange);
+            message.setBody(result);
         }
     }
 


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

Posted by ac...@apache.org.
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 971c6919ddd197cc11aa238498b5299c4f301e2d
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Apr 14 11:15:11 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms enable key
---
 .../apache/camel/component/aws2/kms/KMS2Producer.java | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java b/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
index 8bf4631..e768187 100644
--- a/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
+++ b/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
@@ -26,8 +26,6 @@ import org.apache.camel.util.URISupport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import software.amazon.awssdk.awscore.exception.AwsServiceException;
-import software.amazon.awssdk.services.ec2.model.RunInstancesRequest;
-import software.amazon.awssdk.services.ec2.model.RunInstancesResponse;
 import software.amazon.awssdk.services.kms.KmsClient;
 import software.amazon.awssdk.services.kms.model.CreateKeyRequest;
 import software.amazon.awssdk.services.kms.model.CreateKeyResponse;
@@ -281,7 +279,21 @@ public class KMS2Producer extends DefaultProducer {
         }
     }
 
-    private void enableKey(KmsClient kmsClient, Exchange exchange) {
+    private void enableKey(KmsClient kmsClient, Exchange exchange) throws InvalidPayloadException {
+        if (getConfiguration().isPojoRequest()) {
+            Object payload = exchange.getIn().getMandatoryBody();
+            if (payload instanceof EnableKeyRequest) {
+                EnableKeyResponse result;
+                try {
+                    result = kmsClient.enableKey((EnableKeyRequest) payload);
+                } catch (AwsServiceException ase) {
+                    LOG.trace("Enable Key command returned the error code {}", ase.awsErrorDetails().errorCode());
+                    throw ase;
+                }
+                Message message = getMessageForResponse(exchange);
+                message.setBody(result);
+            }
+        } else {
         EnableKeyRequest.Builder builder = EnableKeyRequest.builder();
         if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(KMS2Constants.KEY_ID))) {
             String keyId = exchange.getIn().getHeader(KMS2Constants.KEY_ID, String.class);
@@ -298,6 +310,7 @@ public class KMS2Producer extends DefaultProducer {
         }
         Message message = getMessageForResponse(exchange);
         message.setBody(result);
+        }
     }
 
     public static Message getMessageForResponse(final Exchange exchange) {


[camel] 09/10: CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms added a little test

Posted by ac...@apache.org.
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 6acf9e5a89d50728476b00e231f2fe1c64aa1916
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Apr 14 11:29:49 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms added a little test
---
 .../camel/component/aws2/kms/KMSProducerTest.java   | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/components/camel-aws2-kms/src/test/java/org/apache/camel/component/aws2/kms/KMSProducerTest.java b/components/camel-aws2-kms/src/test/java/org/apache/camel/component/aws2/kms/KMSProducerTest.java
index 0a16d29..8ace11d 100644
--- a/components/camel-aws2-kms/src/test/java/org/apache/camel/component/aws2/kms/KMSProducerTest.java
+++ b/components/camel-aws2-kms/src/test/java/org/apache/camel/component/aws2/kms/KMSProducerTest.java
@@ -26,6 +26,7 @@ import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
 import software.amazon.awssdk.services.kms.model.CreateKeyResponse;
 import software.amazon.awssdk.services.kms.model.DescribeKeyResponse;
+import software.amazon.awssdk.services.kms.model.ListKeysRequest;
 import software.amazon.awssdk.services.kms.model.ListKeysResponse;
 import software.amazon.awssdk.services.kms.model.ScheduleKeyDeletionResponse;
 
@@ -57,6 +58,25 @@ public class KMSProducerTest extends CamelTestSupport {
         assertEquals(1, resultGet.keys().size());
         assertEquals("keyId", resultGet.keys().get(0).keyId());
     }
+    
+    @Test
+    public void kmsListKeysPojoTest() throws Exception {
+
+        mock.expectedMessageCount(1);
+        Exchange exchange = template.request("direct:listKeysPojo", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(KMS2Constants.OPERATION, KMS2Operations.listKeys);
+                exchange.getIn().setBody(ListKeysRequest.builder().limit(10).build());
+            }
+        });
+
+        assertMockEndpointsSatisfied();
+
+        ListKeysResponse resultGet = (ListKeysResponse)exchange.getIn().getBody();
+        assertEquals(1, resultGet.keys().size());
+        assertEquals("keyId", resultGet.keys().get(0).keyId());
+    }
 
     @Test
     public void kmsCreateKeyTest() throws Exception {
@@ -152,6 +172,7 @@ public class KMSProducerTest extends CamelTestSupport {
             @Override
             public void configure() throws Exception {
                 from("direct:listKeys").to("aws2-kms://test?kmsClient=#amazonKmsClient&operation=listKeys").to("mock:result");
+                from("direct:listKeysPojo").to("aws2-kms://test?kmsClient=#amazonKmsClient&operation=listKeys&pojoRequest=true").to("mock:result");
                 from("direct:createKey").to("aws2-kms://test?kmsClient=#amazonKmsClient&operation=createKey").to("mock:result");
                 from("direct:disableKey").to("aws2-kms://test?kmsClient=#amazonKmsClient&operation=disableKey").to("mock:result");
                 from("direct:enableKey").to("aws2-kms://test?kmsClient=#amazonKmsClient&operation=enableKey").to("mock:result");


[camel] 04/10: CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms scheduled key deletion

Posted by ac...@apache.org.
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 65b4653cbcc4e624ef6f3df97e328dcd7fd6249d
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Apr 14 11:11:28 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms scheduled key deletion
---
 .../apache/camel/component/aws2/kms/KMS2Producer.java   | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java b/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
index 83f34d8..0d04235 100644
--- a/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
+++ b/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
@@ -175,7 +175,7 @@ public class KMS2Producer extends DefaultProducer {
         }
     }
 
-    private void disableKey(KmsClient kmsClient, Exchange exchange) {
+    private void disableKey(KmsClient kmsClient, Exchange exchange) throws InvalidPayloadException {
         if (getConfiguration().isPojoRequest()) {
             Object payload = exchange.getIn().getMandatoryBody();
             if (payload instanceof DisableKeyRequest) {
@@ -210,6 +210,20 @@ public class KMS2Producer extends DefaultProducer {
     }
 
     private void scheduleKeyDeletion(KmsClient kmsClient, Exchange exchange) {
+        if (getConfiguration().isPojoRequest()) {
+            Object payload = exchange.getIn().getMandatoryBody();
+            if (payload instanceof ScheduleKeyDeletionRequest) {
+                ScheduleKeyDeletionResponse result;
+                try {
+                    result = kmsClient.scheduleKeyDeletion((ScheduleKeyDeletionRequest) payload);
+                } catch (AwsServiceException ase) {
+                    LOG.trace("Schedule Key Deletion command returned the error code {}", ase.awsErrorDetails().errorCode());
+                    throw ase;
+                }
+                Message message = getMessageForResponse(exchange);
+                message.setBody(result);
+            }
+        } else {
         ScheduleKeyDeletionRequest.Builder builder = ScheduleKeyDeletionRequest.builder();
         if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(KMS2Constants.KEY_ID))) {
             String keyId = exchange.getIn().getHeader(KMS2Constants.KEY_ID, String.class);
@@ -230,6 +244,7 @@ public class KMS2Producer extends DefaultProducer {
         }
         Message message = getMessageForResponse(exchange);
         message.setBody(result);
+        }
     }
 
     private void describeKey(KmsClient kmsClient, Exchange exchange) {


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

Posted by ac...@apache.org.
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 fac900a9011cdd3968617206ddb5894423fb6448
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Tue Apr 14 10:43:06 2020 +0200

    CAMEL-14868 - Camel-AWS2-*: Where possible, give the possiblity to the end user to pass an AWS Request pojo as body, aws2-kms disable key
---
 .../org/apache/camel/component/aws2/kms/KMS2Producer.java | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java b/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
index e107a00..83f34d8 100644
--- a/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
+++ b/components/camel-aws2-kms/src/main/java/org/apache/camel/component/aws2/kms/KMS2Producer.java
@@ -176,6 +176,20 @@ public class KMS2Producer extends DefaultProducer {
     }
 
     private void disableKey(KmsClient kmsClient, Exchange exchange) {
+        if (getConfiguration().isPojoRequest()) {
+            Object payload = exchange.getIn().getMandatoryBody();
+            if (payload instanceof DisableKeyRequest) {
+                DisableKeyResponse result;
+                try {
+                    result = kmsClient.disableKey((DisableKeyRequest) payload);
+                } catch (AwsServiceException ase) {
+                    LOG.trace("Disable Key command returned the error code {}", ase.awsErrorDetails().errorCode());
+                    throw ase;
+                }
+                Message message = getMessageForResponse(exchange);
+                message.setBody(result);
+            }
+        } else {
         DisableKeyRequest.Builder builder = DisableKeyRequest.builder();
         if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(KMS2Constants.KEY_ID))) {
             String keyId = exchange.getIn().getHeader(KMS2Constants.KEY_ID, String.class);
@@ -192,6 +206,7 @@ public class KMS2Producer extends DefaultProducer {
         }
         Message message = getMessageForResponse(exchange);
         message.setBody(result);
+        }
     }
 
     private void scheduleKeyDeletion(KmsClient kmsClient, Exchange exchange) {