google mail source Google Mail Source

Provided by: "Apache Software Foundation"

Support Level for this Kamelet is: "Stable"

Receive data from Google Mail.

Configuration Options

The following table summarizes the configuration options available for the google-mail-source Kamelet:

Property Name Description Type Default Example

accessToken

Access Token

Required OAuth 2 access token for google mail application. This typically expires after an hour so refreshToken is recommended for long term usage.

string

applicationName

Application name

Required Google Mail application name.

string

clientId

Client ID

Required Client ID of the gmail application.

string

clientSecret

Client Secret

Required Client Secret of the gmail application.

string

index

Index

Required An index for the google mail endpoint.

string

refreshToken

Refresh Token

Required OAuth 2 refresh token for google mail application. Using this, the Google Calendar component can obtain a new accessToken whenever the current one expires - a necessity if the application is long-lived.

string

delay

Delay

The number of milliseconds before the next poll.

integer

500

labels

Gmail Labels

Comma separated list of labels to take into account.

string

inbox

markAsRead

Mark as Read

Mark the message as read once it has been consumed.

boolean

true

query

Gmail Query

The query to execute on gmail box.

string

is:unread

is:unread -category:(promotions OR social)

Dependencies

At runtime, the google-mail-source Kamelet relies upon the presence of the following dependencies:

  • camel:jackson

  • camel:kamelet

  • camel:google-mail

Camel Jbang usage

Prerequisites

  • You’ve installed Jbang.

  • You have executed the following command:

jbang app install camel@apache/camel

Supposing you have a file named route.yaml with this content:

- route:
    from:
      uri: "kamelet:timer-source"
      parameters:
        period: 10000
        message: 'test'
      steps:
        - to:
            uri: "kamelet:log-sink"

You can now run it directly through the following command

camel run route.yaml

Camel K Enviroment Usage

This section describes how you can use the google-mail-source.

Knative source

You can use the google-mail-source Kamelet as a Knative source by binding it to a Knative object.

google-mail-source-binding.yaml
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
  name: google-mail-source-binding
spec:
  source:
    ref:
      kind: Kamelet
      apiVersion: camel.apache.org/v1alpha1
      name: google-mail-source
    properties:
      accessToken: The Access Token
      applicationName: The Application name
      clientId: The Client ID
      clientSecret: The Client Secret
      index: The Index
      refreshToken: The Refresh Token
  sink:
    ref:
      kind: Channel
      apiVersion: messaging.knative.dev/v1
      name: mychannel

Prerequisite

You have Camel K installed on the cluster.

Procedure for using the cluster CLI

  1. Save the google-mail-source-binding.yaml file to your local drive, and then edit it as needed for your configuration.

  2. Run the source by using the following command:

    kubectl apply -f google-mail-source-binding.yaml

Procedure for using the Kamel CLI

Configure and run the source by using the following command:

kamel bind google-mail-source -p "source.accessToken=The Access Token" -p "source.applicationName=The Application name" -p "source.clientId=The Client ID" -p "source.clientSecret=The Client Secret" -p "source.index=The Index" -p "source.refreshToken=The Refresh Token" channel:mychannel

This command creates the KameletBinding in the current namespace on the cluster.

Kafka source

You can use the google-mail-source Kamelet as a Kafka source by binding it to a Kafka topic.

google-mail-source-binding.yaml
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
  name: google-mail-source-binding
spec:
  source:
    ref:
      kind: Kamelet
      apiVersion: camel.apache.org/v1alpha1
      name: google-mail-source
    properties:
      accessToken: The Access Token
      applicationName: The Application name
      clientId: The Client ID
      clientSecret: The Client Secret
      index: The Index
      refreshToken: The Refresh Token
  sink:
    ref:
      kind: KafkaTopic
      apiVersion: kafka.strimzi.io/v1beta1
      name: my-topic

Prerequisites

  • You’ve installed Strimzi.

  • You’ve created a topic named my-topic in the current namespace.

  • You have Camel K installed on the cluster.

Procedure for using the cluster CLI

  1. Save the google-mail-source-binding.yaml file to your local drive, and then edit it as needed for your configuration.

  2. Run the source by using the following command:

    kubectl apply -f google-mail-source-binding.yaml

Procedure for using the Kamel CLI

Configure and run the source by using the following command:

kamel bind google-mail-source -p "source.accessToken=The Access Token" -p "source.applicationName=The Application name" -p "source.clientId=The Client ID" -p "source.clientSecret=The Client Secret" -p "source.index=The Index" -p "source.refreshToken=The Refresh Token" kafka.strimzi.io/v1beta1:KafkaTopic:my-topic

This command creates the KameletBinding in the current namespace on the cluster.