This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch mariadb-source
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git

commit cee62e17b86154bcace2c735e6d94c3cc9c1eda8
Author: Andrea Cosentino <[email protected]>
AuthorDate: Fri Jun 18 14:36:22 2021 +0200

    Added MariaDB Source Kamelet
---
 mariadb-source.kamelet.yaml | 95 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)

diff --git a/mariadb-source.kamelet.yaml b/mariadb-source.kamelet.yaml
new file mode 100644
index 0000000..25f667f
--- /dev/null
+++ b/mariadb-source.kamelet.yaml
@@ -0,0 +1,95 @@
+apiVersion: camel.apache.org/v1alpha1
+kind: Kamelet
+metadata:
+  name: mariadb-source
+  annotations:
+    camel.apache.org/kamelet.support.level: "Preview"
+    camel.apache.org/catalog.version: "main-SNAPSHOT"
+    camel.apache.org/kamelet.icon: 
"data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyBoZWlnaHQ9IjExOC4xIiB2aWV3Qm94PSIwLDAsNDE2LjQsMTE4LjEiIHdpZHRoPSI0MTYuNCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KIDxtZXRhZGF0YS8+CiA8c3dpdGNoIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMy45MSAtMjMuOTUpIj4KICA8Zm9yZWlnbk9iamVjdCBoZWlnaHQ9IjEiIHJlcXVpcmVkRXh0ZW5zaW9ucz0iaHR0cDovL25zLmFkb2JlLmNvbS9BZG9iZUlsbHVzdHJhdG9yLzEwLjAvIiB3aWR0aD0iMSIvPgogIDxnPgogICA8ZyB0cmFuc2Zvcm09In
 [...]
+    camel.apache.org/provider: "Apache Software Foundation"
+    camel.apache.org/kamelet.group: "SQL"
+  labels:
+    camel.apache.org/kamelet.type: "source"
+spec:
+  definition:
+    title: "MariaDB Source"
+    description: |-
+      Query data from a MariaDB Database.
+
+      In you KameletBinding file you'll need to explicitly declare the SQL 
Server driver dependency in spec->integration->dependencies
+      
+      - "mvn:org.mariadb.jdbc:mariadb-java-client:<version>"
+    required:
+      - serverName
+      - username
+      - password
+      - query
+      - databaseName
+    type: object
+    properties:
+      serverName:
+        title: Server Name
+        description: Server Name for the data source
+        type: string
+        example: localhost
+      port:
+        title: Port
+        description: Server Port for the data source
+        type: string
+        default: 3306
+      username:
+        title: Username
+        description: The username to use for accessing a secured MariaDB 
Database
+        type: string
+      password:
+        title: Password
+        description: The password to use for accessing a secured MariaDB 
Database
+        type: string
+        format: password
+        x-descriptors:
+        - urn:alm:descriptor:com.tectonic.ui:password
+      query:
+        title: Query
+        description: The Query to execute against the MariaDB Database
+        type: string
+        example: 'INSERT INTO accounts (username,city) VALUES 
(:#username,:#city)'
+      databaseName:
+        title: Database Name
+        description: The Database Name we are pointing
+        type: string
+      consumedQuery:
+        title: Consumed Query
+        description: A query to run on a tuple consumed
+        type: string
+        example: 'DELETE FROM accounts where user_id = :#user_id'
+  types:
+    in:
+      mediaType: application/json
+  dependencies:
+  - "camel:jackson"
+  - "camel:kamelet"
+  - "camel:sql"
+  - "mvn:org.apache.commons:commons-dbcp2:2.8.0"
+  flow:
+    beans:
+      - name: dsBean
+        type: "#class:org.apache.commons.dbcp2.BasicDataSource"
+        property:
+          - key: username
+            value: '{{username}}'
+          - key: password
+            value: '{{password}}'
+          - key: url
+            value: 'jdbc:mariadb://{{serverName}}:{{port}}/{{databaseName}}'
+          - key: driverClassName
+            value: 'org.mariadb.jdbc.Driver'
+    from:
+      uri: "sql:{{query}}"
+      parameters:
+        dataSource: "#bean:{{dsBean}}"
+        onConsume: "{{?consumedQuery}}"
+      steps:
+      - marshal:
+          json: 
+            library: Jackson
+      - to: "kamelet:sink"

Reply via email to