oscerd commented on a change in pull request #5612:
URL: https://github.com/apache/camel/pull/5612#discussion_r642781072



##########
File path: components/camel-huaweicloud-functiongraph/pom.xml
##########
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.camel</groupId>
+  <artifactId>camel-huaweicloud-functiongraph</artifactId>
+  <packaging>jar</packaging>
+  <version>3.11.0-SNAPSHOT</version>
+
+  <name>Camel FunctionGraph Component</name>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+  </properties>
+
+  <dependencyManagement>

Review comment:
       BOM is not needed here. You need to use the components pom as parent
   ```
   
       <parent>
           <groupId>org.apache.camel</groupId>
           <artifactId>camel-azure-parent</artifactId>
           <version>3.11.0-SNAPSHOT</version>
       </parent>
   ```

##########
File path: components/camel-huaweicloud-functiongraph/pom.xml
##########
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.camel</groupId>
+  <artifactId>camel-huaweicloud-functiongraph</artifactId>
+  <packaging>jar</packaging>
+  <version>3.11.0-SNAPSHOT</version>
+
+  <name>Camel FunctionGraph Component</name>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <!-- Camel BOM -->
+      <dependency>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-bom</artifactId>
+        <version>3.9.0</version>
+        <scope>import</scope>
+        <type>pom</type>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+
+    <!-- camel -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-support</artifactId>
+    </dependency>
+
+    <!-- HuaweiCloud SDK v3 -->
+    <dependency>
+      <groupId>com.huaweicloud.sdk</groupId>
+      <artifactId>huaweicloud-sdk-functiongraph</artifactId>
+      <version>3.0.43-rc</version>

Review comment:
       Use the version from parent pom.

