saravanakumar1987 opened a new pull request, #30260:
URL: https://github.com/apache/camel/pull/30260

   # Description
   
   Fixes [CAMEL-27092](https://issues.apache.org/jira/browse/CAMEL-27092), 
which has the same three points as CAMEL-27036 for camel-alibaba-sms 
(apache/camel#30257).
   
   ## What was wrong
   
   - `FCEndpoint` marked `region` as required, but `FCUtils.createClient` needs 
the region or the endpoint: it throws `Region or endpoint is required` only 
when both are empty. And the client of `com.aliyun:fc_open20210406` 2.1.0 uses 
the endpoint as it is when it is set.
   - So the endpoint validation of the catalog reported a URI with an endpoint 
and without a region as missing the required option `region`.
   - The producer reads the header `CamelAlibabaFcOperation` like the other 
input headers, but `FCHeaders` had no constant for it. Only `FCProperties` 
declared it, and the build reads only the headers class, so the header was 
missing from the header list of the component JSON, the Endpoint DSL and the 
doc page.
   - `FCProperties` had `@Metadata` with texts of its own on its five names. 
The build did not read them, because the `headersClass` of `FCEndpoint` is 
`FCHeaders`.
   
   ## The change
   
   - `region` no longer has `@Metadata(required = true)`. The change marks no 
other option as required (`endpoint` stays optional), and changes no 
description.
   - `FCHeaders` has `OPERATION` as its first constant, defined, like the four 
other constants that `FCProperties` also declares, as `FCProperties.OPERATION`, 
with the label `producer`, the type `String` and the text of 
`AlibabaOtsHeaders.OPERATION`: "The operation that the producer performs. This 
header replaces the operation option. If this header is not set, an exchange 
property of the same name replaces the operation option." The producer resolves 
the operation in this order, with `OpenApiClientSupport.resolveString`: the 
header, then the exchange property, then the option.
   - `FCProperties` keeps its five constants, without the `@Metadata` 
annotations and their import.
   - The component JSON and its catalog copy have `region` as not required, and 
the header `CamelAlibabaFcOperation`. The other headers and options keep their 
texts. In the Endpoint DSL, the Javadoc of `region(String)` no longer says 
"Required: true", and the header name builder has the new method 
`alibabaFcOperation()`.
   - `FCUtils`, the tests of the module and the doc page do not change. The doc 
page lists the headers through the generated include, so it gains 
`CamelAlibabaFcOperation` without a change.
   
   There is no upgrade-guide entry, because no route changes: `FCUtils` and the 
producer do not change. No option, header name or Java API is removed or 
renamed: `FCProperties` keeps its constants, and the Endpoint DSL only gains a 
method. What changes is the metadata that tooling reads: the endpoint 
validation of the catalog now accepts a URI with an endpoint and without a 
region, and the header list of the component has one more header. The catalog 
cannot express that one of the two options is required, so it now also accepts 
a URI with neither. When Camel creates the client from the options, such a URI 
still fails at the first message with `Region or endpoint is required`.
   
   ## Tests
   
   - `CamelCatalogTest#testValidateEndpointAlibabaFc` comes directly after 
`testValidateEndpointTwitterSpecial`, in the style of 
`testValidateEndpointAlibabaSms` of apache/camel#30257. The URI 
`alibaba-fc:invokeFunction?endpoint=12345.cn-hangzhou.fc.aliyuncs.com` 
validates with success, and the header list of the component has 
`CamelAlibabaFcOperation`.
   - There is no new test in the module, because the change is metadata only: 
`FCUtils` and the producer do not change, and the catalog test checks the 
metadata.
   
   ## How it was verified
   
   - With the new test and without the change, `testValidateEndpointAlibabaFc` 
failed at its first assertion: the catalog reported `region` as a missing 
required option.
   - Without the change, a small Java program that called 
`validateEndpointProperties` and `componentModel` on the catalog showed that 
the header list of the component had five headers, without 
`CamelAlibabaFcOperation`.
   - With the change, `mvn install -nsu` in the module ran the 10 tests of the 
module with no failure, error or rerun, and changed only the component JSON 
among the generated files. In that JSON, the five headers that were there 
before kept their texts, so the removed annotations of `FCProperties` had no 
effect on it.
   - With the change, `mvn install -DskipTests -nsu` in `catalog/camel-catalog` 
regenerated the catalog copy of the component JSON, and in 
`dsl/camel-endpointdsl` it regenerated `FCEndpointBuilderFactory`.
   - With the change and the regenerated files, the new test passes.
   
   ## Not changed
   
   - `endpoint` stays without `@Metadata(required = true)`, and the 
descriptions of `region` and `endpoint` do not change.
   - `FCUtils` still reads the header names through the constants of 
`FCProperties`, which have the same values.
   - With `region` and without `endpoint`, the client of 
`com.aliyun:fc_open20210406` 2.1.0 takes its endpoint from its own map of 21 
regions. Each value has the form `account-id.<region>.fc.aliyuncs.com`, with 
the text `account-id` in it. For a region outside the map, 
`com.aliyun:endpoint-util` 0.0.7 gives `fc-open.<region>.aliyuncs.com`. Alibaba 
documents the endpoints of Function Compute in the form 
`<account-ID>.<region-ID>.fc.aliyuncs.com`: 
https://help.aliyun.com/en/functioncompute/fc-endpoints. Both examples of the 
doc page set `region` and no `endpoint`. This change does not touch them.
   
   # Target
   
   - [x] I checked that the commit is targeting the correct branch (Camel 4 
uses the `main` branch)
   
   # Tracking
   
   - [x] If this is a large change, bug fix, or code improvement, I checked 
there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for 
the change (usually before you start working on it).
   
   # Apache Camel coding standards and style
   
   - [x] I checked that each commit in the pull request has a meaningful 
subject line and body.
   - [x] I have run `mvn clean install -Dquickly -DskipTests` from the root 
folder on upstream `main` (8e904a3bb0f7, the parent of this commit), and then, 
with the change, `mvn install -nsu` in 
`components/camel-alibaba/camel-alibaba-fc`, which also runs its code 
generators, the formatter and the import sorter, and `mvn install -DskipTests 
-nsu` in `catalog/camel-catalog` and in `dsl/camel-endpointdsl`. I have 
committed all auto-generated changes: the component JSON, its catalog copy and 
`FCEndpointBuilderFactory`.
   
   The commands that were run:
   
   ```
   # without the change, with the new test, in catalog/camel-catalog
   mvn -o -B test -Dtest=CamelCatalogTest#testValidateEndpointAlibabaFc 
-Dsurefire.failIfNoSpecifiedTests=false -Dsurefire.rerunFailingTestsCount=0
   # with the change, in components/camel-alibaba/camel-alibaba-fc
   mvn install -nsu
   # then in catalog/camel-catalog and in dsl/camel-endpointdsl
   mvn install -DskipTests -nsu
   # then the test command again, in catalog/camel-catalog
   ```
   
   # AI-assisted contributions
   
   - [x] If this PR includes AI-generated code, commits have proper 
co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR 
description identifies the AI tool used.
   
   The change, the test and this text were drafted with Claude Code 
(Anthropic), from the ticket, the code of camel-alibaba-fc, camel-alibaba-ots, 
camel-catalog and the Endpoint DSL, the bytecode of 
`com.aliyun:fc_open20210406` 2.1.0 and `com.aliyun:endpoint-util` 0.0.7, and 
the sources of `com.aliyun:tea-openapi` 0.3.20. The test was run as described 
above. The change and the claims of this text were checked by an independent AI 
review.
   
   _Claude Code on behalf of saravanakumar1987_
   
   🤖 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