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.git
The following commit(s) were added to refs/heads/main by this push:
new 251aa272bf1 CAMEL-20846: Add capability to configure
elasticsearch-rest-client with component options (#14446)
251aa272bf1 is described below
commit 251aa272bf1584121fdb0e21b6d67b686a51f1f6
Author: James Netherton <[email protected]>
AuthorDate: Mon Jun 10 16:02:17 2024 +0100
CAMEL-20846: Add capability to configure elasticsearch-rest-client with
component options (#14446)
---
.../components/elasticsearch-rest-client.json | 14 +-
...ElasticsearchRestClientComponentConfigurer.java | 59 +++++++
.../rest/client/elasticsearch-rest-client.json | 14 +-
.../client/ElasticsearchRestClientComponent.java | 146 ++++++++++++++++-
...SearchRestClientComponentConfigurationTest.java | 66 ++++++++
...ticsearchRestClientComponentBuilderFactory.java | 175 +++++++++++++++++++++
6 files changed, 469 insertions(+), 5 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/elasticsearch-rest-client.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/elasticsearch-rest-client.json
index 6edf65e32ae..a36af6dc55d 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/elasticsearch-rest-client.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/elasticsearch-rest-client.json
@@ -23,8 +23,18 @@
"remote": true
},
"componentProperties": {
- "lazyStartProducer": { "index": 0, "kind": "property", "displayName":
"Lazy Start Producer", "group": "producer", "label": "producer", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether the producer should be started lazy (on the first message). By
starting lazy you can use this to allow CamelContext and routes to startup in
situations where a producer may otherwise fail [...]
- "autowiredEnabled": { "index": 1, "kind": "property", "displayName":
"Autowired Enabled", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": true, "description":
"Whether autowiring is enabled. This is used for automatic autowiring options
(the option must be marked as autowired) by looking up in the registry to find
if there is a single instance of matching t [...]
+ "connectionTimeout": { "index": 0, "kind": "property", "displayName":
"Connection Timeout", "group": "producer", "label": "", "required": false,
"type": "integer", "javaType": "int", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": 30000, "description": "Connection timeout" },
+ "hostAddressesList": { "index": 1, "kind": "property", "displayName":
"Host Addresses List", "group": "producer", "label": "", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "List of host Addresses,
multiple hosts can be separated by comma." },
+ "lazyStartProducer": { "index": 2, "kind": "property", "displayName":
"Lazy Start Producer", "group": "producer", "label": "producer", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether the producer should be started lazy (on the first message). By
starting lazy you can use this to allow CamelContext and routes to startup in
situations where a producer may otherwise fail [...]
+ "socketTimeout": { "index": 3, "kind": "property", "displayName": "Socket
Timeout", "group": "producer", "label": "", "required": false, "type":
"integer", "javaType": "int", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": 30000, "description": "Socket timeout" },
+ "autowiredEnabled": { "index": 4, "kind": "property", "displayName":
"Autowired Enabled", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": true, "description":
"Whether autowiring is enabled. This is used for automatic autowiring options
(the option must be marked as autowired) by looking up in the registry to find
if there is a single instance of matching t [...]
+ "enableSniffer": { "index": 5, "kind": "property", "displayName": "Enable
Sniffer", "group": "advanced", "label": "advanced", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "description": "Enabling Sniffer" },
+ "restClient": { "index": 6, "kind": "property", "displayName": "Rest
Client", "group": "advanced", "label": "advanced", "required": false, "type":
"object", "javaType": "org.elasticsearch.client.RestClient", "deprecated":
false, "autowired": true, "secret": false, "description": "Rest Client of type
org.elasticsearch.client.RestClient. This is only for advanced usage" },
+ "sniffAfterFailureDelay": { "index": 7, "kind": "property", "displayName":
"Sniff After Failure Delay", "group": "advanced", "label": "advanced",
"required": false, "type": "integer", "javaType": "int", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": 60000, "description":
"Sniffer after failure delay (in millis)" },
+ "snifferInterval": { "index": 8, "kind": "property", "displayName":
"Sniffer Interval", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 60000, "description": "Sniffer interval
(in millis)" },
+ "certificatePath": { "index": 9, "kind": "property", "displayName":
"Certificate Path", "group": "security", "label": "security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "supportFileReference": true,
"description": "Certificate Path" },
+ "password": { "index": 10, "kind": "property", "displayName": "Password",
"group": "security", "label": "security", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": true, "description": "Password" },
+ "user": { "index": 11, "kind": "property", "displayName": "User", "group":
"security", "label": "security", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": true, "description": "Username" }
},
"properties": {
"clusterName": { "index": 0, "kind": "path", "displayName": "Cluster
Name", "group": "producer", "label": "", "required": true, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "description": "Cluster Name" },
diff --git
a/components/camel-elasticsearch-rest-client/src/generated/java/org/apache/camel/component/elasticsearch/rest/client/ElasticsearchRestClientComponentConfigurer.java
b/components/camel-elasticsearch-rest-client/src/generated/java/org/apache/camel/component/elasticsearch/rest/client/ElasticsearchRestClientComponentConfigurer.java
index 3ccfb2b9013..0db4ab9e77c 100644
---
a/components/camel-elasticsearch-rest-client/src/generated/java/org/apache/camel/component/elasticsearch/rest/client/ElasticsearchRestClientComponentConfigurer.java
+++
b/components/camel-elasticsearch-rest-client/src/generated/java/org/apache/camel/component/elasticsearch/rest/client/ElasticsearchRestClientComponentConfigurer.java
@@ -25,19 +25,60 @@ public class ElasticsearchRestClientComponentConfigurer
extends PropertyConfigur
switch (ignoreCase ? name.toLowerCase() : name) {
case "autowiredenabled":
case "autowiredEnabled":
target.setAutowiredEnabled(property(camelContext, boolean.class, value));
return true;
+ case "certificatepath":
+ case "certificatePath":
target.setCertificatePath(property(camelContext, java.lang.String.class,
value)); return true;
+ case "connectiontimeout":
+ case "connectionTimeout":
target.setConnectionTimeout(property(camelContext, int.class, value)); return
true;
+ case "enablesniffer":
+ case "enableSniffer": target.setEnableSniffer(property(camelContext,
boolean.class, value)); return true;
+ case "hostaddresseslist":
+ case "hostAddressesList":
target.setHostAddressesList(property(camelContext, java.lang.String.class,
value)); return true;
case "lazystartproducer":
case "lazyStartProducer":
target.setLazyStartProducer(property(camelContext, boolean.class, value));
return true;
+ case "password": target.setPassword(property(camelContext,
java.lang.String.class, value)); return true;
+ case "restclient":
+ case "restClient": target.setRestClient(property(camelContext,
org.elasticsearch.client.RestClient.class, value)); return true;
+ case "sniffafterfailuredelay":
+ case "sniffAfterFailureDelay":
target.setSniffAfterFailureDelay(property(camelContext, int.class, value));
return true;
+ case "snifferinterval":
+ case "snifferInterval":
target.setSnifferInterval(property(camelContext, int.class, value)); return
true;
+ case "sockettimeout":
+ case "socketTimeout": target.setSocketTimeout(property(camelContext,
int.class, value)); return true;
+ case "user": target.setUser(property(camelContext,
java.lang.String.class, value)); return true;
default: return false;
}
}
+ @Override
+ public String[] getAutowiredNames() {
+ return new String[]{"restClient"};
+ }
+
@Override
public Class<?> getOptionType(String name, boolean ignoreCase) {
switch (ignoreCase ? name.toLowerCase() : name) {
case "autowiredenabled":
case "autowiredEnabled": return boolean.class;
+ case "certificatepath":
+ case "certificatePath": return java.lang.String.class;
+ case "connectiontimeout":
+ case "connectionTimeout": return int.class;
+ case "enablesniffer":
+ case "enableSniffer": return boolean.class;
+ case "hostaddresseslist":
+ case "hostAddressesList": return java.lang.String.class;
case "lazystartproducer":
case "lazyStartProducer": return boolean.class;
+ case "password": return java.lang.String.class;
+ case "restclient":
+ case "restClient": return org.elasticsearch.client.RestClient.class;
+ case "sniffafterfailuredelay":
+ case "sniffAfterFailureDelay": return int.class;
+ case "snifferinterval":
+ case "snifferInterval": return int.class;
+ case "sockettimeout":
+ case "socketTimeout": return int.class;
+ case "user": return java.lang.String.class;
default: return null;
}
}
@@ -48,8 +89,26 @@ public class ElasticsearchRestClientComponentConfigurer
extends PropertyConfigur
switch (ignoreCase ? name.toLowerCase() : name) {
case "autowiredenabled":
case "autowiredEnabled": return target.isAutowiredEnabled();
+ case "certificatepath":
+ case "certificatePath": return target.getCertificatePath();
+ case "connectiontimeout":
+ case "connectionTimeout": return target.getConnectionTimeout();
+ case "enablesniffer":
+ case "enableSniffer": return target.isEnableSniffer();
+ case "hostaddresseslist":
+ case "hostAddressesList": return target.getHostAddressesList();
case "lazystartproducer":
case "lazyStartProducer": return target.isLazyStartProducer();
+ case "password": return target.getPassword();
+ case "restclient":
+ case "restClient": return target.getRestClient();
+ case "sniffafterfailuredelay":
+ case "sniffAfterFailureDelay": return
target.getSniffAfterFailureDelay();
+ case "snifferinterval":
+ case "snifferInterval": return target.getSnifferInterval();
+ case "sockettimeout":
+ case "socketTimeout": return target.getSocketTimeout();
+ case "user": return target.getUser();
default: return null;
}
}
diff --git
a/components/camel-elasticsearch-rest-client/src/generated/resources/META-INF/org/apache/camel/component/elasticsearch/rest/client/elasticsearch-rest-client.json
b/components/camel-elasticsearch-rest-client/src/generated/resources/META-INF/org/apache/camel/component/elasticsearch/rest/client/elasticsearch-rest-client.json
index 6edf65e32ae..a36af6dc55d 100644
---
a/components/camel-elasticsearch-rest-client/src/generated/resources/META-INF/org/apache/camel/component/elasticsearch/rest/client/elasticsearch-rest-client.json
+++
b/components/camel-elasticsearch-rest-client/src/generated/resources/META-INF/org/apache/camel/component/elasticsearch/rest/client/elasticsearch-rest-client.json
@@ -23,8 +23,18 @@
"remote": true
},
"componentProperties": {
- "lazyStartProducer": { "index": 0, "kind": "property", "displayName":
"Lazy Start Producer", "group": "producer", "label": "producer", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether the producer should be started lazy (on the first message). By
starting lazy you can use this to allow CamelContext and routes to startup in
situations where a producer may otherwise fail [...]
- "autowiredEnabled": { "index": 1, "kind": "property", "displayName":
"Autowired Enabled", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": true, "description":
"Whether autowiring is enabled. This is used for automatic autowiring options
(the option must be marked as autowired) by looking up in the registry to find
if there is a single instance of matching t [...]
+ "connectionTimeout": { "index": 0, "kind": "property", "displayName":
"Connection Timeout", "group": "producer", "label": "", "required": false,
"type": "integer", "javaType": "int", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": 30000, "description": "Connection timeout" },
+ "hostAddressesList": { "index": 1, "kind": "property", "displayName":
"Host Addresses List", "group": "producer", "label": "", "required": false,
"type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "List of host Addresses,
multiple hosts can be separated by comma." },
+ "lazyStartProducer": { "index": 2, "kind": "property", "displayName":
"Lazy Start Producer", "group": "producer", "label": "producer", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": false, "description":
"Whether the producer should be started lazy (on the first message). By
starting lazy you can use this to allow CamelContext and routes to startup in
situations where a producer may otherwise fail [...]
+ "socketTimeout": { "index": 3, "kind": "property", "displayName": "Socket
Timeout", "group": "producer", "label": "", "required": false, "type":
"integer", "javaType": "int", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": 30000, "description": "Socket timeout" },
+ "autowiredEnabled": { "index": 4, "kind": "property", "displayName":
"Autowired Enabled", "group": "advanced", "label": "advanced", "required":
false, "type": "boolean", "javaType": "boolean", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": true, "description":
"Whether autowiring is enabled. This is used for automatic autowiring options
(the option must be marked as autowired) by looking up in the registry to find
if there is a single instance of matching t [...]
+ "enableSniffer": { "index": 5, "kind": "property", "displayName": "Enable
Sniffer", "group": "advanced", "label": "advanced", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "description": "Enabling Sniffer" },
+ "restClient": { "index": 6, "kind": "property", "displayName": "Rest
Client", "group": "advanced", "label": "advanced", "required": false, "type":
"object", "javaType": "org.elasticsearch.client.RestClient", "deprecated":
false, "autowired": true, "secret": false, "description": "Rest Client of type
org.elasticsearch.client.RestClient. This is only for advanced usage" },
+ "sniffAfterFailureDelay": { "index": 7, "kind": "property", "displayName":
"Sniff After Failure Delay", "group": "advanced", "label": "advanced",
"required": false, "type": "integer", "javaType": "int", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": 60000, "description":
"Sniffer after failure delay (in millis)" },
+ "snifferInterval": { "index": 8, "kind": "property", "displayName":
"Sniffer Interval", "group": "advanced", "label": "advanced", "required":
false, "type": "integer", "javaType": "int", "deprecated": false, "autowired":
false, "secret": false, "defaultValue": 60000, "description": "Sniffer interval
(in millis)" },
+ "certificatePath": { "index": 9, "kind": "property", "displayName":
"Certificate Path", "group": "security", "label": "security", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "supportFileReference": true,
"description": "Certificate Path" },
+ "password": { "index": 10, "kind": "property", "displayName": "Password",
"group": "security", "label": "security", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": true, "description": "Password" },
+ "user": { "index": 11, "kind": "property", "displayName": "User", "group":
"security", "label": "security", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": true, "description": "Username" }
},
"properties": {
"clusterName": { "index": 0, "kind": "path", "displayName": "Cluster
Name", "group": "producer", "label": "", "required": true, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "description": "Cluster Name" },
diff --git
a/components/camel-elasticsearch-rest-client/src/main/java/org/apache/camel/component/elasticsearch/rest/client/ElasticsearchRestClientComponent.java
b/components/camel-elasticsearch-rest-client/src/main/java/org/apache/camel/component/elasticsearch/rest/client/ElasticsearchRestClientComponent.java
index 45c71a587df..7e3d7eb8ea1 100644
---
a/components/camel-elasticsearch-rest-client/src/main/java/org/apache/camel/component/elasticsearch/rest/client/ElasticsearchRestClientComponent.java
+++
b/components/camel-elasticsearch-rest-client/src/main/java/org/apache/camel/component/elasticsearch/rest/client/ElasticsearchRestClientComponent.java
@@ -19,18 +19,162 @@ package
org.apache.camel.component.elasticsearch.rest.client;
import java.util.Map;
import org.apache.camel.Endpoint;
+import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.annotations.Component;
import org.apache.camel.support.DefaultComponent;
+import org.elasticsearch.client.RestClient;
@Component("elasticsearch-rest-client")
public class ElasticsearchRestClientComponent extends DefaultComponent {
+ @Metadata(label = "advanced", autowired = true)
+ RestClient restClient;
+ @Metadata
+ String hostAddressesList;
+ @Metadata(defaultValue = "" +
ElasticSearchRestClientConstant.SOCKET_CONNECTION_TIMEOUT)
+ private int connectionTimeout =
ElasticSearchRestClientConstant.SOCKET_CONNECTION_TIMEOUT;
+ @Metadata(defaultValue = "" +
ElasticSearchRestClientConstant.SOCKET_CONNECTION_TIMEOUT)
+ private int socketTimeout =
ElasticSearchRestClientConstant.SOCKET_CONNECTION_TIMEOUT;
+ @Metadata(label = "security", secret = true)
+ private String user;
+ @Metadata(label = "security", secret = true)
+ private String password;
+ @Metadata(label = "security", supportFileReference = true)
+ private String certificatePath;
+ @Metadata(label = "advanced")
+ private boolean enableSniffer;
+ @Metadata(label = "advanced", defaultValue = "" +
ElasticSearchRestClientConstant.SNIFFER_INTERVAL_AND_FAILURE_DELAY)
+ private int snifferInterval =
ElasticSearchRestClientConstant.SNIFFER_INTERVAL_AND_FAILURE_DELAY;
+ @Metadata(label = "advanced", defaultValue = "" +
ElasticSearchRestClientConstant.SNIFFER_INTERVAL_AND_FAILURE_DELAY)
+ private int sniffAfterFailureDelay =
ElasticSearchRestClientConstant.SNIFFER_INTERVAL_AND_FAILURE_DELAY;
+
protected Endpoint createEndpoint(String uri, String remaining,
Map<String, Object> parameters) throws Exception {
if (remaining == null || remaining.isBlank()) {
throw new IllegalArgumentException("Cluster Name must be
specified.");
}
- Endpoint endpoint = new ElasticsearchRestClientEndpoint(uri, this);
+
+ ElasticsearchRestClientEndpoint endpoint = new
ElasticsearchRestClientEndpoint(uri, this);
+ endpoint.setRestClient(restClient);
+ endpoint.setHostAddressesList(hostAddressesList);
+ endpoint.setConnectionTimeout(connectionTimeout);
+ endpoint.setSocketTimeout(socketTimeout);
+ endpoint.setUser(user);
+ endpoint.setPassword(password);
+ endpoint.setCertificatePath(certificatePath);
+ endpoint.setEnableSniffer(enableSniffer);
+ endpoint.setSnifferInterval(snifferInterval);
+ endpoint.setSniffAfterFailureDelay(sniffAfterFailureDelay);
setProperties(endpoint, parameters);
return endpoint;
}
+
+ /**
+ * Rest Client of type org.elasticsearch.client.RestClient. This is only
for advanced usage
+ */
+ public RestClient getRestClient() {
+ return restClient;
+ }
+
+ public void setRestClient(RestClient restClient) {
+ this.restClient = restClient;
+ }
+
+ /**
+ * List of host Addresses, multiple hosts can be separated by comma.
+ */
+ public String getHostAddressesList() {
+ return hostAddressesList;
+ }
+
+ public void setHostAddressesList(String hostAddressesList) {
+ this.hostAddressesList = hostAddressesList;
+ }
+
+ /**
+ * Connection timeout
+ */
+ public int getConnectionTimeout() {
+ return connectionTimeout;
+ }
+
+ public void setConnectionTimeout(int connectionTimeout) {
+ this.connectionTimeout = connectionTimeout;
+ }
+
+ /**
+ * Socket timeout
+ */
+ public int getSocketTimeout() {
+ return socketTimeout;
+ }
+
+ public void setSocketTimeout(int socketTimeout) {
+ this.socketTimeout = socketTimeout;
+ }
+
+ /**
+ * Username
+ */
+ public String getUser() {
+ return user;
+ }
+
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ /**
+ * Password
+ */
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ /**
+ * Certificate Path
+ */
+ public String getCertificatePath() {
+ return certificatePath;
+ }
+
+ public void setCertificatePath(String certificatePath) {
+ this.certificatePath = certificatePath;
+ }
+
+ /**
+ * Enabling Sniffer
+ */
+ public boolean isEnableSniffer() {
+ return enableSniffer;
+ }
+
+ public void setEnableSniffer(boolean enableSniffer) {
+ this.enableSniffer = enableSniffer;
+ }
+
+ /**
+ * Sniffer interval (in millis)
+ */
+ public int getSnifferInterval() {
+ return snifferInterval;
+ }
+
+ public void setSnifferInterval(int snifferInterval) {
+ this.snifferInterval = snifferInterval;
+ }
+
+ /**
+ * Sniffer after failure delay (in millis)
+ */
+ public int getSniffAfterFailureDelay() {
+ return sniffAfterFailureDelay;
+ }
+
+ public void setSniffAfterFailureDelay(int sniffAfterFailureDelay) {
+ this.sniffAfterFailureDelay = sniffAfterFailureDelay;
+ }
}
diff --git
a/components/camel-elasticsearch-rest-client/src/test/java/org/apache/camel/component/elasticsearch/rest/client/ElasticSearchRestClientComponentConfigurationTest.java
b/components/camel-elasticsearch-rest-client/src/test/java/org/apache/camel/component/elasticsearch/rest/client/ElasticSearchRestClientComponentConfigurationTest.java
new file mode 100644
index 00000000000..01e1e38a38b
--- /dev/null
+++
b/components/camel-elasticsearch-rest-client/src/test/java/org/apache/camel/component/elasticsearch/rest/client/ElasticSearchRestClientComponentConfigurationTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.elasticsearch.rest.client;
+
+import java.io.IOException;
+
+import org.apache.camel.test.junit5.CamelTestSupport;
+import org.apache.http.HttpHost;
+import org.elasticsearch.client.RestClient;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+
+public class ElasticSearchRestClientComponentConfigurationTest extends
CamelTestSupport {
+
+ @Test
+ void componentConfiguration() throws IOException {
+ RestClient client = RestClient.builder(new HttpHost("localhost",
9200)).build();
+
+ try {
+ ElasticsearchRestClientComponent component = new
ElasticsearchRestClientComponent();
+ component.setHostAddressesList("localhost:9200");
+ component.setUser("camel");
+ component.setPassword("c4m3l");
+ component.setEnableSniffer(true);
+ component.setConnectionTimeout(100);
+ component.setSocketTimeout(200);
+ component.setSniffAfterFailureDelay(300);
+ component.setSnifferInterval(400);
+ component.setCertificatePath("/foo/bar");
+ component.setRestClient(client);
+
+ context.addComponent("elasticsearch-rest-client", component);
+
+ ElasticsearchRestClientEndpoint endpoint = context.getEndpoint(
+ "elasticsearch-rest-client:camel?operation=CREATE_INDEX",
ElasticsearchRestClientEndpoint.class);
+ assertEquals(component.getHostAddressesList(),
endpoint.getHostAddressesList());
+ assertEquals(component.getUser(), endpoint.getUser());
+ assertEquals(component.getPassword(), endpoint.getPassword());
+ assertEquals(component.isEnableSniffer(),
endpoint.isEnableSniffer());
+ assertEquals(component.getConnectionTimeout(),
endpoint.getConnectionTimeout());
+ assertEquals(component.getSocketTimeout(),
endpoint.getSocketTimeout());
+ assertEquals(component.getSniffAfterFailureDelay(),
endpoint.getSniffAfterFailureDelay());
+ assertEquals(component.getSnifferInterval(),
endpoint.getSnifferInterval());
+ assertEquals(component.getCertificatePath(),
endpoint.getCertificatePath());
+ assertSame(component.getRestClient(), endpoint.getRestClient());
+ } finally {
+ client.close();
+ }
+ }
+}
diff --git
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/ElasticsearchRestClientComponentBuilderFactory.java
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/ElasticsearchRestClientComponentBuilderFactory.java
index e8c5ccbef99..89fcef0e377 100644
---
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/ElasticsearchRestClientComponentBuilderFactory.java
+++
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/ElasticsearchRestClientComponentBuilderFactory.java
@@ -53,6 +53,38 @@ public interface
ElasticsearchRestClientComponentBuilderFactory {
interface ElasticsearchRestClientComponentBuilder extends
ComponentBuilder<ElasticsearchRestClientComponent> {
+ /**
+ * Connection timeout.
+ *
+ * The option is a: <code>int</code> type.
+ *
+ * Default: 30000
+ * Group: producer
+ *
+ * @param connectionTimeout the value to set
+ * @return the dsl builder
+ */
+ default ElasticsearchRestClientComponentBuilder connectionTimeout(int
connectionTimeout) {
+ doSetProperty("connectionTimeout", connectionTimeout);
+ return this;
+ }
+
+ /**
+ * List of host Addresses, multiple hosts can be separated by comma.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: producer
+ *
+ * @param hostAddressesList the value to set
+ * @return the dsl builder
+ */
+ default ElasticsearchRestClientComponentBuilder
hostAddressesList(java.lang.String hostAddressesList) {
+ doSetProperty("hostAddressesList", hostAddressesList);
+ return this;
+ }
+
+
/**
* Whether the producer should be started lazy (on the first message).
* By starting lazy you can use this to allow CamelContext and routes
to
@@ -78,6 +110,23 @@ public interface
ElasticsearchRestClientComponentBuilderFactory {
}
+ /**
+ * Socket timeout.
+ *
+ * The option is a: <code>int</code> type.
+ *
+ * Default: 30000
+ * Group: producer
+ *
+ * @param socketTimeout the value to set
+ * @return the dsl builder
+ */
+ default ElasticsearchRestClientComponentBuilder socketTimeout(int
socketTimeout) {
+ doSetProperty("socketTimeout", socketTimeout);
+ return this;
+ }
+
+
/**
* Whether autowiring is enabled. This is used for automatic autowiring
* options (the option must be marked as autowired) by looking up in
the
@@ -98,6 +147,122 @@ public interface
ElasticsearchRestClientComponentBuilderFactory {
doSetProperty("autowiredEnabled", autowiredEnabled);
return this;
}
+
+
+ /**
+ * Enabling Sniffer.
+ *
+ * The option is a: <code>boolean</code> type.
+ *
+ * Default: false
+ * Group: advanced
+ *
+ * @param enableSniffer the value to set
+ * @return the dsl builder
+ */
+ default ElasticsearchRestClientComponentBuilder enableSniffer(boolean
enableSniffer) {
+ doSetProperty("enableSniffer", enableSniffer);
+ return this;
+ }
+
+ /**
+ * Rest Client of type org.elasticsearch.client.RestClient. This is
only
+ * for advanced usage.
+ *
+ * The option is a:
+ * <code>org.elasticsearch.client.RestClient</code> type.
+ *
+ * Group: advanced
+ *
+ * @param restClient the value to set
+ * @return the dsl builder
+ */
+ default ElasticsearchRestClientComponentBuilder
restClient(org.elasticsearch.client.RestClient restClient) {
+ doSetProperty("restClient", restClient);
+ return this;
+ }
+
+
+ /**
+ * Sniffer after failure delay (in millis).
+ *
+ * The option is a: <code>int</code> type.
+ *
+ * Default: 60000
+ * Group: advanced
+ *
+ * @param sniffAfterFailureDelay the value to set
+ * @return the dsl builder
+ */
+ default ElasticsearchRestClientComponentBuilder
sniffAfterFailureDelay(int sniffAfterFailureDelay) {
+ doSetProperty("sniffAfterFailureDelay", sniffAfterFailureDelay);
+ return this;
+ }
+
+
+ /**
+ * Sniffer interval (in millis).
+ *
+ * The option is a: <code>int</code> type.
+ *
+ * Default: 60000
+ * Group: advanced
+ *
+ * @param snifferInterval the value to set
+ * @return the dsl builder
+ */
+ default ElasticsearchRestClientComponentBuilder snifferInterval(int
snifferInterval) {
+ doSetProperty("snifferInterval", snifferInterval);
+ return this;
+ }
+
+ /**
+ * Certificate Path.
+ *
+ * This option can also be loaded from an existing file, by prefixing
+ * with file: or classpath: followed by the location of the file.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: security
+ *
+ * @param certificatePath the value to set
+ * @return the dsl builder
+ */
+ default ElasticsearchRestClientComponentBuilder
certificatePath(java.lang.String certificatePath) {
+ doSetProperty("certificatePath", certificatePath);
+ return this;
+ }
+
+ /**
+ * Password.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: security
+ *
+ * @param password the value to set
+ * @return the dsl builder
+ */
+ default ElasticsearchRestClientComponentBuilder
password(java.lang.String password) {
+ doSetProperty("password", password);
+ return this;
+ }
+
+ /**
+ * Username.
+ *
+ * The option is a: <code>java.lang.String</code> type.
+ *
+ * Group: security
+ *
+ * @param user the value to set
+ * @return the dsl builder
+ */
+ default ElasticsearchRestClientComponentBuilder user(java.lang.String
user) {
+ doSetProperty("user", user);
+ return this;
+ }
}
class ElasticsearchRestClientComponentBuilderImpl
@@ -113,8 +278,18 @@ public interface
ElasticsearchRestClientComponentBuilderFactory {
String name,
Object value) {
switch (name) {
+ case "connectionTimeout": ((ElasticsearchRestClientComponent)
component).setConnectionTimeout((int) value); return true;
+ case "hostAddressesList": ((ElasticsearchRestClientComponent)
component).setHostAddressesList((java.lang.String) value); return true;
case "lazyStartProducer": ((ElasticsearchRestClientComponent)
component).setLazyStartProducer((boolean) value); return true;
+ case "socketTimeout": ((ElasticsearchRestClientComponent)
component).setSocketTimeout((int) value); return true;
case "autowiredEnabled": ((ElasticsearchRestClientComponent)
component).setAutowiredEnabled((boolean) value); return true;
+ case "enableSniffer": ((ElasticsearchRestClientComponent)
component).setEnableSniffer((boolean) value); return true;
+ case "restClient": ((ElasticsearchRestClientComponent)
component).setRestClient((org.elasticsearch.client.RestClient) value); return
true;
+ case "sniffAfterFailureDelay": ((ElasticsearchRestClientComponent)
component).setSniffAfterFailureDelay((int) value); return true;
+ case "snifferInterval": ((ElasticsearchRestClientComponent)
component).setSnifferInterval((int) value); return true;
+ case "certificatePath": ((ElasticsearchRestClientComponent)
component).setCertificatePath((java.lang.String) value); return true;
+ case "password": ((ElasticsearchRestClientComponent)
component).setPassword((java.lang.String) value); return true;
+ case "user": ((ElasticsearchRestClientComponent)
component).setUser((java.lang.String) value); return true;
default: return false;
}
}