Skip to content

Commit

Permalink
Add HTTP sink kamelet and fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolaferraro committed Apr 13, 2021
1 parent 32f143d commit 85ee518
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 8 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ on:
- 'NOTICE'

env:
CAMEL_K_VERSION: 1.3.1
YAKS_VERSION: 0.3.0
CAMEL_K_VERSION: 1.3.2
YAKS_VERSION: 0.4.0-202104120032

jobs:
test:
Expand All @@ -49,15 +49,15 @@ jobs:
uses: actions/checkout@v2
- name: Get Camel K CLI
run: |
curl -L --silent https://github.com/apache/camel-k/releases/download/v${CAMEL_K_VERSION}/camel-k-client-${CAMEL_K_VERSION}-linux-64bit.tar.gz -o kamel.tar.gz
curl --fail -L --silent https://github.com/apache/camel-k/releases/download/v${CAMEL_K_VERSION}/camel-k-client-${CAMEL_K_VERSION}-linux-64bit.tar.gz -o kamel.tar.gz
mkdir -p _kamel
tar -zxf kamel.tar.gz --directory ./_kamel
sudo mv ./_kamel/kamel /usr/local/bin/
rm kamel.tar.gz
rm -r _kamel
- name: Get YAKS CLI
run: |
curl -L https://github.com/citrusframework/yaks/releases/download/v${YAKS_VERSION}/yaks-${YAKS_VERSION}-linux-64bit.tar.gz -o yaks.tar.gz
curl --fail -L --silent https://github.com/citrusframework/yaks/releases/download/${YAKS_VERSION}/yaks-${YAKS_VERSION}-linux-64bit.tar.gz -o yaks.tar.gz
mkdir -p _yaks
tar -zxf yaks.tar.gz --directory ./_yaks
sudo mv ./_yaks/yaks /usr/local/bin/
Expand Down
8 changes: 8 additions & 0 deletions docs/modules/ROOT/assets/images/kamelets/http-sink.svg
Loading
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 @@ -24,6 +24,7 @@
* xref:ROOT:google-calendar-source.adoc[image:kamelets/google-calendar-source.svg[] Google Calendar Source]
* xref:ROOT:google-mail-source.adoc[image:kamelets/google-mail-source.svg[] Google Mail Source]
* xref:ROOT:google-sheets-source.adoc[image:kamelets/google-sheets-source.svg[] Google Sheets Source]
* xref:ROOT:http-sink.adoc[image:kamelets/http-sink.svg[] HTTP Sink]
* 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:kafka-source.adoc[image:kamelets/kafka-source.svg[] Kafka Source]
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/dropbox-source.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The following table summarizes the configuration options available for the `drop
| Property| Name| Description| Type| Default| Example
| *accessToken {empty}* *| Dropbox Access Token| The access Token to use to access Dropbox| string| |
| *clientIdentifier {empty}* *| The client identifier| Dropbox App client Identifier| string| |
| *period {empty}* *| Period between polls| The interval between fetches to the earthquake API in milliseconds| integer| `10000`|
| *period {empty}* *| Period between polls| The interval between fetches to the Dropbox remote path in milliseconds| integer| `10000`|
| *query {empty}* *| Querys| A space-separated list of sub-strings to search for. A file matches only if it contains all the sub-strings. If this option is not set, all files will be matched.| string| |
| *remotePath {empty}* *| Remote path| Original file or folder to work with| string| |
|===
Expand Down
61 changes: 61 additions & 0 deletions docs/modules/ROOT/pages/http-sink.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
= image:kamelets/http-sink.svg[] HTTP Sink

*Provided by: "Apache Software Foundation"*

Forwards an event to a HTTP endpoint

== Configuration Options

The following table summarizes the configuration options available for the `http-sink` Kamelet:
[width="100%",cols="2,^2,3,^2,^2,^3",options="header"]
|===
| Property| Name| Description| Type| Default| Example
| *url {empty}* *| URL| The URL to send data to| string| | `"https://my-service/path"`
| method| Method| The HTTP method to use| string| `"POST"`|
|===

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

== Usage

This section summarizes how the `http-sink` can be used in various contexts.

=== Knative Sink

The `http-sink` Kamelet can be used as Knative sink by binding it to a Knative object.

.http-sink-binding.yaml
[source,yaml]
----
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
name: http-sink-binding
spec:
source:
ref:
kind: InMemoryChannel
apiVersion: messaging.knative.dev/v1
name: mychannel
sink:
ref:
kind: Kamelet
apiVersion: camel.apache.org/v1alpha1
name: http-sink
properties:
url: "https://my-service/path"
----

Make sure you have xref:latest@camel-k::installation/installation.adoc[Camel K installed] into the Kubernetes cluster you're connected to.

Save the `http-sink-binding.yaml` file into your hard drive, then configure it according to your needs.

You can run the sink using the following command:

[source,shell]
----
kubectl apply -f http-sink-binding.yaml
----
// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
8 changes: 5 additions & 3 deletions earthquake-source.kamelet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
- set-header:
name: CamelCaffeineAction
constant: GET
- to-d: "caffeine-cache:cache-${routeId}?key=lastUpdate"
- tod: "caffeine-cache:cache-${routeId}?key=lastUpdate"
- choice:
when:
- simple: "${header.CamelCaffeineActionHasResult}"
Expand All @@ -56,7 +56,9 @@ spec:
- set-header:
name: CamelHttpMethod
constant: GET
- to-d: "https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&updatedafter=${exchangeProperty.lastUpdate}&orderby=time-asc"
- tod: "https://earthquake.usgs.gov/fdsnws/event/1/query?format=geojson&updatedafter=${exchangeProperty.lastUpdate}&orderby=time-asc"
- remove-header:
header-name: CamelHttpMethod
- unmarshal:
json: {}
- set-property:
Expand All @@ -72,7 +74,7 @@ spec:
- set-header:
name: CamelCaffeineAction
constant: PUT
- to-d: "caffeine-cache:cache-${routeId}?key=lastUpdate"
- tod: "caffeine-cache:cache-${routeId}?key=lastUpdate"
- claim-check:
operation: Pop
- split:
Expand Down
38 changes: 38 additions & 0 deletions http-sink.kamelet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
apiVersion: camel.apache.org/v1alpha1
kind: Kamelet
metadata:
name: http-sink
annotations:
camel.apache.org/kamelet.icon: "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI0MjAiCmhlaWdodD0iNDIwIiBzdHJva2U9IiMwMDAiIGZpbGw9Im5vbmUiPgo8cGF0aCBzdHJva2Utd2lkdGg9IjI2IgpkPSJNMjA5LDE1YTE5NSwxOTUgMCAxLDAgMiwweiIvPgo8cGF0aCBzdHJva2Utd2lkdGg9IjE4IgpkPSJtMjEwLDE1djM5MG0xOTUtMTk1SDE1TTU5LDkwYTI2MCwyNjAgMCAwLDAgMzAyLDAgbTAsMjQwIGEyNjAsMjYwIDAgMCwwLTMwMiwwTTE5NSwyMGEyNTAsMjUwIDAgMCwwIDAsMzgyIG0zMCwwIGEyNTAsMjUwIDAgMCwwIDAtMzgyIi8+Cjwvc3ZnPg=="
camel.apache.org/provider: "Apache Software Foundation"
labels:
camel.apache.org/kamelet.type: sink
camel.apache.org/requires.runtime: "camel-quarkus"
spec:
definition:
title: HTTP Sink
description: Forwards an event to a HTTP endpoint
required:
- url
properties:
url:
title: URL
description: The URL to send data to
type: string
example: "https://my-service/path"
pattern: "^(http|https)://.*"
method:
title: Method
description: The HTTP method to use
type: string
default: POST
dependencies:
- camel-quarkus:http
flow:
from:
uri: kamelet:source
steps:
- set-header:
name: CamelHttpMethod
constant: "{{method}}"
- to: "{{url}}"

0 comments on commit 85ee518

Please sign in to comment.