This is an automated email from the ASF dual-hosted git repository. cdeppisch pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
The following commit(s) were added to refs/heads/main by this push: new 192b067e Adding drop-field-action Kamelet 192b067e is described below commit 192b067e395903f01ca85ed645c39b9fcce65427 Author: Christoph Deppisch <cdeppi...@redhat.com> AuthorDate: Tue Sep 19 11:30:51 2023 +0200 Adding drop-field-action Kamelet - Works similar to insert-field-action Kamelet - Use 'Transformation' namespace for action Kamelets working on Json struct fields --- .../drop-field-action.kamelet.yaml | 26 ++++------ kamelets/extract-field-action.kamelet.yaml | 2 +- kamelets/hoist-field-action.kamelet.yaml | 6 +-- kamelets/insert-field-action.kamelet.yaml | 6 +-- kamelets/mask-field-action.kamelet.yaml | 6 +-- .../camel/kamelets/utils/transform/DropField.java | 59 ++++++++++++++++++++++ ...kamelet.yaml => drop-field-action.kamelet.yaml} | 26 ++++------ .../kamelets/extract-field-action.kamelet.yaml | 2 +- .../kamelets/hoist-field-action.kamelet.yaml | 6 +-- .../kamelets/insert-field-action.kamelet.yaml | 6 +-- .../kamelets/mask-field-action.kamelet.yaml | 6 +-- 11 files changed, 99 insertions(+), 52 deletions(-) diff --git a/library/camel-kamelets/src/main/resources/kamelets/insert-field-action.kamelet.yaml b/kamelets/drop-field-action.kamelet.yaml similarity index 89% copy from library/camel-kamelets/src/main/resources/kamelets/insert-field-action.kamelet.yaml copy to kamelets/drop-field-action.kamelet.yaml index 8d273014..7c93c0f1 100644 --- a/library/camel-kamelets/src/main/resources/kamelets/insert-field-action.kamelet.yaml +++ b/kamelets/drop-field-action.kamelet.yaml @@ -17,7 +17,7 @@ apiVersion: camel.apache.org/v1 kind: Kamelet metadata: - name: insert-field-action + name: drop-field-action labels: camel.apache.org/kamelet.type: "action" annotations: @@ -26,27 +26,22 @@ metadata: camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG [...] camel.apache.org/provider: "Apache Software Foundation" camel.apache.org/kamelet.group: "Actions" - camel.apache.org/kamelet.namespace: "Kafka" + camel.apache.org/kamelet.namespace: "Transformation" spec: definition: - title: "Insert Field Action" + title: "Drop Field Action" description: |- - Adds a custom field with a simple language parsed value to the message in transit. + Removes a custom field by given name from the message in transit. - The insert field action expected an application/json content type. + The drop field action expects an application/json content type. - If for example you have an array like '{ "foo":"John", "bar":30 }' and your action has been configured with field as 'element' and value as 'hello', you'll get '{ "foo":"John", "bar":30, "element":"hello" }' + If for example you have an object like '{ "foo":"John", "bar":30, "element":"hello" }' and your action has been configured with field as 'element', you'll get '{ "foo":"John", "bar":30 }' as a result because the field 'element' has been removed. required: - field - - value properties: field: title: Field - description: The name of the field to be added - type: string - value: - title: Value - description: The value of the field + description: The name of the field to be removed type: string type: object dependencies: @@ -56,11 +51,10 @@ spec: - "camel:kamelet" template: beans: - - name: insertField - type: "#class:org.apache.camel.kamelets.utils.transform.InsertField" + - name: dropField + type: "#class:org.apache.camel.kamelets.utils.transform.DropField" properties: field: '{{field}}' - value: '{{value}}' from: uri: kamelet:source steps: @@ -76,7 +70,7 @@ spec: library: Jackson unmarshalType: com.fasterxml.jackson.databind.JsonNode - process: - ref: "{{insertField}}" + ref: "{{dropField}}" - choice: when: - simple: "${exchangeProperty[deserialized]} == 'true'" diff --git a/kamelets/extract-field-action.kamelet.yaml b/kamelets/extract-field-action.kamelet.yaml index 549a595a..36606cab 100644 --- a/kamelets/extract-field-action.kamelet.yaml +++ b/kamelets/extract-field-action.kamelet.yaml @@ -26,7 +26,7 @@ metadata: camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG [...] camel.apache.org/provider: "Apache Software Foundation" camel.apache.org/kamelet.group: "Actions" - camel.apache.org/kamelet.namespace: "Kafka" + camel.apache.org/kamelet.namespace: "Transformation" spec: definition: title: "Extract Field Action" diff --git a/kamelets/hoist-field-action.kamelet.yaml b/kamelets/hoist-field-action.kamelet.yaml index ff20dd75..c3ecb93e 100644 --- a/kamelets/hoist-field-action.kamelet.yaml +++ b/kamelets/hoist-field-action.kamelet.yaml @@ -26,7 +26,7 @@ metadata: camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG [...] camel.apache.org/provider: "Apache Software Foundation" camel.apache.org/kamelet.group: "Actions" - camel.apache.org/kamelet.namespace: "Kafka" + camel.apache.org/kamelet.namespace: "Transformation" spec: definition: title: "Hoist Field Action" @@ -53,7 +53,7 @@ spec: - simple: "${header[Content-Type]} == 'application/json'" steps: - unmarshal: - json: + json: library: Jackson unmarshalType: com.fasterxml.jackson.databind.JsonNode - set-property: @@ -61,7 +61,7 @@ spec: constant: "{{field}}" - bean: "org.apache.camel.kamelets.utils.transform.HoistField" - marshal: - json: + json: library: Jackson unmarshalType: com.fasterxml.jackson.databind.JsonNode - set-header: diff --git a/kamelets/insert-field-action.kamelet.yaml b/kamelets/insert-field-action.kamelet.yaml index 8d273014..f5b3806d 100644 --- a/kamelets/insert-field-action.kamelet.yaml +++ b/kamelets/insert-field-action.kamelet.yaml @@ -26,16 +26,16 @@ metadata: camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG [...] camel.apache.org/provider: "Apache Software Foundation" camel.apache.org/kamelet.group: "Actions" - camel.apache.org/kamelet.namespace: "Kafka" + camel.apache.org/kamelet.namespace: "Transformation" spec: definition: title: "Insert Field Action" description: |- Adds a custom field with a simple language parsed value to the message in transit. - The insert field action expected an application/json content type. + The insert field action expects an application/json content type. - If for example you have an array like '{ "foo":"John", "bar":30 }' and your action has been configured with field as 'element' and value as 'hello', you'll get '{ "foo":"John", "bar":30, "element":"hello" }' + If for example you have an object like '{ "foo":"John", "bar":30 }' and your action has been configured with field as 'element' and value as 'hello', you'll get '{ "foo":"John", "bar":30, "element":"hello" }' as a result required: - field - value diff --git a/kamelets/mask-field-action.kamelet.yaml b/kamelets/mask-field-action.kamelet.yaml index b922af3c..da299e38 100644 --- a/kamelets/mask-field-action.kamelet.yaml +++ b/kamelets/mask-field-action.kamelet.yaml @@ -26,7 +26,7 @@ metadata: camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG [...] camel.apache.org/provider: "Apache Software Foundation" camel.apache.org/kamelet.group: "Actions" - camel.apache.org/kamelet.namespace: "Kafka" + camel.apache.org/kamelet.namespace: "Transformation" spec: definition: title: "Mask Fields Action" @@ -61,7 +61,7 @@ spec: name: deserialized constant: "true" - unmarshal: - json: + json: library: Jackson unmarshalType: com.fasterxml.jackson.databind.JsonNode - set-property: @@ -76,7 +76,7 @@ spec: - simple: "${exchangeProperty[deserialized]} == 'true'" steps: - marshal: - json: + json: library: Jackson unmarshalType: com.fasterxml.jackson.databind.JsonNode - set-header: diff --git a/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/transform/DropField.java b/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/transform/DropField.java new file mode 100644 index 00000000..9641669f --- /dev/null +++ b/library/camel-kamelets-utils/src/main/java/org/apache/camel/kamelets/utils/transform/DropField.java @@ -0,0 +1,59 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.kamelets.utils.transform; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.JsonNodeType; +import com.fasterxml.jackson.databind.node.ObjectNode; +import org.apache.camel.Exchange; +import org.apache.camel.InvalidPayloadException; +import org.apache.camel.Processor; + +public class DropField implements Processor { + + String field; + + /** + * Default constructor. + */ + public DropField() { + } + + /** + * Constructor using fields. + * @param field the field name to drop. + */ + public DropField(String field, String value) { + this.field = field; + } + + public void process(Exchange ex) throws InvalidPayloadException { + JsonNode body = ex.getMessage().getBody(JsonNode.class); + if (body == null) { + throw new InvalidPayloadException(ex, JsonNode.class); + } + + if (body.getNodeType().equals(JsonNodeType.OBJECT)) { + ((ObjectNode) body).remove(field); + ex.getMessage().setBody(body); + } + } + + public void setField(String field) { + this.field = field; + } +} diff --git a/library/camel-kamelets/src/main/resources/kamelets/insert-field-action.kamelet.yaml b/library/camel-kamelets/src/main/resources/kamelets/drop-field-action.kamelet.yaml similarity index 89% copy from library/camel-kamelets/src/main/resources/kamelets/insert-field-action.kamelet.yaml copy to library/camel-kamelets/src/main/resources/kamelets/drop-field-action.kamelet.yaml index 8d273014..7c93c0f1 100644 --- a/library/camel-kamelets/src/main/resources/kamelets/insert-field-action.kamelet.yaml +++ b/library/camel-kamelets/src/main/resources/kamelets/drop-field-action.kamelet.yaml @@ -17,7 +17,7 @@ apiVersion: camel.apache.org/v1 kind: Kamelet metadata: - name: insert-field-action + name: drop-field-action labels: camel.apache.org/kamelet.type: "action" annotations: @@ -26,27 +26,22 @@ metadata: camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG [...] camel.apache.org/provider: "Apache Software Foundation" camel.apache.org/kamelet.group: "Actions" - camel.apache.org/kamelet.namespace: "Kafka" + camel.apache.org/kamelet.namespace: "Transformation" spec: definition: - title: "Insert Field Action" + title: "Drop Field Action" description: |- - Adds a custom field with a simple language parsed value to the message in transit. + Removes a custom field by given name from the message in transit. - The insert field action expected an application/json content type. + The drop field action expects an application/json content type. - If for example you have an array like '{ "foo":"John", "bar":30 }' and your action has been configured with field as 'element' and value as 'hello', you'll get '{ "foo":"John", "bar":30, "element":"hello" }' + If for example you have an object like '{ "foo":"John", "bar":30, "element":"hello" }' and your action has been configured with field as 'element', you'll get '{ "foo":"John", "bar":30 }' as a result because the field 'element' has been removed. required: - field - - value properties: field: title: Field - description: The name of the field to be added - type: string - value: - title: Value - description: The value of the field + description: The name of the field to be removed type: string type: object dependencies: @@ -56,11 +51,10 @@ spec: - "camel:kamelet" template: beans: - - name: insertField - type: "#class:org.apache.camel.kamelets.utils.transform.InsertField" + - name: dropField + type: "#class:org.apache.camel.kamelets.utils.transform.DropField" properties: field: '{{field}}' - value: '{{value}}' from: uri: kamelet:source steps: @@ -76,7 +70,7 @@ spec: library: Jackson unmarshalType: com.fasterxml.jackson.databind.JsonNode - process: - ref: "{{insertField}}" + ref: "{{dropField}}" - choice: when: - simple: "${exchangeProperty[deserialized]} == 'true'" diff --git a/library/camel-kamelets/src/main/resources/kamelets/extract-field-action.kamelet.yaml b/library/camel-kamelets/src/main/resources/kamelets/extract-field-action.kamelet.yaml index 549a595a..36606cab 100644 --- a/library/camel-kamelets/src/main/resources/kamelets/extract-field-action.kamelet.yaml +++ b/library/camel-kamelets/src/main/resources/kamelets/extract-field-action.kamelet.yaml @@ -26,7 +26,7 @@ metadata: camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG [...] camel.apache.org/provider: "Apache Software Foundation" camel.apache.org/kamelet.group: "Actions" - camel.apache.org/kamelet.namespace: "Kafka" + camel.apache.org/kamelet.namespace: "Transformation" spec: definition: title: "Extract Field Action" diff --git a/library/camel-kamelets/src/main/resources/kamelets/hoist-field-action.kamelet.yaml b/library/camel-kamelets/src/main/resources/kamelets/hoist-field-action.kamelet.yaml index ff20dd75..c3ecb93e 100644 --- a/library/camel-kamelets/src/main/resources/kamelets/hoist-field-action.kamelet.yaml +++ b/library/camel-kamelets/src/main/resources/kamelets/hoist-field-action.kamelet.yaml @@ -26,7 +26,7 @@ metadata: camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG [...] camel.apache.org/provider: "Apache Software Foundation" camel.apache.org/kamelet.group: "Actions" - camel.apache.org/kamelet.namespace: "Kafka" + camel.apache.org/kamelet.namespace: "Transformation" spec: definition: title: "Hoist Field Action" @@ -53,7 +53,7 @@ spec: - simple: "${header[Content-Type]} == 'application/json'" steps: - unmarshal: - json: + json: library: Jackson unmarshalType: com.fasterxml.jackson.databind.JsonNode - set-property: @@ -61,7 +61,7 @@ spec: constant: "{{field}}" - bean: "org.apache.camel.kamelets.utils.transform.HoistField" - marshal: - json: + json: library: Jackson unmarshalType: com.fasterxml.jackson.databind.JsonNode - set-header: diff --git a/library/camel-kamelets/src/main/resources/kamelets/insert-field-action.kamelet.yaml b/library/camel-kamelets/src/main/resources/kamelets/insert-field-action.kamelet.yaml index 8d273014..f5b3806d 100644 --- a/library/camel-kamelets/src/main/resources/kamelets/insert-field-action.kamelet.yaml +++ b/library/camel-kamelets/src/main/resources/kamelets/insert-field-action.kamelet.yaml @@ -26,16 +26,16 @@ metadata: camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG [...] camel.apache.org/provider: "Apache Software Foundation" camel.apache.org/kamelet.group: "Actions" - camel.apache.org/kamelet.namespace: "Kafka" + camel.apache.org/kamelet.namespace: "Transformation" spec: definition: title: "Insert Field Action" description: |- Adds a custom field with a simple language parsed value to the message in transit. - The insert field action expected an application/json content type. + The insert field action expects an application/json content type. - If for example you have an array like '{ "foo":"John", "bar":30 }' and your action has been configured with field as 'element' and value as 'hello', you'll get '{ "foo":"John", "bar":30, "element":"hello" }' + If for example you have an object like '{ "foo":"John", "bar":30 }' and your action has been configured with field as 'element' and value as 'hello', you'll get '{ "foo":"John", "bar":30, "element":"hello" }' as a result required: - field - value diff --git a/library/camel-kamelets/src/main/resources/kamelets/mask-field-action.kamelet.yaml b/library/camel-kamelets/src/main/resources/kamelets/mask-field-action.kamelet.yaml index b922af3c..da299e38 100644 --- a/library/camel-kamelets/src/main/resources/kamelets/mask-field-action.kamelet.yaml +++ b/library/camel-kamelets/src/main/resources/kamelets/mask-field-action.kamelet.yaml @@ -26,7 +26,7 @@ metadata: camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG [...] camel.apache.org/provider: "Apache Software Foundation" camel.apache.org/kamelet.group: "Actions" - camel.apache.org/kamelet.namespace: "Kafka" + camel.apache.org/kamelet.namespace: "Transformation" spec: definition: title: "Mask Fields Action" @@ -61,7 +61,7 @@ spec: name: deserialized constant: "true" - unmarshal: - json: + json: library: Jackson unmarshalType: com.fasterxml.jackson.databind.JsonNode - set-property: @@ -76,7 +76,7 @@ spec: - simple: "${exchangeProperty[deserialized]} == 'true'" steps: - marshal: - json: + json: library: Jackson unmarshalType: com.fasterxml.jackson.databind.JsonNode - set-header: