saravanakumar1987 opened a new pull request, #30254: URL: https://github.com/apache/camel/pull/30254
# Description Fixes [CAMEL-27046](https://issues.apache.org/jira/browse/CAMEL-27046), the follow-up of the review of apache/camel#30193. ## What was wrong - `AlibabaEventBridgeEndpoint` marked `region` as required, and not `endpoint`. The SDK client needs the endpoint, and sends the region only as a header: in `com.aliyun:eventbridge-client` 1.3.14, the constructor of `EventBridgeClient` throws `'endpoint' can not be unset` when the config has no endpoint, and a request sends the region only in the header `x-eventbridge-regionId`, when it is set. - `AlibabaEventBridgeUtils.createClient` threw `Region or endpoint is required` only when both were empty. So a URI with only a region passed this check, and failed at the first message with `'endpoint' can not be unset`. - So the endpoint validation of the catalog reported a URI with an endpoint and without a region as missing the required option `region`, and accepted a URI with a region and without an endpoint. - The producer reads the header `CamelAlibabaEventBridgeOperation` like the other input headers, but only `AlibabaEventBridgeProperties` declared its constant. The build reads the headers class and its supertypes, not this subclass, so the header was missing from the header list of the component JSON, the Endpoint DSL and the doc page, and the `@Metadata` text of the constant was not used. - Every example of the doc page set a region and no endpoint. ## The change - `endpoint` has `@Metadata(required = true)`, as the endpoint of `AlibabaOtsEndpoint` has, and `region` no longer has it. - `createClient` checks the endpoint alone, and throws an `IllegalArgumentException` with "Endpoint is required" when it is empty. It then always sets the endpoint on the config of the SDK. - `OPERATION` moves from `AlibabaEventBridgeProperties` into `AlibabaEventBridgeHeaders`, with 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. `AlibabaEventBridgeProperties` extends `AlibabaEventBridgeHeaders`, so `AlibabaEventBridgeProperties.OPERATION` still compiles. - The component JSON and its catalog copy have `endpoint` as required, `region` as not required, and the header `CamelAlibabaEventBridgeOperation`. In the Endpoint DSL, the Javadoc of `endpoint(String)` says "Required: true" instead of that of `region(String)`, and the header name builder has the new method `alibabaEventBridgeOperation()`. - In the doc page, each example that creates the client from the options, nine URIs and three YAML routes, also sets `endpoint` to `12345.eventbridge.cn-hangzhou.aliyuncs.com`. This is the documented form `<AccountID>.eventbridge.<region>.aliyuncs.com`, with the made-up account ID 12345 that the page already uses in its event source ARNs. The region stays. No sentence of the page said that the region is required, or that the region determines the endpoint. - In the doc page, the list of the constant classes now says that `AlibabaEventBridgeProperties` inherits all constants of `AlibabaEventBridgeHeaders`, such as `OPERATION`, and the table of the headers that the producer evaluates has a row for `OPERATION`. The sentence below that table now says that these headers override the exchange property or the endpoint option, instead of the query parameter, as the operation is in the path of the URI. The catalog copy of the page is regenerated. There is no upgrade-guide entry, because no route that works changes. A URI without `endpoint` already failed at the first message, unless an `eventBridgeClient` is set or autowired, and with such a client the producer uses neither option. No option, header name or Java API is removed or renamed: `AlibabaEventBridgeProperties.OPERATION` still compiles, and the Endpoint DSL only gains a method. What changes is the metadata that tooling reads. The endpoint validation of the catalog now reports a URI without `endpoint` as missing a required option, also when a client is set or autowired, as it reported a URI without `region` before. A URI with a region and without an endpoint now fails at the first message with "Endpoint is required" instead of `'endpoint' can not be unset`. ## Tests - `CamelCatalogTest#testValidateEndpointAlibabaEventBridge` comes directly after `testValidateEndpointTimerDuration`, in the style of `testValidateEndpointConsumerOnly`. A URI with `endpoint` and without `region` validates with success. A URI with `region` and without `endpoint` reports `endpoint` as a missing required option. The header list of the component has `CamelAlibabaEventBridgeOperation`. - The new `CreateClientTest` of the module: for an `AlibabaEventBridgeEndpoint` with a region and access keys, but without the endpoint option, `createClient` throws an `IllegalArgumentException` with "Endpoint is required". ## How it was verified - With the new tests and without the change, `testValidateEndpointAlibabaEventBridge` failed at its first assertion: the catalog reported `region` as a missing required option. - With the new tests and without the change, `CreateClientTest` failed: `createClient` threw `TeaException: 'endpoint' can not be unset` from the SDK. - Without the change, a small Java program that called `validateEndpointProperties` and `componentModel` on the catalog showed that the catalog accepted the URI with a region and without an endpoint, and that the header list of the component had ten headers, without `CamelAlibabaEventBridgeOperation`. - With the change, `mvn install -nsu` in the module ran 37 tests with no failure, error or rerun, and changed only the component JSON among the generated files. - With the change, `mvn install -DskipTests -nsu` in `catalog/camel-catalog` regenerated the catalog copies of the component JSON and of the doc page, and in `dsl/camel-endpointdsl` it regenerated `AlibabaEventBridgeEndpointBuilderFactory`. - With the change and the regenerated files, both new tests pass. ## Not changed - This change does not touch `AlibabaEventBridgeUtils.toCloudEvent`, `MapCloudEventValidator` or the doc page below the table of the Map keys, which apache/camel#30205 changed. That pull request was merged after the base of this branch, and this branch merges with `main` without conflicts. - `region` keeps its description: it already says that the producer sends it in the header `x-eventbridge-regionId`. The description of `endpoint` already said that the region does not determine the endpoint, so that this option is required. # 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` (3568946284f4, the parent of this commit), and then, with the change, `mvn install -nsu` in `components/camel-alibaba/camel-alibaba-eventbridge`, 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, the catalog copy of the doc page and `AlibabaEventBridgeEndpointBuilderFactory`. The commands that were run: ``` # without the change, with the new tests, in catalog/camel-catalog mvn -o -B test -Dtest=CamelCatalogTest#testValidateEndpointAlibabaEventBridge -Dsurefire.failIfNoSpecifiedTests=false -Dsurefire.rerunFailingTestsCount=0 # and in components/camel-alibaba/camel-alibaba-eventbridge mvn -o -B test -Dtest=CreateClientTest -Dsurefire.failIfNoSpecifiedTests=false -Dsurefire.rerunFailingTestsCount=0 # with the change, in components/camel-alibaba/camel-alibaba-eventbridge mvn install -nsu # then in catalog/camel-catalog and in dsl/camel-endpointdsl mvn install -DskipTests -nsu # then the two test commands again, each in its folder ``` # 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 tests and this text were drafted with Claude Code (Anthropic), from the ticket, the code of camel-alibaba-eventbridge, camel-alibaba-ots, camel-catalog and the Endpoint DSL, and the sources of `com.aliyun:eventbridge-client` 1.3.14. The tests were 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]
