davsclaus opened a new pull request, #3212:
URL: https://github.com/apache/camel-kamelets/pull/3212

   Part of #3170: `http-source` and `http-sink` can go through an HTTP proxy 
and follow redirects, and `http-source` can use another method than GET. 
`rest-openapi-sink` can set the `Accept` and `Content-Type` of the request. 
`graphql-sink` can take its query from a file, with an operation name and 
variables, and go through a proxy.
   
   ### The options
   
   All the options are optional and use optional placeholders without a 
`default`. When they are not set, the endpoint URIs are exactly the ones of 
`main` (see the last rows of the table).
   
   **`http-source` and `http-sink`**
   
   | Option | Template mapping | What it does |
   |---|---|---|
   | `method` (`http-source` only) | `httpMethod: "{{?method}}"` | The HTTP 
method of the request; `GET` when it is not set. The sink already had `method`. 
|
   | `followRedirects` | `followRedirects: "{{?followRedirects}}"` | Follow a 
3xx to its `Location`. |
   | `proxyHost` | `proxyHost: "{{?proxyHost}}"` | Host of an HTTP proxy. 
`pattern: ^[A-Za-z0-9._-]+$`. |
   | `proxyPort` | `proxyPort: "{{?proxyPort}}"` | Its port. The proxy is used 
only when both are set. |
   | `proxyUser` | `proxyAuthUsername: "{{?proxyUser}}"` | Proxy login. 
`urn:camel:group:credentials`. |
   | `proxyPassword` | `proxyAuthPassword: "RAW({{?proxyPassword}})"` | Proxy 
password: `format: password`, credentials. |
   
   The names `proxyHost`, `proxyPort`, `proxyUser` and `proxyPassword` are the 
ones `fhir-sink` and `slack-source` already use.
   
   **`rest-openapi-sink`**
   
   | Option | Template mapping | What it does |
   |---|---|---|
   | `consumes` | `consumes: "RAW({{?consumes}})"` | The `Accept` header, in 
place of the types of the responses in the specification. |
   | `produces` | `produces: "RAW({{?produces}})"` | The `Content-Type` header, 
in place of the type of the request body in the specification. |
   
   `consumes` and `produces` are `RAW()` because a media type such as 
`application/vnd.api+json` has a `+`, which a URI turns into a space. Their 
`pattern` allows no spaces. With spaces, as in `application/json, text/csv`, 
the `Accept` header reached the server as `application/json,+text/csv`. The 
descriptions say to separate the types with commas and no spaces.
   
   **`graphql-sink`**
   
   | Option | Template mapping | What it does |
   |---|---|---|
   | `queryFile` | `&queryFile={{?queryFile}}` | Load the query from `file:` or 
`classpath:`. The body is then not the query. `pattern: 
^(classpath:\|file:)[^?&#]+$`. |
   | `operationName` | `&operationName={{?operationName}}` | The operation to 
run. `pattern` is the GraphQL name syntax. |
   | `variables` | `&variables=RAW({{?variables}})` | The variables, as a JSON 
object. `RAW()` keeps `&`, `+` and parentheses. |
   | `proxyHost` | `&proxyHost={{?proxyHost}}` | An HTTP proxy, as `host:port`. 
`pattern: ^[A-Za-z0-9._-]+:[0-9]{1,5}$`. |
   
   The graphql component takes the proxy as one `host:port` value, and has no 
proxy login. Two Kamelet options `proxyHost` and `proxyPort` cannot be joined 
into one URI value that disappears when both are unset, so the Kamelet option 
keeps the component's name and format. Its description and its pattern say that 
the port is included. A proxy that asks for a login answers 407, and the 
description says that it is not supported.
   
   With `queryFile` and without `variables`, a Map body is sent as the 
variables, as the component does. The Input paragraph says so.
   
   ### Not added
   
   - **NTLM (`authDomain`, `authHost`).** At 4.24 the `http` component marks 
`authDomain`, `authHost`, `proxyAuthDomain` and `proxyAuthNtHost` as 
deprecated, and says that NTLM is deprecated. A new Kamelet option should not 
point to a deprecated one. `authMethod: NTLM` with `authUsername` and 
`authPassword` still works as before.
   - Authentication for rest-openapi-sink is left for a later PR.
   - **Proxy for `rest-openapi-sink`.** It was not in the issue.
   
   ### Verification
   
   Camel JBang 4.24.0-SNAPSHOT with `--local-kamelet-dir`. The services were a 
local Python HTTP server that logged each request (method, path, headers and 
body), and two `ubuntu/squid` containers: one open, one that asks for a Basic 
login. The target `http://host.docker.internal:18590` cannot be resolved on the 
host, only inside Docker, so a call to it can only succeed through the proxy.
   
   | Case | Result |
   |---|---|
   | `http-source`, no new options | `GET`, as on `main` |
   | `http-source`, `method: POST` | `POST /src?case=method`, empty body |
   | `http-source`, `proxyHost`/`proxyPort` of the open squid | 200; squid logs 
