You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2021/02/26 08:03:52 UTC

[camel-kamelets] branch master updated: Fix #18: add mail source kamelet

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

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


The following commit(s) were added to refs/heads/master by this push:
     new f4ab965  Fix #18: add mail source kamelet
f4ab965 is described below

commit f4ab965285e87c97b44f5403e8b4ac2abc8da6af
Author: nicolaferraro <ni...@gmail.com>
AuthorDate: Thu Feb 25 23:07:39 2021 +0100

    Fix #18: add mail source kamelet
---
 .../assets/images/kamelets/mail-imap-source.svg    | 68 ++++++++++++++++++++
 docs/modules/ROOT/nav.adoc                         |  1 +
 docs/modules/ROOT/pages/mail-imap-source.adoc      | 67 ++++++++++++++++++++
 mail-imap-source.kamelet.yaml                      | 74 ++++++++++++++++++++++
 4 files changed, 210 insertions(+)

diff --git a/docs/modules/ROOT/assets/images/kamelets/mail-imap-source.svg b/docs/modules/ROOT/assets/images/kamelets/mail-imap-source.svg
new file mode 100644
index 0000000..c7eee96
--- /dev/null
+++ b/docs/modules/ROOT/assets/images/kamelets/mail-imap-source.svg
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/"
+   xmlns:cc="http://creativecommons.org/ns#"
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+   xmlns:svg="http://www.w3.org/2000/svg"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   viewBox="0 0 16.200001 12.2"
+   version="1.1"
+   id="svg5"
+   sodipodi:docname="Breezeicons-places-16-folder-mail.svg"
+   width="16.200001"
+   height="12.2"
+   inkscape:version="1.0.2 (e86c870879, 2021-01-15)">
+  <metadata
+     id="metadata9">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="1920"
+     inkscape:window-height="1016"
+     id="namedview7"
+     showgrid="false"
+     fit-margin-top="0.1"
+     fit-margin-right="0.1"
+     fit-margin-left="0.1"
+     fit-margin-bottom="0.1"
+     inkscape:zoom="53.5"
+     inkscape:cx="8.1"
+     inkscape:cy="3.1093458"
+     inkscape:window-x="0"
+     inkscape:window-y="27"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="svg5" />
+  <defs
+     id="defs3051">
+    <style
+       type="text/css"
+       id="current-color-scheme">
+      .ColorScheme-Text {
+        color:#4d4d4d;
+      }
+      </style>
+  </defs>
+  <path
+     style="fill:currentColor;fill-opacity:1;stroke:none"
+     d="m 0.1,0.1 v 12 h 16 v -12 z m 1.4140625,1 H 14.685938 L 8.1,7.6859375 Z M 1.1,2.1 l 4,4 -4,4 z m 14,0 v 8 l -4,-4 z M 5.8070312,6.8070312 8.1,9.1 10.392969,6.8070312 14.685938,11.1 H 1.5140625 Z"
+     id="rect4144"
+     class="ColorScheme-Text" />
+</svg>
diff --git a/docs/modules/ROOT/nav.adoc b/docs/modules/ROOT/nav.adoc
index 478c47c..5c9e7c8 100644
--- a/docs/modules/ROOT/nav.adoc
+++ b/docs/modules/ROOT/nav.adoc
@@ -5,6 +5,7 @@
 * xref:ROOT:bitcoin-source.adoc[image:kamelets/bitcoin-source.svg[] Bitcoin Source]
 * xref:ROOT:http-source.adoc[image:kamelets/http-source.svg[] HTTP Source]
 * xref:ROOT:jira-source.adoc[image:kamelets/jira-source.svg[] Jira Source]
+* xref:ROOT:mail-imap-source.adoc[image:kamelets/mail-imap-source.svg[] Mail IMAP Source]
 * xref:ROOT:minio-source.adoc[image:kamelets/minio-source.svg[] Minio Source]
 * xref:ROOT:mqtt-source.adoc[image:kamelets/mqtt-source.svg[] MQTT Source]
 * xref:ROOT:salesforce-source.adoc[image:kamelets/salesforce-source.svg[] Salesforce Source]