##########
File path: 
components/camel-huaweicloud-functiongraph/src/main/java/org/apache/camel/FunctionGraphEndpoint.java
##########
@@ -0,0 +1,244 @@
+/*
+ * 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;
+
+import com.huaweicloud.sdk.functiongraph.v2.FunctionGraphClient;
+import org.apache.camel.Category;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.models.ServiceKeys;
+import org.apache.camel.support.DefaultEndpoint;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+
+import java.util.concurrent.ExecutorService;
+
+/**
+ * Huawei Cloud component to integrate with FunctionGraph services
+ */
+@UriEndpoint(firstVersion = "3.11.0-SNAPSHOT", scheme = 
"hwcloud-functiongraph", title = "FunctionGraph", 
syntax="hwcloud-functiongraph:operation",
+             category = {Category.CLOUD, Category.SERVERLESS}, producerOnly = 
true)
+public class FunctionGraphEndpoint extends DefaultEndpoint {
+
+    @UriPath(description = "Operation to be performed", displayName = 
"Operation", label = "producer", secret = false)
+    @Metadata(required = true)
+    private String operation;
+
+    @UriParam(description = "FunctionGraph service region. This is lower 
precedence than endpoint based configuration",
+            displayName = "Service region", secret = false)
+    @Metadata(required = true)
+    private String region;
+
+    @UriParam(description = "Cloud project ID", displayName = "Project ID", 
secret = false)
+    @Metadata(required = true)
+    private String projectId;
+
+    @UriParam(description = "Functions that can be logically grouped together",
+            displayName = "Function package", secret = false)
+    @Metadata(required = false)
+    private String functionPackage;
+
+    @UriParam(description = "Name of the function to invoke",
+            displayName = "Function name", secret = false)
+    @Metadata(required = false)
+    private String functionName;
+
+    @UriParam(description = "Proxy server ip/hostname", displayName = "Proxy 
server host", secret = false)
+    @Metadata(required = false)
+    private String proxyHost;
+
+    @UriParam(description = "Proxy server port", displayName = "Proxy server 
port", secret = false)
+    @Metadata(required = false)
+    private int proxyPort;
+
+    @UriParam(description = "Proxy authentication user", displayName = "Proxy 
user", secret = true)
+    @Metadata(required = false)
+    private String proxyUser;
+
+    @UriParam(description = "Proxy authentication password", displayName = 
"Proxy password", secret = true)
+    @Metadata(required = false)
+    private String proxyPassword;
+
+    @UriParam(description = "Ignore SSL verification", displayName = "SSL 
Verification Ignored", secret = false,
+            defaultValue = "false")
+    @Metadata(required = false)
+    private boolean ignoreSslVerification;
+
+    @UriParam(description = "FunctionGraph url. Carries higher precedence than 
region parameter based client initialization",
+            displayName = "Service endpoint", secret = false)
+    @Metadata(required = false)
+    private String endpoint;
+
+    @UriParam(description = "Configuration object for cloud service 
authentication", displayName = "Service Configuration",
+            secret = true)
+    @Metadata(required = false)
+    private ServiceKeys serviceKeys;
+
+    @UriParam(description = "Authentication key for the cloud user", 
displayName = "API authentication key (AK)", secret = true)
+    @Metadata(required = true)
+    private String authenticationKey;
+
+    @UriParam(description = "Secret key for the cloud user", displayName = 
"API secret key (SK)", secret = true)
+    @Metadata(required = true)
+    private String secretKey;
+
+    private FunctionGraphClient functionGraphClient;
+
+    public FunctionGraphEndpoint() {
+    }
+
+    public FunctionGraphEndpoint(String uri, String operation, 
FunctionGraphComponent component) {
+        super(uri, component);
+        this.operation = operation;
+    }
+
+    public Producer createProducer() throws Exception {
+        return new FunctionGraphProducer(this);
+    }
+
+    public Consumer createConsumer(Processor processor) throws Exception {
+        throw new UnsupportedOperationException("You cannot receive messages 
from this endpoint");
+    }
+
+    public String getRegion() {
+        return region;
+    }
+
+    public void setRegion(String region) {
+        this.region = region;
+    }
+
+    public String getProjectId() {
+        return projectId;
+    }
+
+    public void setProjectId(String projectId) {
+        this.projectId = projectId;
+    }
+
+    public String getFunctionPackage() {
+        return functionPackage;
+    }
+
+    public void setFunctionPackage(String functionPackage) {
+        this.functionPackage = functionPackage;
+    }
+
+    public String getFunctionName() {
+        return functionName;
+    }
+
+    public void setFunctionName(String functionName) {
+        this.functionName = functionName;
+    }
+
+    public String getOperation() {
+        return operation;
+    }
+
+    public void setOperation(String operation) {
+        this.operation = operation;
+    }
+
+    public String getProxyHost() {
+        return proxyHost;
+    }
+
+    public void setProxyHost(String proxyHost) {
+        this.proxyHost = proxyHost;
+    }
+
+    public int getProxyPort() {
+        return proxyPort;
+    }
+
+    public void setProxyPort(int proxyPort) {
+        this.proxyPort = proxyPort;
+    }
+
+    public String getProxyUser() {
+        return proxyUser;
+    }
+
+    public void setProxyUser(String proxyUser) {
+        this.proxyUser = proxyUser;
+    }
+
+    public String getProxyPassword() {
+        return proxyPassword;
+    }
+
+    public void setProxyPassword(String proxyPassword) {
+        this.proxyPassword = proxyPassword;
+    }
+
+    public boolean isIgnoreSslVerification() {
+        return ignoreSslVerification;
+    }
+
+    public void setIgnoreSslVerification(boolean ignoreSslVerification) {
+        this.ignoreSslVerification = ignoreSslVerification;
+    }
+
+    public String getEndpoint() {
+        return endpoint;
+    }
+
+    public void setEndpoint(String endpoint) {
+        this.endpoint = endpoint;
+    }
+
+    public ServiceKeys getServiceKeys() {
+        return serviceKeys;
+    }
+
+    public void setServiceKeys(ServiceKeys serviceKeys) {
+        this.serviceKeys = serviceKeys;
+    }
+
+    public String getAuthenticationKey() {
+        return authenticationKey;
+    }
+
+    public void setAuthenticationKey(String authenticationKey) {
+        this.authenticationKey = authenticationKey;
+    }
+
+    public String getSecretKey() {
+        return secretKey;
+    }
+
+    public void setSecretKey(String secretKey) {
+        this.secretKey = secretKey;
+    }
+
+    public FunctionGraphClient getFunctionGraphClient() {
+        return functionGraphClient;
+    }
+
+    public void setFunctionGraphClient(FunctionGraphClient 
functionGraphClient) {
+        this.functionGraphClient = functionGraphClient;
+    }
+
+    public ExecutorService createExecutor() {
+        // TODO: Delete me when you implemented your custom component

Review comment:
       Fix or remove the TODO

##########
File path: components/camel-huaweicloud-functiongraph/pom.xml
##########
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.camel</groupId>
+  <artifactId>camel-huaweicloud-functiongraph</artifactId>
+  <packaging>jar</packaging>
+  <version>3.11.0-SNAPSHOT</version>
+
+  <name>Camel FunctionGraph Component</name>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <!-- Camel BOM -->
+      <dependency>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-bom</artifactId>
+        <version>3.9.0</version>
+        <scope>import</scope>
+        <type>pom</type>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+
+    <!-- camel -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-support</artifactId>
+    </dependency>
+
+    <!-- HuaweiCloud SDK v3 -->
+    <dependency>
+      <groupId>com.huaweicloud.sdk</groupId>
+      <artifactId>huaweicloud-sdk-functiongraph</artifactId>
+      <version>3.0.43-rc</version>
+    </dependency>
+
+    <dependency>
+      <groupId>com.google.code.gson</groupId>
+      <artifactId>gson</artifactId>
+      <version>2.8.6</version>

Review comment:
       Same

##########
File path: components/camel-huaweicloud-functiongraph/pom.xml
##########
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.camel</groupId>
+  <artifactId>camel-huaweicloud-functiongraph</artifactId>
+  <packaging>jar</packaging>
+  <version>3.11.0-SNAPSHOT</version>
+
+  <name>Camel FunctionGraph Component</name>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <!-- Camel BOM -->
+      <dependency>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-bom</artifactId>
+        <version>3.9.0</version>
+        <scope>import</scope>
+        <type>pom</type>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+
+    <!-- camel -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-support</artifactId>
+    </dependency>
+
+    <!-- HuaweiCloud SDK v3 -->
+    <dependency>
+      <groupId>com.huaweicloud.sdk</groupId>
+      <artifactId>huaweicloud-sdk-functiongraph</artifactId>
+      <version>3.0.43-rc</version>
+    </dependency>
+
+    <dependency>
+      <groupId>com.google.code.gson</groupId>
+      <artifactId>gson</artifactId>
+      <version>2.8.6</version>
+    </dependency>
+
+    <!-- logging -->
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <version>2.13.3</version>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- testing -->
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <version>5.7.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <defaultGoal>install</defaultGoal>
+
+    <plugins>
+      
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <version>3.8.1</version>

Review comment:
       Take as example the other components, all of this stuff will be 
inherited from components pom and parent pom and camel pom.

##########
File path: components/camel-huaweicloud-functiongraph/pom.xml
##########
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.camel</groupId>
+  <artifactId>camel-huaweicloud-functiongraph</artifactId>
+  <packaging>jar</packaging>
+  <version>3.11.0-SNAPSHOT</version>
+
+  <name>Camel FunctionGraph Component</name>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <!-- Camel BOM -->
+      <dependency>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-bom</artifactId>
+        <version>3.9.0</version>
+        <scope>import</scope>
+        <type>pom</type>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+
+    <!-- camel -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-support</artifactId>
+    </dependency>
+
+    <!-- HuaweiCloud SDK v3 -->
+    <dependency>
+      <groupId>com.huaweicloud.sdk</groupId>
+      <artifactId>huaweicloud-sdk-functiongraph</artifactId>
+      <version>3.0.43-rc</version>
+    </dependency>
+
+    <dependency>
+      <groupId>com.google.code.gson</groupId>
+      <artifactId>gson</artifactId>
+      <version>2.8.6</version>
+    </dependency>
+
+    <!-- logging -->
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <version>2.13.3</version>

Review comment:
       Same

##########
File path: components/camel-huaweicloud-functiongraph/pom.xml
##########
@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd";>
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.camel</groupId>
+  <artifactId>camel-huaweicloud-functiongraph</artifactId>
+  <packaging>jar</packaging>
+  <version>3.11.0-SNAPSHOT</version>
+
+  <name>Camel FunctionGraph Component</name>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+  </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <!-- Camel BOM -->
+      <dependency>
+        <groupId>org.apache.camel</groupId>
+        <artifactId>camel-bom</artifactId>
+        <version>3.9.0</version>
+        <scope>import</scope>
+        <type>pom</type>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
+  <dependencies>
+
+    <!-- camel -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-support</artifactId>
+    </dependency>
+
+    <!-- HuaweiCloud SDK v3 -->
+    <dependency>
+      <groupId>com.huaweicloud.sdk</groupId>
+      <artifactId>huaweicloud-sdk-functiongraph</artifactId>
+      <version>3.0.43-rc</version>
+    </dependency>
+
+    <dependency>
+      <groupId>com.google.code.gson</groupId>
+      <artifactId>gson</artifactId>
+      <version>2.8.6</version>
+    </dependency>
+
+    <!-- logging -->
+    <dependency>
+      <groupId>org.apache.logging.log4j</groupId>
+      <artifactId>log4j-slf4j-impl</artifactId>
+      <version>2.13.3</version>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- testing -->
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <version>5.7.0</version>

Review comment:
       Same

##########
File path: 
components/camel-huaweicloud-functiongraph/src/main/java/org/apache/camel/FunctionGraphProducer.java
##########
@@ -0,0 +1,246 @@
+/*
+ * 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;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.huaweicloud.sdk.core.auth.BasicCredentials;
+import com.huaweicloud.sdk.core.http.HttpConfig;
+import com.huaweicloud.sdk.functiongraph.v2.FunctionGraphClient;
+import com.huaweicloud.sdk.functiongraph.v2.model.InvokeFunctionRequest;
+import com.huaweicloud.sdk.functiongraph.v2.model.InvokeFunctionResponse;
+import com.huaweicloud.sdk.functiongraph.v2.region.FunctionGraphRegion;
+import org.apache.camel.constants.FunctionGraphConstants;
+import org.apache.camel.constants.FunctionGraphOperations;
+import org.apache.camel.constants.FunctionGraphProperties;
+import org.apache.camel.models.ClientConfigurations;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class FunctionGraphProducer extends DefaultProducer {
+    private static final Logger LOG = 
LoggerFactory.getLogger(FunctionGraphProducer.class);
+    private FunctionGraphEndpoint endpoint;
+    private ClientConfigurations clientConfigurations;
+    private FunctionGraphClient functionGraphClient;
+    private BasicCredentials auth;
+    private HttpConfig httpConfig;
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        this.clientConfigurations = new ClientConfigurations(this.endpoint);
+        initClient();
+    }
+
+    public FunctionGraphProducer(FunctionGraphEndpoint endpoint) {
+        super(endpoint);
+        this.endpoint = endpoint;
+    }
+
+    public void process(Exchange exchange) throws Exception {
+        updateClientConfigs(exchange);
+
+        switch (clientConfigurations.getOperation()) {
+            case FunctionGraphOperations.INVOKE_FUNCTION:
+                invokeFunction(exchange);
+                break;
+            default:
+                throw new UnsupportedOperationException(String.format("%s is 
not a supported operation", clientConfigurations.getOperation()));
+        }
+    }
+
+    private void invokeFunction(Exchange exchange) {
+
+        // convert exchange body to Map object
+        Object body = exchange.getMessage().getBody();
+        Map request;
+        if (body == null) {
+            if (LOG.isErrorEnabled()) {
+                LOG.error("Exchange body is null");
+            }
+            throw new IllegalArgumentException("Exchange body is mandatory and 
should be a valid Map or JSON string");
+        } else if (body instanceof Map) {
+            request = exchange.getMessage().getBody(Map.class);
+        } else {
+            String strBody = exchange.getMessage().getBody(String.class);
+            try {
+                request = new ObjectMapper().readValue(strBody, HashMap.class);
+            } catch (JsonProcessingException e) {
+                if (LOG.isErrorEnabled()) {
+                    LOG.error("Invalid response body given");
+                }
+                throw new IllegalArgumentException("Request body must be a 
JSON or a HashMap");
+            }
+        }
+
+        // checking for function name and function package
+        if (ObjectHelper.isEmpty(clientConfigurations.getFunctionName())) {
+            if (LOG.isErrorEnabled()) {
+                LOG.error("Function name not found.");
+            }
+            throw new IllegalArgumentException("Function name is mandatory for 
invokeFunction.");
+        }
+        if 
(ObjectHelper.isEmpty(exchange.getProperty(FunctionGraphProperties.FUNCTION_PACKAGE))
+                && ObjectHelper.isEmpty(endpoint.getFunctionPackage())) {
+            if (LOG.isWarnEnabled()) {
+                LOG.warn("Function package not found. Continuing to invoke 
function with 'default' function package");
+            }
+        }
+
+        // invoke the function
+        InvokeFunctionRequest invokeFunctionRequest = new 
InvokeFunctionRequest()
+                .withBody(request)
+                
.withFunctionUrn(FunctionGraphUtils.composeUrn(FunctionGraphConstants.URN_FORMAT,
 clientConfigurations))
+                
.withXCFFRequestVersion(FunctionGraphConstants.REQUEST_VERSION);
+
+        if (ObjectHelper.isNotEmpty(clientConfigurations.getXCffLogType())) {
+            
invokeFunctionRequest.withXCffLogType(clientConfigurations.getXCffLogType());
+        }
+
+        InvokeFunctionResponse response = 
functionGraphClient.invokeFunction(invokeFunctionRequest);
+        String responseBody = 
FunctionGraphUtils.extractJsonFieldAsString(response.getResult(), 
FunctionGraphConstants.RESPONSE_BODY);
+        exchange.getMessage().setBody(responseBody);
+        if (ObjectHelper.isNotEmpty(clientConfigurations.getXCffLogType())) {
+            exchange.setProperty(FunctionGraphProperties.XCFFLOGS, 
response.getLog());
+        }
+        LOG.info("Invoke Function results: " + response);
+    }
+
+    /**
+     * Initialize the client
+     */
+    private void initClient() {

Review comment:
       This should be done in the endpoint. I don't think you'll change the 
client options many times. So it makes sense to do this just one time in 
endpoint and use client instance in producer.

##########
File path: 
components/camel-huaweicloud-functiongraph/src/main/java/org/apache/camel/FunctionGraphProducer.java
##########
@@ -0,0 +1,246 @@
+/*
+ * 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;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.huaweicloud.sdk.core.auth.BasicCredentials;
+import com.huaweicloud.sdk.core.http.HttpConfig;
+import com.huaweicloud.sdk.functiongraph.v2.FunctionGraphClient;
+import com.huaweicloud.sdk.functiongraph.v2.model.InvokeFunctionRequest;
+import com.huaweicloud.sdk.functiongraph.v2.model.InvokeFunctionResponse;
+import com.huaweicloud.sdk.functiongraph.v2.region.FunctionGraphRegion;
+import org.apache.camel.constants.FunctionGraphConstants;
+import org.apache.camel.constants.FunctionGraphOperations;
+import org.apache.camel.constants.FunctionGraphProperties;
+import org.apache.camel.models.ClientConfigurations;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class FunctionGraphProducer extends DefaultProducer {
+    private static final Logger LOG = 
LoggerFactory.getLogger(FunctionGraphProducer.class);
+    private FunctionGraphEndpoint endpoint;
+    private ClientConfigurations clientConfigurations;
+    private FunctionGraphClient functionGraphClient;
+    private BasicCredentials auth;
+    private HttpConfig httpConfig;
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        this.clientConfigurations = new ClientConfigurations(this.endpoint);
+        initClient();
+    }
+
+    public FunctionGraphProducer(FunctionGraphEndpoint endpoint) {
+        super(endpoint);
+        this.endpoint = endpoint;
+    }
+
+    public void process(Exchange exchange) throws Exception {
+        updateClientConfigs(exchange);
+
+        switch (clientConfigurations.getOperation()) {
+            case FunctionGraphOperations.INVOKE_FUNCTION:

Review comment:
       Are there plan to implement more operations? Otherwise there is not the 
need to the switch.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to