`TCP_MISS/200 GET http://host.docker.internal:18590/src`; the server sees `Via: 
1.1 ... (squid/6.13)` |
   | `http-source`, login squid, `proxyUser` and `proxyPassword` `pr0xy+P@ss` | 
squid logs a 407, then `TCP_MISS/200 ... proxyuser`; the password with `+` and 
`@` arrives as it is |
   | `http-source`, login squid, no proxy login | Fails with 407; no message, 
the error is logged |
   | `http-source`, `/redirect` (302), `followRedirects` not set | No message: 
`statusCode: 302, redirectLocation: /target?...` logged |
   | `http-source`, `/redirect`, `followRedirects: true` | Message from 
`/target`, `GET`, 200 |
   | `http-sink`, open squid | 200; squid logs the `POST`; the server sees 
`Via` |
   | `http-sink`, login squid, `method: PUT`, proxy login | 407, then `PUT` 
with `proxyuser`, 200 |
   | `http-sink`, login squid, wrong proxy password | Fails with 407 |
   | `http-sink`, `proxyHost` without `proxyPort` | No proxy: the request goes 
straight to the server |
   | `http-sink`, `https://camel.apache.org/`, `method: HEAD`, open squid | 
200; squid logs `TCP_TUNNEL/200 CONNECT camel.apache.org:443` |
   | `http-sink`, 302, `followRedirects` not set | Fails: `statusCode: 302, 
redirectLocation: /target?...` |
   | `http-sink`, `followRedirects: true`, `POST` answered 301, 302, 303 | 
Followed as `GET` without the body |
   | `http-sink`, `followRedirects: true`, `POST` answered 307, 308 | Followed 
as `POST` with the body |
   | `http-sink`, `followRedirects: true`, `PUT` answered 302 | Followed as 
`PUT` with the body |
   | `http-sink`, message headers `CamelHttpMethod: DELETE`, `CamelHttpUri`, 
`CamelHttpPath`, `CamelHttpQuery`, `CamelHttpRawQuery`, `CamelRestHttpUri`, 
`CamelRestHttpQuery`, `proxyHost`/`proxyPort`, `Host` | `POST 
/sink?case=headers` to the configured URL, no proxy, `Host: 127.0.0.1:18590` |
   | `rest-openapi-sink`, `consumes: 
application/vnd.api+json,application/json;q=0.5`, `produces: 
application/merge-patch+json` | `Accept` and `Content-Type` arrive exactly so; 
the `+` is kept |
   | `rest-openapi-sink`, `consumes` with a space after the comma | `Accept: 
application/vnd.api+json,application/json;+q=0.5`: hence the pattern without 
spaces |
   | `rest-openapi-sink`, `Content-Type: text/plain` and `Accept: text/csv` 
headers on the message, with both options | The headers of the message are sent 
|
   | `graphql-sink`, `queryFile: file:...`, `operationName: AddBook`, 
`variables: {"title":"Dune (1965) & more","year":1965,"meta":{"tags":{"a":1}}}` 
| Request body has the query of the file, `"operationName":"AddBook"` and the 
variables exactly; the text body is not sent |
   | `graphql-sink`, `queryFile`, no `variables`, Map body 
`{"title":"Emma","year":1815}` | Sent as 
`"variables":{"title":"Emma","year":1815}` |
   | `graphql-sink`, `queryFile: classpath:add-book.graphql`, `operationName: 
ListBooks` | Query of the resource, `"operationName":"ListBooks"` |
   | `graphql-sink`, `queryFile` of a file that does not exist | Fails the 
message: `Failed to read query file: file:/nonexistent/x.graphql` |
   | `graphql-sink`, body `query A { a } query B { b }`, `operationName: B` | 
`"operationName":"B"` in the body |
   | `graphql-sink`, `proxyHost: 127.0.0.1:13128` | 200; squid logs `POST 
http://host.docker.internal:18590/graphql`; the server sees `Via` |
   | `graphql-sink`, the login squid | Fails with 407 |
   | `graphql-sink`, message headers `CamelHttpMethod`, `CamelHttpUri`, 
`CamelHttpPath`, `CamelHttpQuery`, `CamelRestHttpUri`, `CamelRestHttpQuery` | 
`POST /graphql?case=headers` to the configured URL |
   | Options unset: `camel get endpoint --json` for `http-source` (with and 
without login), `http-sink`, `rest-openapi-sink`, `graphql-sink` (with and 
without `accessToken`), Kamelets from `main` and from this PR | The 31 endpoint 
URIs are identical |
   
   The examples on the pages are the cases above with the addresses of the docs.
   
   `./mvnw clean verify -DskipTests` and then `./mvnw clean verify` passed. 
Neither ran `install`. The copies of the Kamelets in `library/camel-kamelets` 
were refreshed with `./mvnw -pl library/camel-kamelets 
resources:copy-resources@copy-resource-one`, and `kamelets-index.json` was 
regenerated by the build: the summaries of `http-source` (no longer "with an 
HTTP GET request") and `graphql-sink` (the query can come from a file) changed.
   
   _Claude Code on behalf of Claus Ibsen_
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to