You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2021/04/26 06:26:11 UTC

[camel] branch main updated (edf5b5a -> 197065b)

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from edf5b5a  Regen
     new 67698db  CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - Athena component
     new e0c1fa8  CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - Athena component
     new 446a2ba  CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - Athena component
     new 197065b  CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - Athena component

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../camel/catalog/components/aws2-athena.json      |  2 +
 .../camel/catalog/docs/aws2-athena-component.adoc  |  6 ++-
 .../aws2/athena/Athena2ComponentConfigurer.java    |  6 +++
 .../aws2/athena/Athena2EndpointConfigurer.java     |  6 +++
 .../aws2/athena/Athena2EndpointUriFactory.java     |  3 +-
 .../camel/component/aws2/athena/aws2-athena.json   |  2 +
 .../src/main/docs/aws2-athena-component.adoc       |  6 ++-
 .../component/aws2/athena/Athena2Component.java    |  8 ++--
 .../aws2/athena/Athena2Configuration.java          | 17 ++++++++
 .../component/aws2/athena/Athena2Endpoint.java     | 45 +------------------
 .../aws2/athena/client/Athena2ClientFactory.java}  | 22 +++++-----
 .../aws2/athena/client/Athena2InternalClient.java} | 16 +++----
 .../impl/Athena2ClientIAMOptimizedImpl.java}       | 45 +++++++------------
 .../client/impl/Athena2ClientStandardImpl.java}    | 49 ++++++++-------------
 .../aws2/athena/AthenaClientFactoryTest.java       | 51 ++++++++++++++++++++++
 .../dsl/Aws2AthenaComponentBuilderFactory.java     | 19 ++++++++
 .../dsl/Athena2EndpointBuilderFactory.java         | 37 ++++++++++++++++
 .../modules/ROOT/pages/aws2-athena-component.adoc  |  6 ++-
 18 files changed, 212 insertions(+), 134 deletions(-)
 copy components/camel-aws/{camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/client/AWS2S3ClientFactory.java => camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/Athena2ClientFactory.java} (56%)
 copy components/camel-aws/{camel-aws2-kinesis/src/main/java/org/apache/camel/component/aws2/kinesis/client/KinesisInternalClient.java => camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/Athena2InternalClient.java} (70%)
 copy components/camel-aws/{camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/client/impl/AWS2S3ClientIAMOptimizedImpl.java => camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientIAMOptimizedImpl.java} (56%)
 copy components/camel-aws/{camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/client/impl/AWS2S3ClientStandardImpl.java => camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientStandardImpl.java} (64%)
 create mode 100644 components/camel-aws/camel-aws2-athena/src/test/java/org/apache/camel/component/aws2/athena/AthenaClientFactoryTest.java

[camel] 01/04: CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - Athena component

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 67698db92c0865362b0db8773aee3d3811059cae
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Apr 26 08:14:06 2021 +0200

    CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - Athena component
---
 .../component/aws2/athena/Athena2Component.java    |  5 +-
 .../aws2/athena/Athena2Configuration.java          | 16 ++++
 .../component/aws2/athena/Athena2Endpoint.java     | 38 +--------
 .../aws2/athena/client/Athena2ClientFactory.java   | 41 ++++++++++
 .../aws2/athena/client/Athena2InternalClient.java  | 32 ++++++++
 .../client/impl/Athena2ClientIAMOptimizedImpl.java | 73 ++++++++++++++++++
 .../impl/Athena2ClientStandardImpl.java}           | 89 ++++++----------------
 7 files changed, 189 insertions(+), 105 deletions(-)

diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Component.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Component.java
index 721b693..1ca4ae2 100644
--- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Component.java
+++ b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Component.java
@@ -52,9 +52,10 @@ public class Athena2Component extends DefaultComponent {
                 = this.configuration != null ? this.configuration.copy() : new Athena2Configuration();
         Athena2Endpoint endpoint = new Athena2Endpoint(uri, this, configuration);
         setProperties(endpoint, parameters);
-        if (configuration.getAmazonAthenaClient() == null && (configuration.getAccessKey() == null
+        if (!configuration.isUseDefaultCredentialsProvider() && configuration.getAmazonAthenaClient() == null
+                && (configuration.getAccessKey() == null
                 || configuration.getSecretKey() == null)) {
-            throw new IllegalArgumentException("accessKey/secretKey or amazonAthenaClient must be specified");
+            throw new IllegalArgumentException("useDefaultCredentialsProvider is set to false, accessKey/secretKey or amazonAthenaClient must be specified");
         }
         return endpoint;
     }
diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Configuration.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Configuration.java
index 9180697..f8b6841 100644
--- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Configuration.java
+++ b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Configuration.java
@@ -136,6 +136,10 @@ public class Athena2Configuration implements Cloneable {
     private Integer proxyPort;
     @UriParam
     private String region;
+    @UriParam(defaultValue = "false",
+            description = "Set whether the Athena client should expect to load credentials through a default credentials provider or to expect " +
+                    "static credentials to be passed in")
+    private boolean useDefaultCredentialsProvider;
 
     public String getAccessKey() {
         return accessKey;
@@ -441,6 +445,18 @@ public class Athena2Configuration implements Cloneable {
         this.includeTrace = includeTrace;
     }
 
+    /**
+     * Set whether the Athena client should expect to load credentials through a default credentials provider or to expect
+     * static credentials to be passed in.
+     */
+    public void setUseDefaultCredentialsProvider(Boolean useDefaultCredentialsProvider) {
+        this.useDefaultCredentialsProvider = useDefaultCredentialsProvider;
+    }
+
+    public Boolean isUseDefaultCredentialsProvider() {
+        return useDefaultCredentialsProvider;
+    }
+
     // *************************************************
     //
     // *************************************************
diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java
index d69190a..3a9f757 100644
--- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java
+++ b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java
@@ -23,6 +23,7 @@ import org.apache.camel.Component;
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
+import org.apache.camel.component.aws2.athena.client.Athena2ClientFactory;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.support.DefaultEndpoint;
@@ -68,8 +69,7 @@ public class Athena2Endpoint extends DefaultEndpoint {
         super.doInit();
 
         athenaClient = configuration.getAmazonAthenaClient() != null
-                ? configuration.getAmazonAthenaClient()
-                : createAthenaClient();
+                ? configuration.getAmazonAthenaClient() : Athena2ClientFactory.getAWSAthenaClient(configuration).getAthenaClient();
     }
 
     @Override
@@ -97,38 +97,4 @@ public class Athena2Endpoint extends DefaultEndpoint {
     public void setAthenaClient(AthenaClient athenaClient) {
         this.athenaClient = athenaClient;
     }
-
-    AthenaClient createAthenaClient() {
-        AthenaClient client = null;
-        AthenaClientBuilder clientBuilder = AthenaClient.builder();
-        ProxyConfiguration.Builder proxyConfig = null;
-        ApacheHttpClient.Builder httpClientBuilder = null;
-        boolean isClientConfigFound = false;
-        if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
-            proxyConfig = ProxyConfiguration.builder();
-            URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":"
-                                           + configuration.getProxyPort());
-            proxyConfig.endpoint(proxyEndpoint);
-            httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
-            isClientConfigFound = true;
-        }
-        if (configuration.getAccessKey() != null && configuration.getSecretKey() != null) {
-            AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey());
-            if (isClientConfigFound) {
-                clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder)
-                        .credentialsProvider(StaticCredentialsProvider.create(cred));
-            } else {
-                clientBuilder = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred));
-            }
-        } else {
-            if (!isClientConfigFound) {
-                clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
-            }
-        }
-        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
-            clientBuilder = clientBuilder.region(Region.of(configuration.getRegion()));
-        }
-        client = clientBuilder.build();
-        return client;
-    }
 }
diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/Athena2ClientFactory.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/Athena2ClientFactory.java
new file mode 100644
index 0000000..d9ff716e
--- /dev/null
+++ b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/Athena2ClientFactory.java
@@ -0,0 +1,41 @@
+/*
+ * 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.aws2.athena.client;
+
+import org.apache.camel.component.aws2.athena.Athena2Configuration;
+import org.apache.camel.component.aws2.athena.client.impl.Athena2ClientIAMOptimizedImpl;
+import org.apache.camel.component.aws2.athena.client.impl.Athena2ClientStandardImpl;
+
+/**
+ * Factory class to return the correct type of AWS Athena client.
+ */
+public final class Athena2ClientFactory {
+
+    private Athena2ClientFactory() {
+    }
+
+    /**
+     * Return the correct AWS Athena client (based on remote vs local).
+     * 
+     * @param  configuration configuration
+     * @return               AthenaClient
+     */
+    public static Athena2InternalClient getAWSAthenaClient(Athena2Configuration configuration) {
+        return configuration.isUseDefaultCredentialsProvider()
+                ? new Athena2ClientIAMOptimizedImpl(configuration) : new Athena2ClientStandardImpl(configuration);
+    }
+}
diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/Athena2InternalClient.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/Athena2InternalClient.java
new file mode 100644
index 0000000..8ae91b3
--- /dev/null
+++ b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/Athena2InternalClient.java
@@ -0,0 +1,32 @@
+/*
+ * 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.aws2.athena.client;
+
+import software.amazon.awssdk.services.athena.AthenaClient;
+
+/**
+ * Manage the required actions of an Athena client for either local or remote.
+ */
+public interface Athena2InternalClient {
+
+    /**
+     * Returns an Athena client after a factory method determines which one to return.
+     * 
+     * @return AthenaClient AthenaClient
+     */
+    AthenaClient getAthenaClient();
+}
diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientIAMOptimizedImpl.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientIAMOptimizedImpl.java
new file mode 100644
index 0000000..86266b2
--- /dev/null
+++ b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientIAMOptimizedImpl.java
@@ -0,0 +1,73 @@
+/*
+ * 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.aws2.athena.client.impl;
+
+import org.apache.camel.component.aws2.athena.Athena2Configuration;
+import org.apache.camel.component.aws2.athena.client.Athena2InternalClient;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import software.amazon.awssdk.http.apache.ApacheHttpClient;
+import software.amazon.awssdk.http.apache.ProxyConfiguration;
+import software.amazon.awssdk.regions.Region;
+import software.amazon.awssdk.services.athena.AthenaClient;
+import software.amazon.awssdk.services.athena.AthenaClientBuilder;
+
+import java.net.URI;
+
+/**
+ * Manage an AWS Athena client for all users to use (enabling temporary creds). This implementation is for remote instances
+ * to manage the credentials on their own (eliminating credential rotations)
+ */
+public class Athena2ClientIAMOptimizedImpl implements Athena2InternalClient {
+    private static final Logger LOG = LoggerFactory.getLogger(Athena2ClientIAMOptimizedImpl.class);
+    private Athena2Configuration configuration;
+
+    /**
+     * Constructor that uses the config file.
+     */
+    public Athena2ClientIAMOptimizedImpl(Athena2Configuration configuration) {
+        LOG.trace("Creating an AWS Athena client for an ec2 instance with IAM temporary credentials (normal for ec2s).");
+        this.configuration = configuration;
+    }
+
+    /**
+     * Getting the s3 aws client that is used.
+     * 
+     * @return Amazon S3 Client.
+     */
+    @Override
+    public AthenaClient getAthenaClient() {
+        AthenaClient client = null;
+        AthenaClientBuilder clientBuilder = AthenaClient.builder();
+        ProxyConfiguration.Builder proxyConfig = null;
+        ApacheHttpClient.Builder httpClientBuilder = null;
+        if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
+            proxyConfig = ProxyConfiguration.builder();
+            URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":"
+                                           + configuration.getProxyPort());
+            proxyConfig.endpoint(proxyEndpoint);
+            httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
+            clientBuilder = clientBuilder.httpClientBuilder(httpClientBuilder);
+        }
+        if (ObjectHelper.isNotEmpty(configuration.getRegion())) {
+            clientBuilder = clientBuilder.region(Region.of(configuration.getRegion()));
+        }
+        client = clientBuilder.build();
+        return client;
+    }
+}
diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientStandardImpl.java
similarity index 59%
copy from components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java
copy to components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientStandardImpl.java
index d69190a..1a6665d 100644
--- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java
+++ b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientStandardImpl.java
@@ -14,19 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.component.aws2.athena;
+package org.apache.camel.component.aws2.athena.client.impl;
 
-import java.net.URI;
-
-import org.apache.camel.Category;
-import org.apache.camel.Component;
-import org.apache.camel.Consumer;
-import org.apache.camel.Processor;
-import org.apache.camel.Producer;
-import org.apache.camel.spi.UriEndpoint;
-import org.apache.camel.spi.UriParam;
-import org.apache.camel.support.DefaultEndpoint;
+import org.apache.camel.component.aws2.athena.Athena2Configuration;
+import org.apache.camel.component.aws2.athena.client.Athena2InternalClient;
 import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
 import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
 import software.amazon.awssdk.http.apache.ApacheHttpClient;
