Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Google Cloud Functions Sink Kamelet #641

Merged
merged 11 commits into from
Dec 17, 2021
19 changes: 19 additions & 0 deletions docs/modules/ROOT/assets/images/kamelets/google-functions-sink.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
* xref:ROOT:ftps-source.adoc[image:kamelets/ftps-source.svg[] FTPS Source]
* xref:ROOT:github-source.adoc[image:kamelets/github-source.svg[] Github Source]
* xref:ROOT:google-calendar-source.adoc[image:kamelets/google-calendar-source.svg[] Google Calendar Source]
* xref:ROOT:google-functions-sink.adoc[image:kamelets/google-functions-sink.svg[] Google Functions Sink]
* xref:ROOT:google-mail-source.adoc[image:kamelets/google-mail-source.svg[] Google Mail Source]
* xref:ROOT:google-pubsub-sink.adoc[image:kamelets/google-pubsub-sink.svg[] Google Pubsub Sink]
* xref:ROOT:google-pubsub-source.adoc[image:kamelets/google-pubsub-source.svg[] Google Pubsub Source]
Expand Down
158 changes: 158 additions & 0 deletions docs/modules/ROOT/pages/google-functions-sink.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT

= image:kamelets/google-functions-sink.svg[] Google Functions Sink

*Provided by: "Apache Software Foundation"*

*Support Level for this Kamelet is: "Preview"*

Send messages to Google Functions.

The serviceAccountKey property needs to be a path to a service account key file.

== Configuration Options

The following table summarizes the configuration options available for the `google-functions-sink` Kamelet:
[width="100%",cols="2,^2,3,^2,^2,^3",options="header"]
|===
| Property| Name| Description| Type| Default| Example
| *functionName {empty}* *| Function Name| The Function Name| string| |
| *projectId {empty}* *| Project Id| The Google Cloud Functions Project Id| string| |
| *region {empty}* *| Region| The Region where the Google Cloud Functions has been deployed| string| |
| *serviceAccountKey {empty}* *| Service Account Key| The Service account key that can be used as credentials for the Google Cloud Functions platform| string| |
|===

NOTE: Fields marked with an asterisk ({empty}*) are mandatory.


== Dependencies

At runtime, the `google-functions-sink` Kamelet relies upon the presence of the following dependencies:

- camel:kamelet
- camel:google-functions
- camel:jackson

== Usage

This section describes how you can use the `google-functions-sink`.

=== Knative Sink

You can use the `google-functions-sink` Kamelet as a Knative sink by binding it to a Knative object.

.google-functions-sink-binding.yaml
[source,yaml]
----
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: google-functions-sink-binding
spec:
source:
ref:
kind: Channel
apiVersion: messaging.knative.dev/v1
name: mychannel
sink:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: google-functions-sink
properties:
functionName: "The Function Name"
projectId: "The Project Id"
region: "The Region"
serviceAccountKey: "The Service Account Key"

----

==== *Prerequisite*

You have xref:{camel-k-version}@camel-k::installation/installation.adoc[Camel K installed] on the cluster.

==== *Procedure for using the cluster CLI*

. Save the `google-functions-sink-binding.yaml` file to your local drive, and then edit it as needed for your configuration.

. Run the sink by using the following command:
+
[source,shell]
----
kubectl apply -f google-functions-sink-binding.yaml
----

==== *Procedure for using the Kamel CLI*

Configure and run the sink by using the following command:

[source,shell]
----
kamel bind channel:mychannel google-functions-sink -p "sink.functionName=The Function Name" -p "sink.projectId=The Project Id" -p "sink.region=The Region" -p "sink.serviceAccountKey=The Service Account Key"
----

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

=== Kafka Sink

You can use the `google-functions-sink` Kamelet as a Kafka sink by binding it to a Kafka topic.

.google-functions-sink-binding.yaml
[source,yaml]
----
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: google-functions-sink-binding
spec:
source:
ref:
kind: KafkaTopic
apiVersion: kafka.strimzi.io/v1beta1
name: my-topic
sink:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: google-functions-sink
properties:
functionName: "The Function Name"
projectId: "The Project Id"
region: "The Region"
serviceAccountKey: "The Service Account Key"

----

==== *Prerequisites*

* You've installed https://strimzi.io/[Strimzi].
* You've created a topic named `my-topic` in the current namespace.
* You have xref:{camel-k-version}@camel-k::installation/installation.adoc[Camel K installed] on the cluster.

==== *Procedure for using the cluster CLI*

. Save the `google-functions-sink-binding.yaml` file to your local drive, and then edit it as needed for your configuration.

. Run the sink by using the following command:
+
[source,shell]
----
kubectl apply -f google-functions-sink-binding.yaml
----

==== *Procedure for using the Kamel CLI*

Configure and run the sink by using the following command:

[source,shell]
----
kamel bind kafka.strimzi.io/v1beta1:KafkaTopic:my-topic google-functions-sink -p "sink.functionName=The Function Name" -p "sink.projectId=The Project Id" -p "sink.region=The Region" -p "sink.serviceAccountKey=The Service Account Key"
----

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

== Kamelet source file

https://github.com/apache/camel-kamelets/blob/main/kamelets/google-functions-sink.kamelet.yaml

// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
74 changes: 74 additions & 0 deletions kamelets/google-functions-sink.kamelet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# ---------------------------------------------------------------------------
# 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: google-functions-sink
annotations:
camel.apache.org/kamelet.support.level: "Preview"
camel.apache.org/catalog.version: "main-SNAP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camel.apache.org/kamelet.group: "Google Functions"
labels:
camel.apache.org/kamelet.type: "sink"
spec:
definition:
title: "Google Functions Sink"
description: |-
Send messages to Google Functions.

The serviceAccountKey property needs to be a path to a service account key file.
required:
- projectId
- functionName
- region
- serviceAccountKey
type: object
properties:
projectId:
title: Project Id
description: The Google Cloud Functions Project Id
type: string
region:
title: Region
description: The Region where the Google Cloud Functions has been deployed
type: string
functionName:
title: Function Name
description: The Function Name
type: string
serviceAccountKey:
title: Service Account Key
description: The Service account key that can be used as credentials for the Google Cloud Functions platform
type: string
x-descriptors:
- urn:camel:group:credentials
dependencies:
- "camel:kamelet"
- "camel:google-functions"
- "camel:jackson"
flow:
from:
uri: kamelet:source
steps:
- to:
uri: "google-functions://{{functionName}}"
parameters:
serviceAccountKey: "{{serviceAccountKey}}"
project: "{{projectId}}"
location: "{{region}}"