diff --git a/docs/modules/ROOT/pages/mail-imap-source.adoc b/docs/modules/ROOT/pages/mail-imap-source.adoc
new file mode 100644
index 0000000..7413b5e
--- /dev/null
+++ b/docs/modules/ROOT/pages/mail-imap-source.adoc
@@ -0,0 +1,67 @@
+// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
+= image:kamelets/mail-imap-source.svg[] Mail IMAP Source
+
+*Provided by: "Apache Software Foundation"*
+
+Receive unread emails from an IMAP mail server, marking them as read once they are received.
+
+== Configuration Options
+
+The following table summarizes the configuration options available for the `mail-imap-source` Kamelet:
+[width="100%",cols="2,^2,3,^2,^2,^3",options="header"]
+|===
+| Property| Name| Description| Type| Default| Example
+| *host {empty}* *| Host| The IMAP server host| string| | `"imap.gmail.com"`
+| *password {empty}* *| Password| The password to access the mail box| string| | 
+| *port {empty}* *| Port| The IMAP server port| string| `993`| 
+| *username {empty}* *| Username| The username to access the mail box| string| | 
+| delay| Delay| The delay between fetches in milliseconds| integer| `60000`| 
+| fetchSize| Fetch Size| The number of messages fetched for each poll (-1 for no limits)| integer| `10`| 
+|===
+
+NOTE: Fields marked with ({empty}*) are mandatory.
+
+== Usage
+
+This section summarizes how the `mail-imap-source` can be used in various contexts.
+
+=== Knative Source
+
+The `mail-imap-source` Kamelet can be used as Knative source by binding it to a Knative object.
+
+.mail-imap-source-binding.yaml
+[source,yaml]
+----
+apiVersion: camel.apache.org/v1alpha1
+kind: KameletBinding
+metadata:
+  name: mail-imap-source-binding
+spec:
+  source:
+    ref:
+      kind: Kamelet
+      apiVersion: camel.apache.org/v1alpha1
+      name: mail-imap-source
+    properties:
+      host: "imap.gmail.com"
+      password: "The Password"
+      username: "The Username"
+  sink:
+    ref:
+      kind: InMemoryChannel
+      apiVersion: messaging.knative.dev/v1
+      name: mychannel
+
+----
+
+Make sure you have xref:latest@camel-k::installation/installation.adoc[Camel K installed] into the Kubernetes cluster you're connected to.
+
+Save the `mail-imap-source-binding.yaml` file into your hard drive, then configure it according to your needs.
+
+You can run the source using the following command:
+
+[source,shell]
+----
+kubectl apply -f mail-imap-source-binding.yaml
+----
+// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
diff --git a/mail-imap-source.kamelet.yaml b/mail-imap-source.kamelet.yaml
new file mode 100644
index 0000000..532154c
--- /dev/null
+++ b/mail-imap-source.kamelet.yaml
@@ -0,0 +1,74 @@
+apiVersion: camel.apache.org/v1alpha1
+kind: Kamelet
+metadata:
+  name: mail-imap-source
+  annotations:
+    camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+CjxzdmcKICAgeG1sbnM6ZGM9Imh0dHA6Ly9wdXJsLm9yZy9kYy9lbGVtZW50cy8xLjEvIgogICB4bWxuczpjYz0iaHR0cDovL2NyZWF0aXZlY29tbW9ucy5vcmcvbnMjIgogICB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiCiAgIHhtbG5zOnN2Zz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIKICAgeG1sbnM6c29kaXBvZGk9Imh0dHA6Ly9zb2RpcG [...]
+    camel.apache.org/provider: "Apache Software Foundation"
+  labels:
+    camel.apache.org/kamelet.type: "source"
+spec:
+  definition:
+    title: "Mail IMAP Source"
+    description: |-
+      Receive unread emails from an IMAP mail server, marking them as read once they are received.
+    required:
+    - host
+    - port
+    - username
+    - password
+    properties:
+      host:
+        title: Host
+        description: The IMAP server host
+        type: string
+        example: imap.gmail.com
+      port:
+        title: Port
+        description: The IMAP server port
+        type: string
+        default: 993
+      username:
+        title: Username
+        description: The username to access the mail box
+        type: string
+      password:
+        title: Password
+        description: The password to access the mail box
+        type: string
+        x-descriptors:
+        - urn:alm:descriptor:com.tectonic.ui:password
+      fetchSize:
+        title: Fetch Size
+        description: The number of messages fetched for each poll (-1 for no limits)
+        type: integer
+        default: 10
+      delay:
+        title: Delay
+        description: The delay between fetches in milliseconds
+        type: integer
+        default: 60000
+  flow:
+    from:
+      uri: "imaps:{{host}}:{{port}}"
+      parameters:
+        username: "{{username}}"
+        password: "{{password}}"
+        fetchSize: "{{fetchSize}}"
+        delay: "{{delay}}"
+      steps:
+      - set-header:
+          name: "ce-subject"
+          simple: "${header.Subject}"
+      - set-header:
+          name: "ce-from"
+          simple: "${header.From}"
+      - set-header:
+          name: "ce-to"
+          simple: "${header.To}"
+      - set-header:
+          name: "ce-cc"
+          simple: "${header.Cc}"
+      - convert-body-to:
+          type: "java.lang.String"
+      - to: "kamelet:sink"