= Huawei FunctionGraph Component
:doctitle: Huawei FunctionGraph
:shortname: hwcloud-functiongraph
:artifactid: camel-huaweicloud-functiongraph
:description: To call serverless functions on Huawei Cloud
:since: 3.11
:supportlevel: Stable
:component-header: Only producer is supported
//Manually maintained attributes
:group: Huawei Cloud
:camel-spring-boot-name: huaweicloud-functiongraph

*Since Camel {since}*

*{component-header}*

Huawei Cloud FunctionGraph component allows you to integrate with https://www.huaweicloud.com/intl/en-us/product/functiongraph.html[FunctionGraph] provided by Huawei Cloud.

Maven users will need to add the following dependency to their `pom.xml` for this component:

[source,xml]
----
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-huaweicloud-functiongraph</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>
----

== URI Format

----
hwcloud-functiongraph:operation[?options]
----


// component-configure options: START

// component-configure options: END

// component options: START
include::partial$component-configure-options.adoc[]
include::partial$component-endpoint-options.adoc[]
// component options: END

// endpoint options: START

// endpoint options: END


== Usage

=== Message properties evaluated by the FunctionGraph producer

[width="100%",cols="10%,10%,80%",options="header",]
|=======================================================================
|Header |Type |Description

|`CamelHwCloudFgOperation` |`String` | Name of operation to invoke

|`CamelHwCloudFgFunction` |`String` | Name of function to invoke operation on

|`CamelHwCloudFgPackage` |`String` | Name of the function package

|`CamelHwCloudFgXCffLogType` | `String` | Type of log to be returned by FunctionGraph operation

|=======================================================================

If the operation, function name, or function package are set, they will override their corresponding query parameter.

=== Message properties set by the FunctionGraph producer

[width="100%",cols="10%,10%,80%",options="header",]
|=======================================================================
|Header |Type |Description

|`CamelHwCloudFgXCffLogs` |`String` | Unique log returned by FunctionGraph after processing the request if `CamelHwCloudFgXCffLogType` is set

|=======================================================================


== List of Supported FunctionGraph Operations

- invokeFunction - to invoke a serverless function

== Using ServiceKey Configuration Bean

Access key and secret keys are required to authenticate against cloud FunctionGraph service. You can avoid having them being exposed
and scattered over in your endpoint uri by wrapping them inside a bean of class `org.apache.camel.component.huaweicloud.functiongraph.models.ServiceKeys`.
Add it to the registry and let Camel look it up by referring the object via endpoint query parameter `serviceKeys`.

Check the following code snippets:

[source,xml]
----
<bean id="myServiceKeyConfig" class="org.apache.camel.component.huaweicloud.functiongraph.models.ServiceKeys">
   <property name="accessKey" value="your_access_key" />
   <property name="secretKey" value="your_secret_key" />
</bean>
----
[source,java]
----
from("direct:triggerRoute")
 .setProperty(FunctionGraphProperties.OPERATION, constant("invokeFunction"))
 .setProperty(FunctionGraphProperties.FUNCTION_NAME ,constant("your_function_name"))
 .setProperty(FunctionGraphProperties.FUNCTION_PACKAGE, constant("your_function_package"))
 .to("hwcloud-functiongraph:invokeFunction?projectId=9071a38e7f6a4ba7b7bcbeb7d4ea6efc&region=cn-north-4&serviceKeys=#myServiceKeyConfig")
----


include::spring-boot:partial$starter.adoc[]
