This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-kamelets.git
The following commit(s) were added to refs/heads/main by this push:
new b376de293 chore: the HTTP Kamelets can go through a proxy and follow
redirects, graphql-sink can take a query file (#3170) (#3212)
b376de293 is described below
commit b376de2930c2b56995edc12910b4783c5ce65e8d
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Nov 18 22:30:15 2026 +0100
chore: the HTTP Kamelets can go through a proxy and follow redirects,
graphql-sink can take a query file (#3170) (#3212)
http-source and http-sink take proxyHost, proxyPort, proxyUser and
proxyPassword (mapped to proxyAuthUsername and proxyAuthPassword, the
password in RAW()), and followRedirects. http-source also takes method,
mapped to the httpMethod option of the endpoint; it is GET when unset.
rest-openapi-sink takes consumes and produces, for the Accept and
Content-Type of the request, in RAW() so that a + in a media type is
kept, and a pattern without spaces, because a space in the value
reaches the server as a +.
graphql-sink takes queryFile, operationName, variables (a JSON object,
in RAW()) and proxyHost, which the graphql component takes as
host:port and without a proxy login.
NTLM domain and host are left out: Camel 4.24 deprecates them.
All the options are optional placeholders without a default, so with
them unset the endpoint URIs are the same as before. The doc pages have
examples for each.
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
.../ROOT/partials/graphql-sink-description.adoc | 31 ++++++++++++++-
.../ROOT/partials/http-sink-description.adoc | 24 +++++++++++-
.../ROOT/partials/http-source-description.adoc | 45 ++++++++++++++++++++++
.../partials/rest-openapi-sink-description.adoc | 17 ++++++++
kamelets/graphql-sink.kamelet.yaml | 34 +++++++++++++---
kamelets/http-sink.kamelet.yaml | 35 ++++++++++++++++-
kamelets/http-source.kamelet.yaml | 44 ++++++++++++++++++++-
kamelets/rest-openapi-sink.kamelet.yaml | 16 +++++++-
.../main/resources/META-INF/kamelets-index.json | 12 +++---
.../resources/kamelets/graphql-sink.kamelet.yaml | 34 +++++++++++++---
.../main/resources/kamelets/http-sink.kamelet.yaml | 35 ++++++++++++++++-
.../resources/kamelets/http-source.kamelet.yaml | 44 ++++++++++++++++++++-
.../kamelets/rest-openapi-sink.kamelet.yaml | 16 +++++++-
13 files changed, 361 insertions(+), 26 deletions(-)
diff --git a/docs/modules/ROOT/partials/graphql-sink-description.adoc
b/docs/modules/ROOT/partials/graphql-sink-description.adoc
index 4f65bcd51..d3a3a4268 100644
--- a/docs/modules/ROOT/partials/graphql-sink-description.adoc
+++ b/docs/modules/ROOT/partials/graphql-sink-description.adoc
@@ -2,7 +2,7 @@
=== GraphQL Operations
-This Kamelet sends the GraphQL query or mutation in the message body to a
GraphQL endpoint, with an HTTP POST, and returns the answer of the server.
+This Kamelet sends a GraphQL query or mutation, from the message body or from
a file, to a GraphQL endpoint, with an HTTP POST, and returns the answer of the
server.
=== Required Configuration
@@ -15,3 +15,32 @@ This Kamelet sends the GraphQL query or mutation in the
message body to a GraphQ
=== Usage
The body of each message must be the text of the query or mutation, such as `{
books { title } }`. The answer of the server, JSON text with `data` and
`errors`, becomes the body of the message, for the next steps of a route.
+
+=== Query from a File
+
+With `queryFile`, the query comes from a file, `file:` followed by its path,
or `classpath:` followed by a resource in the application, and the body is not
sent as the query. The values of the variables of the query come from
`variables`, as a JSON object. When the file defines several operations,
`operationName` picks the one to run.
+
+[source,yaml]
+----
+- to:
+ uri: "kamelet:graphql-sink"
+ parameters:
+ url: "https://api.example.com/graphql"
+ queryFile: "file:/etc/graphql/books.graphql"
+ operationName: AddBook
+ variables: '{"title":"Dune","year":1965}'
+----
+
+With this file, `AddBook` runs with `$title` set to `Dune` and `$year` set to
1965:
+
+[source,graphql]
+----
+query ListBooks { books { title } }
+mutation AddBook($title: String!, $year: Int) { addBook(title: $title, year:
$year) { id } }
+----
+
+When `variables` is not set, a body that is a Map, such as JSON parsed into a
Map, is sent as the variables. Any other body is not sent.
+
+=== Proxy
+
+To send the requests through an HTTP proxy, set `proxyHost` to its host and
port, such as `proxy.example.com:3128`. A proxy that asks for a login is not
supported.
diff --git a/docs/modules/ROOT/partials/http-sink-description.adoc
b/docs/modules/ROOT/partials/http-sink-description.adoc
index c1481d936..ab894412a 100644
--- a/docs/modules/ROOT/partials/http-sink-description.adoc
+++ b/docs/modules/ROOT/partials/http-sink-description.adoc
@@ -62,6 +62,28 @@ A response with a status code outside `okStatusCodeRange`
fails the message. Whe
The response code is then in the `CamelHttpResponseCode` header, and the body
is the response of the service. Setting only `409` would make a 200 response
fail.
+=== Going Through a Proxy
+
+To send the requests through an HTTP proxy, set `proxyHost` and `proxyPort`.
The proxy is used only when both are set. When the proxy asks for a login, also
set `proxyUser` and `proxyPassword`: they are sent after the proxy answers 407
and asks for them.
+
+[source,yaml]
+----
+- to:
+ uri: "kamelet:http-sink"
+ parameters:
+ url: "https://api.example.com/v1/events"
+ proxyHost: proxy.example.com
+ proxyPort: 3128
+ proxyUser: "{{proxy.user}}"
+ proxyPassword: "{{proxy.password}}"
+----
+
+An `https://` address goes through the proxy too, in a tunnel: the proxy sees
the host name, not the request.
+
+=== Following Redirects
+
+A redirect, a response with a status code such as 301, 302 or 307, is not
followed when `followRedirects` is not set: its status code fails the message,
unless it is in `okStatusCodeRange`. With `followRedirects: true`, the request
goes on to the address in the `Location` header of the response. A `POST`
answered with 301, 302 or 303 goes on as a `GET` without the body; 307 and 308
keep the method and the body.
+
=== Trusting a Private Certificate Authority
The certificate of an `https://` service is checked against the certificate
authorities that Java trusts. A service whose certificate is signed by a
private certificate authority fails with `PKIX path building failed`.
@@ -80,4 +102,4 @@ That trust store then replaces the one of Java for every
`https://` call of the
=== Headers
-The Kamelet sets the HTTP method from the `method` option, and removes the
headers that could change where the message is sent, such as `CamelHttpUri`.
The other headers of the message are sent as HTTP headers.
+The Kamelet sets the HTTP method from the `method` option, and removes the
headers that could change where the message is sent, such as `CamelHttpUri`.
The proxy comes only from the options. The other headers of the message are
sent as HTTP headers.
diff --git a/docs/modules/ROOT/partials/http-source-description.adoc
b/docs/modules/ROOT/partials/http-source-description.adoc
index 7655c6eca..11df11933 100644
--- a/docs/modules/ROOT/partials/http-source-description.adoc
+++ b/docs/modules/ROOT/partials/http-source-description.adoc
@@ -7,6 +7,7 @@ The HTTP Source Kamelet periodically fetches data from an HTTP
endpoint. It supp
- **URL**: The HTTP endpoint to fetch data from (required, must start with
http:// or https://)
- **Period**: The interval between fetches in milliseconds (default: 10000)
- **Content Type**: The Accept header content type for the request (default:
"application/json")
+- **Method**: The HTTP method of the request (default: GET)
=== Logging In
@@ -119,6 +120,50 @@ Only a response with a status code in `okStatusCodeRange`
is sent as a message.
The `CamelHttpResponseCode` header of the message then tells a 404 from a 200.
Setting only `404` would stop the 200 responses.
+=== Method
+
+The request is a `GET` when `method` is not set. Some APIs return data only
for a `POST`; set `method: POST` for them. The request has no body.
+
+[source,yaml]
+----
+- route:
+ from:
+ uri: "kamelet:http-source"
+ parameters:
+ url: "https://api.example.com/v1/reports/search"
+ method: POST
+ period: 60000
+ steps:
+ - to:
+ uri: "kamelet:log-sink"
+----
+
+=== Going Through a Proxy
+
+To fetch the address through an HTTP proxy, set `proxyHost` and `proxyPort`.
The proxy is used only when both are set. When the proxy asks for a login, also
set `proxyUser` and `proxyPassword`: they are sent after the proxy answers 407
and asks for them.
+
+[source,yaml]
+----
+- route:
+ from:
+ uri: "kamelet:http-source"
+ parameters:
+ url: "https://api.example.com/v1/orders/status"
+ proxyHost: proxy.example.com
+ proxyPort: 3128
+ proxyUser: "{{proxy.user}}"
+ proxyPassword: "{{proxy.password}}"
+ steps:
+ - to:
+ uri: "kamelet:log-sink"
+----
+
+An `https://` address goes through the proxy too, in a tunnel.
+
+=== Following Redirects
+
+A redirect, a response with a status code such as 301, 302 or 307, is not
followed when `followRedirects` is not set: it sends no message, the error is
logged, and the address is fetched again at the next period. With
`followRedirects: true`, the address in the `Location` header of the response
is fetched, and its response is sent as the message.
+
=== Trusting a Private Certificate Authority
The certificate of an `https://` service is checked against the certificate
authorities that Java trusts. A service whose certificate is signed by a
private certificate authority fails with `PKIX path building failed`.
diff --git a/docs/modules/ROOT/partials/rest-openapi-sink-description.adoc
b/docs/modules/ROOT/partials/rest-openapi-sink-description.adoc
index b2e843aa9..bfbc7b294 100644
--- a/docs/modules/ROOT/partials/rest-openapi-sink-description.adoc
+++ b/docs/modules/ROOT/partials/rest-openapi-sink-description.adoc
@@ -8,6 +8,23 @@ This Kamelet provides integration with RESTful APIs that are
documented using Op
Uses the OpenAPI specification to find the method, the path, the parameters
and the content type of the operation given in `operation`. The path and query
parameters come from headers with the same names as the parameters: for
`/pets/\{petId}`, set the `petId` header. A missing path parameter is not an
error: the request is sent with `\{petId}` in the path. The Kamelet has no
authentication options.
+=== Content Types
+
+The `Accept` and `Content-Type` headers of the request come from the
specification: the content types of the responses of the operation, and the
content type of its request body. `consumes` replaces the `Accept` header, and
`produces` the `Content-Type` header, for an API whose specification lists
other types than the ones it should be called with:
+
+[source,yaml]
+----
+- to:
+ uri: "kamelet:rest-openapi-sink"
+ parameters:
+ specification: "https://api.example.com/openapi.json"
+ operation: updateCustomer
+ produces: "application/merge-patch+json"
+ consumes: "application/json"
+----
+
+Separate several types in `consumes` with commas, without spaces, such as
`application/json,text/csv`. An `Accept` or `Content-Type` header on the
message is sent instead of these options.
+
=== HTTP Operations
Supports various HTTP operations (GET, POST, PUT, DELETE, etc.) as defined in
the OpenAPI specification, providing comprehensive REST API integration
capabilities.
diff --git a/kamelets/graphql-sink.kamelet.yaml
b/kamelets/graphql-sink.kamelet.yaml
index d06fea03d..bbdd8eeba 100644
--- a/kamelets/graphql-sink.kamelet.yaml
+++ b/kamelets/graphql-sink.kamelet.yaml
@@ -31,15 +31,15 @@ spec:
definition:
title: "GraphQL Sink"
description: |-
- Sends the GraphQL query or mutation in the body of each message to a
GraphQL server, with an HTTP POST, and gives back the answer of the server.
+ Sends a GraphQL query or mutation, from the body of each message or from
a file, to a GraphQL server with an HTTP POST, and gives back the answer of the
server.
- Use it to create or change data through a GraphQL API with a mutation,
for example to add a record for each event, or to fetch data with a query.
+ Use it to create or change data through a GraphQL API with a mutation,
for example to add a record for each event, or to fetch data with a query. It
can also run a stored query from `queryFile` each time a message arrives.
- Input: the body is the GraphQL query or mutation itself, as text, such
as `{ books { title } }`. A body that is not text, such as a Map, fails the
message. The other headers of the message, except the Camel ones, are sent as
HTTP headers.
+ Input: the body is the GraphQL query or mutation itself, as text, such
as `{ books { title } }`. A body that is not text, such as a Map, fails the
message. With `queryFile`, the query comes from that file instead, and the body
is not sent, except that a Map body is sent as the variables of the query when
`variables` is not set. The other headers of the message, except the Camel
ones, are sent as HTTP headers.
Output: when it is used inside a route, the body afterwards is the
answer of the server, as JSON text with its `data` and `errors`.
- Good to know: GraphQL errors in the answer do not fail the message, but
an HTTP status outside 200 to 299 does. Since the body is run as a query, only
send it messages from a source you trust.
+ Good to know: GraphQL errors in the answer do not fail the message, but
an HTTP status outside 200 to 299 does. Without `queryFile`, the body is run as
a query, so only send it messages from a source you trust. When the query
defines several operations, `operationName` picks the one to run. To go through
an HTTP proxy, set `proxyHost` to its host and port; a proxy that asks for a
login is not supported. Headers on the message cannot change where the request
is sent.
required:
- url
type: object
@@ -57,6 +57,30 @@ spec:
format: password
x-descriptors:
- urn:camel:group:credentials
+ queryFile:
+ title: Query File
+ description: Where to load the GraphQL query or mutation from, in
place of the body. `classpath:` followed by a resource in the application, or
`file:` followed by the path of a file. The variables then come from
`variables`, or from the body when it is a Map.
+ type: string
+ example: "file:/etc/graphql/add-book.graphql"
+ pattern: "^(classpath:|file:)[^?&#]+$"
+ operationName:
+ title: Operation Name
+ description: The name of the operation to run, when the query defines
more than one, such as `AddBook` for `mutation AddBook { ... }`.
+ type: string
+ example: AddBook
+ pattern: "^[_A-Za-z][_0-9A-Za-z]*$"
+ variables:
+ title: Variables
+ description: The values of the variables of the query, as a JSON
object, such as `{"title":"Dune"}` for a query that declares `$title`. When it
is set, the body is not used as the variables.
+ type: string
+ example: '{"title":"Dune","year":1965}'
+ pattern: "^\\s*\\{[\\s\\S]*\\}\\s*$"
+ proxyHost:
+ title: Proxy
+ description: The host name or IP address and the port of an HTTP proxy
to send the requests through, as `host:port`, such as `proxy.example.com:3128`.
A proxy that asks for a login is not supported.
+ type: string
+ example: "proxy.example.com:3128"
+ pattern: "^[A-Za-z0-9._-]+:[0-9]{1,5}$"
dependencies:
- "camel:graphql"
- "camel:kamelet"
@@ -65,4 +89,4 @@ spec:
uri: kamelet:source
steps:
- to:
- uri: "graphql://{{url}}?accessToken=RAW({{?accessToken}})"
+ uri:
"graphql://{{url}}?accessToken=RAW({{?accessToken}})&queryFile={{?queryFile}}&operationName={{?operationName}}&variables=RAW({{?variables}})&proxyHost={{?proxyHost}}"
diff --git a/kamelets/http-sink.kamelet.yaml b/kamelets/http-sink.kamelet.yaml
index 99a0abc90..284396787 100644
--- a/kamelets/http-sink.kamelet.yaml
+++ b/kamelets/http-sink.kamelet.yaml
@@ -39,7 +39,7 @@ spec:
Output: when it is used inside a route, the body afterwards is the
response of the service.
- Good to know: a response with a status code outside `okStatusCodeRange`,
which is `200-299` when it is not set, fails the message. The address and the
method come only from the options; headers on the message cannot change where
it is sent. Log in either with `authUsername` and `authPassword`, with a static
token in `authBearerToken`, or with `oauth2ClientId`, `oauth2ClientSecret` and
`oauth2TokenEndpoint`: the Kamelet then gets a token from that URL and sends it
as a Bearer token. [...]
+ Good to know: a response with a status code outside `okStatusCodeRange`,
which is `200-299` when it is not set, fails the message. The address, the
method and the proxy come only from the options; headers on the message cannot
change where it is sent. Log in either with `authUsername` and `authPassword`,
with a static token in `authBearerToken`, or with `oauth2ClientId`,
`oauth2ClientSecret` and `oauth2TokenEndpoint`: the Kamelet then gets a token
from that URL and sends it as a Be [...]
required:
- url
type: object
@@ -56,6 +56,34 @@ spec:
type: string
default: POST
enum: ["GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "TRACE",
"PATCH"]
+ followRedirects:
+ title: Follow Redirects
+ description: If true, a redirect, a response with a status code such
as 301, 302 or 307, is followed to the address in its `Location` header. A
`POST` answered with 301, 302 or 303 goes on as a `GET` without the body; 307
and 308 keep the method and the body. When it is not set, the redirect is not
followed, and its status code fails the message unless it is in
`okStatusCodeRange`.
+ type: boolean
+ proxyHost:
+ title: Proxy Host
+ description: The host name or IP address of an HTTP proxy to send the
requests through, without the port. Use it with `proxyPort`; the proxy is used
only when both are set.
+ type: string
+ example: proxy.example.com
+ pattern: "^[A-Za-z0-9._-]+$"
+ proxyPort:
+ title: Proxy Port
+ description: The port of the HTTP proxy in `proxyHost`.
+ type: integer
+ example: 3128
+ proxyUser:
+ title: Proxy User
+ description: The user to log in to the HTTP proxy as, when the proxy
asks for a login. Use it with `proxyPassword`.
+ type: string
+ x-descriptors:
+ - urn:camel:group:credentials
+ proxyPassword:
+ title: Proxy Password
+ description: The password of `proxyUser` for the HTTP proxy.
+ type: string
+ format: password
+ x-descriptors:
+ - urn:camel:group:credentials
okStatusCodeRange:
title: OK Status Codes
description: The status codes of a response that do not fail the
message, as ranges such as `200-299` and single codes, separated by commas
without spaces. When it is not set, it is `200-299`. List the 2xx codes too,
for example `200-299,404` to also accept 404.
@@ -147,6 +175,11 @@ spec:
- to:
uri: "{{url}}"
parameters:
+ followRedirects: "{{?followRedirects}}"
+ proxyHost: "{{?proxyHost}}"
+ proxyPort: "{{?proxyPort}}"
+ proxyAuthUsername: "{{?proxyUser}}"
+ proxyAuthPassword: "RAW({{?proxyPassword}})"
authMethod: "{{?authMethod}}"
authUsername: "{{?authUsername}}"
authPassword: "{{?authPassword}}"
diff --git a/kamelets/http-source.kamelet.yaml
b/kamelets/http-source.kamelet.yaml
index e163af3d1..7b3431a56 100644
--- a/kamelets/http-source.kamelet.yaml
+++ b/kamelets/http-source.kamelet.yaml
@@ -31,13 +31,13 @@ spec:
definition:
title: "HTTP Source"
description: |-
- Fetches a web address with an HTTP GET request at a regular interval,
and sends each response as a message.
+ Fetches a web address with an HTTP request, a GET unless `method` says
otherwise, at a regular interval, and sends each response as a message.
Use it to poll a REST API, a feed or a status page for its current data,
for example fetch the state of the orders every minute. To receive the requests
that other systems send instead, use `webhook-source`.
Output: the body is the body of the response, as bytes. The headers of
the response, such as `Content-Type`, are copied to the message, and
`CamelHttpResponseCode` holds the status code.
- Good to know: it fetches the address every `period` and sends a message
for each response, even when the data has not changed. A response with a status
code outside `okStatusCodeRange`, which is `200-299` when it is not set, sends
no message: the error is logged, and the address is fetched again at the next
period. Log in either with `authUsername` and `authPassword`, with a static
token in `authBearerToken`, or with `oauth2ClientId`, `oauth2ClientSecret` and
`oauth2TokenEndpoint`: [...]
+ Good to know: it fetches the address every `period` and sends a message
for each response, even when the data has not changed. A response with a status
code outside `okStatusCodeRange`, which is `200-299` when it is not set, sends
no message: the error is logged, and the address is fetched again at the next
period. Log in either with `authUsername` and `authPassword`, with a static
token in `authBearerToken`, or with `oauth2ClientId`, `oauth2ClientSecret` and
`oauth2TokenEndpoint`: [...]
required:
- url
type: object
@@ -60,6 +60,40 @@ spec:
type: string
example: "https://api.example.com/v1/orders/status"
pattern: "^(http|https)://.*"
+ method:
+ title: Method
+ description: The HTTP method of the request, such as `POST` for an API
that expects one to return data. When it is not set, it is `GET`. The request
has no body.
+ type: string
+ enum: ["GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "TRACE",
"PATCH"]
+ example: POST
+ followRedirects:
+ title: Follow Redirects
+ description: If true, a redirect, a response with a status code such
as 301, 302 or 307, is followed to the address in its `Location` header, and
the response from there is sent as the message. When it is not set, the
redirect is not followed, so it sends no message unless its status code is in
`okStatusCodeRange`.
+ type: boolean
+ proxyHost:
+ title: Proxy Host
+ description: The host name or IP address of an HTTP proxy to send the
requests through, without the port. Use it with `proxyPort`; the proxy is used
only when both are set.
+ type: string
+ example: proxy.example.com
+ pattern: "^[A-Za-z0-9._-]+$"
+ proxyPort:
+ title: Proxy Port
+ description: The port of the HTTP proxy in `proxyHost`.
+ type: integer
+ example: 3128
+ proxyUser:
+ title: Proxy User
+ description: The user to log in to the HTTP proxy as, when the proxy
asks for a login. Use it with `proxyPassword`.
+ type: string
+ x-descriptors:
+ - urn:camel:group:credentials
+ proxyPassword:
+ title: Proxy Password
+ description: The password of `proxyUser` for the HTTP proxy.
+ type: string
+ format: password
+ x-descriptors:
+ - urn:camel:group:credentials
okStatusCodeRange:
title: OK Status Codes
description: The status codes of a response that is sent as a message,
as ranges such as `200-299` and single codes, separated by commas without
spaces. When it is not set, it is `200-299`. List the 2xx codes too, for
example `200-299,404` to also send the 404 responses.
@@ -154,6 +188,12 @@ spec:
- to:
uri: "{{url}}"
parameters:
+ httpMethod: "{{?method}}"
+ followRedirects: "{{?followRedirects}}"
+ proxyHost: "{{?proxyHost}}"
+ proxyPort: "{{?proxyPort}}"
+ proxyAuthUsername: "{{?proxyUser}}"
+ proxyAuthPassword: "RAW({{?proxyPassword}})"
authMethod: "{{?authMethod}}"
authUsername: "{{?authUsername}}"
authPassword: "{{?authPassword}}"
diff --git a/kamelets/rest-openapi-sink.kamelet.yaml
b/kamelets/rest-openapi-sink.kamelet.yaml
index 41834f0c7..e03b8068d 100644
--- a/kamelets/rest-openapi-sink.kamelet.yaml
+++ b/kamelets/rest-openapi-sink.kamelet.yaml
@@ -35,7 +35,7 @@ spec:
Use it to call an API that publishes an OpenAPI (Swagger) document
without writing its URLs by hand, for example to create a customer or look up
an order in a service of your company. For a call to a fixed URL, use
`http-sink`.
- Input: the body is the request body, such as JSON text, and is sent with
the content type the specification gives for the operation. The path and query
parameters of the operation come from headers of the same name: for
`/pets/\{petId}`, set the `petId` header. The other headers of the message,
except the Camel ones, are sent as HTTP headers.
+ Input: the body is the request body, such as JSON text, and is sent with
the content type the specification gives for the operation, or the one in
`produces`. The path and query parameters of the operation come from headers of
the same name: for `/pets/\{petId}`, set the `petId` header. The other headers
of the message, except the Camel ones, are sent as HTTP headers.
Output: when it is used inside a route, the body afterwards is the
response of the API, as bytes, with the headers of the response and its status
code in `CamelHttpResponseCode`.
@@ -71,6 +71,18 @@ spec:
description: If true, each request is checked against the
specification before it is sent. A request that does not match it, such as one
without a required parameter, fails the message and is not sent.
type: boolean
default: false
+ consumes:
+ title: Accepted Response Types
+ description: The content types of the response to ask the API for,
sent as the `Accept` header, in place of the ones the specification lists for
the responses of the operation. Separate several types with commas, without
spaces, such as `application/json,text/csv`. An `Accept` header on the message
is sent instead.
+ type: string
+ example: "application/json"
+ pattern: "^[A-Za-z0-9*][A-Za-z0-9!$^_.+*/=;,-]*$"
+ produces:
+ title: Request Content Type
+ description: The content type of the request body, sent as the
`Content-Type` header, such as `application/json`, in place of the one the
specification gives for the request body of the operation. A `Content-Type`
header on the message is sent instead.
+ type: string
+ example: "application/merge-patch+json"
+ pattern: "^[A-Za-z0-9*][A-Za-z0-9!$^_.+*/=;,-]*$"
dependencies:
- "camel:rest-openapi"
- "camel:http"
@@ -87,3 +99,5 @@ spec:
basePath: "{{?basePath}}"
requestValidationEnabled: "{{clientRequestValidation}}"
host: "{{?host}}"
+ consumes: "RAW({{?consumes}})"
+ produces: "RAW({{?produces}})"
diff --git
a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
index 951033395..10cfd9b03 100644
--- a/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
+++ b/library/camel-kamelets/src/main/resources/META-INF/kamelets-index.json
@@ -984,8 +984,8 @@
"type" : "sink",
"supportLevel" : "Stable",
"title" : "GraphQL Sink",
- "summary" : "Sends the GraphQL query or mutation in the body of each
message to a GraphQL server, with an HTTP POST, and gives back the answer of
the server.",
- "description" : "Sends the GraphQL query or mutation in the body of each
message to a GraphQL server, with an HTTP POST, and gives back the answer of
the server.\n\nUse it to create or change data through a GraphQL API with a
mutation, for example to add a record for each event, or to fetch data with a
query.\n\nInput: the body is the GraphQL query or mutation itself, as text,
such as `{ books { title } }`. A body that is not text, such as a Map, fails
the message. The other headers [...]
+ "summary" : "Sends a GraphQL query or mutation, from the body of each
message or from a file, to a GraphQL server with an HTTP POST, and gives back
the answer of the server.",
+ "description" : "Sends a GraphQL query or mutation, from the body of each
message or from a file, to a GraphQL server with an HTTP POST, and gives back
the answer of the server.\n\nUse it to create or change data through a GraphQL
API with a mutation, for example to add a record for each event, or to fetch
data with a query. It can also run a stored query from `queryFile` each time a
message arrives.\n\nInput: the body is the GraphQL query or mutation itself, as
text, such as `{ book [...]
"group" : "Graphql",
"namespace" : "Graphql",
"provider" : "Apache Software Foundation"
@@ -1025,7 +1025,7 @@
"supportLevel" : "Stable",
"title" : "HTTP Sink",
"summary" : "Sends each message to a web service or REST API as an HTTP or
HTTPS request, for example a POST of JSON to a webhook.",
- "description" : "Sends each message to a web service or REST API as an
HTTP or HTTPS request, for example a POST of JSON to a webhook.\n\nUse it to
push data to any service that accepts HTTP calls, such as a webhook, a REST API
or a serverless function.\n\nInput: the body is sent as the request body, as
text, bytes or a stream. Turn structured data such as a Map into JSON text
first, for example with `json-serialize-action`. The `Content-Type` header is
sent as the content type of th [...]
+ "description" : "Sends each message to a web service or REST API as an
HTTP or HTTPS request, for example a POST of JSON to a webhook.\n\nUse it to
push data to any service that accepts HTTP calls, such as a webhook, a REST API
or a serverless function.\n\nInput: the body is sent as the request body, as
text, bytes or a stream. Turn structured data such as a Map into JSON text
first, for example with `json-serialize-action`. The `Content-Type` header is
sent as the content type of th [...]
"group" : "HTTP",
"namespace" : "HTTP",
"provider" : "Apache Software Foundation"
@@ -1034,8 +1034,8 @@
"type" : "source",
"supportLevel" : "Stable",
"title" : "HTTP Source",
- "summary" : "Fetches a web address with an HTTP GET request at a regular
interval, and sends each response as a message.",
- "description" : "Fetches a web address with an HTTP GET request at a
regular interval, and sends each response as a message.\n\nUse it to poll a
REST API, a feed or a status page for its current data, for example fetch the
state of the orders every minute. To receive the requests that other systems
send instead, use `webhook-source`.\n\nOutput: the body is the body of the
response, as bytes. The headers of the response, such as `Content-Type`, are
copied to the message, and `CamelHtt [...]
+ "summary" : "Fetches a web address with an HTTP request, a GET unless
`method` says otherwise, at a regular interval, and sends each response as a
message.",
+ "description" : "Fetches a web address with an HTTP request, a GET unless
`method` says otherwise, at a regular interval, and sends each response as a
message.\n\nUse it to poll a REST API, a feed or a status page for its current
data, for example fetch the state of the orders every minute. To receive the
requests that other systems send instead, use `webhook-source`.\n\nOutput: the
body is the body of the response, as bytes. The headers of the response, such
as `Content-Type`, are c [...]
"group" : "HTTP",
"namespace" : "HTTP",
"provider" : "Apache Software Foundation"
@@ -1885,7 +1885,7 @@
"supportLevel" : "Stable",
"title" : "REST OpenAPI Sink",
"summary" : "Calls one operation of a REST API for each message, building
the request (method, path, parameters and content type) from the OpenAPI
specification of the API.",
- "description" : "Calls one operation of a REST API for each message,
building the request (method, path, parameters and content type) from the
OpenAPI specification of the API.\n\nUse it to call an API that publishes an
OpenAPI (Swagger) document without writing its URLs by hand, for example to
create a customer or look up an order in a service of your company. For a call
to a fixed URL, use `http-sink`.\n\nInput: the body is the request body, such
as JSON text, and is sent with the [...]
+ "description" : "Calls one operation of a REST API for each message,
building the request (method, path, parameters and content type) from the
OpenAPI specification of the API.\n\nUse it to call an API that publishes an
OpenAPI (Swagger) document without writing its URLs by hand, for example to
create a customer or look up an order in a service of your company. For a call
to a fixed URL, use `http-sink`.\n\nInput: the body is the request body, such
as JSON text, and is sent with the [...]
"group" : "HTTP",
"namespace" : "HTTP",
"provider" : "Apache Software Foundation"
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/graphql-sink.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/graphql-sink.kamelet.yaml
index d06fea03d..bbdd8eeba 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/graphql-sink.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/graphql-sink.kamelet.yaml
@@ -31,15 +31,15 @@ spec:
definition:
title: "GraphQL Sink"
description: |-
- Sends the GraphQL query or mutation in the body of each message to a
GraphQL server, with an HTTP POST, and gives back the answer of the server.
+ Sends a GraphQL query or mutation, from the body of each message or from
a file, to a GraphQL server with an HTTP POST, and gives back the answer of the
server.
- Use it to create or change data through a GraphQL API with a mutation,
for example to add a record for each event, or to fetch data with a query.
+ Use it to create or change data through a GraphQL API with a mutation,
for example to add a record for each event, or to fetch data with a query. It
can also run a stored query from `queryFile` each time a message arrives.
- Input: the body is the GraphQL query or mutation itself, as text, such
as `{ books { title } }`. A body that is not text, such as a Map, fails the
message. The other headers of the message, except the Camel ones, are sent as
HTTP headers.
+ Input: the body is the GraphQL query or mutation itself, as text, such
as `{ books { title } }`. A body that is not text, such as a Map, fails the
message. With `queryFile`, the query comes from that file instead, and the body
is not sent, except that a Map body is sent as the variables of the query when
`variables` is not set. The other headers of the message, except the Camel
ones, are sent as HTTP headers.
Output: when it is used inside a route, the body afterwards is the
answer of the server, as JSON text with its `data` and `errors`.
- Good to know: GraphQL errors in the answer do not fail the message, but
an HTTP status outside 200 to 299 does. Since the body is run as a query, only
send it messages from a source you trust.
+ Good to know: GraphQL errors in the answer do not fail the message, but
an HTTP status outside 200 to 299 does. Without `queryFile`, the body is run as
a query, so only send it messages from a source you trust. When the query
defines several operations, `operationName` picks the one to run. To go through
an HTTP proxy, set `proxyHost` to its host and port; a proxy that asks for a
login is not supported. Headers on the message cannot change where the request
is sent.
required:
- url
type: object
@@ -57,6 +57,30 @@ spec:
format: password
x-descriptors:
- urn:camel:group:credentials
+ queryFile:
+ title: Query File
+ description: Where to load the GraphQL query or mutation from, in
place of the body. `classpath:` followed by a resource in the application, or
`file:` followed by the path of a file. The variables then come from
`variables`, or from the body when it is a Map.
+ type: string
+ example: "file:/etc/graphql/add-book.graphql"
+ pattern: "^(classpath:|file:)[^?&#]+$"
+ operationName:
+ title: Operation Name
+ description: The name of the operation to run, when the query defines
more than one, such as `AddBook` for `mutation AddBook { ... }`.
+ type: string
+ example: AddBook
+ pattern: "^[_A-Za-z][_0-9A-Za-z]*$"
+ variables:
+ title: Variables
+ description: The values of the variables of the query, as a JSON
object, such as `{"title":"Dune"}` for a query that declares `$title`. When it
is set, the body is not used as the variables.
+ type: string
+ example: '{"title":"Dune","year":1965}'
+ pattern: "^\\s*\\{[\\s\\S]*\\}\\s*$"
+ proxyHost:
+ title: Proxy
+ description: The host name or IP address and the port of an HTTP proxy
to send the requests through, as `host:port`, such as `proxy.example.com:3128`.
A proxy that asks for a login is not supported.
+ type: string
+ example: "proxy.example.com:3128"
+ pattern: "^[A-Za-z0-9._-]+:[0-9]{1,5}$"
dependencies:
- "camel:graphql"
- "camel:kamelet"
@@ -65,4 +89,4 @@ spec:
uri: kamelet:source
steps:
- to:
- uri: "graphql://{{url}}?accessToken=RAW({{?accessToken}})"
+ uri:
"graphql://{{url}}?accessToken=RAW({{?accessToken}})&queryFile={{?queryFile}}&operationName={{?operationName}}&variables=RAW({{?variables}})&proxyHost={{?proxyHost}}"
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/http-sink.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/http-sink.kamelet.yaml
index 99a0abc90..284396787 100644
--- a/library/camel-kamelets/src/main/resources/kamelets/http-sink.kamelet.yaml
+++ b/library/camel-kamelets/src/main/resources/kamelets/http-sink.kamelet.yaml
@@ -39,7 +39,7 @@ spec:
Output: when it is used inside a route, the body afterwards is the
response of the service.
- Good to know: a response with a status code outside `okStatusCodeRange`,
which is `200-299` when it is not set, fails the message. The address and the
method come only from the options; headers on the message cannot change where
it is sent. Log in either with `authUsername` and `authPassword`, with a static
token in `authBearerToken`, or with `oauth2ClientId`, `oauth2ClientSecret` and
`oauth2TokenEndpoint`: the Kamelet then gets a token from that URL and sends it
as a Bearer token. [...]
+ Good to know: a response with a status code outside `okStatusCodeRange`,
which is `200-299` when it is not set, fails the message. The address, the
method and the proxy come only from the options; headers on the message cannot
change where it is sent. Log in either with `authUsername` and `authPassword`,
with a static token in `authBearerToken`, or with `oauth2ClientId`,
`oauth2ClientSecret` and `oauth2TokenEndpoint`: the Kamelet then gets a token
from that URL and sends it as a Be [...]
required:
- url
type: object
@@ -56,6 +56,34 @@ spec:
type: string
default: POST
enum: ["GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "TRACE",
"PATCH"]
+ followRedirects:
+ title: Follow Redirects
+ description: If true, a redirect, a response with a status code such
as 301, 302 or 307, is followed to the address in its `Location` header. A
`POST` answered with 301, 302 or 303 goes on as a `GET` without the body; 307
and 308 keep the method and the body. When it is not set, the redirect is not
followed, and its status code fails the message unless it is in
`okStatusCodeRange`.
+ type: boolean
+ proxyHost:
+ title: Proxy Host
+ description: The host name or IP address of an HTTP proxy to send the
requests through, without the port. Use it with `proxyPort`; the proxy is used
only when both are set.
+ type: string
+ example: proxy.example.com
+ pattern: "^[A-Za-z0-9._-]+$"
+ proxyPort:
+ title: Proxy Port
+ description: The port of the HTTP proxy in `proxyHost`.
+ type: integer
+ example: 3128
+ proxyUser:
+ title: Proxy User
+ description: The user to log in to the HTTP proxy as, when the proxy
asks for a login. Use it with `proxyPassword`.
+ type: string
+ x-descriptors:
+ - urn:camel:group:credentials
+ proxyPassword:
+ title: Proxy Password
+ description: The password of `proxyUser` for the HTTP proxy.
+ type: string
+ format: password
+ x-descriptors:
+ - urn:camel:group:credentials
okStatusCodeRange:
title: OK Status Codes
description: The status codes of a response that do not fail the
message, as ranges such as `200-299` and single codes, separated by commas
without spaces. When it is not set, it is `200-299`. List the 2xx codes too,
for example `200-299,404` to also accept 404.
@@ -147,6 +175,11 @@ spec:
- to:
uri: "{{url}}"
parameters:
+ followRedirects: "{{?followRedirects}}"
+ proxyHost: "{{?proxyHost}}"
+ proxyPort: "{{?proxyPort}}"
+ proxyAuthUsername: "{{?proxyUser}}"
+ proxyAuthPassword: "RAW({{?proxyPassword}})"
authMethod: "{{?authMethod}}"
authUsername: "{{?authUsername}}"
authPassword: "{{?authPassword}}"
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/http-source.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/http-source.kamelet.yaml
index e163af3d1..7b3431a56 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/http-source.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/http-source.kamelet.yaml
@@ -31,13 +31,13 @@ spec:
definition:
title: "HTTP Source"
description: |-
- Fetches a web address with an HTTP GET request at a regular interval,
and sends each response as a message.
+ Fetches a web address with an HTTP request, a GET unless `method` says
otherwise, at a regular interval, and sends each response as a message.
Use it to poll a REST API, a feed or a status page for its current data,
for example fetch the state of the orders every minute. To receive the requests
that other systems send instead, use `webhook-source`.
Output: the body is the body of the response, as bytes. The headers of
the response, such as `Content-Type`, are copied to the message, and
`CamelHttpResponseCode` holds the status code.
- Good to know: it fetches the address every `period` and sends a message
for each response, even when the data has not changed. A response with a status
code outside `okStatusCodeRange`, which is `200-299` when it is not set, sends
no message: the error is logged, and the address is fetched again at the next
period. Log in either with `authUsername` and `authPassword`, with a static
token in `authBearerToken`, or with `oauth2ClientId`, `oauth2ClientSecret` and
`oauth2TokenEndpoint`: [...]
+ Good to know: it fetches the address every `period` and sends a message
for each response, even when the data has not changed. A response with a status
code outside `okStatusCodeRange`, which is `200-299` when it is not set, sends
no message: the error is logged, and the address is fetched again at the next
period. Log in either with `authUsername` and `authPassword`, with a static
token in `authBearerToken`, or with `oauth2ClientId`, `oauth2ClientSecret` and
`oauth2TokenEndpoint`: [...]
required:
- url
type: object
@@ -60,6 +60,40 @@ spec:
type: string
example: "https://api.example.com/v1/orders/status"
pattern: "^(http|https)://.*"
+ method:
+ title: Method
+ description: The HTTP method of the request, such as `POST` for an API
that expects one to return data. When it is not set, it is `GET`. The request
has no body.
+ type: string
+ enum: ["GET", "POST", "PUT", "DELETE", "HEAD", "OPTIONS", "TRACE",
"PATCH"]
+ example: POST
+ followRedirects:
+ title: Follow Redirects
+ description: If true, a redirect, a response with a status code such
as 301, 302 or 307, is followed to the address in its `Location` header, and
the response from there is sent as the message. When it is not set, the
redirect is not followed, so it sends no message unless its status code is in
`okStatusCodeRange`.
+ type: boolean
+ proxyHost:
+ title: Proxy Host
+ description: The host name or IP address of an HTTP proxy to send the
requests through, without the port. Use it with `proxyPort`; the proxy is used
only when both are set.
+ type: string
+ example: proxy.example.com
+ pattern: "^[A-Za-z0-9._-]+$"
+ proxyPort:
+ title: Proxy Port
+ description: The port of the HTTP proxy in `proxyHost`.
+ type: integer
+ example: 3128
+ proxyUser:
+ title: Proxy User
+ description: The user to log in to the HTTP proxy as, when the proxy
asks for a login. Use it with `proxyPassword`.
+ type: string
+ x-descriptors:
+ - urn:camel:group:credentials
+ proxyPassword:
+ title: Proxy Password
+ description: The password of `proxyUser` for the HTTP proxy.
+ type: string
+ format: password
+ x-descriptors:
+ - urn:camel:group:credentials
okStatusCodeRange:
title: OK Status Codes
description: The status codes of a response that is sent as a message,
as ranges such as `200-299` and single codes, separated by commas without
spaces. When it is not set, it is `200-299`. List the 2xx codes too, for
example `200-299,404` to also send the 404 responses.
@@ -154,6 +188,12 @@ spec:
- to:
uri: "{{url}}"
parameters:
+ httpMethod: "{{?method}}"
+ followRedirects: "{{?followRedirects}}"
+ proxyHost: "{{?proxyHost}}"
+ proxyPort: "{{?proxyPort}}"
+ proxyAuthUsername: "{{?proxyUser}}"
+ proxyAuthPassword: "RAW({{?proxyPassword}})"
authMethod: "{{?authMethod}}"
authUsername: "{{?authUsername}}"
authPassword: "{{?authPassword}}"
diff --git
a/library/camel-kamelets/src/main/resources/kamelets/rest-openapi-sink.kamelet.yaml
b/library/camel-kamelets/src/main/resources/kamelets/rest-openapi-sink.kamelet.yaml
index 41834f0c7..e03b8068d 100644
---
a/library/camel-kamelets/src/main/resources/kamelets/rest-openapi-sink.kamelet.yaml
+++
b/library/camel-kamelets/src/main/resources/kamelets/rest-openapi-sink.kamelet.yaml
@@ -35,7 +35,7 @@ spec:
Use it to call an API that publishes an OpenAPI (Swagger) document
without writing its URLs by hand, for example to create a customer or look up
an order in a service of your company. For a call to a fixed URL, use
`http-sink`.
- Input: the body is the request body, such as JSON text, and is sent with
the content type the specification gives for the operation. The path and query
parameters of the operation come from headers of the same name: for
`/pets/\{petId}`, set the `petId` header. The other headers of the message,
except the Camel ones, are sent as HTTP headers.
+ Input: the body is the request body, such as JSON text, and is sent with
the content type the specification gives for the operation, or the one in
`produces`. The path and query parameters of the operation come from headers of
the same name: for `/pets/\{petId}`, set the `petId` header. The other headers
of the message, except the Camel ones, are sent as HTTP headers.
Output: when it is used inside a route, the body afterwards is the
response of the API, as bytes, with the headers of the response and its status
code in `CamelHttpResponseCode`.
@@ -71,6 +71,18 @@ spec:
description: If true, each request is checked against the
specification before it is sent. A request that does not match it, such as one
without a required parameter, fails the message and is not sent.
type: boolean
default: false
+ consumes:
+ title: Accepted Response Types
+ description: The content types of the response to ask the API for,
sent as the `Accept` header, in place of the ones the specification lists for
the responses of the operation. Separate several types with commas, without
spaces, such as `application/json,text/csv`. An `Accept` header on the message
is sent instead.
+ type: string
+ example: "application/json"
+ pattern: "^[A-Za-z0-9*][A-Za-z0-9!$^_.+*/=;,-]*$"
+ produces:
+ title: Request Content Type
+ description: The content type of the request body, sent as the
`Content-Type` header, such as `application/json`, in place of the one the
specification gives for the request body of the operation. A `Content-Type`
header on the message is sent instead.
+ type: string
+ example: "application/merge-patch+json"
+ pattern: "^[A-Za-z0-9*][A-Za-z0-9!$^_.+*/=;,-]*$"
dependencies:
- "camel:rest-openapi"
- "camel:http"
@@ -87,3 +99,5 @@ spec:
basePath: "{{?basePath}}"
requestValidationEnabled: "{{clientRequestValidation}}"
host: "{{?host}}"
+ consumes: "RAW({{?consumes}})"
+ produces: "RAW({{?produces}})"