Skip to content

Commit

Permalink
CMLK-2007: Add resolve-pojo-schema-action Kamelet
Browse files Browse the repository at this point in the history
- Add Kamelet as "preview"
- Add some YAKS E2E test for Avro and Protobuf serialization/deserialization
  • Loading branch information
christophd committed May 7, 2024
1 parent 3cca7b1 commit 0e81579
Show file tree
Hide file tree
Showing 27 changed files with 1,012 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ jobs:
yaks run test/extract-field $YAKS_RUN_OPTIONS
yaks run test/http-sink $YAKS_RUN_OPTIONS
yaks run test/insert-field $YAKS_RUN_OPTIONS
yaks run test/avro $YAKS_RUN_OPTIONS
yaks run test/protobuf $YAKS_RUN_OPTIONS
yaks run test/ftp/sink $YAKS_RUN_OPTIONS
yaks run test/ftp/source $YAKS_RUN_OPTIONS
yaks run test/kafka $YAKS_RUN_OPTIONS
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
* xref:ROOT:protobuf-serialize-action.adoc[image:kamelets/protobuf-serialize-action.svg[] Protobuf Serialize Action]
* xref:ROOT:regex-router-action.adoc[image:kamelets/regex-router-action.svg[] Regex Router Action]
* xref:ROOT:replace-field-action.adoc[image:kamelets/replace-field-action.svg[] Replace Field Action]
* xref:ROOT:resolve-pojo-schema-action.adoc[image:kamelets/resolve-pojo-schema-action.svg[] Resolve Schema Action]
* xref:ROOT:salesforce-create-sink.adoc[image:kamelets/salesforce-create-sink.svg[] Salesforce Create Sink]
* xref:ROOT:salesforce-delete-sink.adoc[image:kamelets/salesforce-delete-sink.svg[] Salesforce Delete Sink]
* xref:ROOT:salesforce-source.adoc[image:kamelets/salesforce-source.svg[] Salesforce Source]
Expand Down
159 changes: 159 additions & 0 deletions docs/modules/ROOT/pages/resolve-pojo-schema-action.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT

= image:kamelets/resolve-pojo-schema-action.svg[] Resolve Schema Action

*Provided by: "Red Hat"*

Resolves schema from given mime type and payload. Sets the resolved schema, the schema type and its content class as properties for later reference.

== Configuration Options

The following table summarizes the configuration options available for the `resolve-pojo-schema-action` Kamelet:
[width="100%",cols="2,^2,3,^2,^2,^3",options="header"]
|===
| Property| Name| Description| Type| Default| Example
| contentClass| Content Class| Type information of the content object. Fully qualified class name.| string| | `"org.apache.camel.content.Foo"`
| mimeType| Mime Type| The mime type to determine the schema resolver implementation that should perform the operation.| string| `"application/json"`| `"application/json"`
| schema| Schema| Optional schema content (as single-line, using JSON format).| string| |
| targetMimeType| Target Mime Type| Additional mime type information used to determine the schema resolver. Usually only used in combination with mime type "application/x-java-object"| string| | `"application/json"`
|===

NOTE: Fields marked with an asterisk ({empty}*) are mandatory.


== Dependencies

At runtime, the `resolve-pojo-schema-action` Kamelet relies upon the presence of the following dependencies:

- mvn:org.apache.camel.kamelets:camel-kamelets-utils:2.3.0
- camel:kamelet
- camel:core
- camel:jackson-avro
- camel:jackson-protobuf

== Usage

This section describes how you can use the `resolve-pojo-schema-action`.

=== Knative Action

You can use the `resolve-pojo-schema-action` Kamelet as an intermediate step in a Knative binding.

.resolve-pojo-schema-action-binding.yaml
[source,yaml]
----
apiVersion: camel.apache.org/v1
kind: KameletBinding
metadata:
name: resolve-pojo-schema-action-binding
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: timer-source
properties:
message: "Hello"
steps:
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: resolve-pojo-schema-action
sink:
ref:
kind: Channel
apiVersion: messaging.knative.dev/v1
name: mychannel
----

==== *Prerequisite*

Make sure you have *"Red Hat Integration - Camel K"* installed into the OpenShift cluster you're connected to.

==== *Procedure for using the cluster CLI*

. Save the `resolve-pojo-schema-action-binding.yaml` file to your local drive, and then edit it as needed for your configuration.

. Run the action by using the following command:
+
[source,shell]
----
oc apply -f resolve-pojo-schema-action-binding.yaml
----

==== *Procedure for using the Kamel CLI*

Configure and run the action by using the following command:

