This is an automated email from the ASF dual-hosted git repository. acosentino 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 ed976214 Added Opensearch Sink Kamelet (#1592) ed976214 is described below commit ed976214a59c97e90ecbb2376b51ddb44425cc24 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Thu Aug 24 17:43:24 2023 +0200 Added Opensearch Sink Kamelet (#1592) Signed-off-by: Andrea Cosentino <anco...@gmail.com> --- docs/modules/ROOT/nav.adoc | 1 + kamelets/opensearch-index-sink.kamelet.yaml | 147 +++++++++++++++++++++ .../kamelets/opensearch-index-sink.kamelet.yaml | 147 +++++++++++++++++++++ 3 files changed, 295 insertions(+) diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc index e4917abf..d270b26d 100644 --- a/docs/modules/ROOT/nav.adoc +++ b/docs/modules/ROOT/nav.adoc @@ -161,6 +161,7 @@ * xref:ogcapi-features-action.adoc[] * xref:openai-classification-action.adoc[] * xref:openai-completion-action.adoc[] +* xref:opensearch-index-sink.adoc[] * xref:oracle-database-sink.adoc[] * xref:oracle-database-source.adoc[] * xref:pdf-action.adoc[] diff --git a/kamelets/opensearch-index-sink.kamelet.yaml b/kamelets/opensearch-index-sink.kamelet.yaml new file mode 100644 index 00000000..8b41883b --- /dev/null +++ b/kamelets/opensearch-index-sink.kamelet.yaml @@ -0,0 +1,147 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- +apiVersion: camel.apache.org/v1alpha1 +kind: Kamelet +metadata: + name: opensearch-index-sink + labels: + camel.apache.org/kamelet.type: "sink" + annotations: + camel.apache.org/kamelet.support.level: "Stable" + camel.apache.org/catalog.version: "4.0.0-SNAPSHOT" + camel.apache.org/kamelet.group: "OpenSearch" + camel.apache.org/kamelet.namespace: "Search" + camel.apache.org/provider: "Apache Software Foundation" + camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCAzNzIgNzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+Cjx0aXRsZT5PcGVuU2VhcmNoIGxvZ288L3RpdGxlPgo8ZGVzYz5TZWFyY2ggZW5naW5lIHNvZnR3YXJlIGZvcmsgb2YgRWxhc3RpY3NlYXJjaDwvZGVzYz4KIDxwYXRoIGQ9Im02MS43Mzc0IDI2LjVjLTEuMjQ5NiAwLTIuMjYyNiAxLjAxMy0yLjI2MjYgMi4yNjI2IDAgMTguNjE4OC0xNS4wOTM0IDMzLjcxMjItMzMuNzEyMiAzMy43MTIyLTEuMjQ5NiAwLTIuMjYyNi [...] +spec: + definition: + title: "OpenSearch Index Sink" + description: |- + Stores JSON-formatted data into Opensearch. + + The input data must be formatted in JSON according to the requirements of the index. + + If you specify the `certificate` property, you must base64 encode it before you pass it as a parameter. + + In the header, you can set the following properties: + + - `indexId` / `ce-indexid`: The index ID for OpenSearch. + + - `indexName` / `ce-indexname`: The index name for OpenSearch. + + If you do not set a property in the header, the Kamelet uses the exchange ID for the index setting. + required: + - clusterName + - hostAddresses + type: object + properties: + user: + title: Username + description: The username to connect to OpenSearch. + type: string + x-descriptors: + - urn:camel:group:credentials + password: + title: Password + description: The password to connect to OpenSearch. + type: string + format: password + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:password + - urn:camel:group:credentials + enableSSL: + title: Enable SSL + description: Specifies to connect by using SSL. + type: boolean + default: false + x-descriptors: + - 'urn:alm:descriptor:com.tectonic.ui:checkbox' + hostAddresses: + title: Host Addresses + description: A comma-separated list of remote transport addresses in `ip:port format`. + type: string + example: quickstart-es-http:9200 + clusterName: + title: OpenSearch Cluster Name + description: The name of the OpenSearch cluster. + type: string + example: quickstart + indexName: + title: Index in OpenSearch + description: The name of the OpenSearch index. + type: string + example: data + certificate: + title: Certificate + description: The Certificate for accessing the OpenSearch cluster. You must encode this value in base64. + type: string + types: + out: + mediaType: text/plain + in: + mediaType: application/json + dependencies: + - "camel:core" + - "camel:jackson" + - "camel:kamelet" + - "camel:opensearch" + - "camel:gson" + - "camel:bean" + template: + beans: + - name: local-opensearch + type: "#class:org.apache.camel.component.opensearch.OpensearchComponent" + properties: + user: "{{?user}}" + password: "{{?password}}" + from: + uri: kamelet:source + steps: + - choice: + when: + - simple: "${header[indexId]}" + steps: + - set-header: + name: "indexId" + simple: "${header[indexId]}" + - simple: "${header[ce-indexid]}" + steps: + - set-header: + name: "indexId" + simple: "${header[ce-indexid]}" + - choice: + when: + - simple: "${header[indexName]}" + steps: + - set-header: + name: "indexName" + simple: "${header[indexName]}" + - simple: "${header[ce-indexname]}" + steps: + - set-header: + name: "indexName" + simple: "${header[ce-indexname]}" + - unmarshal: + json: {} + - to: + uri: "{{local-opensearch}}:{{clusterName}}" + parameters: + operation: "INDEX" + hostAddresses: "{{hostAddresses}}" + enableSSL: "{{enableSSL}}" + indexName: "{{?indexName}}" + certificatePath: "base64:{{?certificate}}" diff --git a/library/camel-kamelets/src/main/resources/kamelets/opensearch-index-sink.kamelet.yaml b/library/camel-kamelets/src/main/resources/kamelets/opensearch-index-sink.kamelet.yaml new file mode 100644 index 00000000..8b41883b --- /dev/null +++ b/library/camel-kamelets/src/main/resources/kamelets/opensearch-index-sink.kamelet.yaml @@ -0,0 +1,147 @@ +# --------------------------------------------------------------------------- +# 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. +# --------------------------------------------------------------------------- +apiVersion: camel.apache.org/v1alpha1 +kind: Kamelet +metadata: + name: opensearch-index-sink + labels: + camel.apache.org/kamelet.type: "sink" + annotations: + camel.apache.org/kamelet.support.level: "Stable" + camel.apache.org/catalog.version: "4.0.0-SNAPSHOT" + camel.apache.org/kamelet.group: "OpenSearch" + camel.apache.org/kamelet.namespace: "Search" + camel.apache.org/provider: "Apache Software Foundation" + camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCAzNzIgNzIiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+Cjx0aXRsZT5PcGVuU2VhcmNoIGxvZ288L3RpdGxlPgo8ZGVzYz5TZWFyY2ggZW5naW5lIHNvZnR3YXJlIGZvcmsgb2YgRWxhc3RpY3NlYXJjaDwvZGVzYz4KIDxwYXRoIGQ9Im02MS43Mzc0IDI2LjVjLTEuMjQ5NiAwLTIuMjYyNiAxLjAxMy0yLjI2MjYgMi4yNjI2IDAgMTguNjE4OC0xNS4wOTM0IDMzLjcxMjItMzMuNzEyMiAzMy43MTIyLTEuMjQ5NiAwLTIuMjYyNi [...] +spec: + definition: + title: "OpenSearch Index Sink" + description: |- + Stores JSON-formatted data into Opensearch. + + The input data must be formatted in JSON according to the requirements of the index. + + If you specify the `certificate` property, you must base64 encode it before you pass it as a parameter. + + In the header, you can set the following properties: + + - `indexId` / `ce-indexid`: The index ID for OpenSearch. + + - `indexName` / `ce-indexname`: The index name for OpenSearch. + + If you do not set a property in the header, the Kamelet uses the exchange ID for the index setting. + required: + - clusterName + - hostAddresses + type: object + properties: + user: + title: Username + description: The username to connect to OpenSearch. + type: string + x-descriptors: + - urn:camel:group:credentials + password: + title: Password + description: The password to connect to OpenSearch. + type: string + format: password + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:password + - urn:camel:group:credentials + enableSSL: + title: Enable SSL + description: Specifies to connect by using SSL. + type: boolean + default: false + x-descriptors: + - 'urn:alm:descriptor:com.tectonic.ui:checkbox' + hostAddresses: + title: Host Addresses + description: A comma-separated list of remote transport addresses in `ip:port format`. + type: string + example: quickstart-es-http:9200 + clusterName: + title: OpenSearch Cluster Name + description: The name of the OpenSearch cluster. + type: string + example: quickstart + indexName: + title: Index in OpenSearch + description: The name of the OpenSearch index. + type: string + example: data + certificate: + title: Certificate + description: The Certificate for accessing the OpenSearch cluster. You must encode this value in base64. + type: string + types: + out: + mediaType: text/plain + in: + mediaType: application/json + dependencies: + - "camel:core" + - "camel:jackson" + - "camel:kamelet" + - "camel:opensearch" + - "camel:gson" + - "camel:bean" + template: + beans: + - name: local-opensearch + type: "#class:org.apache.camel.component.opensearch.OpensearchComponent" + properties: + user: "{{?user}}" + password: "{{?password}}" + from: + uri: kamelet:source + steps: + - choice: + when: + - simple: "${header[indexId]}" + steps: + - set-header: + name: "indexId" + simple: "${header[indexId]}" + - simple: "${header[ce-indexid]}" + steps: + - set-header: + name: "indexId" + simple: "${header[ce-indexid]}" + - choice: + when: + - simple: "${header[indexName]}" + steps: + - set-header: + name: "indexName" + simple: "${header[indexName]}" + - simple: "${header[ce-indexname]}" + steps: + - set-header: + name: "indexName" + simple: "${header[ce-indexname]}" + - unmarshal: + json: {} + - to: + uri: "{{local-opensearch}}:{{clusterName}}" + parameters: + operation: "INDEX" + hostAddresses: "{{hostAddresses}}" + enableSSL: "{{enableSSL}}" + indexName: "{{?indexName}}" + certificatePath: "base64:{{?certificate}}"