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
The following commit(s) were added to refs/heads/main by this push:
new ed0fe0a745f CAMEL-20798: EndpointServiceLocation on components to make
it possible to know which remote system Camel connects to to assist for
monitoring and observability - AWS S3 (#14274)
ed0fe0a745f is described below
commit ed0fe0a745feec80bd0f44f6dcbfe26ea96283ff
Author: Andrea Cosentino <[email protected]>
AuthorDate: Wed May 29 13:08:05 2024 +0200
CAMEL-20798: EndpointServiceLocation on components to make it possible to
know which remote system Camel connects to to assist for monitoring and
observability - AWS S3 (#14274)
Signed-off-by: Andrea Cosentino <[email protected]>
---
.../camel/component/aws2/s3/AWS2S3Endpoint.java | 34 +++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git
a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Endpoint.java
b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Endpoint.java
index 0e137a18853..df222e918a2 100644
---
a/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Endpoint.java
+++
b/components/camel-aws/camel-aws2-s3/src/main/java/org/apache/camel/component/aws2/s3/AWS2S3Endpoint.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.component.aws2.s3;
+import java.util.Map;
+
import org.apache.camel.Category;
import org.apache.camel.Component;
import org.apache.camel.Consumer;
@@ -23,6 +25,7 @@ import org.apache.camel.Processor;
import org.apache.camel.Producer;
import org.apache.camel.component.aws2.s3.client.AWS2S3ClientFactory;
import org.apache.camel.component.aws2.s3.stream.AWS2S3StreamUploadProducer;
+import org.apache.camel.spi.EndpointServiceLocation;
import org.apache.camel.spi.Metadata;
import org.apache.camel.spi.UriEndpoint;
import org.apache.camel.spi.UriParam;
@@ -43,7 +46,7 @@ import
software.amazon.awssdk.services.s3.model.PutBucketPolicyRequest;
@UriEndpoint(firstVersion = "3.2.0", scheme = "aws2-s3", title = "AWS S3
Storage Service",
syntax = "aws2-s3://bucketNameOrArn", category = {
Category.CLOUD, Category.FILE },
headersClass = AWS2S3Constants.class)
-public class AWS2S3Endpoint extends ScheduledPollEndpoint {
+public class AWS2S3Endpoint extends ScheduledPollEndpoint implements
EndpointServiceLocation {
private static final Logger LOG =
LoggerFactory.getLogger(AWS2S3Endpoint.class);
@@ -64,6 +67,35 @@ public class AWS2S3Endpoint extends ScheduledPollEndpoint {
this.configuration = configuration;
}
+ @Override
+ public String getServiceUrl() {
+ if (!configuration.isOverrideEndpoint()) {
+ if (configuration.isForcePathStyle()) {
+ return getServiceProtocol() + "." + configuration.getRegion()
+ "." + ".amazonaws.com" + "/"
+ + configuration.getBucketName() + "/";
+ } else {
+ return configuration.getBucketName() + "." +
configuration.getRegion() + "." + getServiceProtocol()
+ + ".amazonaws.com/";
+ }
+ } else if
(ObjectHelper.isNotEmpty(configuration.getUriEndpointOverride())) {
+ return configuration.getUriEndpointOverride();
+ }
+ return null;
+ }
+
+ @Override
+ public String getServiceProtocol() {
+ return "s3";
+ }
+
+ @Override
+ public Map<String, String> getServiceMetadata() {
+ if (configuration.getRegion() != null) {
+ return Map.of("region", configuration.getRegion());
+ }
+ return null;
+ }
+
@Override
public Consumer createConsumer(Processor processor) throws Exception {
AWS2S3Consumer s3Consumer = new AWS2S3Consumer(this, processor);