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 73840de29cee5c0654a76bd0318d242ccb1c9383
Author: Andrea Cosentino <anco...@gmail.com>
AuthorDate: Fri Jun 28 10:54:13 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 Functions
    
    Signed-off-by: Andrea Cosentino <anco...@gmail.com>
---
 .../google/functions/GoogleCloudFunctionsEndpoint.java | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git 
a/components/camel-google/camel-google-functions/src/main/java/org/apache/camel/component/google/functions/GoogleCloudFunctionsEndpoint.java
 
b/components/camel-google/camel-google-functions/src/main/java/org/apache/camel/component/google/functions/GoogleCloudFunctionsEndpoint.java
index faf6f59e42b..090a58f1408 100644
--- 
a/components/camel-google/camel-google-functions/src/main/java/org/apache/camel/component/google/functions/GoogleCloudFunctionsEndpoint.java
+++ 
b/components/camel-google/camel-google-functions/src/main/java/org/apache/camel/component/google/functions/GoogleCloudFunctionsEndpoint.java
@@ -21,9 +21,13 @@ 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.DefaultEndpoint;
+import org.apache.camel.util.ObjectHelper;
+
+import java.util.Map;
 
 /**
  * Manage and invoke Google Cloud Functions
@@ -35,7 +39,7 @@ import org.apache.camel.support.DefaultEndpoint;
              syntax = "google-functions:functionName", category = {
                      Category.CLOUD },
              producerOnly = true, headersClass = 
GoogleCloudFunctionsConstants.class)
-public class GoogleCloudFunctionsEndpoint extends DefaultEndpoint {
+public class GoogleCloudFunctionsEndpoint extends DefaultEndpoint implements 
EndpointServiceLocation {
 
     @UriParam
     private GoogleCloudFunctionsConfiguration configuration;
@@ -90,4 +94,16 @@ public class GoogleCloudFunctionsEndpoint extends 
DefaultEndpoint {
         return cloudFunctionsClient;
     }
 
+    @Override
+    public String getServiceUrl() {
+        if (ObjectHelper.isNotEmpty(configuration.getFunctionName()) && 
ObjectHelper.isNotEmpty(ObjectHelper.isNotEmpty(configuration.getProject()) && 
ObjectHelper.isNotEmpty(configuration.getLocation()))) {
+            return getServiceProtocol() + ":" + configuration.getProject() + 
":" + configuration.getFunctionName() + ":" + configuration.getLocation();
+        }
+        return null;
+    }
+
+    @Override
+    public String getServiceProtocol() {
+        return "functions";
+    }
 }

Reply via email to