191 lines
9.7 KiB
JSON
191 lines
9.7 KiB
JSON
|
|
{
|
||
|
|
"apiVersion": "camel.apache.org/v1",
|
||
|
|
"kind": "Kamelet",
|
||
|
|
"metadata": {
|
||
|
|
"name": "extract-field-action",
|
||
|
|
"labels": {
|
||
|
|
"camel.apache.org/kamelet.type": "action"
|
||
|
|
},
|
||
|
|
"annotations": {
|
||
|
|
"camel.apache.org/kamelet.support.level": "Stable",
|
||
|
|
"camel.apache.org/catalog.version": "4.22.1",
|
||
|
|
"camel.apache.org/kamelet.icon": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG9kaS5zb3VyY2Vmb3JnZS5uZXQvRFREL3NvZGlwb2RpLTAuZHRkIgogICB4bWxuczppbmtzY2FwZT0iaHR0cDovL3d3dy5pbmtzY2FwZS5vcmcvbmFtZXNwYWNlcy9pbmtzY2FwZSIKICAgdmlld0JveD0iMCAtMjU2IDE3OTIgMTc5MiIKICAgaWQ9InN2ZzMwMjUiCiAgIHZlcnNpb249IjEuMSIKICAgaW5rc2NhcGU6dmVyc2lvbj0iMC40OC4zLjEgcjk4ODYiCiAgIHdpZHRoPSIxMDAlIgogICBoZWlnaHQ9IjEwMCUiCiAgIHNvZGlwb2RpOmRv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AtMTA3LDEzOCAtMTAsMTIgLTEwLDI0IDAsMTAgOSwyMyAyNiwzNiA5OC41LDEwNy41IDcyLjUsNzEuNSA5NC41LDcxLjUgMTMsMCAyNiwtMTAgbCAxMzgsLTEwNyBxIDQ0LDIzIDkxLDM4IDE2LDEzNiAyOSwxODYgNywyOCAzNiwyOCBoIDIyMiBxIDE0LDAgMjQuNSwtOC41IFEgOTE0LDEzOTEgOTE1LDEzNzggbCAyOCwtMTg0IHEgNDksLTE2IDkwLC0zNyBsIDE0MiwxMDcgcSA5LDkgMjQsOSAxMywwIDI1LC0xMCAxMjksLTExOSAxNjUsLTE3MCA3LC04IDcsLTIyIDAsLTEyIC04LC0yMyAtMTUsLTIxIC01MSwtNjYuNSAtMzYsLTQ1LjUgLTU0LC03MC41IDI2LC01MCA0MSwtOTggbCAxODMsLTI4IHEgMTMsLTIgMjEsLTEyLjUgOCwtMTAuNSA4LC0yMy41IHoiCiAgICAgICBpZD0icGF0aDMwMjkiCiAgICAgICBpbmtzY2FwZTpjb25uZWN0b3ItY3VydmF0dXJlPSIwIgogICAgICAgc3R5bGU9ImZpbGw6Y3VycmVudENvbG9yIiAvPgogIDwvZz4KPC9zdmc+Cg==",
|
||
|
|
"camel.apache.org/provider": "Apache Software Foundation",
|
||
|
|
"camel.apache.org/kamelet.group": "Actions",
|
||
|
|
"camel.apache.org/kamelet.namespace": "Transformation"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"spec": {
|
||
|
|
"definition": {
|
||
|
|
"title": "Extract Field Action",
|
||
|
|
"description": "Extract a field from the message body.",
|
||
|
|
"required": [
|
||
|
|
"field"
|
||
|
|
],
|
||
|
|
"properties": {
|
||
|
|
"field": {
|
||
|
|
"title": "Field",
|
||
|
|
"description": "The name of the field to extract",
|
||
|
|
"type": "string"
|
||
|
|
},
|
||
|
|
"headerOutput": {
|
||
|
|
"title": "Header Output",
|
||
|
|
"description": "If enable the action will store the extracted field in an header named CamelKameletsExtractFieldName",
|
||
|
|
"type": "boolean",
|
||
|
|
"default": false
|
||
|
|
},
|
||
|
|
"headerOutputName": {
|
||
|
|
"title": "Header Output Name",
|
||
|
|
"description": "A custom name for the header containing the extracted field",
|
||
|
|
"default": "none",
|
||
|
|
"type": "string"
|
||
|
|
},
|
||
|
|
"strictHeaderCheck": {
|
||
|
|
"title": "Strict Header Check",
|
||
|
|
"description": "If enabled the action will check if the header output name (custom or default) has been used already in the exchange. If so, the extracted field is stored in the message body, if not, the extracted field is stored in the selected header (custom or default).",
|
||
|
|
"type": "boolean",
|
||
|
|
"default": false
|
||
|
|
},
|
||
|
|
"trimField": {
|
||
|
|
"title": "Trim Field",
|
||
|
|
"description": "If enabled we return the Raw extracted field",
|
||
|
|
"type": "boolean",
|
||
|
|
"default": false
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"type": "object"
|
||
|
|
},
|
||
|
|
"dependencies": [
|
||
|
|
"camel:kamelet",
|
||
|
|
"camel:core",
|
||
|
|
"camel:jackson",
|
||
|
|
"camel:kafka"
|
||
|
|
],
|
||
|
|
"template": {
|
||
|
|
"beans": [
|
||
|
|
{
|
||
|
|
"name": "extractField",
|
||
|
|
"type": "#class:org.apache.camel.component.kafka.transform.ExtractField",
|
||
|
|
"properties": {
|
||
|
|
"field": "{{field}}",
|
||
|
|
"headerOutput": "{{headerOutput}}",
|
||
|
|
"headerOutputName": "{{headerOutputName}}",
|
||
|
|
"strictHeaderCheck": "{{strictHeaderCheck}}",
|
||
|
|
"trimField": "{{trimField}}"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"from": {
|
||
|
|
"uri": "kamelet:source",
|
||
|
|
"steps": [
|
||
|
|
{
|
||
|
|
"choice": {
|
||
|
|
"when": [
|
||
|
|
{
|
||
|
|
"simple": "${header[Content-Type]} == 'application/json'",
|
||
|
|
"steps": [
|
||
|
|
{
|
||
|
|
"setProperty": {
|
||
|
|
"name": "deserialized",
|
||
|
|
"constant": "true"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"unmarshal": {
|
||
|
|
"json": {
|
||
|
|
"library": "Jackson",
|
||
|
|
"unmarshalType": "com.fasterxml.jackson.databind.JsonNode"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"process": {
|
||
|
|
"ref": "{{extractField}}"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"choice": {
|
||
|
|
"when": [
|
||
|
|
{
|
||
|
|
"simple": "${exchangeProperty[trimField]} == 'false'",
|
||
|
|
"steps": [
|
||
|
|
{
|
||
|
|
"choice": {
|
||
|
|
"when": [
|
||
|
|
{
|
||
|
|
"simple": "${exchangeProperty[deserialized]} == 'true'",
|
||
|
|
"steps": [
|
||
|
|
{
|
||
|
|
"marshal": {
|
||
|
|
"json": {
|
||
|
|
"library": "Jackson",
|
||
|
|
"unmarshalType": "com.fasterxml.jackson.databind.JsonNode"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"setHeader": {
|
||
|
|
"name": "Content-Type",
|
||
|
|
"constant": "application/json"
|
||
|
|
}
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"propertiesSchema": {
|
||
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||
|
|
"type": "object",
|
||
|
|
"title": "Extract Field Action",
|
||
|
|
"description": "Extract a field from the message body.",
|
||
|
|
"required": [
|
||
|
|
"field"
|
||
|
|
],
|
||
|
|
"properties": {
|
||
|
|
"field": {
|
||
|
|
"type": "string",
|
||
|
|
"title": "Field",
|
||
|
|
"description": "The name of the field to extract"
|
||
|
|
},
|
||
|
|
"headerOutput": {
|
||
|
|
"type": "boolean",
|
||
|
|
"title": "Header Output",
|
||
|
|
"description": "If enable the action will store the extracted field in an header named CamelKameletsExtractFieldName",
|
||
|
|
"default": false
|
||
|
|
},
|
||
|
|
"headerOutputName": {
|
||
|
|
"type": "string",
|
||
|
|
"title": "Header Output Name",
|
||
|
|
"description": "A custom name for the header containing the extracted field",
|
||
|
|
"default": "none"
|
||
|
|
},
|
||
|
|
"strictHeaderCheck": {
|
||
|
|
"type": "boolean",
|
||
|
|
"title": "Strict Header Check",
|
||
|
|
"description": "If enabled the action will check if the header output name (custom or default) has been used already in the exchange. If so, the extracted field is stored in the message body, if not, the extracted field is stored in the selected header (custom or default).",
|
||
|
|
"default": false
|
||
|
|
},
|
||
|
|
"trimField": {
|
||
|
|
"type": "boolean",
|
||
|
|
"title": "Trim Field",
|
||
|
|
"description": "If enabled we return the Raw extracted field",
|
||
|
|
"default": false
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|