davsclaus commented on code in PR #24844:
URL: https://github.com/apache/camel/pull/24844#discussion_r4206867311


##########
components/camel-apicurio-registry/src/generated/java/org/apache/camel/component/apicurioregistry/ApicurioRegistryEndpointUriFactory.java:
##########
@@ -0,0 +1,124 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.component.apicurioregistry;
+
+import javax.annotation.processing.Generated;
+import java.net.URISyntaxException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.camel.spi.EndpointUriFactory;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@Generated("org.apache.camel.maven.packaging.GenerateEndpointUriFactoryMojo")
+public class ApicurioRegistryEndpointUriFactory extends 
org.apache.camel.support.component.EndpointUriFactorySupport implements 
EndpointUriFactory {
+
+    private static final String BASE = ":groupId/artifactId";
+
+    private static final Set<String> PROPERTY_NAMES;
+    private static final Set<String> SECRET_PROPERTY_NAMES;
+    private static final Set<String> ENDPOINT_IDENTITY_PROPERTY_NAMES;
+    private static final Map<String, String> MULTI_VALUE_PREFIXES;
+    static {
+        Set<String> props = new HashSet<>(41);
+        props.add("artifactId");
+        props.add("artifactType");
+        props.add("authType");
+        props.add("backoffErrorThreshold");
+        props.add("backoffIdleThreshold");
+        props.add("backoffMultiplier");
+        props.add("bridgeErrorHandler");
+        props.add("clientId");
+        props.add("clientSecret");
+        props.add("delay");
+        props.add("exceptionHandler");
+        props.add("exchangePattern");
+        props.add("failOnValidation");
+        props.add("fetchContent");
+        props.add("greedy");
+        props.add("groupId");
+        props.add("ifExists");
+        props.add("initialDelay");
+        props.add("lazyStartProducer");
+        props.add("operation");
+        props.add("password");
+        props.add("pollStrategy");
+        props.add("proxyHost");
+        props.add("proxyPassword");
+        props.add("proxyPort");
+        props.add("proxyUsername");
+        props.add("registryClient");
+        props.add("registryUrl");
+        props.add("repeatCount");
+        props.add("runLoggingLevel");
+        props.add("scheduledExecutorService");
+        props.add("scheduler");
+        props.add("schedulerProperties");
+        props.add("scope");
+        props.add("sendEmptyMessageWhenIdle");
+        props.add("sslContextParameters");
+        props.add("startScheduler");
+        props.add("timeUnit");
+        props.add("tokenEndpoint");
+        props.add("useFixedDelay");
+        props.add("username");
+        PROPERTY_NAMES = Collections.unmodifiableSet(props);
+        Set<String> secretProps = new HashSet<>(3);
+        secretProps.add("clientSecret");
+        secretProps.add("password");
+        secretProps.add("proxyPassword");
+        SECRET_PROPERTY_NAMES = Collections.unmodifiableSet(secretProps);
+        ENDPOINT_IDENTITY_PROPERTY_NAMES = Collections.emptySet();
+        Map<String, String> prefixes = new HashMap<>(1);
+        prefixes.put("schedulerProperties", "scheduler.");
+        MULTI_VALUE_PREFIXES = Collections.unmodifiableMap(prefixes);
+    }
+
+    @Override
+    public boolean isEnabled(String scheme) {
+        return "apicurio-registry".equals(scheme);
+    }
+
+    @Override
+    public String buildUri(String scheme, Map<String, Object> properties, 
boolean encode) throws URISyntaxException {
+        String syntax = scheme + BASE;
+        String uri = syntax;
+
+        Map<String, Object> copy = new HashMap<>(properties);

Review Comment:
   This file is stale against current main. CAMEL-25407 (#27474) changed the 
generator, so building the module on main regenerates this line as `Map<String, 
Object> copy = copyParameters(properties);`. Please rebase and commit the 
regenerated file, otherwise CI on main will flag it as an uncommitted change.



##########
components/camel-apicurio-registry/src/main/java/org/apache/camel/component/apicurioregistry/ApicurioRegistryEndpoint.java:
##########
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.apicurioregistry;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import io.apicurio.registry.client.RegistryClientFactory;
+import io.apicurio.registry.client.common.RegistryClientOptions;
+import io.apicurio.registry.rest.client.RegistryClient;
+import io.vertx.core.Vertx;
+import io.vertx.core.net.ProxyOptions;
+import io.vertx.ext.auth.oauth2.OAuth2Auth;
+import io.vertx.ext.auth.oauth2.OAuth2FlowType;
+import io.vertx.ext.auth.oauth2.OAuth2Options;
+import io.vertx.ext.auth.oauth2.Oauth2Credentials;
+import io.vertx.ext.web.client.OAuth2WebClient;
+import io.vertx.ext.web.client.WebClient;
+import io.vertx.ext.web.client.WebClientOptions;
+import io.vertx.ext.web.client.WebClientSession;
+import org.apache.camel.Category;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.vertx.common.VertxHelper;
+import org.apache.camel.spi.EndpointServiceLocation;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.ScheduledPollEndpoint;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * Manage artifacts, versions, and groups in Apicurio Registry v3.
+ */
+@UriEndpoint(firstVersion = "4.23.0", scheme = "apicurio-registry", title = 
"Apicurio Registry",
+             syntax = "apicurio-registry:groupId/artifactId",
+             category = { Category.CLOUD, Category.API }, headersClass = 
ApicurioRegistryConstants.class)
+public class ApicurioRegistryEndpoint extends ScheduledPollEndpoint implements 
EndpointServiceLocation {
+
+    @UriPath(description = "The artifact group ID")
+    private String groupId;
+
+    @UriPath(description = "The artifact ID")
+    private String artifactId;
+
+    @UriParam
+    private ApicurioRegistryConfiguration configuration;
+
+    @UriParam(label = "advanced", description = "To use a pre-configured 
RegistryClient instance")
+    private RegistryClient registryClient;
+
+    private WebClient ownedWebClient;
+    private OAuth2Auth oauth2;
+
+    ApicurioRegistryEndpoint(String uri, ApicurioRegistryComponent component,
+                             ApicurioRegistryConfiguration configuration,
+                             String groupId, String artifactId) {
+        super(uri, component);
+        this.configuration = configuration;
+        this.groupId = groupId;
+        this.artifactId = artifactId;
+    }
+
+    @Override
+    public Producer createProducer() throws Exception {
+        return new ApicurioRegistryProducer(this, configuration);
+    }
+
+    @Override
+    public Consumer createConsumer(Processor processor) throws Exception {
+        if (ObjectHelper.isEmpty(groupId) || ObjectHelper.isEmpty(artifactId)) 
{
+            throw new IllegalArgumentException(
+                    "Both groupId and artifactId are required for the 
consumer, for example apicurio-registry:myGroup/myArtifact");
+        }
+        ApicurioRegistryConsumer consumer = new ApicurioRegistryConsumer(this, 
processor, configuration);
+        configureConsumer(consumer);
+        return consumer;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        if (registryClient == null) {
+            Vertx vertx = ((ApicurioRegistryComponent) 
getComponent()).getOrCreateVertx();
+            try {
+                ownedWebClient = createWebClient(vertx);
+                registryClient = RegistryClientFactory.create(
+                        
RegistryClientOptions.create(configuration.getRegistryUrl(), 
vertx).customWebClient(ownedWebClient));
+            } catch (Exception e) {
+                closeOwnedResources();
+                throw e;
+            }
+        }
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+        if (ownedWebClient != null) {
+            registryClient = null;
+            closeOwnedResources();
+        }
+    }
+
+    private void closeOwnedResources() {
+        // the SDK client has no close method, so the HTTP connection pool 
lives in the WebClient we created
+        if (ownedWebClient != null) {
+            ownedWebClient.close();
+            ownedWebClient = null;
+        }
+        if (oauth2 != null) {
+            oauth2.close();
+            oauth2 = null;
+        }
+    }
+
+    WebClientOptions createWebClientOptions() throws Exception {
+        WebClientOptions options = new WebClientOptions();
+        if (configuration.getSslContextParameters() != null) {
+            VertxHelper.setupSSLOptions(getCamelContext(), 
configuration.getSslContextParameters(), options);
+        }
+        if (ObjectHelper.isNotEmpty(configuration.getProxyHost())) {
+            ProxyOptions proxy = new 
ProxyOptions().setHost(configuration.getProxyHost());
+            if (configuration.getProxyPort() != null) {
+                proxy.setPort(configuration.getProxyPort());
+            }
+            if (ObjectHelper.isNotEmpty(configuration.getProxyUsername())) {
+                proxy.setUsername(configuration.getProxyUsername());
+                proxy.setPassword(configuration.getProxyPassword());
+            }
+            options.setProxyOptions(proxy);
+        }
+        return options;
+    }
+
+    private WebClient createWebClient(Vertx vertx) throws Exception {
+        WebClientOptions options = createWebClientOptions();
+        WebClient webClient = WebClient.create(vertx, options);
+        String authType = configuration.getAuthType();
+        if ("basic".equalsIgnoreCase(authType)) {
+            String credentials = configuration.getUsername() + ":" + 
configuration.getPassword();
+            return 
WebClientSession.create(webClient).addHeader("Authorization",
+                    "Basic " + 
Base64.getEncoder().encodeToString(credentials.getBytes(StandardCharsets.UTF_8)));
+        } else if ("oidc".equalsIgnoreCase(authType)) {
+            oauth2 = OAuth2Auth.create(vertx, new OAuth2Options()
+                    .setFlow(OAuth2FlowType.CLIENT)
+                    .setHttpClientOptions(options)
+                    .setClientId(configuration.getClientId())
+                    .setClientSecret(configuration.getClientSecret())
+                    .setTokenPath(configuration.getTokenEndpoint()));
+            Oauth2Credentials credentials = new Oauth2Credentials();
+            if (configuration.getScope() != null) {
+                credentials.addScope(configuration.getScope());
+            }
+            return OAuth2WebClient.create(webClient, 
oauth2).withCredentials(credentials);
+        }

Review Comment:
   Related to oscerd's fail-fast comment above: an `authType` value other than 
`none`/`basic`/`oidc` (e.g. a typo like `oauth`) falls through here and 
silently creates an unauthenticated client. Could the same validation reject 
unknown values with an `IllegalArgumentException` when the endpoint starts?



##########
components/camel-apicurio-registry/src/main/java/org/apache/camel/component/apicurioregistry/ApicurioRegistryEndpoint.java:
##########
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.apicurioregistry;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import io.apicurio.registry.client.RegistryClientFactory;
+import io.apicurio.registry.client.common.RegistryClientOptions;
+import io.apicurio.registry.rest.client.RegistryClient;
+import io.vertx.core.Vertx;
+import io.vertx.core.net.ProxyOptions;
+import io.vertx.ext.auth.oauth2.OAuth2Auth;
+import io.vertx.ext.auth.oauth2.OAuth2FlowType;
+import io.vertx.ext.auth.oauth2.OAuth2Options;
+import io.vertx.ext.auth.oauth2.Oauth2Credentials;
+import io.vertx.ext.web.client.OAuth2WebClient;
+import io.vertx.ext.web.client.WebClient;
+import io.vertx.ext.web.client.WebClientOptions;
+import io.vertx.ext.web.client.WebClientSession;
+import org.apache.camel.Category;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.vertx.common.VertxHelper;
+import org.apache.camel.spi.EndpointServiceLocation;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.ScheduledPollEndpoint;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * Manage artifacts, versions, and groups in Apicurio Registry v3.
+ */
+@UriEndpoint(firstVersion = "4.23.0", scheme = "apicurio-registry", title = 
"Apicurio Registry",
+             syntax = "apicurio-registry:groupId/artifactId",
+             category = { Category.CLOUD, Category.API }, headersClass = 
ApicurioRegistryConstants.class)
+public class ApicurioRegistryEndpoint extends ScheduledPollEndpoint implements 
EndpointServiceLocation {
+
+    @UriPath(description = "The artifact group ID")
+    private String groupId;
+
+    @UriPath(description = "The artifact ID")
+    private String artifactId;
+
+    @UriParam
+    private ApicurioRegistryConfiguration configuration;
+
+    @UriParam(label = "advanced", description = "To use a pre-configured 
RegistryClient instance")
+    private RegistryClient registryClient;
+
+    private WebClient ownedWebClient;
+    private OAuth2Auth oauth2;
+
+    ApicurioRegistryEndpoint(String uri, ApicurioRegistryComponent component,
+                             ApicurioRegistryConfiguration configuration,
+                             String groupId, String artifactId) {
+        super(uri, component);
+        this.configuration = configuration;
+        this.groupId = groupId;
+        this.artifactId = artifactId;
+    }
+
+    @Override
+    public Producer createProducer() throws Exception {
+        return new ApicurioRegistryProducer(this, configuration);
+    }
+
+    @Override
+    public Consumer createConsumer(Processor processor) throws Exception {
+        if (ObjectHelper.isEmpty(groupId) || ObjectHelper.isEmpty(artifactId)) 
{
+            throw new IllegalArgumentException(
+                    "Both groupId and artifactId are required for the 
consumer, for example apicurio-registry:myGroup/myArtifact");
+        }
+        ApicurioRegistryConsumer consumer = new ApicurioRegistryConsumer(this, 
processor, configuration);
+        configureConsumer(consumer);
+        return consumer;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        if (registryClient == null) {
+            Vertx vertx = ((ApicurioRegistryComponent) 
getComponent()).getOrCreateVertx();
+            try {
+                ownedWebClient = createWebClient(vertx);
+                registryClient = RegistryClientFactory.create(
+                        
RegistryClientOptions.create(configuration.getRegistryUrl(), 
vertx).customWebClient(ownedWebClient));
+            } catch (Exception e) {
+                closeOwnedResources();
+                throw e;
+            }
+        }
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+        if (ownedWebClient != null) {
+            registryClient = null;
+            closeOwnedResources();
+        }
+    }
+
+    private void closeOwnedResources() {
+        // the SDK client has no close method, so the HTTP connection pool 
lives in the WebClient we created
+        if (ownedWebClient != null) {
+            ownedWebClient.close();
+            ownedWebClient = null;
+        }
+        if (oauth2 != null) {
+            oauth2.close();
+            oauth2 = null;
+        }
+    }
+
+    WebClientOptions createWebClientOptions() throws Exception {
+        WebClientOptions options = new WebClientOptions();
+        if (configuration.getSslContextParameters() != null) {
+            VertxHelper.setupSSLOptions(getCamelContext(), 
configuration.getSslContextParameters(), options);
+        }
+        if (ObjectHelper.isNotEmpty(configuration.getProxyHost())) {
+            ProxyOptions proxy = new 
ProxyOptions().setHost(configuration.getProxyHost());
+            if (configuration.getProxyPort() != null) {
+                proxy.setPort(configuration.getProxyPort());
+            }
+            if (ObjectHelper.isNotEmpty(configuration.getProxyUsername())) {
+                proxy.setUsername(configuration.getProxyUsername());
+                proxy.setPassword(configuration.getProxyPassword());
+            }
+            options.setProxyOptions(proxy);
+        }
+        return options;
+    }
+
+    private WebClient createWebClient(Vertx vertx) throws Exception {
+        WebClientOptions options = createWebClientOptions();
+        WebClient webClient = WebClient.create(vertx, options);
+        String authType = configuration.getAuthType();
+        if ("basic".equalsIgnoreCase(authType)) {
+            String credentials = configuration.getUsername() + ":" + 
configuration.getPassword();
+            return 
WebClientSession.create(webClient).addHeader("Authorization",

Review Comment:
   Question: `WebClientSession` also stores cookies from responses (e.g. 
load-balancer cookies) and sends them on every later request, shared across all 
producer threads of this endpoint. Is that intended, or is the session only 
used to add the static `Authorization` header? If it's only for the header, it 
may be worth a short comment here (or a plain `WebClient` with the header added 
per request, if the Vert.x adapter allows it).



##########
components/camel-apicurio-registry/src/main/java/org/apache/camel/component/apicurioregistry/ApicurioRegistryProducer.java:
##########
@@ -0,0 +1,333 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.apicurioregistry;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import io.apicurio.registry.rest.client.RegistryClient;
+import io.apicurio.registry.rest.client.models.ArtifactMetaData;
+import io.apicurio.registry.rest.client.models.ArtifactSearchResults;
+import io.apicurio.registry.rest.client.models.ArtifactSortBy;
+import io.apicurio.registry.rest.client.models.CreateArtifact;
+import io.apicurio.registry.rest.client.models.CreateArtifactResponse;
+import io.apicurio.registry.rest.client.models.CreateGroup;
+import io.apicurio.registry.rest.client.models.CreateVersion;
+import io.apicurio.registry.rest.client.models.GroupMetaData;
+import io.apicurio.registry.rest.client.models.IfArtifactExists;
+import io.apicurio.registry.rest.client.models.RuleViolationProblemDetails;
+import io.apicurio.registry.rest.client.models.SearchedVersion;
+import io.apicurio.registry.rest.client.models.SortOrder;
+import io.apicurio.registry.rest.client.models.VersionContent;
+import io.apicurio.registry.rest.client.models.VersionMetaData;
+import io.apicurio.registry.rest.client.models.VersionSearchResults;
+import io.apicurio.registry.rest.client.models.VersionSortBy;
+import org.apache.camel.Message;
+import org.apache.camel.spi.InvokeOnHeader;
+import org.apache.camel.support.HeaderSelectorProducer;
+import org.apache.camel.util.ObjectHelper;
+
+public class ApicurioRegistryProducer extends HeaderSelectorProducer {
+
+    private static final int PAGE_SIZE = 100;
+
+    private final ApicurioRegistryEndpoint endpoint;
+    private final ApicurioRegistryConfiguration configuration;
+
+    public ApicurioRegistryProducer(ApicurioRegistryEndpoint endpoint,
+                                    ApicurioRegistryConfiguration 
configuration) {
+        super(endpoint, ApicurioRegistryConstants.HEADER_OPERATION, 
configuration::getOperation);
+        this.endpoint = endpoint;
+        this.configuration = configuration;
+    }
+
+    private RegistryClient getClient() {
+        return endpoint.getRegistryClient();
+    }
+
+    private String resolveGroupId(Message message) {
+        String gid = 
message.getHeader(ApicurioRegistryConstants.HEADER_GROUP_ID, String.class);
+        return gid != null ? gid : endpoint.getGroupId();
+    }
+
+    private String resolveArtifactId(Message message) {
+        String aid = 
message.getHeader(ApicurioRegistryConstants.HEADER_ARTIFACT_ID, String.class);
+        return aid != null ? aid : endpoint.getArtifactId();
+    }
+
+    private String requireGroupId(Message message, String operation) {
+        return require(resolveGroupId(message), "groupId", 
ApicurioRegistryConstants.HEADER_GROUP_ID, operation);
+    }
+
+    private String requireArtifactId(Message message, String operation) {
+        return require(resolveArtifactId(message), "artifactId", 
ApicurioRegistryConstants.HEADER_ARTIFACT_ID, operation);
+    }
+
+    private static String require(String value, String name, String header, 
String operation) {
+        if (ObjectHelper.isEmpty(value)) {
+            throw new IllegalArgumentException(
+                    "The " + operation + " operation requires the " + name + 
": set it in the endpoint path or the "
+                                               + header + " header");
+        }
+        return value;
+    }
+
+    @InvokeOnHeader(ApicurioRegistryConstants.OPERATION_CREATE_ARTIFACT)
+    public void createArtifact(Message message) {
+        String groupId = requireGroupId(message, "createArtifact");
+        String artifactId = resolveArtifactId(message);
+        String artifactType = message.getHeader(
+                ApicurioRegistryConstants.HEADER_ARTIFACT_TYPE, 
configuration.getArtifactType(), String.class);
+        String name = 
message.getHeader(ApicurioRegistryConstants.HEADER_ARTIFACT_NAME, String.class);
+        String description = 
message.getHeader(ApicurioRegistryConstants.HEADER_ARTIFACT_DESCRIPTION, 
String.class);
+        String content = message.getBody(String.class);
+        String contentType = message.getHeader(
+                ApicurioRegistryConstants.HEADER_CONTENT_TYPE, 
"application/json", String.class);
+        String ifExistsVal = message.getHeader(
+                ApicurioRegistryConstants.HEADER_IF_EXISTS, 
configuration.getIfExists(), String.class);
+
+        CreateArtifact createArtifact = new CreateArtifact();
+        createArtifact.setArtifactId(artifactId);
+        createArtifact.setArtifactType(artifactType);
+        createArtifact.setName(name);
+        createArtifact.setDescription(description);
+
+        if (content != null) {
+            CreateVersion firstVersion = new CreateVersion();
+            VersionContent vc = new VersionContent();
+            vc.setContent(content);
+            vc.setContentType(contentType);
+            firstVersion.setContent(vc);
+            createArtifact.setFirstVersion(firstVersion);
+        }
+
+        CreateArtifactResponse result = 
getClient().groups().byGroupId(groupId).artifacts()
+                .post(createArtifact, config -> {
+                    if (ifExistsVal != null) {
+                        config.queryParameters.ifExists = 
IfArtifactExists.forValue(ifExistsVal);

Review Comment:
   Minor: `IfArtifactExists.forValue(...)` returns null for an unknown value, 
so a typo in `ifExists` (or the header) is dropped silently and the registry 
default (FAIL) is used. Reusing your `parseEnum` helper would give the same 
clear error as the search headers.



##########
components/camel-apicurio-registry/src/main/java/org/apache/camel/component/apicurioregistry/ApicurioRegistryEndpoint.java:
##########
@@ -0,0 +1,208 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.apicurioregistry;
+
+import java.nio.charset.StandardCharsets;
+import java.util.Base64;
+
+import io.apicurio.registry.client.RegistryClientFactory;
+import io.apicurio.registry.client.common.RegistryClientOptions;
+import io.apicurio.registry.rest.client.RegistryClient;
+import io.vertx.core.Vertx;
+import io.vertx.core.net.ProxyOptions;
+import io.vertx.ext.auth.oauth2.OAuth2Auth;
+import io.vertx.ext.auth.oauth2.OAuth2FlowType;
+import io.vertx.ext.auth.oauth2.OAuth2Options;
+import io.vertx.ext.auth.oauth2.Oauth2Credentials;
+import io.vertx.ext.web.client.OAuth2WebClient;
+import io.vertx.ext.web.client.WebClient;
+import io.vertx.ext.web.client.WebClientOptions;
+import io.vertx.ext.web.client.WebClientSession;
+import org.apache.camel.Category;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.vertx.common.VertxHelper;
+import org.apache.camel.spi.EndpointServiceLocation;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.apache.camel.support.ScheduledPollEndpoint;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * Manage artifacts, versions, and groups in Apicurio Registry v3.
+ */
+@UriEndpoint(firstVersion = "4.23.0", scheme = "apicurio-registry", title = 
"Apicurio Registry",
+             syntax = "apicurio-registry:groupId/artifactId",
+             category = { Category.CLOUD, Category.API }, headersClass = 
ApicurioRegistryConstants.class)
+public class ApicurioRegistryEndpoint extends ScheduledPollEndpoint implements 
EndpointServiceLocation {
+
+    @UriPath(description = "The artifact group ID")
+    private String groupId;
+
+    @UriPath(description = "The artifact ID")
+    private String artifactId;
+
+    @UriParam
+    private ApicurioRegistryConfiguration configuration;
+
+    @UriParam(label = "advanced", description = "To use a pre-configured 
RegistryClient instance")
+    private RegistryClient registryClient;
+
+    private WebClient ownedWebClient;
+    private OAuth2Auth oauth2;
+
+    ApicurioRegistryEndpoint(String uri, ApicurioRegistryComponent component,
+                             ApicurioRegistryConfiguration configuration,
+                             String groupId, String artifactId) {
+        super(uri, component);
+        this.configuration = configuration;
+        this.groupId = groupId;
+        this.artifactId = artifactId;
+    }
+
+    @Override
+    public Producer createProducer() throws Exception {
+        return new ApicurioRegistryProducer(this, configuration);
+    }
+
+    @Override
+    public Consumer createConsumer(Processor processor) throws Exception {
+        if (ObjectHelper.isEmpty(groupId) || ObjectHelper.isEmpty(artifactId)) 
{
+            throw new IllegalArgumentException(
+                    "Both groupId and artifactId are required for the 
consumer, for example apicurio-registry:myGroup/myArtifact");
+        }
+        ApicurioRegistryConsumer consumer = new ApicurioRegistryConsumer(this, 
processor, configuration);
+        configureConsumer(consumer);
+        return consumer;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        if (registryClient == null) {
+            Vertx vertx = ((ApicurioRegistryComponent) 
getComponent()).getOrCreateVertx();
+            try {
+                ownedWebClient = createWebClient(vertx);
+                registryClient = RegistryClientFactory.create(
+                        
RegistryClientOptions.create(configuration.getRegistryUrl(), 
vertx).customWebClient(ownedWebClient));
+            } catch (Exception e) {
+                closeOwnedResources();
+                throw e;
+            }
+        }
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+        if (ownedWebClient != null) {
+            registryClient = null;
+            closeOwnedResources();
+        }
+    }
+
+    private void closeOwnedResources() {
+        // the SDK client has no close method, so the HTTP connection pool 
lives in the WebClient we created
+        if (ownedWebClient != null) {
+            ownedWebClient.close();
+            ownedWebClient = null;
+        }
+        if (oauth2 != null) {
+            oauth2.close();
+            oauth2 = null;
+        }
+    }
+
+    WebClientOptions createWebClientOptions() throws Exception {
+        WebClientOptions options = new WebClientOptions();
+        if (configuration.getSslContextParameters() != null) {
+            VertxHelper.setupSSLOptions(getCamelContext(), 
configuration.getSslContextParameters(), options);
+        }
+        if (ObjectHelper.isNotEmpty(configuration.getProxyHost())) {
+            ProxyOptions proxy = new 
ProxyOptions().setHost(configuration.getProxyHost());
+            if (configuration.getProxyPort() != null) {
+                proxy.setPort(configuration.getProxyPort());
+            }
+            if (ObjectHelper.isNotEmpty(configuration.getProxyUsername())) {
+                proxy.setUsername(configuration.getProxyUsername());
+                proxy.setPassword(configuration.getProxyPassword());
+            }
+            options.setProxyOptions(proxy);
+        }
+        return options;
+    }
+
+    private WebClient createWebClient(Vertx vertx) throws Exception {
+        WebClientOptions options = createWebClientOptions();
+        WebClient webClient = WebClient.create(vertx, options);
+        String authType = configuration.getAuthType();
+        if ("basic".equalsIgnoreCase(authType)) {
+            String credentials = configuration.getUsername() + ":" + 
configuration.getPassword();
+            return 
WebClientSession.create(webClient).addHeader("Authorization",
+                    "Basic " + 
Base64.getEncoder().encodeToString(credentials.getBytes(StandardCharsets.UTF_8)));
+        } else if ("oidc".equalsIgnoreCase(authType)) {
+            oauth2 = OAuth2Auth.create(vertx, new OAuth2Options()
+                    .setFlow(OAuth2FlowType.CLIENT)

Review Comment:
   Nit: `OAuth2Options.setFlow(...)` is deprecated in Vert.x 4.5 (it shows up 
as a compiler warning). Setting the flow on the credentials (`new 
Oauth2Credentials().setFlow(OAuth2FlowType.CLIENT)`) avoids the deprecated API.



-- 
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