You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2023/08/25 16:28:17 UTC

[camel-kamelets] branch main updated: Added Opensearch Search Source Kamelet (#1594)

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 92320f96 Added Opensearch Search Source Kamelet (#1594)
92320f96 is described below

commit 92320f96ccb38bb8ebf3a603b7ba774ec4a9e41f
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Aug 25 18:28:11 2023 +0200

    Added Opensearch Search Source Kamelet (#1594)
    
    Signed-off-by: Andrea Cosentino <an...@gmail.com>
---
 docs/modules/ROOT/nav.adoc                         |   1 +
 kamelets/opensearch-search-source.kamelet.yaml     | 126 +++++++++++++++++++++
 .../kamelets/opensearch-search-source.kamelet.yaml | 126 +++++++++++++++++++++
 script/validator/validator.go                      |   2 +-
 4 files changed, 254 insertions(+), 1 deletion(-)

diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc
index d270b26d..d2cf515a 100644
--- a/docs/modules/ROOT/nav.adoc
+++ b/docs/modules/ROOT/nav.adoc
@@ -162,6 +162,7 @@
 * xref:openai-classification-action.adoc[]
 * xref:openai-completion-action.adoc[]
 * xref:opensearch-index-sink.adoc[]
+* xref:opensearch-search-source.adoc[]
 * xref:oracle-database-sink.adoc[]
 * xref:oracle-database-source.adoc[]
 * xref:pdf-action.adoc[]
diff --git a/kamelets/opensearch-search-source.kamelet.yaml b/kamelets/opensearch-search-source.kamelet.yaml
new file mode 100644
index 00000000..3812c98d
--- /dev/null
+++ b/kamelets/opensearch-search-source.kamelet.yaml
@@ -0,0 +1,126 @@
+# ---------------------------------------------------------------------------
+# 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-search-source
+  labels:
+    camel.apache.org/kamelet.type: "source"
+  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 Search Source"
+    description: |-
+      Search data on OpenSearch
+      
+      The `query` parameter must be formatted in JSON.
+
+      If you specify the `certificate` property, you must base64 encode it before you pass it as a parameter.
+    required:
+      - query
+      - clusterName
+      - indexName
+      - hostAddresses
+    type: object
+    properties:
+      period:
+        title: Period
+        description: The time interval between two searches
+        type: integer
+        default: 1000
+      query:
+        title: Query
+        description: The query we want to use to search on OpenSearch.
+        type: string
+      user:
+        title: Username
+        description: Username to connect to OpenSearch.
+        type: string
+        x-descriptors:
+        - urn:camel:group:credentials
+      password:
+        title: Password
+        description: 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: Do we want to connect using SSL?
+        type: boolean
+        default: false
+        x-descriptors:
+        - 'urn:alm:descriptor:com.tectonic.ui:checkbox'
+      hostAddresses:
+        title: Host Addresses
+        description: Comma separated list with ip:port formatted remote transport addresses to use.
+        type: string
+      indexName:
+        title: Index in OpenSearch
+        description: The name of the index to act against.
+        type: string
+      clusterName:
+        title: OpenSearch Cluster Name
+        description: The name of the cluster.
+        type: string
+      certificate:
+        title: Certificate 
+        description: The Certificate for accessing the Opensearch cluster. You must encode this value in base64.
+        type: string
+  types:
+    out:
+      mediaType: application/json
+  dependencies:
+      - "camel:core"
+      - "camel:kamelet"
+      - "camel:timer"
+      - "camel:opensearch"
+      - "camel:gson"
+  template:
+    beans:
+      - name: local-opensearch
+        type: "#class:org.apache.camel.component.opensearch.OpensearchComponent"
+        properties:
+            user: "{{?user}}"
+            password: "{{?password}}"
+    from:
+      uri: timer:tick
+      parameters:
+        period: "{{period}}"
+      steps:
+        - set-body:
+            constant: "{{query?nested=false}}"
+        - to:
+            uri: "{{local-opensearch}}:{{clusterName}}"
+            parameters:
+              operation: "SEARCH"
+              indexName: "{{indexName}}"
+              hostAddresses: "{{hostAddresses}}"
+              enableSSL: "{{enableSSL}}"
+              certificatePath: "base64:{{?certificate}}"
+        - marshal:
+            json:
+              library: Gson
+        - to: kamelet:sink
diff --git a/library/camel-kamelets/src/main/resources/kamelets/opensearch-search-source.kamelet.yaml b/library/camel-kamelets/src/main/resources/kamelets/opensearch-search-source.kamelet.yaml
new file mode 100644
index 00000000..3812c98d
--- /dev/null
+++ b/library/camel-kamelets/src/main/resources/kamelets/opensearch-search-source.kamelet.yaml
@@ -0,0 +1,126 @@
+# ---------------------------------------------------------------------------
+# 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-search-source
+  labels:
+    camel.apache.org/kamelet.type: "source"
+  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 Search Source"
+    description: |-
+      Search data on OpenSearch
+      
+      The `query` parameter must be formatted in JSON.
+
+      If you specify the `certificate` property, you must base64 encode it before you pass it as a parameter.
+    required:
+      - query
+      - clusterName
+      - indexName
+      - hostAddresses
+    type: object
+    properties:
+      period:
+        title: Period
+        description: The time interval between two searches
+        type: integer
+        default: 1000
+      query:
+        title: Query
+        description: The query we want to use to search on OpenSearch.
+        type: string
+      user:
+        title: Username
+        description: Username to connect to OpenSearch.
+        type: string
+        x-descriptors:
+        - urn:camel:group:credentials
+      password:
+        title: Password
+        description: 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: Do we want to connect using SSL?
+        type: boolean
+        default: false
+        x-descriptors:
+        - 'urn:alm:descriptor:com.tectonic.ui:checkbox'
+      hostAddresses:
+        title: Host Addresses
+        description: Comma separated list with ip:port formatted remote transport addresses to use.
+        type: string
+      indexName:
+        title: Index in OpenSearch
+        description: The name of the index to act against.
+        type: string
+      clusterName:
+        title: OpenSearch Cluster Name
+        description: The name of the cluster.
+        type: string
+      certificate:
+        title: Certificate 
+        description: The Certificate for accessing the Opensearch cluster. You must encode this value in base64.
+        type: string
+  types:
+    out:
+      mediaType: application/json
+  dependencies:
+      - "camel:core"
+      - "camel:kamelet"
+      - "camel:timer"
+      - "camel:opensearch"
+      - "camel:gson"
+  template:
+    beans:
+      - name: local-opensearch
+        type: "#class:org.apache.camel.component.opensearch.OpensearchComponent"
+        properties:
+            user: "{{?user}}"
+            password: "{{?password}}"
+    from:
+      uri: timer:tick
+      parameters:
+        period: "{{period}}"
+      steps:
+        - set-body:
+            constant: "{{query?nested=false}}"
+        - to:
+            uri: "{{local-opensearch}}:{{clusterName}}"
+            parameters:
+              operation: "SEARCH"
+              indexName: "{{indexName}}"
+              hostAddresses: "{{hostAddresses}}"
+              enableSSL: "{{enableSSL}}"
+              certificatePath: "base64:{{?certificate}}"
+        - marshal:
+            json:
+              library: Gson
+        - to: kamelet:sink
diff --git a/script/validator/validator.go b/script/validator/validator.go
index 7477330e..b67a0c05 100644
--- a/script/validator/validator.go
+++ b/script/validator/validator.go
@@ -402,7 +402,7 @@ func listKamelets(dir string) []KameletInfo {
 
 func verifyUsedParams(kamelets []KameletInfo) (errors []error) {
 	for _, k := range kamelets {
-	        if (k.FileName != "../../kamelets/azure-storage-blob-source.kamelet.yaml" && k.FileName != "../../kamelets/aws-s3-cdc-source.kamelet.yaml"  && k.FileName != "../../kamelets/set-kafka-key-action.kamelet.yaml"  && k.FileName != "../../kamelets/azure-storage-blob-cdc-source.kamelet.yaml" && k.FileName != "../../kamelets/google-storage-cdc-source.kamelet.yaml" && k.FileName != "../../kamelets/elasticsearch-search-source.kamelet.yaml") {
+	        if (k.FileName != "../../kamelets/azure-storage-blob-source.kamelet.yaml" && k.FileName != "../../kamelets/aws-s3-cdc-source.kamelet.yaml"  && k.FileName != "../../kamelets/set-kafka-key-action.kamelet.yaml"  && k.FileName != "../../kamelets/azure-storage-blob-cdc-source.kamelet.yaml" && k.FileName != "../../kamelets/google-storage-cdc-source.kamelet.yaml" && k.FileName != "../../kamelets/elasticsearch-search-source.kamelet.yaml" && k.FileName != "../../kamelets/opensearch-searc [...]
 		used := getUsedParams(k.Kamelet)
 		declared := getDeclaredParams(k.Kamelet)
 		for p := range used {