[source,shell]
----
kamel bind timer-source?message=Hello --step resolve-pojo-schema-action channel:mychannel
----

This command creates the KameletBinding in the current namespace on the cluster.

=== Kafka Action

You can use the `resolve-pojo-schema-action` Kamelet as an intermediate step in a Kafka binding.

.resolve-pojo-schema-action-binding.yaml
[source,yaml]
----
apiVersion: camel.apache.org/v1
kind: KameletBinding
metadata:
name: resolve-pojo-schema-action-binding
spec:
source:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: timer-source
properties:
message: "Hello"
steps:
- ref:
kind: Kamelet
apiVersion: camel.apache.org/v1
name: resolve-pojo-schema-action
sink:
ref:
kind: KafkaTopic
apiVersion: kafka.strimzi.io/v1beta1
name: my-topic
----

==== *Prerequisites*

Ensure that you've installed the *AMQ Streams* operator in your OpenShift cluster and created a topic named `my-topic` in the current namespace.
Make also sure you have *"Red Hat Integration - Camel K"* installed into the OpenShift cluster you're connected to.

==== *Procedure for using the cluster CLI*

. Save the `resolve-pojo-schema-action-binding.yaml` file to your local drive, and then edit it as needed for your configuration.

. Run the action by using the following command:
+
[source,shell]
----
oc apply -f resolve-pojo-schema-action-binding.yaml
----

==== *Procedure for using the Kamel CLI*

Configure and run the action by using the following command:

[source,shell]
----
kamel bind timer-source?message=Hello --step resolve-pojo-schema-action kafka.strimzi.io/v1beta1:KafkaTopic:my-topic
----

This command creates the KameletBinding in the current namespace on the cluster.

== Kamelet source file

https://github.com/openshift-integration/kamelet-catalog/blob/main/resolve-pojo-schema-action.kamelet.yaml

// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
apiVersion: camel.apache.org/v1
kind: Kamelet
metadata:
name: resolve-pojo-schema-action
annotations:
camel.apache.org/kamelet.support.level: "Preview"
camel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EgNDksLTE2IDkwLC0zNyBsIDE0MiwxMDcgcSA5LDkgMjQsOSAxMywwIDI1LC0xMCAxMjksLTExOSAxNjUsLTE3MCA3LC04IDcsLTIyIDAsLTEyIC04LC0yMyAtMTUsLTIxIC01MSwtNjYuNSAtMzYsLTQ1LjUgLTU0LC03MC41IDI2LC01MCA0MSwtOTggbCAxODMsLTI4IHEgMTMsLTIgMjEsLTEyLjUgOCwtMTAuNSA4LC0yMy41IHoiCiAgICAgICBpZD0icGF0aDMwMjkiCiAgICAgICBpbmtzY2FwZTpjb25uZWN0b3ItY3VydmF0dXJlPSIwIgogICAgICAgc3R5bGU9ImZpbGw6Y3VycmVudENvbG9yIiAvPgogIDwvZz4KPC9zdmc+Cg=="
camel.apache.org/provider: "Red Hat"
camel.apache.org/kamelet.group: "Actions"
camel.apache.org/kamelet.namespace: "Transformation"
labels:
camel.apache.org/kamelet.type: "action"
spec:
definition:
title: "Resolve Schema Action"
description: "Resolves schema from given mime type and payload. Sets the resolved schema, the schema type and its content class as properties for later reference."
type: object
properties:
mimeType:
title: Mime Type
description: The mime type to determine the schema resolver implementation that should perform the operation.
type: string
default: "application/json"
example: "application/json"
schema:
title: Schema
description: Optional schema content (as single-line, using JSON format).
type: string
contentClass:
title: Content Class
description: Type information of the content object. Fully qualified class name.
type: string
example: "org.apache.camel.content.Foo"
targetMimeType:
title: Target Mime Type
description: Additional mime type information used to determine the schema resolver. Usually only used in combination with mime type "application/x-java-object"
type: string
example: "application/json"
dependencies:
- "mvn:org.apache.camel.kamelets:camel-kamelets-utils:2.3.0"
- "camel:kamelet"
- "camel:core"
- "camel:jackson-avro"
- "camel:jackson-protobuf"
template:
beans:
- name: schemaResolver
type: "#class:org.apache.camel.kamelets.utils.format.schema.DelegatingSchemaResolver"
properties:
mimeType: '{{mimeType}}'
schema: '{{schema:}}'
contentClass: '{{contentClass:}}'
targetMimeType: '{{targetMimeType:}}'
from:
uri: "kamelet:source"
steps:
- process:
ref: "{{schemaResolver}}"
Loading

0 comments on commit 0e81579

Please sign in to comment.