This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch CAMEL-20798-gcp in repository https://gitbox.apache.org/repos/asf/camel.git
commit 6c43495ccdfcb40f654da0943e21a0e2d12ee2fb Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Fri Jun 28 11:13:48 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 - Google Storage Signed-off-by: Andrea Cosentino <anco...@gmail.com> --- .../google/storage/GoogleCloudStorageEndpoint.java | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/components/camel-google/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageEndpoint.java b/components/camel-google/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageEndpoint.java index b28ab11c6cf..41e3e1fea62 100644 --- a/components/camel-google/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageEndpoint.java +++ b/components/camel-google/camel-google-storage/src/main/java/org/apache/camel/component/google/storage/GoogleCloudStorageEndpoint.java @@ -25,12 +25,16 @@ import org.apache.camel.Category; import org.apache.camel.Consumer; import org.apache.camel.Processor; import org.apache.camel.Producer; +import org.apache.camel.spi.EndpointServiceLocation; import org.apache.camel.spi.UriEndpoint; import org.apache.camel.spi.UriParam; import org.apache.camel.support.ScheduledPollEndpoint; +import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.util.Map; + /** * Store and retrieve objects from Google Cloud Storage Service using the google-cloud-storage library. * @@ -39,7 +43,7 @@ import org.slf4j.LoggerFactory; */ @UriEndpoint(firstVersion = "3.9.0", scheme = "google-storage", title = "Google Storage", syntax = "google-storage:bucketName", category = { Category.CLOUD }, headersClass = GoogleCloudStorageConstants.class) -public class GoogleCloudStorageEndpoint extends ScheduledPollEndpoint { +public class GoogleCloudStorageEndpoint extends ScheduledPollEndpoint implements EndpointServiceLocation { private static final Logger LOG = LoggerFactory.getLogger(GoogleCloudStorageEndpoint.class); @@ -120,4 +124,26 @@ public class GoogleCloudStorageEndpoint extends ScheduledPollEndpoint { return storageClient; } + @Override + public String getServiceUrl() { + if (ObjectHelper.isNotEmpty(configuration.getBucketName()) && ObjectHelper.isNotEmpty(configuration.getStorageLocation())) { + return getServiceProtocol() + ":" + configuration.getStorageLocation() + ":" + + configuration.getBucketName(); + } + return null; + } + + @Override + public String getServiceProtocol() { + return "storage"; + } + + @Override + public Map<String, String> getServiceMetadata() { + if (configuration.getStorageClass() != null) { + return Map.of("storageClass", configuration.getStorageClass().name()); + } + return null; + } + }