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 2023/12/21 10:17:03 UTC

(camel) branch CAMEL-20271 created (now 405b21cea07)

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

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


      at 405b21cea07 CAMEL-20271 - Camel-AWS-Cloudtrail: Improve consumers by adding more information as exchange headers

This branch includes the following new commits:

     new 0e2e04636f2 CAMEL-20271 - Camel-AWS-Cloudtrail: Improve consumers by adding more information as exchange headers
     new 405b21cea07 CAMEL-20271 - Camel-AWS-Cloudtrail: Improve consumers by adding more information as exchange headers

The 2 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.



(camel) 02/02: CAMEL-20271 - Camel-AWS-Cloudtrail: Improve consumers by adding more information as exchange headers

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch CAMEL-20271
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 405b21cea0792b56c86ef6a6d12e6ce298334e9e
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Dec 21 11:16:47 2023 +0100

    CAMEL-20271 - Camel-AWS-Cloudtrail: Improve consumers by adding more information as exchange headers
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../org/apache/camel/catalog/components/aws-cloudtrail.json         | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-cloudtrail.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-cloudtrail.json
index 6b472daa954..365616cb18a 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-cloudtrail.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws-cloudtrail.json
@@ -43,6 +43,12 @@
     "useDefaultCredentialsProvider": { "index": 18, "kind": "property", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws.cloudtrail.CloudtrailConfiguration", "configurationField": "configuration", "description": "Set whether the Cloudtrail client shoul [...]
     "useProfileCredentialsProvider": { "index": 19, "kind": "property", "displayName": "Use Profile Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws.cloudtrail.CloudtrailConfiguration", "configurationField": "configuration", "description": "Set whether the Cloudtrail client shoul [...]
   },
+  "headers": {
+    "CamelAwsCloudTrailEventId": { "index": 0, "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The event ID of the cloud trail event consumed.", "constantName": "org.apache.camel.component.aws.cloudtrail.CloudtrailConstants#EVENT_ID" },
+    "CamelAwsCloudTrailEventName": { "index": 1, "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The event Name of the cloud trail event consumed.", "constantName": "org.apache.camel.component.aws.cloudtrail.CloudtrailConstants#EVENT_NAME" },
+    "CamelAwsCloudTrailEventSource": { "index": 2, "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The event Source of the cloud trail event consumed.", "constantName": "org.apache.camel.component.aws.cloudtrail.CloudtrailConstants#EVENT_SOURCE" },
+    "CamelAwsCloudTrailEventUsername": { "index": 3, "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The associated username of the event of the cloud trail event consumed.", "constantName": "org.apache.camel.component.aws.cloudtrail.CloudtrailConstants#USERNAME" }
+  },
   "properties": {
     "label": { "index": 0, "kind": "path", "displayName": "Label", "group": "consumer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws.cloudtrail.CloudtrailConfiguration", "configurationField": "configuration", "description": "A label for indexing cloudtrail endpoints" },
     "eventSource": { "index": 1, "kind": "parameter", "displayName": "Event Source", "group": "consumer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws.cloudtrail.CloudtrailConfiguration", "configurationField": "configuration", "description": "Specify an event source to select events" },


(camel) 01/02: CAMEL-20271 - Camel-AWS-Cloudtrail: Improve consumers by adding more information as exchange headers

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch CAMEL-20271
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 0e2e04636f2d0bdc6feb4a821e6d81b9ff414c35
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Thu Dec 21 11:06:11 2023 +0100

    CAMEL-20271 - Camel-AWS-Cloudtrail: Improve consumers by adding more information as exchange headers
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 .../camel/component/aws/cloudtrail/aws-cloudtrail.json    |  6 ++++++
 .../component/aws/cloudtrail/CloudtrailConstants.java     | 15 +++++++++++++++
 .../component/aws/cloudtrail/CloudtrailConsumer.java      | 12 ++++++------
 3 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/components/camel-aws/camel-aws-cloudtrail/src/generated/resources/org/apache/camel/component/aws/cloudtrail/aws-cloudtrail.json b/components/camel-aws/camel-aws-cloudtrail/src/generated/resources/org/apache/camel/component/aws/cloudtrail/aws-cloudtrail.json
index 6b472daa954..365616cb18a 100644
--- a/components/camel-aws/camel-aws-cloudtrail/src/generated/resources/org/apache/camel/component/aws/cloudtrail/aws-cloudtrail.json
+++ b/components/camel-aws/camel-aws-cloudtrail/src/generated/resources/org/apache/camel/component/aws/cloudtrail/aws-cloudtrail.json
@@ -43,6 +43,12 @@
     "useDefaultCredentialsProvider": { "index": 18, "kind": "property", "displayName": "Use Default Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws.cloudtrail.CloudtrailConfiguration", "configurationField": "configuration", "description": "Set whether the Cloudtrail client shoul [...]
     "useProfileCredentialsProvider": { "index": 19, "kind": "property", "displayName": "Use Profile Credentials Provider", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws.cloudtrail.CloudtrailConfiguration", "configurationField": "configuration", "description": "Set whether the Cloudtrail client shoul [...]
   },
+  "headers": {
+    "CamelAwsCloudTrailEventId": { "index": 0, "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The event ID of the cloud trail event consumed.", "constantName": "org.apache.camel.component.aws.cloudtrail.CloudtrailConstants#EVENT_ID" },
+    "CamelAwsCloudTrailEventName": { "index": 1, "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The event Name of the cloud trail event consumed.", "constantName": "org.apache.camel.component.aws.cloudtrail.CloudtrailConstants#EVENT_NAME" },
+    "CamelAwsCloudTrailEventSource": { "index": 2, "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The event Source of the cloud trail event consumed.", "constantName": "org.apache.camel.component.aws.cloudtrail.CloudtrailConstants#EVENT_SOURCE" },
+    "CamelAwsCloudTrailEventUsername": { "index": 3, "kind": "header", "displayName": "", "group": "consumer", "label": "", "required": false, "javaType": "String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "The associated username of the event of the cloud trail event consumed.", "constantName": "org.apache.camel.component.aws.cloudtrail.CloudtrailConstants#USERNAME" }
+  },
   "properties": {
     "label": { "index": 0, "kind": "path", "displayName": "Label", "group": "consumer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws.cloudtrail.CloudtrailConfiguration", "configurationField": "configuration", "description": "A label for indexing cloudtrail endpoints" },
     "eventSource": { "index": 1, "kind": "parameter", "displayName": "Event Source", "group": "consumer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws.cloudtrail.CloudtrailConfiguration", "configurationField": "configuration", "description": "Specify an event source to select events" },
diff --git a/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/CloudtrailConstants.java b/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/CloudtrailConstants.java
index 3578d1ff1e0..b2db9a7099b 100644
--- a/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/CloudtrailConstants.java
+++ b/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/CloudtrailConstants.java
@@ -16,5 +16,20 @@
  */
 package org.apache.camel.component.aws.cloudtrail;
 
+import org.apache.camel.spi.Metadata;
+
 public interface CloudtrailConstants {
+
+    @Metadata(description = "The event ID of the cloud trail event consumed.",
+              javaType = "String")
+    String EVENT_ID = "CamelAwsCloudTrailEventId";
+    @Metadata(description = "The event Name of the cloud trail event consumed.",
+              javaType = "String")
+    String EVENT_NAME = "CamelAwsCloudTrailEventName";
+    @Metadata(description = "The event Source of the cloud trail event consumed.",
+              javaType = "String")
+    String EVENT_SOURCE = "CamelAwsCloudTrailEventSource";
+    @Metadata(description = "The associated username of the event of the cloud trail event consumed.",
+              javaType = "String")
+    String USERNAME = "CamelAwsCloudTrailEventUsername";
 }
diff --git a/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/CloudtrailConsumer.java b/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/CloudtrailConsumer.java
index 1740d05c0bf..f74a831e2f7 100644
--- a/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/CloudtrailConsumer.java
+++ b/components/camel-aws/camel-aws-cloudtrail/src/main/java/org/apache/camel/component/aws/cloudtrail/CloudtrailConsumer.java
@@ -30,11 +30,7 @@ import org.apache.camel.support.ScheduledBatchPollingConsumer;
 import org.apache.camel.util.CastUtils;
 import org.apache.camel.util.ObjectHelper;
 import software.amazon.awssdk.services.cloudtrail.CloudTrailClient;
-import software.amazon.awssdk.services.cloudtrail.model.Event;
-import software.amazon.awssdk.services.cloudtrail.model.LookupAttribute;
-import software.amazon.awssdk.services.cloudtrail.model.LookupAttributeKey;
-import software.amazon.awssdk.services.cloudtrail.model.LookupEventsRequest;
-import software.amazon.awssdk.services.cloudtrail.model.LookupEventsResponse;
+import software.amazon.awssdk.services.cloudtrail.model.*;
 
 public class CloudtrailConsumer extends ScheduledBatchPollingConsumer {
     private static Instant lastTime;
@@ -107,7 +103,11 @@ public class CloudtrailConsumer extends ScheduledBatchPollingConsumer {
 
     protected Exchange createExchange(Event event) {
         Exchange exchange = createExchange(true);
-        exchange.getIn().setBody(event.cloudTrailEvent().getBytes(StandardCharsets.UTF_8));
+        exchange.getMessage().setBody(event.cloudTrailEvent().getBytes(StandardCharsets.UTF_8));
+        exchange.getMessage().setHeader(CloudtrailConstants.EVENT_ID, event.eventId());
+        exchange.getMessage().setHeader(CloudtrailConstants.EVENT_NAME, event.eventName());
+        exchange.getMessage().setHeader(CloudtrailConstants.EVENT_SOURCE, event.eventSource());
+        exchange.getMessage().setHeader(CloudtrailConstants.USERNAME, event.username());
         return exchange;
     }
 }