@@ -35,70 +29,31 @@ import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.athena.AthenaClient;
 import software.amazon.awssdk.services.athena.AthenaClientBuilder;
 
+import java.net.URI;
+
 /**
- * Access AWS Athena service using AWS SDK version 2.x.
+ * Manage an AWS Athena client for all users to use. This implementation is for local instances to use a static and solid
+ * credential set.
  */
-@UriEndpoint(firstVersion = "3.4.0", scheme = "aws2-athena", title = "AWS 2 Athena", syntax = "aws2-athena:label",
-             producerOnly = true, category = {
-                     Category.CLOUD, Category.DATABASE })
-public class Athena2Endpoint extends DefaultEndpoint {
-
-    private AthenaClient athenaClient;
-
-    @UriParam
+public class Athena2ClientStandardImpl implements Athena2InternalClient {
+    private static final Logger LOG = LoggerFactory.getLogger(Athena2ClientStandardImpl.class);
     private Athena2Configuration configuration;
 
-    public Athena2Endpoint(String uri, Component component, Athena2Configuration configuration) {
-        super(uri, component);
+    /**
+     * Constructor that uses the config file.
+     */
+    public Athena2ClientStandardImpl(Athena2Configuration configuration) {
+        LOG.trace("Creating an AWS Athena manager using static credentials.");
         this.configuration = configuration;
     }
 
+    /**
+     * Getting the Athena AWS client that is used.
+     * 
+     * @return Amazon Athena Client.
+     */
     @Override
-    public Consumer createConsumer(Processor processor) throws Exception {
-        throw new UnsupportedOperationException("You cannot receive messages from this endpoint");
-    }
-
-    @Override
-    public Producer createProducer() throws Exception {
-        return new Athena2Producer(this);
-    }
-
-    @Override
-    public void doInit() throws Exception {
-        super.doInit();
-
-        athenaClient = configuration.getAmazonAthenaClient() != null
-                ? configuration.getAmazonAthenaClient()
-                : createAthenaClient();
-    }
-
-    @Override
-    public void doStop() throws Exception {
-        if (ObjectHelper.isEmpty(configuration.getAmazonAthenaClient())) {
-            if (athenaClient != null) {
-                athenaClient.close();
-            }
-        }
-        super.doStop();
-    }
-
-    public Athena2Configuration getConfiguration() {
-        return configuration;
-    }
-
-    public void setConfiguration(Athena2Configuration configuration) {
-        this.configuration = configuration;
-    }
-
     public AthenaClient getAthenaClient() {
-        return athenaClient;
-    }
-
-    public void setAthenaClient(AthenaClient athenaClient) {
-        this.athenaClient = athenaClient;
-    }
-
-    AthenaClient createAthenaClient() {
         AthenaClient client = null;
         AthenaClientBuilder clientBuilder = AthenaClient.builder();
         ProxyConfiguration.Builder proxyConfig = null;
@@ -107,7 +62,7 @@ public class Athena2Endpoint extends DefaultEndpoint {
         if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
             proxyConfig = ProxyConfiguration.builder();
             URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":"
-                                           + configuration.getProxyPort());
+                    + configuration.getProxyPort());
             proxyConfig.endpoint(proxyEndpoint);
             httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
             isClientConfigFound = true;

[camel] 02/04: CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - Athena component

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit e0c1fa8b0024d695b5cf241cac00fbd0d137f74b
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Apr 26 08:14:47 2021 +0200

    CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - Athena component
---
 .../camel/catalog/docs/aws2-athena-component.adoc  |  6 ++--
 .../aws2/athena/Athena2ComponentConfigurer.java    |  6 ++++
 .../aws2/athena/Athena2EndpointConfigurer.java     |  6 ++++
 .../aws2/athena/Athena2EndpointUriFactory.java     |  3 +-
 .../camel/component/aws2/athena/aws2-athena.json   |  2 ++
 .../src/main/docs/aws2-athena-component.adoc       |  6 ++--
 .../component/aws2/athena/Athena2Component.java    |  5 +--
 .../aws2/athena/Athena2Configuration.java          |  9 +++---
 .../component/aws2/athena/Athena2Endpoint.java     | 11 ++-----
 .../client/impl/Athena2ClientIAMOptimizedImpl.java |  8 ++---
 .../client/impl/Athena2ClientStandardImpl.java     | 10 +++---
 .../dsl/Aws2AthenaComponentBuilderFactory.java     | 19 +++++++++++
 .../dsl/Athena2EndpointBuilderFactory.java         | 37 ++++++++++++++++++++++
 .../modules/ROOT/pages/aws2-athena-component.adoc  |  6 ++--
 14 files changed, 103 insertions(+), 31 deletions(-)

diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-athena-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-athena-component.adoc
index 8c5bd92..33aabc1 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-athena-component.adoc
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/aws2-athena-component.adoc
@@ -60,7 +60,7 @@ from("direct:start")
 
 
 // component options: START
-The AWS 2 Athena component supports 29 options, which are listed below.
+The AWS 2 Athena component supports 30 options, which are listed below.
 
 
 
@@ -92,6 +92,7 @@ The AWS 2 Athena component supports 29 options, which are listed below.
 | *resetWaitTimeoutOnRetry* (producer) | Reset the waitTimeout countdown in the event of a query retry. If set to true, potential max time spent waiting for queries is equal to waitTimeout x maxAttempts. See the section 'Waiting for Query Completion and Retrying Failed Queries' to learn more. | true | boolean
 | *retry* (producer) | Optional comma separated list of error types to retry the query for. Use 'retryable' to retry all retryable failure conditions (e.g. generic errors and resources exhausted), 'generic' to retry 'GENERIC_INTERNAL_ERROR' failures, 'exhausted' to retry queries that have exhausted resource limits, 'always' to always retry regardless of failure condition, or 'never' or null to never retry (default). See the section 'Waiting for Query Completion and Retrying Failed Querie [...]
 | *secretKey* (producer) | Amazon AWS Secret Key. |  | String
+| *useDefaultCredentialsProvider* (producer) | Set whether the Athena client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in | false | boolean
 | *waitTimeout* (producer) | Optional max wait time in millis to wait for a successful query completion. See the section 'Waiting for Query Completion and Retrying Failed Queries' to learn more. | 0 | long
 | *workGroup* (producer) | The workgroup to use for running the query. |  | String
 | *autowiredEnabled* (advanced) | 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 type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | boolean
@@ -128,7 +129,7 @@ with the following path and query parameters:
 |===
 
 
-=== Query Parameters (27 parameters):
+=== Query Parameters (28 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -158,6 +159,7 @@ with the following path and query parameters:
 | *resetWaitTimeoutOnRetry* (producer) | Reset the waitTimeout countdown in the event of a query retry. If set to true, potential max time spent waiting for queries is equal to waitTimeout x maxAttempts. See the section 'Waiting for Query Completion and Retrying Failed Queries' to learn more. | true | boolean
 | *retry* (producer) | Optional comma separated list of error types to retry the query for. Use 'retryable' to retry all retryable failure conditions (e.g. generic errors and resources exhausted), 'generic' to retry 'GENERIC_INTERNAL_ERROR' failures, 'exhausted' to retry queries that have exhausted resource limits, 'always' to always retry regardless of failure condition, or 'never' or null to never retry (default). See the section 'Waiting for Query Completion and Retrying Failed Querie [...]
 | *secretKey* (producer) | Amazon AWS Secret Key. |  | String
+| *useDefaultCredentialsProvider* (producer) | Set whether the Athena client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in | false | boolean
 | *waitTimeout* (producer) | Optional max wait time in millis to wait for a successful query completion. See the section 'Waiting for Query Completion and Retrying Failed Queries' to learn more. | 0 | long
 | *workGroup* (producer) | The workgroup to use for running the query. |  | String
 | *clientRequestToken* (advanced) | A unique string to ensure issues queries are idempotent. It is unlikely you will need to set this. |  | String
diff --git a/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2ComponentConfigurer.java b/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2ComponentConfigurer.java
index f2ae089..7a6d2ac 100644
--- a/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2ComponentConfigurer.java
+++ b/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2ComponentConfigurer.java
@@ -76,6 +76,8 @@ public class Athena2ComponentConfigurer extends PropertyConfigurerSupport implem
         case "retry": getOrCreateConfiguration(target).setRetry(property(camelContext, java.lang.String.class, value)); return true;
         case "secretkey":
         case "secretKey": getOrCreateConfiguration(target).setSecretKey(property(camelContext, java.lang.String.class, value)); return true;
+        case "usedefaultcredentialsprovider":
+        case "useDefaultCredentialsProvider": getOrCreateConfiguration(target).setUseDefaultCredentialsProvider(property(camelContext, boolean.class, value)); return true;
         case "waittimeout":
         case "waitTimeout": getOrCreateConfiguration(target).setWaitTimeout(property(camelContext, long.class, value)); return true;
         case "workgroup":
@@ -140,6 +142,8 @@ public class Athena2ComponentConfigurer extends PropertyConfigurerSupport implem
         case "retry": return java.lang.String.class;
         case "secretkey":
         case "secretKey": return java.lang.String.class;
+        case "usedefaultcredentialsprovider":
+        case "useDefaultCredentialsProvider": return boolean.class;
         case "waittimeout":
         case "waitTimeout": return long.class;
         case "workgroup":
@@ -200,6 +204,8 @@ public class Athena2ComponentConfigurer extends PropertyConfigurerSupport implem
         case "retry": return getOrCreateConfiguration(target).getRetry();
         case "secretkey":
         case "secretKey": return getOrCreateConfiguration(target).getSecretKey();
+        case "usedefaultcredentialsprovider":
+        case "useDefaultCredentialsProvider": return getOrCreateConfiguration(target).isUseDefaultCredentialsProvider();
         case "waittimeout":
         case "waitTimeout": return getOrCreateConfiguration(target).getWaitTimeout();
         case "workgroup":
diff --git a/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2EndpointConfigurer.java b/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2EndpointConfigurer.java
index 19db31c..de4faaa 100644
--- a/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2EndpointConfigurer.java
+++ b/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2EndpointConfigurer.java
@@ -66,6 +66,8 @@ public class Athena2EndpointConfigurer extends PropertyConfigurerSupport impleme
         case "retry": target.getConfiguration().setRetry(property(camelContext, java.lang.String.class, value)); return true;
         case "secretkey":
         case "secretKey": target.getConfiguration().setSecretKey(property(camelContext, java.lang.String.class, value)); return true;
+        case "usedefaultcredentialsprovider":
+        case "useDefaultCredentialsProvider": target.getConfiguration().setUseDefaultCredentialsProvider(property(camelContext, boolean.class, value)); return true;
         case "waittimeout":
         case "waitTimeout": target.getConfiguration().setWaitTimeout(property(camelContext, long.class, value)); return true;
         case "workgroup":
@@ -127,6 +129,8 @@ public class Athena2EndpointConfigurer extends PropertyConfigurerSupport impleme
         case "retry": return java.lang.String.class;
         case "secretkey":
         case "secretKey": return java.lang.String.class;
+        case "usedefaultcredentialsprovider":
+        case "useDefaultCredentialsProvider": return boolean.class;
         case "waittimeout":
         case "waitTimeout": return long.class;
         case "workgroup":
@@ -184,6 +188,8 @@ public class Athena2EndpointConfigurer extends PropertyConfigurerSupport impleme
         case "retry": return target.getConfiguration().getRetry();
         case "secretkey":
         case "secretKey": return target.getConfiguration().getSecretKey();
+        case "usedefaultcredentialsprovider":
+        case "useDefaultCredentialsProvider": return target.getConfiguration().isUseDefaultCredentialsProvider();
         case "waittimeout":
         case "waitTimeout": return target.getConfiguration().getWaitTimeout();
         case "workgroup":
diff --git a/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2EndpointUriFactory.java b/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2EndpointUriFactory.java
index 39b6570..21b0382 100644
--- a/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2EndpointUriFactory.java
+++ b/components/camel-aws/camel-aws2-athena/src/generated/java/org/apache/camel/component/aws2/athena/Athena2EndpointUriFactory.java
@@ -20,7 +20,7 @@ public class Athena2EndpointUriFactory extends org.apache.camel.support.componen
     private static final Set<String> PROPERTY_NAMES;
     private static final Set<String> SECRET_PROPERTY_NAMES;
     static {
-        Set<String> props = new HashSet<>(28);
+        Set<String> props = new HashSet<>(29);
         props.add("outputLocation");
         props.add("workGroup");
         props.add("kmsKey");
@@ -38,6 +38,7 @@ public class Athena2EndpointUriFactory extends org.apache.camel.support.componen
         props.add("proxyProtocol");
         props.add("secretKey");
         props.add("resetWaitTimeoutOnRetry");
+        props.add("useDefaultCredentialsProvider");
         props.add("label");
         props.add("queryExecutionId");
         props.add("queryString");
diff --git a/components/camel-aws/camel-aws2-athena/src/generated/resources/org/apache/camel/component/aws2/athena/aws2-athena.json b/components/camel-aws/camel-aws2-athena/src/generated/resources/org/apache/camel/component/aws2/athena/aws2-athena.json
index eb4767a..f4e0f35 100644
--- a/components/camel-aws/camel-aws2-athena/src/generated/resources/org/apache/camel/component/aws2/athena/aws2-athena.json
+++ b/components/camel-aws/camel-aws2-athena/src/generated/resources/org/apache/camel/component/aws2/athena/aws2-athena.json
@@ -47,6 +47,7 @@
     "resetWaitTimeoutOnRetry": { "kind": "property", "displayName": "Reset Wait Timeout On Retry", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Reset the waitTimeout countdown in the event of a query retry. If set  [...]
     "retry": { "kind": "property", "displayName": "Retry", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "enum": [ "never", "always", "retryable", "exhausted", "generic" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "never", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional comma separated list o [...]
     "secretKey": { "kind": "property", "displayName": "Secret Key", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key." },
+    "useDefaultCredentialsProvider": { "kind": "property", "displayName": "Use Default Credentials Provider", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to load credentials th [...]
     "waitTimeout": { "kind": "property", "displayName": "Wait Timeout", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 0, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional max wait time in millis to wait for a successful query completion. See the section 'Waiting fo [...]
     "workGroup": { "kind": "property", "displayName": "Work Group", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The workgroup to use for running the query." },
     "autowiredEnabled": { "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 type, which t [...]
@@ -78,6 +79,7 @@
     "resetWaitTimeoutOnRetry": { "kind": "parameter", "displayName": "Reset Wait Timeout On Retry", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Reset the waitTimeout countdown in the event of a query retry. If set [...]
     "retry": { "kind": "parameter", "displayName": "Retry", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "enum": [ "never", "always", "retryable", "exhausted", "generic" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "never", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional comma separated list  [...]
     "secretKey": { "kind": "parameter", "displayName": "Secret Key", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key." },
+    "useDefaultCredentialsProvider": { "kind": "parameter", "displayName": "Use Default Credentials Provider", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to load credentials t [...]
     "waitTimeout": { "kind": "parameter", "displayName": "Wait Timeout", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 0, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional max wait time in millis to wait for a successful query completion. See the section 'Waiting f [...]
     "workGroup": { "kind": "parameter", "displayName": "Work Group", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The workgroup to use for running the query." },
     "clientRequestToken": { "kind": "parameter", "displayName": "Client Request Token", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "A unique string to ensure issues queries are idempotent. It is unlikely you will need to set this." }
diff --git a/components/camel-aws/camel-aws2-athena/src/main/docs/aws2-athena-component.adoc b/components/camel-aws/camel-aws2-athena/src/main/docs/aws2-athena-component.adoc
index 8c5bd92..33aabc1 100644
--- a/components/camel-aws/camel-aws2-athena/src/main/docs/aws2-athena-component.adoc
+++ b/components/camel-aws/camel-aws2-athena/src/main/docs/aws2-athena-component.adoc
@@ -60,7 +60,7 @@ from("direct:start")
 
 
 // component options: START
-The AWS 2 Athena component supports 29 options, which are listed below.
+The AWS 2 Athena component supports 30 options, which are listed below.
 
 
 
@@ -92,6 +92,7 @@ The AWS 2 Athena component supports 29 options, which are listed below.
 | *resetWaitTimeoutOnRetry* (producer) | Reset the waitTimeout countdown in the event of a query retry. If set to true, potential max time spent waiting for queries is equal to waitTimeout x maxAttempts. See the section 'Waiting for Query Completion and Retrying Failed Queries' to learn more. | true | boolean
 | *retry* (producer) | Optional comma separated list of error types to retry the query for. Use 'retryable' to retry all retryable failure conditions (e.g. generic errors and resources exhausted), 'generic' to retry 'GENERIC_INTERNAL_ERROR' failures, 'exhausted' to retry queries that have exhausted resource limits, 'always' to always retry regardless of failure condition, or 'never' or null to never retry (default). See the section 'Waiting for Query Completion and Retrying Failed Querie [...]
 | *secretKey* (producer) | Amazon AWS Secret Key. |  | String
+| *useDefaultCredentialsProvider* (producer) | Set whether the Athena client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in | false | boolean
 | *waitTimeout* (producer) | Optional max wait time in millis to wait for a successful query completion. See the section 'Waiting for Query Completion and Retrying Failed Queries' to learn more. | 0 | long
 | *workGroup* (producer) | The workgroup to use for running the query. |  | String
 | *autowiredEnabled* (advanced) | 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 type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | boolean
@@ -128,7 +129,7 @@ with the following path and query parameters:
 |===
 
 
-=== Query Parameters (27 parameters):
+=== Query Parameters (28 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -158,6 +159,7 @@ with the following path and query parameters:
 | *resetWaitTimeoutOnRetry* (producer) | Reset the waitTimeout countdown in the event of a query retry. If set to true, potential max time spent waiting for queries is equal to waitTimeout x maxAttempts. See the section 'Waiting for Query Completion and Retrying Failed Queries' to learn more. | true | boolean
 | *retry* (producer) | Optional comma separated list of error types to retry the query for. Use 'retryable' to retry all retryable failure conditions (e.g. generic errors and resources exhausted), 'generic' to retry 'GENERIC_INTERNAL_ERROR' failures, 'exhausted' to retry queries that have exhausted resource limits, 'always' to always retry regardless of failure condition, or 'never' or null to never retry (default). See the section 'Waiting for Query Completion and Retrying Failed Querie [...]
 | *secretKey* (producer) | Amazon AWS Secret Key. |  | String
+| *useDefaultCredentialsProvider* (producer) | Set whether the Athena client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in | false | boolean
 | *waitTimeout* (producer) | Optional max wait time in millis to wait for a successful query completion. See the section 'Waiting for Query Completion and Retrying Failed Queries' to learn more. | 0 | long
 | *workGroup* (producer) | The workgroup to use for running the query. |  | String
 | *clientRequestToken* (advanced) | A unique string to ensure issues queries are idempotent. It is unlikely you will need to set this. |  | String
diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Component.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Component.java
index 1ca4ae2..8d5b9f3 100644
--- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Component.java
+++ b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Component.java
@@ -54,8 +54,9 @@ public class Athena2Component extends DefaultComponent {
         setProperties(endpoint, parameters);
         if (!configuration.isUseDefaultCredentialsProvider() && configuration.getAmazonAthenaClient() == null
                 && (configuration.getAccessKey() == null
-                || configuration.getSecretKey() == null)) {
-            throw new IllegalArgumentException("useDefaultCredentialsProvider is set to false, accessKey/secretKey or amazonAthenaClient must be specified");
+                        || configuration.getSecretKey() == null)) {
+            throw new IllegalArgumentException(
+                    "useDefaultCredentialsProvider is set to false, accessKey/secretKey or amazonAthenaClient must be specified");
         }
         return endpoint;
     }
diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Configuration.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Configuration.java
index f8b6841..220c6b6 100644
--- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Configuration.java
+++ b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Configuration.java
@@ -137,8 +137,9 @@ public class Athena2Configuration implements Cloneable {
     @UriParam
     private String region;
     @UriParam(defaultValue = "false",
-            description = "Set whether the Athena client should expect to load credentials through a default credentials provider or to expect " +
-                    "static credentials to be passed in")
+              description = "Set whether the Athena client should expect to load credentials through a default credentials provider or to expect "
+                            +
+                            "static credentials to be passed in")
     private boolean useDefaultCredentialsProvider;
 
     public String getAccessKey() {
@@ -446,8 +447,8 @@ public class Athena2Configuration implements Cloneable {
     }
 
     /**
-     * Set whether the Athena client should expect to load credentials through a default credentials provider or to expect
-     * static credentials to be passed in.
+     * Set whether the Athena client should expect to load credentials through a default credentials provider or to
+     * expect static credentials to be passed in.
      */
     public void setUseDefaultCredentialsProvider(Boolean useDefaultCredentialsProvider) {
         this.useDefaultCredentialsProvider = useDefaultCredentialsProvider;
diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java
index 3a9f757..b80524c 100644
--- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java
+++ b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/Athena2Endpoint.java
@@ -16,8 +16,6 @@
  */
 package org.apache.camel.component.aws2.athena;
 
-import java.net.URI;
-
 import org.apache.camel.Category;
 import org.apache.camel.Component;
 import org.apache.camel.Consumer;
@@ -28,13 +26,7 @@ import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.support.DefaultEndpoint;
 import org.apache.camel.util.ObjectHelper;
-import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
-import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
-import software.amazon.awssdk.http.apache.ApacheHttpClient;
-import software.amazon.awssdk.http.apache.ProxyConfiguration;
-import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.athena.AthenaClient;
-import software.amazon.awssdk.services.athena.AthenaClientBuilder;
 
 /**
  * Access AWS Athena service using AWS SDK version 2.x.
@@ -69,7 +61,8 @@ public class Athena2Endpoint extends DefaultEndpoint {
         super.doInit();
 
         athenaClient = configuration.getAmazonAthenaClient() != null
-                ? configuration.getAmazonAthenaClient() : Athena2ClientFactory.getAWSAthenaClient(configuration).getAthenaClient();
+                ? configuration.getAmazonAthenaClient()
+                : Athena2ClientFactory.getAWSAthenaClient(configuration).getAthenaClient();
     }
 
     @Override
diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientIAMOptimizedImpl.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientIAMOptimizedImpl.java
index 86266b2..9fce28a 100644
--- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientIAMOptimizedImpl.java
+++ b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientIAMOptimizedImpl.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.aws2.athena.client.impl;
 
+import java.net.URI;
+
 import org.apache.camel.component.aws2.athena.Athena2Configuration;
 import org.apache.camel.component.aws2.athena.client.Athena2InternalClient;
 import org.apache.camel.util.ObjectHelper;
@@ -27,11 +29,9 @@ import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.athena.AthenaClient;
 import software.amazon.awssdk.services.athena.AthenaClientBuilder;
 
-import java.net.URI;
-
 /**
- * Manage an AWS Athena client for all users to use (enabling temporary creds). This implementation is for remote instances
- * to manage the credentials on their own (eliminating credential rotations)
+ * Manage an AWS Athena client for all users to use (enabling temporary creds). This implementation is for remote
+ * instances to manage the credentials on their own (eliminating credential rotations)
  */
 public class Athena2ClientIAMOptimizedImpl implements Athena2InternalClient {
     private static final Logger LOG = LoggerFactory.getLogger(Athena2ClientIAMOptimizedImpl.class);
diff --git a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientStandardImpl.java b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientStandardImpl.java
index 1a6665d..515131b 100644
--- a/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientStandardImpl.java
+++ b/components/camel-aws/camel-aws2-athena/src/main/java/org/apache/camel/component/aws2/athena/client/impl/Athena2ClientStandardImpl.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.aws2.athena.client.impl;
 
+import java.net.URI;
+
 import org.apache.camel.component.aws2.athena.Athena2Configuration;
 import org.apache.camel.component.aws2.athena.client.Athena2InternalClient;
 import org.apache.camel.util.ObjectHelper;
@@ -29,11 +31,9 @@ import software.amazon.awssdk.regions.Region;
 import software.amazon.awssdk.services.athena.AthenaClient;
 import software.amazon.awssdk.services.athena.AthenaClientBuilder;
 
-import java.net.URI;
-
 /**
- * Manage an AWS Athena client for all users to use. This implementation is for local instances to use a static and solid
- * credential set.
+ * Manage an AWS Athena client for all users to use. This implementation is for local instances to use a static and
+ * solid credential set.
  */
 public class Athena2ClientStandardImpl implements Athena2InternalClient {
     private static final Logger LOG = LoggerFactory.getLogger(Athena2ClientStandardImpl.class);
@@ -62,7 +62,7 @@ public class Athena2ClientStandardImpl implements Athena2InternalClient {
         if (ObjectHelper.isNotEmpty(configuration.getProxyHost()) && ObjectHelper.isNotEmpty(configuration.getProxyPort())) {
             proxyConfig = ProxyConfiguration.builder();
             URI proxyEndpoint = URI.create(configuration.getProxyProtocol() + "://" + configuration.getProxyHost() + ":"
-                    + configuration.getProxyPort());
+                                           + configuration.getProxyPort());
             proxyConfig.endpoint(proxyEndpoint);
             httpClientBuilder = ApacheHttpClient.builder().proxyConfiguration(proxyConfig.build());
             isClientConfigFound = true;
diff --git a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2AthenaComponentBuilderFactory.java b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2AthenaComponentBuilderFactory.java
index c39abb3..c5ccd68 100644
--- a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2AthenaComponentBuilderFactory.java
+++ b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/Aws2AthenaComponentBuilderFactory.java
@@ -470,6 +470,24 @@ public interface Aws2AthenaComponentBuilderFactory {
             return this;
         }
         /**
+         * Set whether the Athena client should expect to load credentials
+         * through a default credentials provider or to expect static
+         * credentials to be passed in.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: false
+         * Group: producer
+         * 
+         * @param useDefaultCredentialsProvider the value to set
+         * @return the dsl builder
+         */
+        default Aws2AthenaComponentBuilder useDefaultCredentialsProvider(
+                boolean useDefaultCredentialsProvider) {
+            doSetProperty("useDefaultCredentialsProvider", useDefaultCredentialsProvider);
+            return this;
+        }
+        /**
          * Optional max wait time in millis to wait for a successful query
          * completion. See the section 'Waiting for Query Completion and
          * Retrying Failed Queries' to learn more.
@@ -586,6 +604,7 @@ public interface Aws2AthenaComponentBuilderFactory {
             case "resetWaitTimeoutOnRetry": getOrCreateConfiguration((Athena2Component) component).setResetWaitTimeoutOnRetry((boolean) value); return true;
             case "retry": getOrCreateConfiguration((Athena2Component) component).setRetry((java.lang.String) value); return true;
             case "secretKey": getOrCreateConfiguration((Athena2Component) component).setSecretKey((java.lang.String) value); return true;
+            case "useDefaultCredentialsProvider": getOrCreateConfiguration((Athena2Component) component).setUseDefaultCredentialsProvider((boolean) value); return true;
             case "waitTimeout": getOrCreateConfiguration((Athena2Component) component).setWaitTimeout((long) value); return true;
             case "workGroup": getOrCreateConfiguration((Athena2Component) component).setWorkGroup((java.lang.String) value); return true;
             case "autowiredEnabled": ((Athena2Component) component).setAutowiredEnabled((boolean) value); return true;
diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Athena2EndpointBuilderFactory.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Athena2EndpointBuilderFactory.java
index 4b7762a..f130992 100644
--- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Athena2EndpointBuilderFactory.java
+++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/Athena2EndpointBuilderFactory.java
@@ -663,6 +663,43 @@ public interface Athena2EndpointBuilderFactory {
             return this;
         }
         /**
+         * Set whether the Athena client should expect to load credentials
+         * through a default credentials provider or to expect static
+         * credentials to be passed in.
+         * 
+         * The option is a: &lt;code&gt;boolean&lt;/code&gt; type.
+         * 
+         * Default: false
+         * Group: producer
+         * 
+         * @param useDefaultCredentialsProvider the value to set
+         * @return the dsl builder
+         */
+        default Athena2EndpointBuilder useDefaultCredentialsProvider(
+                boolean useDefaultCredentialsProvider) {
+            doSetProperty("useDefaultCredentialsProvider", useDefaultCredentialsProvider);
+            return this;
+        }
+        /**
+         * Set whether the Athena client should expect to load credentials
+         * through a default credentials provider or to expect static
+         * credentials to be passed in.
+         * 
+         * The option will be converted to a &lt;code&gt;boolean&lt;/code&gt;
+         * type.
+         * 
+         * Default: false
+         * Group: producer
+         * 
+         * @param useDefaultCredentialsProvider the value to set
+         * @return the dsl builder
+         */
+        default Athena2EndpointBuilder useDefaultCredentialsProvider(
+                String useDefaultCredentialsProvider) {
+            doSetProperty("useDefaultCredentialsProvider", useDefaultCredentialsProvider);
+            return this;
+        }
+        /**
          * Optional max wait time in millis to wait for a successful query
          * completion. See the section 'Waiting for Query Completion and
          * Retrying Failed Queries' to learn more.
diff --git a/docs/components/modules/ROOT/pages/aws2-athena-component.adoc b/docs/components/modules/ROOT/pages/aws2-athena-component.adoc
index 5ae054f..98e18fb 100644
--- a/docs/components/modules/ROOT/pages/aws2-athena-component.adoc
+++ b/docs/components/modules/ROOT/pages/aws2-athena-component.adoc
@@ -62,7 +62,7 @@ from("direct:start")
 
 
 // component options: START
-The AWS 2 Athena component supports 29 options, which are listed below.
+The AWS 2 Athena component supports 30 options, which are listed below.
 
 
 
@@ -94,6 +94,7 @@ The AWS 2 Athena component supports 29 options, which are listed below.
 | *resetWaitTimeoutOnRetry* (producer) | Reset the waitTimeout countdown in the event of a query retry. If set to true, potential max time spent waiting for queries is equal to waitTimeout x maxAttempts. See the section 'Waiting for Query Completion and Retrying Failed Queries' to learn more. | true | boolean
 | *retry* (producer) | Optional comma separated list of error types to retry the query for. Use 'retryable' to retry all retryable failure conditions (e.g. generic errors and resources exhausted), 'generic' to retry 'GENERIC_INTERNAL_ERROR' failures, 'exhausted' to retry queries that have exhausted resource limits, 'always' to always retry regardless of failure condition, or 'never' or null to never retry (default). See the section 'Waiting for Query Completion and Retrying Failed Querie [...]
 | *secretKey* (producer) | Amazon AWS Secret Key. |  | String
+| *useDefaultCredentialsProvider* (producer) | Set whether the Athena client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in | false | boolean
 | *waitTimeout* (producer) | Optional max wait time in millis to wait for a successful query completion. See the section 'Waiting for Query Completion and Retrying Failed Queries' to learn more. | 0 | long
 | *workGroup* (producer) | The workgroup to use for running the query. |  | String
 | *autowiredEnabled* (advanced) | 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 type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. | true | boolean
@@ -130,7 +131,7 @@ with the following path and query parameters:
 |===
 
 
-=== Query Parameters (27 parameters):
+=== Query Parameters (28 parameters):
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -160,6 +161,7 @@ with the following path and query parameters:
 | *resetWaitTimeoutOnRetry* (producer) | Reset the waitTimeout countdown in the event of a query retry. If set to true, potential max time spent waiting for queries is equal to waitTimeout x maxAttempts. See the section 'Waiting for Query Completion and Retrying Failed Queries' to learn more. | true | boolean
 | *retry* (producer) | Optional comma separated list of error types to retry the query for. Use 'retryable' to retry all retryable failure conditions (e.g. generic errors and resources exhausted), 'generic' to retry 'GENERIC_INTERNAL_ERROR' failures, 'exhausted' to retry queries that have exhausted resource limits, 'always' to always retry regardless of failure condition, or 'never' or null to never retry (default). See the section 'Waiting for Query Completion and Retrying Failed Querie [...]
 | *secretKey* (producer) | Amazon AWS Secret Key. |  | String
+| *useDefaultCredentialsProvider* (producer) | Set whether the Athena client should expect to load credentials through a default credentials provider or to expect static credentials to be passed in | false | boolean
 | *waitTimeout* (producer) | Optional max wait time in millis to wait for a successful query completion. See the section 'Waiting for Query Completion and Retrying Failed Queries' to learn more. | 0 | long
 | *workGroup* (producer) | The workgroup to use for running the query. |  | String
 | *clientRequestToken* (advanced) | A unique string to ensure issues queries are idempotent. It is unlikely you will need to set this. |  | String

[camel] 04/04: CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - Athena component

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 197065be1bf91361f0e87a0f2847f000b96e1702
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Apr 26 08:25:38 2021 +0200

    CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - Athena component
---
 .../resources/org/apache/camel/catalog/components/aws2-athena.json      | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-athena.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-athena.json
index eb4767a..f4e0f35 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-athena.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/aws2-athena.json
@@ -47,6 +47,7 @@
     "resetWaitTimeoutOnRetry": { "kind": "property", "displayName": "Reset Wait Timeout On Retry", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Reset the waitTimeout countdown in the event of a query retry. If set  [...]
     "retry": { "kind": "property", "displayName": "Retry", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "enum": [ "never", "always", "retryable", "exhausted", "generic" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "never", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional comma separated list o [...]
     "secretKey": { "kind": "property", "displayName": "Secret Key", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key." },
+    "useDefaultCredentialsProvider": { "kind": "property", "displayName": "Use Default Credentials Provider", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to load credentials th [...]
     "waitTimeout": { "kind": "property", "displayName": "Wait Timeout", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 0, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional max wait time in millis to wait for a successful query completion. See the section 'Waiting fo [...]
     "workGroup": { "kind": "property", "displayName": "Work Group", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The workgroup to use for running the query." },
     "autowiredEnabled": { "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 type, which t [...]
@@ -78,6 +79,7 @@
     "resetWaitTimeoutOnRetry": { "kind": "parameter", "displayName": "Reset Wait Timeout On Retry", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Reset the waitTimeout countdown in the event of a query retry. If set [...]
     "retry": { "kind": "parameter", "displayName": "Retry", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "enum": [ "never", "always", "retryable", "exhausted", "generic" ], "deprecated": false, "autowired": false, "secret": false, "defaultValue": "never", "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional comma separated list  [...]
     "secretKey": { "kind": "parameter", "displayName": "Secret Key", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": true, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Amazon AWS Secret Key." },
+    "useDefaultCredentialsProvider": { "kind": "parameter", "displayName": "Use Default Credentials Provider", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Set whether the Athena client should expect to load credentials t [...]
     "waitTimeout": { "kind": "parameter", "displayName": "Wait Timeout", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "long", "deprecated": false, "autowired": false, "secret": false, "defaultValue": 0, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "Optional max wait time in millis to wait for a successful query completion. See the section 'Waiting f [...]
     "workGroup": { "kind": "parameter", "displayName": "Work Group", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "The workgroup to use for running the query." },
     "clientRequestToken": { "kind": "parameter", "displayName": "Client Request Token", "group": "advanced", "label": "advanced", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "configurationClass": "org.apache.camel.component.aws2.athena.Athena2Configuration", "configurationField": "configuration", "description": "A unique string to ensure issues queries are idempotent. It is unlikely you will need to set this." }

[camel] 03/04: CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - Athena component

Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 446a2ba90478005b48fb188c5c1bf8299047fcc5
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Mon Apr 26 08:20:12 2021 +0200

    CAMEL-16465 - Camel-AWS: Add useDefaultCredentialProvider option to all the components - Athena component
---
 .../aws2/athena/AthenaClientFactoryTest.java       | 51 ++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/components/camel-aws/camel-aws2-athena/src/test/java/org/apache/camel/component/aws2/athena/AthenaClientFactoryTest.java b/components/camel-aws/camel-aws2-athena/src/test/java/org/apache/camel/component/aws2/athena/AthenaClientFactoryTest.java
new file mode 100644
index 0000000..4c04dcd
--- /dev/null
+++ b/components/camel-aws/camel-aws2-athena/src/test/java/org/apache/camel/component/aws2/athena/AthenaClientFactoryTest.java
@@ -0,0 +1,51 @@
+/*
+ * 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.aws2.athena;
+
+import org.apache.camel.component.aws2.athena.client.Athena2ClientFactory;
+import org.apache.camel.component.aws2.athena.client.Athena2InternalClient;
+import org.apache.camel.component.aws2.athena.client.impl.Athena2ClientIAMOptimizedImpl;
+import org.apache.camel.component.aws2.athena.client.impl.Athena2ClientStandardImpl;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class AthenaClientFactoryTest {
+
+    @Test
+    public void getStandardAthenaClientDefault() {
+        Athena2Configuration AthenaConfiguration = new Athena2Configuration();
+        Athena2InternalClient athenaClient = Athena2ClientFactory.getAWSAthenaClient(AthenaConfiguration);
+        assertTrue(athenaClient instanceof Athena2ClientStandardImpl);
+    }
+
+    @Test
+    public void getStandardAthenaClient() {
+        Athena2Configuration AthenaConfiguration = new Athena2Configuration();
+        AthenaConfiguration.setUseDefaultCredentialsProvider(false);
+        Athena2InternalClient athenaClient = Athena2ClientFactory.getAWSAthenaClient(AthenaConfiguration);
+        assertTrue(athenaClient instanceof Athena2ClientStandardImpl);
+    }
+
+    @Test
+    public void getIAMOptimizedAthenaClient() {
+        Athena2Configuration AthenaConfiguration = new Athena2Configuration();
+        AthenaConfiguration.setUseDefaultCredentialsProvider(true);
+        Athena2InternalClient athenaClient = Athena2ClientFactory.getAWSAthenaClient(AthenaConfiguration);
+        assertTrue(athenaClient instanceof Athena2ClientIAMOptimizedImpl);
+    }
+}