From d6868f06288b185e5f384aaaa229b7e19a1d8d38 Mon Sep 17 00:00:00 2001 From: Christoph Deppisch Date: Wed, 6 Sep 2023 18:03:24 +0200 Subject: [PATCH] Expose Kamelet data type information - AWS DDB sink Kamelet input data type information - AWS S3 source output data type information --- kamelets/aws-ddb-sink.kamelet.yaml | 46 ++++++++++++++-- kamelets/aws-s3-source.kamelet.yaml | 55 +++++++++++++++++++ .../converter/aws2/ddb/Ddb2JsonInputType.java | 8 +-- .../kamelets/aws-ddb-sink.kamelet.yaml | 46 ++++++++++++++-- .../kamelets/aws-s3-source.kamelet.yaml | 55 +++++++++++++++++++ 5 files changed, 196 insertions(+), 14 deletions(-) diff --git a/kamelets/aws-ddb-sink.kamelet.yaml b/kamelets/aws-ddb-sink.kamelet.yaml index f6e7bcd03..f778f1d2b 100644 --- a/kamelets/aws-ddb-sink.kamelet.yaml +++ b/kamelets/aws-ddb-sink.kamelet.yaml @@ -44,10 +44,11 @@ spec: For DeleteItem operation the Json body defines only the primary key attributes that identify the item to delete. For UpdateItem operation the Json body defines both key attributes to identify the item to be updated and all item attributes tht get updated on the item. - The given Json body can use "key" and "item" as top level properties. Both define a Json object that will be mapped to respective attribute value maps + The given Json body can use "operation", "key" and "item" as top level properties that will be mapped to respective attribute value maps. { - "key": {}, - "item": {} + "operation": "PutItem" + "key": {}, + "item": {} } required: - table @@ -104,9 +105,44 @@ spec: x-descriptors: - 'urn:alm:descriptor:com.tectonic.ui:checkbox' default: false - types: + dataTypes: in: - mediaType: application/json + default: json + types: + json: + format: "aws2-ddb:application-json" + description: |- + Json representation of a DDB operation. The input type supports the operations: PutItem, UpdateItem, DeleteItem + + For PutItem operation the Json body defines all item attributes. + For DeleteItem operation the Json body defines only the primary key attributes that identify the item to delete. + For UpdateItem operation the Json body defines both key attributes to identify the item to be updated and all item attributes tht get updated on the item. + + The given Json body can use "operation", "key" and "item" as top level properties that will be mapped to respective attribute value maps. + headers: + CamelAwsDdbOperation: + title: Operation + description: The operation to perform. Overwrites the operation given in the Json body. One of PutItem, UpdateItem, DeleteItem. + default: PutItem + type: string + CamelAwsDdbReturnValues: + title: Return Values + description: Use this parameter if you want to get the attribute name-value pairs before or after they are modified. Possible values are NONE, ALL_OLD, UPDATED_OLD, ALL_NEW, UPDATED_NEW. + type: string + mediaType: application/json + schema: + type: object + required: [ "key" ] + properties: + operation: + type: string + description: The operator to perform. One of PutItem, UpdateItem, DeleteItem + key: + type: object + description: The primary key specifies the selection criteria for the query. + item: + type: object + description: Attribute value map specifies all attributes to change with the given operation. dependencies: - mvn:org.apache.camel.kamelets:camel-kamelets-utils:4.1.0-SNAPSHOT - "camel:core" diff --git a/kamelets/aws-s3-source.kamelet.yaml b/kamelets/aws-s3-source.kamelet.yaml index 823425034..c38cc9900 100644 --- a/kamelets/aws-s3-source.kamelet.yaml +++ b/kamelets/aws-s3-source.kamelet.yaml @@ -101,6 +101,61 @@ spec: description: The number of milliseconds before the next poll of the selected bucket. type: integer default: 500 + dataTypes: + out: + default: binary + headers: + CamelAwsS3BucketName: + title: S3 Bucket Name + description: The bucket name which has been used to retrieve objects + type: string + CamelAwsS3Key: + title: S3 Key + description: The key under which the retrieved object is stored + type: string + CamelAwsS3ContentType: + title: Content Type + description: The content type of the retrieved object. + default: application/octet-stream + type: string + CamelAwsS3ETag: + title: ETag Value + description: |- + The hex encoded 128-bit MD5 digest of the associated object according to RFC 1864. + This data is used as an integrity check to verify that the data received by the caller is the same data that was sent by Amazon S3. + type: string + types: + binary: + format: "application-octet-stream" + description: Default binary representation of the S3 object retrieved from the bucket. + mediaType: application/octet-stream + cloudevents: + format: "aws2-s3:application-cloudevents" + description: |- + Output data type represents AWS S3 get object response as CloudEvent V1. The data type sets Camel specific CloudEvent headers on the exchange with + respective data from the S3 bucket and its derived object. + headers: + CamelCloudEventID: + title: CloudEvent ID + description: The Camel exchange id set as event id + type: string + CamelCloudEventType: + title: CloudEvent Type + description: The event type + default: "org.apache.camel.event.aws.s3.getObject" + type: string + CamelCloudEventSource: + title: CloudEvent Source + description: The event source. By default, the S3 bucket name with prefix "aws.s3.bucket.". + type: string + CamelCloudEventSubject: + title: CloudEvent Subject + description: The event subject. Usually the S3 key. + type: string + CamelCloudEventTime: + title: CloudEvent Time + description: The exchange creation timestamp as event time. + type: string dependencies: - "camel:core" - "camel:aws2-s3" diff --git a/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/converter/aws2/ddb/Ddb2JsonInputType.java b/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/converter/aws2/ddb/Ddb2JsonInputType.java index b9b20f3fd..d56b6f0e4 100644 --- a/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/converter/aws2/ddb/Ddb2JsonInputType.java +++ b/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/format/converter/aws2/ddb/Ddb2JsonInputType.java @@ -59,8 +59,8 @@ * For UpdateItem operation the Json body defines both key attributes to identify the item to be updated and all item * attributes tht get updated on the item. * - * The given Json body can use "operation", "key" and "item" as top level properties. Both define a Json object that - * will be mapped to respective attribute value maps: + * The given Json body can use "operation", "key" and "item" as top level properties that will be mapped to respective + * attribute value maps: * *
  * {@code
@@ -72,11 +72,11 @@
  * }
  * 
