This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit fd6a9e610cdf67a48f587326d5365a3ab45f686c Author: Claus Ibsen <[email protected]> AuthorDate: Wed Jun 9 16:10:12 2021 +0200 CAMEL-16674: Polished --- .../docs/hwcloud-functiongraph-component.adoc | 40 ++--- components/camel-huaweicloud-functiongraph/pom.xml | 6 +- .../services/org/apache/camel/component.properties | 2 +- .../org/apache/camel/hwcloud-functiongraph.json | 18 +-- .../main/docs/hwcloud-functiongraph-component.adoc | 40 ++--- .../org/apache/camel/FunctionGraphEndpoint.java | 18 ++- .../org/apache/camel/FunctionGraphProducer.java | 28 +--- .../java/org/apache/camel/FunctionGraphUtils.java | 11 -- .../apache/camel/component/hwcloud-functiongraph | 1 - .../src/test/resources/log4j2.properties | 16 +- .../component/ComponentsBuilderFactory.java | 2 +- ...wcloudFunctiongraphComponentBuilderFactory.java | 4 +- .../src/generated/resources/metadata.json | 2 +- .../builder/endpoint/StaticEndpointBuilders.java | 4 +- .../dsl/FunctionGraphEndpointBuilderFactory.java | 168 ++++++++++----------- .../pages/hwcloud-functiongraph-component.adoc | 40 ++--- 16 files changed, 193 insertions(+), 207 deletions(-) diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/hwcloud-functiongraph-component.adoc b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/hwcloud-functiongraph-component.adoc index b85d198..8d27012 100644 --- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/hwcloud-functiongraph-component.adoc +++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/docs/hwcloud-functiongraph-component.adoc @@ -2,7 +2,7 @@ = FunctionGraph Component :docTitle: FunctionGraph :artifactId: camel-huaweicloud-functiongraph -:description: Huawei Cloud component to integrate with FunctionGraph services +:description: To call serverless functions on Huawei Cloud :since: 3.11 :supportLevel: Preview :component-header: Only producer is supported @@ -17,21 +17,21 @@ Huawei Cloud FunctionGraph component allows you to integrate with https://www.hu Maven users will need to add the following dependency to their `pom.xml` for this component: [source,xml] ------------------------------------------------------------- +---- <dependency> <groupId>org.apache.camel</groupId>git <artifactId>camel-huaweicloud-functiongraph</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency> ------------------------------------------------------------- +---- == URI Format -[source,java] -------------------------------- +[source,text] +---- hwcloud-functiongraph:operation[?options] -------------------------------- +---- == URI Options @@ -74,20 +74,20 @@ with the following path and query parameters: [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type -| *authenticationKey* (producer) | *Required* Authentication key for the cloud user | | String | *endpoint* (producer) | FunctionGraph url. Carries higher precedence than region parameter based client initialization | | String | *functionName* (producer) | Name of the function to invoke | | String | *functionPackage* (producer) | Functions that can be logically grouped together | | String -| *ignoreSslVerification* (producer) | Ignore SSL verification | false | boolean | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...] | *projectId* (producer) | *Required* Cloud project ID | | String -| *proxyHost* (producer) | Proxy server ip/hostname | | String -| *proxyPassword* (producer) | Proxy authentication password | | String -| *proxyPort* (producer) | Proxy server port | | int -| *proxyUser* (producer) | Proxy authentication user | | String | *region* (producer) | *Required* FunctionGraph service region. This is lower precedence than endpoint based configuration | | String -| *secretKey* (producer) | *Required* Secret key for the cloud user | | String | *serviceKeys* (producer) | Configuration object for cloud service authentication | | ServiceKeys +| *proxyHost* (proxy) | Proxy server ip/hostname | | String +| *proxyPassword* (proxy) | Proxy authentication password | | String +| *proxyPort* (proxy) | Proxy server port | | int +| *proxyUser* (proxy) | Proxy authentication user | | String +| *authenticationKey* (security) | *Required* Authentication key for the cloud user | | String +| *ignoreSslVerification* (security) | Ignore SSL verification | false | boolean +| *secretKey* (security) | *Required* Secret key for the cloud user | | String |=== // endpoint options: END @@ -125,13 +125,15 @@ If the operation, function name, or function package are set, they will override == List of Supported FunctionGraph Operations -- invokeFunction +- invokeFunction - to invoke a serverless function == Using ServiceKey Configuration Bean + Authentication key and secret keys are required to authenticate against cloud smn 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 +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] ---- @@ -141,10 +143,10 @@ Check the following code snippets </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®ion=cn-north-4&serviceKeys=#myServiceKeyConfig") --------------------------------------------------------------------------------- +---- diff --git a/components/camel-huaweicloud-functiongraph/pom.xml b/components/camel-huaweicloud-functiongraph/pom.xml index a13ceca..bd6b319 100644 --- a/components/camel-huaweicloud-functiongraph/pom.xml +++ b/components/camel-huaweicloud-functiongraph/pom.xml @@ -1,17 +1,21 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- + 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. + --> <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"> @@ -27,7 +31,7 @@ <artifactId>camel-huaweicloud-functiongraph</artifactId> <packaging>jar</packaging> <name>Camel :: Huawei Cloud FunctionGraph Component</name> - <description>A Camel Huawei Cloud FunctionGraph Component</description> + <description>To call serverless functions on Huawei Cloud</description> <dependencies> diff --git a/components/camel-huaweicloud-functiongraph/src/generated/resources/META-INF/services/org/apache/camel/component.properties b/components/camel-huaweicloud-functiongraph/src/generated/resources/META-INF/services/org/apache/camel/component.properties index 46dd860..410f4c5 100644 --- a/components/camel-huaweicloud-functiongraph/src/generated/resources/META-INF/services/org/apache/camel/component.properties +++ b/components/camel-huaweicloud-functiongraph/src/generated/resources/META-INF/services/org/apache/camel/component.properties @@ -4,4 +4,4 @@ groupId=org.apache.camel artifactId=camel-huaweicloud-functiongraph version=3.11.0-SNAPSHOT projectName=Camel :: Huawei Cloud FunctionGraph Component -projectDescription=A Camel Huawei Cloud FunctionGraph Component +projectDescription=To call serverless functions on Huawei Cloud diff --git a/components/camel-huaweicloud-functiongraph/src/generated/resources/org/apache/camel/hwcloud-functiongraph.json b/components/camel-huaweicloud-functiongraph/src/generated/resources/org/apache/camel/hwcloud-functiongraph.json index 1bf3bc8..9aff16d 100644 --- a/components/camel-huaweicloud-functiongraph/src/generated/resources/org/apache/camel/hwcloud-functiongraph.json +++ b/components/camel-huaweicloud-functiongraph/src/generated/resources/org/apache/camel/hwcloud-functiongraph.json @@ -3,7 +3,7 @@ "kind": "component", "name": "hwcloud-functiongraph", "title": "FunctionGraph", - "description": "Huawei Cloud component to integrate with FunctionGraph services", + "description": "To call serverless functions on Huawei Cloud", "deprecated": false, "firstVersion": "3.11.0", "label": "cloud,serverless", @@ -27,19 +27,19 @@ }, "properties": { "operation": { "kind": "path", "displayName": "Operation", "group": "producer", "label": "producer", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Operation to be performed" }, - "authenticationKey": { "kind": "parameter", "displayName": "API authentication key (AK)", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "description": "Authentication key for the cloud user" }, "endpoint": { "kind": "parameter", "displayName": "Service endpoint", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "FunctionGraph url. Carries higher precedence than region parameter based client initialization" }, "functionName": { "kind": "parameter", "displayName": "Function name", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Name of the function to invoke" }, "functionPackage": { "kind": "parameter", "displayName": "Function package", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Functions that can be logically grouped together" }, - "ignoreSslVerification": { "kind": "parameter", "displayName": "SSL Verification Ignored", "group": "producer", "label": "", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": false, "description": "Ignore SSL verification" }, "lazyStartProducer": { "kind": "parameter", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during sta [...] "projectId": { "kind": "parameter", "displayName": "Project ID", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Cloud project ID" }, - "proxyHost": { "kind": "parameter", "displayName": "Proxy server host", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Proxy server ip\/hostname" }, - "proxyPassword": { "kind": "parameter", "displayName": "Proxy password", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "description": "Proxy authentication password" }, - "proxyPort": { "kind": "parameter", "displayName": "Proxy server port", "group": "producer", "label": "", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Proxy server port" }, - "proxyUser": { "kind": "parameter", "displayName": "Proxy user", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "description": "Proxy authentication user" }, "region": { "kind": "parameter", "displayName": "Service region", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "FunctionGraph service region. This is lower precedence than endpoint based configuration" }, - "secretKey": { "kind": "parameter", "displayName": "API secret key (SK)", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "description": "Secret key for the cloud user" }, - "serviceKeys": { "kind": "parameter", "displayName": "Service Configuration", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.models.ServiceKeys", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "description": "Configuration object for cloud service authentication" } + "serviceKeys": { "kind": "parameter", "displayName": "Service Configuration", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.models.ServiceKeys", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "description": "Configuration object for cloud service authentication" }, + "proxyHost": { "kind": "parameter", "displayName": "Proxy server host", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Proxy server ip\/hostname" }, + "proxyPassword": { "kind": "parameter", "displayName": "Proxy password", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "description": "Proxy authentication password" }, + "proxyPort": { "kind": "parameter", "displayName": "Proxy server port", "group": "proxy", "label": "proxy", "required": false, "type": "integer", "javaType": "int", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "description": "Proxy server port" }, + "proxyUser": { "kind": "parameter", "displayName": "Proxy user", "group": "proxy", "label": "proxy", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "description": "Proxy authentication user" }, + "authenticationKey": { "kind": "parameter", "displayName": "API authentication key (AK)", "group": "security", "label": "security", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "description": "Authentication key for the cloud user" }, + "ignoreSslVerification": { "kind": "parameter", "displayName": "SSL Verification Ignored", "group": "security", "label": "security", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "defaultValue": false, "description": "Ignore SSL verification" }, + "secretKey": { "kind": "parameter", "displayName": "API secret key (SK)", "group": "security", "label": "security", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": true, "description": "Secret key for the cloud user" } } } diff --git a/components/camel-huaweicloud-functiongraph/src/main/docs/hwcloud-functiongraph-component.adoc b/components/camel-huaweicloud-functiongraph/src/main/docs/hwcloud-functiongraph-component.adoc index b85d198..8d27012 100644 --- a/components/camel-huaweicloud-functiongraph/src/main/docs/hwcloud-functiongraph-component.adoc +++ b/components/camel-huaweicloud-functiongraph/src/main/docs/hwcloud-functiongraph-component.adoc @@ -2,7 +2,7 @@ = FunctionGraph Component :docTitle: FunctionGraph :artifactId: camel-huaweicloud-functiongraph -:description: Huawei Cloud component to integrate with FunctionGraph services +:description: To call serverless functions on Huawei Cloud :since: 3.11 :supportLevel: Preview :component-header: Only producer is supported @@ -17,21 +17,21 @@ Huawei Cloud FunctionGraph component allows you to integrate with https://www.hu Maven users will need to add the following dependency to their `pom.xml` for this component: [source,xml] ------------------------------------------------------------- +---- <dependency> <groupId>org.apache.camel</groupId>git <artifactId>camel-huaweicloud-functiongraph</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency> ------------------------------------------------------------- +---- == URI Format -[source,java] -------------------------------- +[source,text] +---- hwcloud-functiongraph:operation[?options] -------------------------------- +---- == URI Options @@ -74,20 +74,20 @@ with the following path and query parameters: [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type -| *authenticationKey* (producer) | *Required* Authentication key for the cloud user | | String | *endpoint* (producer) | FunctionGraph url. Carries higher precedence than region parameter based client initialization | | String | *functionName* (producer) | Name of the function to invoke | | String | *functionPackage* (producer) | Functions that can be logically grouped together | | String -| *ignoreSslVerification* (producer) | Ignore SSL verification | false | boolean | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...] | *projectId* (producer) | *Required* Cloud project ID | | String -| *proxyHost* (producer) | Proxy server ip/hostname | | String -| *proxyPassword* (producer) | Proxy authentication password | | String -| *proxyPort* (producer) | Proxy server port | | int -| *proxyUser* (producer) | Proxy authentication user | | String | *region* (producer) | *Required* FunctionGraph service region. This is lower precedence than endpoint based configuration | | String -| *secretKey* (producer) | *Required* Secret key for the cloud user | | String | *serviceKeys* (producer) | Configuration object for cloud service authentication | | ServiceKeys +| *proxyHost* (proxy) | Proxy server ip/hostname | | String +| *proxyPassword* (proxy) | Proxy authentication password | | String +| *proxyPort* (proxy) | Proxy server port | | int +| *proxyUser* (proxy) | Proxy authentication user | | String +| *authenticationKey* (security) | *Required* Authentication key for the cloud user | | String +| *ignoreSslVerification* (security) | Ignore SSL verification | false | boolean +| *secretKey* (security) | *Required* Secret key for the cloud user | | String |=== // endpoint options: END @@ -125,13 +125,15 @@ If the operation, function name, or function package are set, they will override == List of Supported FunctionGraph Operations -- invokeFunction +- invokeFunction - to invoke a serverless function == Using ServiceKey Configuration Bean + Authentication key and secret keys are required to authenticate against cloud smn 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 +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] ---- @@ -141,10 +143,10 @@ Check the following code snippets </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®ion=cn-north-4&serviceKeys=#myServiceKeyConfig") --------------------------------------------------------------------------------- +---- diff --git a/components/camel-huaweicloud-functiongraph/src/main/java/org/apache/camel/FunctionGraphEndpoint.java b/components/camel-huaweicloud-functiongraph/src/main/java/org/apache/camel/FunctionGraphEndpoint.java index f516ea7..b445e01 100644 --- a/components/camel-huaweicloud-functiongraph/src/main/java/org/apache/camel/FunctionGraphEndpoint.java +++ b/components/camel-huaweicloud-functiongraph/src/main/java/org/apache/camel/FunctionGraphEndpoint.java @@ -29,7 +29,7 @@ import org.apache.camel.support.DefaultEndpoint; import org.apache.camel.util.ObjectHelper; /** - * Huawei Cloud component to integrate with FunctionGraph services + * To call serverless functions on Huawei Cloud */ @UriEndpoint(firstVersion = "3.11.0", scheme = "hwcloud-functiongraph", title = "FunctionGraph", syntax = "hwcloud-functiongraph:operation", @@ -59,24 +59,24 @@ public class FunctionGraphEndpoint extends DefaultEndpoint { @Metadata(required = false) private String functionName; - @UriParam(description = "Proxy server ip/hostname", displayName = "Proxy server host", secret = false) + @UriParam(description = "Proxy server ip/hostname", displayName = "Proxy server host", secret = false, label = "proxy") @Metadata(required = false) private String proxyHost; - @UriParam(description = "Proxy server port", displayName = "Proxy server port", secret = false) + @UriParam(description = "Proxy server port", displayName = "Proxy server port", secret = false, label = "proxy") @Metadata(required = false) private int proxyPort; - @UriParam(description = "Proxy authentication user", displayName = "Proxy user", secret = true) + @UriParam(description = "Proxy authentication user", displayName = "Proxy user", secret = true, label = "proxy") @Metadata(required = false) private String proxyUser; - @UriParam(description = "Proxy authentication password", displayName = "Proxy password", secret = true) + @UriParam(description = "Proxy authentication password", displayName = "Proxy password", secret = true, label = "proxy") @Metadata(required = false) private String proxyPassword; @UriParam(description = "Ignore SSL verification", displayName = "SSL Verification Ignored", secret = false, - defaultValue = "false") + defaultValue = "false", label = "security") @Metadata(required = false) private boolean ignoreSslVerification; @@ -90,11 +90,13 @@ public class FunctionGraphEndpoint extends DefaultEndpoint { @Metadata(required = false) private ServiceKeys serviceKeys; - @UriParam(description = "Authentication key for the cloud user", displayName = "API authentication key (AK)", secret = true) + @UriParam(description = "Authentication key for the cloud user", displayName = "API authentication key (AK)", secret = true, + label = "security") @Metadata(required = true) private String authenticationKey; - @UriParam(description = "Secret key for the cloud user", displayName = "API secret key (SK)", secret = true) + @UriParam(description = "Secret key for the cloud user", displayName = "API secret key (SK)", secret = true, + label = "security") @Metadata(required = true) private String secretKey; diff --git a/components/camel-huaweicloud-functiongraph/src/main/java/org/apache/camel/FunctionGraphProducer.java b/components/camel-huaweicloud-functiongraph/src/main/java/org/apache/camel/FunctionGraphProducer.java index 778f062..b3117b2 100644 --- a/components/camel-huaweicloud-functiongraph/src/main/java/org/apache/camel/FunctionGraphProducer.java +++ b/components/camel-huaweicloud-functiongraph/src/main/java/org/apache/camel/FunctionGraphProducer.java @@ -76,23 +76,14 @@ public class FunctionGraphProducer extends DefaultProducer { 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"); } } else { - if (LOG.isErrorEnabled()) { - LOG.error("Exchange body is not valid"); - } throw new IllegalArgumentException("Exchange body is mandatory and should be a valid Map or JSON string"); } // 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)) @@ -119,13 +110,12 @@ public class FunctionGraphProducer extends DefaultProducer { if (ObjectHelper.isNotEmpty(clientConfigurations.getXCffLogType())) { exchange.setProperty(FunctionGraphProperties.XCFFLOGS, response.getLog()); } - LOG.info("Invoke Function results: " + response); + + LOG.debug("Invoke Function results: {}", response); } /** * Update dynamic client configurations - * - * @param exchange */ private void updateClientConfigs(Exchange exchange) { resetDynamicConfigs(); @@ -133,9 +123,6 @@ public class FunctionGraphProducer extends DefaultProducer { // checking for required operation if (ObjectHelper.isEmpty(exchange.getProperty(FunctionGraphProperties.OPERATION)) && ObjectHelper.isEmpty(endpoint.getOperation())) { - if (LOG.isErrorEnabled()) { - LOG.error("No operation name given. Cannot proceed with FunctionGraph operations."); - } throw new IllegalArgumentException("Operation name not found"); } else { clientConfigurations.setOperation( @@ -147,9 +134,6 @@ public class FunctionGraphProducer extends DefaultProducer { // checking for required function name (exchange overrides endpoint function name) if (ObjectHelper.isEmpty(exchange.getProperty(FunctionGraphProperties.FUNCTION_NAME)) && ObjectHelper.isEmpty(endpoint.getFunctionName())) { - if (LOG.isErrorEnabled()) { - LOG.error("No function name given."); - } throw new IllegalArgumentException("Function name not found"); } else { clientConfigurations.setFunctionName( @@ -161,9 +145,7 @@ public class FunctionGraphProducer extends DefaultProducer { // checking for optional function package (exchange overrides endpoint function package) if (ObjectHelper.isEmpty(exchange.getProperty(FunctionGraphProperties.FUNCTION_PACKAGE)) && ObjectHelper.isEmpty(endpoint.getFunctionPackage())) { - if (LOG.isWarnEnabled()) { - LOG.warn("No function package given. Defaulting to 'default'."); - } + LOG.warn("No function package given. Defaulting to 'default'."); clientConfigurations.setFunctionPackage(FunctionGraphConstants.DEFAULT_FUNCTION_PACKAGE); } else { clientConfigurations.setFunctionPackage( @@ -174,9 +156,7 @@ public class FunctionGraphProducer extends DefaultProducer { // checking for optional XCffLogType if (ObjectHelper.isEmpty(exchange.getProperty(FunctionGraphProperties.XCFFLOGTYPE))) { - if (LOG.isErrorEnabled()) { - LOG.warn("No XCffLogType given"); - } + LOG.warn("No XCffLogType given"); } else { clientConfigurations.setXCffLogType((String) exchange.getProperty(FunctionGraphProperties.XCFFLOGTYPE)); } diff --git a/components/camel-huaweicloud-functiongraph/src/main/java/org/apache/camel/FunctionGraphUtils.java b/components/camel-huaweicloud-functiongraph/src/main/java/org/apache/camel/FunctionGraphUtils.java index e6e5ae9..7e7d907 100644 --- a/components/camel-huaweicloud-functiongraph/src/main/java/org/apache/camel/FunctionGraphUtils.java +++ b/components/camel-huaweicloud-functiongraph/src/main/java/org/apache/camel/FunctionGraphUtils.java @@ -19,21 +19,14 @@ package org.apache.camel; import com.google.gson.Gson; import com.google.gson.JsonObject; import org.apache.camel.models.ClientConfigurations; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public final class FunctionGraphUtils { - private static final Logger LOG = LoggerFactory.getLogger(FunctionGraphUtils.class.getName()); private FunctionGraphUtils() { } /** * Gets the fieldName from the jsonString and returns it as a String - * - * @param jsonString - * @param fieldName - * @return */ public static String extractJsonFieldAsString(String jsonString, String fieldName) { Gson gson = new Gson(); @@ -42,10 +35,6 @@ public final class FunctionGraphUtils { /** * returns the urn based on urnFormat and clientConfigurations - * - * @param urnFormat - * @param clientConfigurations - * @return */ public static String composeUrn(String urnFormat, ClientConfigurations clientConfigurations) { return String.format(urnFormat, clientConfigurations.getRegion(), diff --git a/components/camel-huaweicloud-functiongraph/src/main/resources/META-INF/services/org/apache/camel/component/hwcloud-functiongraph b/components/camel-huaweicloud-functiongraph/src/main/resources/META-INF/services/org/apache/camel/component/hwcloud-functiongraph deleted file mode 100644 index 9b56097..0000000 --- a/components/camel-huaweicloud-functiongraph/src/main/resources/META-INF/services/org/apache/camel/component/hwcloud-functiongraph +++ /dev/null @@ -1 +0,0 @@ -class=org.apache.camel.FunctionGraphComponent diff --git a/components/camel-huaweicloud-functiongraph/src/test/resources/log4j2.properties b/components/camel-huaweicloud-functiongraph/src/test/resources/log4j2.properties index f87b4d4..b514e71 100644 --- a/components/camel-huaweicloud-functiongraph/src/test/resources/log4j2.properties +++ b/components/camel-huaweicloud-functiongraph/src/test/resources/log4j2.properties @@ -14,9 +14,15 @@ ## See the License for the specific language governing permissions and ## limitations under the License. ## --------------------------------------------------------------------------- -appender.out.type = Console -appender.out.name = out -appender.out.layout.type = PatternLayout -appender.out.layout.pattern = [%30.30t] %-30.30c{1} %-5p %m%n + +appender.file.type = File +appender.file.name = file +appender.file.fileName = target/camel-huaweicloud-functiongraph-test.log +appender.file.layout.type = PatternLayout +appender.file.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n +appender.stdout.type = Console +appender.stdout.name = stdout +appender.stdout.layout.type = PatternLayout +appender.stdout.layout.pattern = %d [%-15.15t] %-5p %-30.30c{1} - %m%n rootLogger.level = INFO -rootLogger.appenderRef.out.ref = out +rootLogger.appenderRef.file.ref = file diff --git a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java index 6628499..d233251 100644 --- a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java +++ b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/ComponentsBuilderFactory.java @@ -1995,7 +1995,7 @@ public interface ComponentsBuilderFactory { } /** * FunctionGraph (camel-huaweicloud-functiongraph) - * Huawei Cloud component to integrate with FunctionGraph services + * To call serverless functions on Huawei Cloud * * Category: cloud,serverless * Since: 3.11 diff --git a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/HwcloudFunctiongraphComponentBuilderFactory.java b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/HwcloudFunctiongraphComponentBuilderFactory.java index f7c2e8e..5b0a40d 100644 --- a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/HwcloudFunctiongraphComponentBuilderFactory.java +++ b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/HwcloudFunctiongraphComponentBuilderFactory.java @@ -23,7 +23,7 @@ import org.apache.camel.builder.component.AbstractComponentBuilder; import org.apache.camel.builder.component.ComponentBuilder; /** - * Huawei Cloud component to integrate with FunctionGraph services + * To call serverless functions on Huawei Cloud * * Generated by camel-package-maven-plugin - do not edit this file! */ @@ -32,7 +32,7 @@ public interface HwcloudFunctiongraphComponentBuilderFactory { /** * FunctionGraph (camel-huaweicloud-functiongraph) - * Huawei Cloud component to integrate with FunctionGraph services + * To call serverless functions on Huawei Cloud * * Category: cloud,serverless * Since: 3.11 diff --git a/core/camel-componentdsl/src/generated/resources/metadata.json b/core/camel-componentdsl/src/generated/resources/metadata.json index c8f62fd..4eb98d7 100644 --- a/core/camel-componentdsl/src/generated/resources/metadata.json +++ b/core/camel-componentdsl/src/generated/resources/metadata.json @@ -3264,7 +3264,7 @@ "kind": "component", "name": "hwcloud-functiongraph", "title": "FunctionGraph", - "description": "Huawei Cloud component to integrate with FunctionGraph services", + "description": "To call serverless functions on Huawei Cloud", "deprecated": false, "firstVersion": "3.11.0", "label": "cloud,serverless", diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java index 503f08e..5be5f39 100644 --- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java +++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/StaticEndpointBuilders.java @@ -6746,7 +6746,7 @@ public class StaticEndpointBuilders { } /** * FunctionGraph (camel-huaweicloud-functiongraph) - * Huawei Cloud component to integrate with FunctionGraph services + * To call serverless functions on Huawei Cloud * * Category: cloud,serverless * Since: 3.11 @@ -6766,7 +6766,7 @@ public class StaticEndpointBuilders { } /** * FunctionGraph (camel-huaweicloud-functiongraph) - * Huawei Cloud component to integrate with FunctionGraph services + * To call serverless functions on Huawei Cloud * * Category: cloud,serverless * Since: 3.11 diff --git a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/FunctionGraphEndpointBuilderFactory.java b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/FunctionGraphEndpointBuilderFactory.java index 3088dbc..6d45a9d 100644 --- a/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/FunctionGraphEndpointBuilderFactory.java +++ b/core/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/FunctionGraphEndpointBuilderFactory.java @@ -22,7 +22,7 @@ import org.apache.camel.builder.EndpointProducerBuilder; import org.apache.camel.builder.endpoint.AbstractEndpointBuilder; /** - * Huawei Cloud component to integrate with FunctionGraph services + * To call serverless functions on Huawei Cloud * * Generated by camel build tools - do NOT edit this file! */ @@ -37,22 +37,6 @@ public interface FunctionGraphEndpointBuilderFactory { extends EndpointProducerBuilder { /** - * Authentication key for the cloud user. - * - * The option is a: <code>java.lang.String</code> type. - * - * Required: true - * Group: producer - * - * @param authenticationKey the value to set - * @return the dsl builder - */ - default FunctionGraphEndpointBuilder authenticationKey( - String authenticationKey) { - doSetProperty("authenticationKey", authenticationKey); - return this; - } - /** * FunctionGraph url. Carries higher precedence than region parameter * based client initialization. * @@ -97,39 +81,6 @@ public interface FunctionGraphEndpointBuilderFactory { return this; } /** - * Ignore SSL verification. - * - * The option is a: <code>boolean</code> type. - * - * Default: false - * Group: producer - * - * @param ignoreSslVerification the value to set - * @return the dsl builder - */ - default FunctionGraphEndpointBuilder ignoreSslVerification( - boolean ignoreSslVerification) { - doSetProperty("ignoreSslVerification", ignoreSslVerification); - return this; - } - /** - * Ignore SSL verification. - * - * The option will be converted to a <code>boolean</code> - * type. - * - * Default: false - * Group: producer - * - * @param ignoreSslVerification the value to set - * @return the dsl builder - */ - default FunctionGraphEndpointBuilder ignoreSslVerification( - String ignoreSslVerification) { - doSetProperty("ignoreSslVerification", ignoreSslVerification); - return this; - } - /** * Whether the producer should be started lazy (on the first message). * By starting lazy you can use this to allow CamelContext and routes to * startup in situations where a producer may otherwise fail during @@ -194,12 +145,58 @@ public interface FunctionGraphEndpointBuilderFactory { return this; } /** - * Proxy server ip/hostname. + * FunctionGraph service region. This is lower precedence than endpoint + * based configuration. * * The option is a: <code>java.lang.String</code> type. * + * Required: true + * Group: producer + * + * @param region the value to set + * @return the dsl builder + */ + default FunctionGraphEndpointBuilder region(String region) { + doSetProperty("region", region); + return this; + } + /** + * Configuration object for cloud service authentication. + * + * The option is a: + * <code>org.apache.camel.models.ServiceKeys</code> type. + * * Group: producer * + * @param serviceKeys the value to set + * @return the dsl builder + */ + default FunctionGraphEndpointBuilder serviceKeys(Object serviceKeys) { + doSetProperty("serviceKeys", serviceKeys); + return this; + } + /** + * Configuration object for cloud service authentication. + * + * The option will be converted to a + * <code>org.apache.camel.models.ServiceKeys</code> type. + * + * Group: producer + * + * @param serviceKeys the value to set + * @return the dsl builder + */ + default FunctionGraphEndpointBuilder serviceKeys(String serviceKeys) { + doSetProperty("serviceKeys", serviceKeys); + return this; + } + /** + * Proxy server ip/hostname. + * + * The option is a: <code>java.lang.String</code> type. + * + * Group: proxy + * * @param proxyHost the value to set * @return the dsl builder */ @@ -212,7 +209,7 @@ public interface FunctionGraphEndpointBuilderFactory { * * The option is a: <code>java.lang.String</code> type. * - * Group: producer + * Group: proxy * * @param proxyPassword the value to set * @return the dsl builder @@ -226,7 +223,7 @@ public interface FunctionGraphEndpointBuilderFactory { * * The option is a: <code>int</code> type. * - * Group: producer + * Group: proxy * * @param proxyPort the value to set * @return the dsl builder @@ -240,7 +237,7 @@ public interface FunctionGraphEndpointBuilderFactory { * * The option will be converted to a <code>int</code> type. * - * Group: producer + * Group: proxy * * @param proxyPort the value to set * @return the dsl builder @@ -254,7 +251,7 @@ public interface FunctionGraphEndpointBuilderFactory { * * The option is a: <code>java.lang.String</code> type. * - * Group: producer + * Group: proxy * * @param proxyUser the value to set * @return the dsl builder @@ -264,64 +261,67 @@ public interface FunctionGraphEndpointBuilderFactory { return this; } /** - * FunctionGraph service region. This is lower precedence than endpoint - * based configuration. + * Authentication key for the cloud user. * * The option is a: <code>java.lang.String</code> type. * * Required: true - * Group: producer + * Group: security * - * @param region the value to set + * @param authenticationKey the value to set * @return the dsl builder */ - default FunctionGraphEndpointBuilder region(String region) { - doSetProperty("region", region); + default FunctionGraphEndpointBuilder authenticationKey( + String authenticationKey) { + doSetProperty("authenticationKey", authenticationKey); return this; } /** - * Secret key for the cloud user. + * Ignore SSL verification. * - * The option is a: <code>java.lang.String</code> type. + * The option is a: <code>boolean</code> type. * - * Required: true - * Group: producer + * Default: false + * Group: security * - * @param secretKey the value to set + * @param ignoreSslVerification the value to set * @return the dsl builder */ - default FunctionGraphEndpointBuilder secretKey(String secretKey) { - doSetProperty("secretKey", secretKey); + default FunctionGraphEndpointBuilder ignoreSslVerification( + boolean ignoreSslVerification) { + doSetProperty("ignoreSslVerification", ignoreSslVerification); return this; } /** - * Configuration object for cloud service authentication. + * Ignore SSL verification. * - * The option is a: - * <code>org.apache.camel.models.ServiceKeys</code> type. + * The option will be converted to a <code>boolean</code> + * type. * - * Group: producer + * Default: false + * Group: security * - * @param serviceKeys the value to set + * @param ignoreSslVerification the value to set * @return the dsl builder */ - default FunctionGraphEndpointBuilder serviceKeys(Object serviceKeys) { - doSetProperty("serviceKeys", serviceKeys); + default FunctionGraphEndpointBuilder ignoreSslVerification( + String ignoreSslVerification) { + doSetProperty("ignoreSslVerification", ignoreSslVerification); return this; } /** - * Configuration object for cloud service authentication. + * Secret key for the cloud user. * - * The option will be converted to a - * <code>org.apache.camel.models.ServiceKeys</code> type. + * The option is a: <code>java.lang.String</code> type. * - * Group: producer + * Required: true + * Group: security * - * @param serviceKeys the value to set + * @param secretKey the value to set * @return the dsl builder */ - default FunctionGraphEndpointBuilder serviceKeys(String serviceKeys) { - doSetProperty("serviceKeys", serviceKeys); + default FunctionGraphEndpointBuilder secretKey(String secretKey) { + doSetProperty("secretKey", secretKey); return this; } } @@ -329,7 +329,7 @@ public interface FunctionGraphEndpointBuilderFactory { public interface FunctionGraphBuilders { /** * FunctionGraph (camel-huaweicloud-functiongraph) - * Huawei Cloud component to integrate with FunctionGraph services + * To call serverless functions on Huawei Cloud * * Category: cloud,serverless * Since: 3.11 @@ -348,7 +348,7 @@ public interface FunctionGraphEndpointBuilderFactory { } /** * FunctionGraph (camel-huaweicloud-functiongraph) - * Huawei Cloud component to integrate with FunctionGraph services + * To call serverless functions on Huawei Cloud * * Category: cloud,serverless * Since: 3.11 diff --git a/docs/components/modules/ROOT/pages/hwcloud-functiongraph-component.adoc b/docs/components/modules/ROOT/pages/hwcloud-functiongraph-component.adoc index 9b549a6..3da00c2 100644 --- a/docs/components/modules/ROOT/pages/hwcloud-functiongraph-component.adoc +++ b/docs/components/modules/ROOT/pages/hwcloud-functiongraph-component.adoc @@ -4,7 +4,7 @@ :page-source: components/camel-huaweicloud-functiongraph/src/main/docs/hwcloud-functiongraph-component.adoc :docTitle: FunctionGraph :artifactId: camel-huaweicloud-functiongraph -:description: Huawei Cloud component to integrate with FunctionGraph services +:description: To call serverless functions on Huawei Cloud :since: 3.11 :supportLevel: Preview :component-header: Only producer is supported @@ -19,21 +19,21 @@ Huawei Cloud FunctionGraph component allows you to integrate with https://www.hu Maven users will need to add the following dependency to their `pom.xml` for this component: [source,xml] ------------------------------------------------------------- +---- <dependency> <groupId>org.apache.camel</groupId>git <artifactId>camel-huaweicloud-functiongraph</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency> ------------------------------------------------------------- +---- == URI Format -[source,java] -------------------------------- +[source,text] +---- hwcloud-functiongraph:operation[?options] -------------------------------- +---- == URI Options @@ -76,20 +76,20 @@ with the following path and query parameters: [width="100%",cols="2,5,^1,2",options="header"] |=== | Name | Description | Default | Type -| *authenticationKey* (producer) | *Required* Authentication key for the cloud user | | String | *endpoint* (producer) | FunctionGraph url. Carries higher precedence than region parameter based client initialization | | String | *functionName* (producer) | Name of the function to invoke | | String | *functionPackage* (producer) | Functions that can be logically grouped together | | String -| *ignoreSslVerification* (producer) | Ignore SSL verification | false | boolean | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...] | *projectId* (producer) | *Required* Cloud project ID | | String -| *proxyHost* (producer) | Proxy server ip/hostname | | String -| *proxyPassword* (producer) | Proxy authentication password | | String -| *proxyPort* (producer) | Proxy server port | | int -| *proxyUser* (producer) | Proxy authentication user | | String | *region* (producer) | *Required* FunctionGraph service region. This is lower precedence than endpoint based configuration | | String -| *secretKey* (producer) | *Required* Secret key for the cloud user | | String | *serviceKeys* (producer) | Configuration object for cloud service authentication | | ServiceKeys +| *proxyHost* (proxy) | Proxy server ip/hostname | | String +| *proxyPassword* (proxy) | Proxy authentication password | | String +| *proxyPort* (proxy) | Proxy server port | | int +| *proxyUser* (proxy) | Proxy authentication user | | String +| *authenticationKey* (security) | *Required* Authentication key for the cloud user | | String +| *ignoreSslVerification* (security) | Ignore SSL verification | false | boolean +| *secretKey* (security) | *Required* Secret key for the cloud user | | String |=== // endpoint options: END @@ -127,13 +127,15 @@ If the operation, function name, or function package are set, they will override == List of Supported FunctionGraph Operations -- invokeFunction +- invokeFunction - to invoke a serverless function == Using ServiceKey Configuration Bean + Authentication key and secret keys are required to authenticate against cloud smn 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 +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] ---- @@ -143,10 +145,10 @@ Check the following code snippets </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®ion=cn-north-4&serviceKeys=#myServiceKeyConfig") --------------------------------------------------------------------------------- +----