* - * The converter will extract the objects and set respective attribute value maps as header entries. This is a + * The transformer will extract the objects and set respective attribute value maps as header entries. This is a * comfortable way to define different key and item attribute value maps e.g. on UpdateItem operation. * * In case key and item attribute value maps are identical you can omit the special top level properties completely. The - * converter will map the whole Json body as is then and use it as source for the attribute value map. + * transformer will map the whole Json body as is then and use it as source for the attribute value map. */ @DataTypeTransformer(name = "aws2-ddb:application-json") public class Ddb2JsonInputType extends Transformer { diff --git a/library/camel-kamelets/src/main/resources/kamelets/aws-ddb-sink.kamelet.yaml b/library/camel-kamelets/src/main/resources/kamelets/aws-ddb-sink.kamelet.yaml index f6e7bcd03..f778f1d2b 100644 --- a/library/camel-kamelets/src/main/resources/kamelets/aws-ddb-sink.kamelet.yaml +++ b/library/camel-kamelets/src/main/resources/kamelets/aws-ddb-sink.kamelet.yaml @@ -44,10 +44,11 @@ spec: For DeleteItem operation the Json body defines only the primary key attributes that identify the item to delete. For UpdateItem operation the Json body defines both key attributes to identify the item to be updated and all item attributes tht get updated on the item. - The given Json body can use "key" and "item" as top level properties. Both define a Json object that will be mapped to respective attribute value maps + The given Json body can use "operation", "key" and "item" as top level properties that will be mapped to respective attribute value maps. { - "key": {}, - "item": {} + "operation": "PutItem" + "key": {}, + "item": {} } required: - table @@ -104,9 +105,44 @@ spec: x-descriptors: - 'urn:alm:descriptor:com.tectonic.ui:checkbox' default: false - types: + dataTypes: in: - mediaType: application/json + default: json + types: + json: + format: "aws2-ddb:application-json" + description: |- + Json representation of a DDB operation. The input type supports the operations: PutItem, UpdateItem, DeleteItem + + For PutItem operation the Json body defines all item attributes. + For DeleteItem operation the Json body defines only the primary key attributes that identify the item to delete. + For UpdateItem operation the Json body defines both key attributes to identify the item to be updated and all item attributes tht get updated on the item. + + The given Json body can use "operation", "key" and "item" as top level properties that will be mapped to respective attribute value maps. + headers: + CamelAwsDdbOperation: + title: Operation + description: The operation to perform. Overwrites the operation given in the Json body. One of PutItem, UpdateItem, DeleteItem. + default: PutItem + type: string + CamelAwsDdbReturnValues: + title: Return Values + description: Use this parameter if you want to get the attribute name-value pairs before or after they are modified. Possible values are NONE, ALL_OLD, UPDATED_OLD, ALL_NEW, UPDATED_NEW. + type: string + mediaType: application/json + schema: + type: object + required: [ "key" ] + properties: + operation: + type: string + description: The operator to perform. One of PutItem, UpdateItem, DeleteItem + key: + type: object + description: The primary key specifies the selection criteria for the query. + item: + type: object + description: Attribute value map specifies all attributes to change with the given operation. dependencies: - mvn:org.apache.camel.kamelets:camel-kamelets-utils:4.1.0-SNAPSHOT - "camel:core" diff --git a/library/camel-kamelets/src/main/resources/kamelets/aws-s3-source.kamelet.yaml b/library/camel-kamelets/src/main/resources/kamelets/aws-s3-source.kamelet.yaml index 823425034..c38cc9900 100644 --- a/library/camel-kamelets/src/main/resources/kamelets/aws-s3-source.kamelet.yaml +++ b/library/camel-kamelets/src/main/resources/kamelets/aws-s3-source.kamelet.yaml @@ -101,6 +101,61 @@ spec: description: The number of milliseconds before the next poll of the selected bucket. type: integer default: 500 + dataTypes: + out: + default: binary + headers: + CamelAwsS3BucketName: + title: S3 Bucket Name + description: The bucket name which has been used to retrieve objects + type: string + CamelAwsS3Key: + title: S3 Key + description: The key under which the retrieved object is stored + type: string + CamelAwsS3ContentType: + title: Content Type + description: The content type of the retrieved object. + default: application/octet-stream + type: string + CamelAwsS3ETag: + title: ETag Value + description: |- + The hex encoded 128-bit MD5 digest of the associated object according to RFC 1864. + This data is used as an integrity check to verify that the data received by the caller is the same data that was sent by Amazon S3. + type: string + types: + binary: + format: "application-octet-stream" + description: Default binary representation of the S3 object retrieved from the bucket. + mediaType: application/octet-stream + cloudevents: + format: "aws2-s3:application-cloudevents" + description: |- + Output data type represents AWS S3 get object response as CloudEvent V1. The data type sets Camel specific CloudEvent headers on the exchange with + respective data from the S3 bucket and its derived object. + headers: + CamelCloudEventID: + title: CloudEvent ID + description: The Camel exchange id set as event id + type: string + CamelCloudEventType: + title: CloudEvent Type + description: The event type + default: "org.apache.camel.event.aws.s3.getObject" + type: string + CamelCloudEventSource: + title: CloudEvent Source + description: The event source. By default, the S3 bucket name with prefix "aws.s3.bucket.". + type: string + CamelCloudEventSubject: + title: CloudEvent Subject + description: The event subject. Usually the S3 key. + type: string + CamelCloudEventTime: + title: CloudEvent Time + description: The exchange creation timestamp as event time. + type: string dependencies: - "camel:core" - "camel:aws2-s3"