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
The following commit(s) were added to refs/heads/main by this push:
new d6e81e4 CAMEL-16717: Base commit for Huawei Cloud IAM Component
(#5667)
d6e81e4 is described below
commit d6e81e4cd415efe1ed4b1d8ccc70defdaf0750ad
Author: Hokutor <[email protected]>
AuthorDate: Mon Jun 14 14:59:56 2021 -0400
CAMEL-16717: Base commit for Huawei Cloud IAM Component (#5667)
* CAMEL-16717 : Base commit for Huawei Cloud IAM Component
* CAMEL-16717 : Delete generated Readme file
* CAMEL-16717 : Update documentation
* CAMEL-16717: Adding Huawei Cloud to documentation
---
bom/camel-bom/pom.xml | 5 +
.../main/docs/hwcloud-functiongraph-component.adoc | 6 +-
.../camel-huawei/camel-huaweicloud-iam/pom.xml | 77 ++++++
.../huaweicloud/iam/IAMComponentConfigurer.java | 61 +++++
.../huaweicloud/iam/IAMEndpointConfigurer.java | 133 ++++++++++
.../huaweicloud/iam/IAMEndpointUriFactory.java | 85 +++++++
.../apache/camel/configurer/hwcloud-iam-component | 2 +
.../apache/camel/configurer/hwcloud-iam-endpoint | 2 +
.../apache/camel/urifactory/hwcloud-iam-endpoint | 2 +
.../component/huaweicloud/iam/hwcloud-iam.json | 48 ++++
.../src/main/docs/hwcloud-iam-component.adoc} | 78 +++---
.../component/huaweicloud/iam/IAMComponent.java | 32 +++
.../component/huaweicloud/iam/IAMEndpoint.java | 281 +++++++++++++++++++++
.../component/huaweicloud/iam/IAMProducer.java | 161 ++++++++++++
.../huaweicloud/iam/constants/IAMOperations.java | 27 ++
.../huaweicloud/iam/constants/IAMProperties.java | 26 ++
.../iam/models/ClientConfigurations.java | 54 ++++
.../huaweicloud/iam/models/ServiceKeys.java | 51 ++++
.../org/apache/camel/component/hwcloud-iam | 1 +
.../huaweicloud/iam/GetGroupUsersTest.java | 66 +++++
.../component/huaweicloud/iam/GetUserTest.java | 72 ++++++
.../component/huaweicloud/iam/IAMMockClient.java | 95 +++++++
.../component/huaweicloud/iam/ListGroupsTest.java | 66 +++++
.../component/huaweicloud/iam/ListUsersTest.java | 65 +++++
.../huaweicloud/iam/TestConfiguration.java | 49 ++++
.../iam/constants/IAMOperationsTest.java | 31 +++
.../iam/constants/IAMPropertiesTest.java | 30 +++
.../src/test/resources/log4j2.properties | 23 ++
.../src/main/docs/hwcloud-smn-component.adoc | 16 +-
components/camel-huawei/pom.xml | 1 +
parent/pom.xml | 5 +
31 files changed, 1595 insertions(+), 56 deletions(-)
diff --git a/bom/camel-bom/pom.xml b/bom/camel-bom/pom.xml
index fd59afc..0441a91 100644
--- a/bom/camel-bom/pom.xml
+++ b/bom/camel-bom/pom.xml
@@ -907,6 +907,11 @@
<artifactId>camel-huaweicloud-functiongraph</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-huaweicloud-iam</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-huaweicloud-smn</artifactId>
diff --git
a/components/camel-huawei/camel-huaweicloud-functiongraph/src/main/docs/hwcloud-functiongraph-component.adoc
b/components/camel-huawei/camel-huaweicloud-functiongraph/src/main/docs/hwcloud-functiongraph-component.adoc
index 7b3fce9..c744533 100644
---
a/components/camel-huawei/camel-huaweicloud-functiongraph/src/main/docs/hwcloud-functiongraph-component.adoc
+++
b/components/camel-huawei/camel-huaweicloud-functiongraph/src/main/docs/hwcloud-functiongraph-component.adoc
@@ -1,6 +1,6 @@
[[hwcloud-functiongraph-component]]
-= FunctionGraph Component
-:docTitle: FunctionGraph
+= Huawei Cloud FunctionGraph Component
+:docTitle: Huawei Cloud FunctionGraph
:artifactId: camel-huaweicloud-functiongraph
:description: To call serverless functions on Huawei Cloud
:since: 3.11
@@ -14,7 +14,7 @@
include::{cq-version}@camel-quarkus:ROOT:partial$reference/components/hwcloud-fu
*{component-header}*
-Huawei Cloud FunctionGraph component allows you to integrate with
https://www.huaweicloud.com/en-us/product/functiongraph.html[FunctionGraph]
services provided by Huawei Cloud.
+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:
diff --git a/components/camel-huawei/camel-huaweicloud-iam/pom.xml
b/components/camel-huawei/camel-huaweicloud-iam/pom.xml
new file mode 100644
index 0000000..b23b3a8
--- /dev/null
+++ b/components/camel-huawei/camel-huaweicloud-iam/pom.xml
@@ -0,0 +1,77 @@
+<?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">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-huawei-parent</artifactId>
+ <version>3.11.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-huaweicloud-iam</artifactId>
+ <packaging>jar</packaging>
+ <name>Camel :: Huawei Cloud IAM Component</name>
+ <description>To securely manage users on Huawei Cloud</description>
+
+ <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-iam</artifactId>
+ <version>${huaweicloud-sdk-version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.code.gson</groupId>
+ <artifactId>gson</artifactId>
+ <version>${gson-version}</version>
+ </dependency>
+
+ <!-- logging -->
+ <dependency>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-slf4j-impl</artifactId>
+ <version>${log4j2-version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter-api</artifactId>
+ <version>${junit-jupiter-version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/generated/java/org/apache/camel/component/huaweicloud/iam/IAMComponentConfigurer.java
b/components/camel-huawei/camel-huaweicloud-iam/src/generated/java/org/apache/camel/component/huaweicloud/iam/IAMComponentConfigurer.java
new file mode 100644
index 0000000..37ff948
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/generated/java/org/apache/camel/component/huaweicloud/iam/IAMComponentConfigurer.java
@@ -0,0 +1,61 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.component.huaweicloud.iam;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spi.ExtendedPropertyConfigurerGetter;
+import org.apache.camel.spi.PropertyConfigurerGetter;
+import org.apache.camel.spi.ConfigurerStrategy;
+import org.apache.camel.spi.GeneratedPropertyConfigurer;
+import org.apache.camel.util.CaseInsensitiveMap;
+import org.apache.camel.support.component.PropertyConfigurerSupport;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@SuppressWarnings("unchecked")
+public class IAMComponentConfigurer extends PropertyConfigurerSupport
implements GeneratedPropertyConfigurer, PropertyConfigurerGetter {
+
+ @Override
+ public boolean configure(CamelContext camelContext, Object obj, String
name, Object value, boolean ignoreCase) {
+ IAMComponent target = (IAMComponent) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "autowiredenabled":
+ case "autowiredEnabled":
target.setAutowiredEnabled(property(camelContext, boolean.class, value));
return true;
+ case "bridgeerrorhandler":
+ case "bridgeErrorHandler":
target.setBridgeErrorHandler(property(camelContext, boolean.class, value));
return true;
+ case "lazystartproducer":
+ case "lazyStartProducer":
target.setLazyStartProducer(property(camelContext, boolean.class, value));
return true;
+ default: return false;
+ }
+ }
+
+ @Override
+ public Class<?> getOptionType(String name, boolean ignoreCase) {
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "autowiredenabled":
+ case "autowiredEnabled": return boolean.class;
+ case "bridgeerrorhandler":
+ case "bridgeErrorHandler": return boolean.class;
+ case "lazystartproducer":
+ case "lazyStartProducer": return boolean.class;
+ default: return null;
+ }
+ }
+
+ @Override
+ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
+ IAMComponent target = (IAMComponent) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "autowiredenabled":
+ case "autowiredEnabled": return target.isAutowiredEnabled();
+ case "bridgeerrorhandler":
+ case "bridgeErrorHandler": return target.isBridgeErrorHandler();
+ case "lazystartproducer":
+ case "lazyStartProducer": return target.isLazyStartProducer();
+ default: return null;
+ }
+ }
+}
+
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/generated/java/org/apache/camel/component/huaweicloud/iam/IAMEndpointConfigurer.java
b/components/camel-huawei/camel-huaweicloud-iam/src/generated/java/org/apache/camel/component/huaweicloud/iam/IAMEndpointConfigurer.java
new file mode 100644
index 0000000..67751a3
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/generated/java/org/apache/camel/component/huaweicloud/iam/IAMEndpointConfigurer.java
@@ -0,0 +1,133 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.component.huaweicloud.iam;
+
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spi.ExtendedPropertyConfigurerGetter;
+import org.apache.camel.spi.PropertyConfigurerGetter;
+import org.apache.camel.spi.ConfigurerStrategy;
+import org.apache.camel.spi.GeneratedPropertyConfigurer;
+import org.apache.camel.util.CaseInsensitiveMap;
+import org.apache.camel.support.component.PropertyConfigurerSupport;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@SuppressWarnings("unchecked")
+public class IAMEndpointConfigurer extends PropertyConfigurerSupport
implements GeneratedPropertyConfigurer, PropertyConfigurerGetter {
+
+ @Override
+ public boolean configure(CamelContext camelContext, Object obj, String
name, Object value, boolean ignoreCase) {
+ IAMEndpoint target = (IAMEndpoint) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "authenticationkey":
+ case "authenticationKey":
target.setAuthenticationKey(property(camelContext, java.lang.String.class,
value)); return true;
+ case "bridgeerrorhandler":
+ case "bridgeErrorHandler":
target.setBridgeErrorHandler(property(camelContext, boolean.class, value));
return true;
+ case "endpoint": target.setEndpoint(property(camelContext,
java.lang.String.class, value)); return true;
+ case "exceptionhandler":
+ case "exceptionHandler":
target.setExceptionHandler(property(camelContext,
org.apache.camel.spi.ExceptionHandler.class, value)); return true;
+ case "exchangepattern":
+ case "exchangePattern":
target.setExchangePattern(property(camelContext,
org.apache.camel.ExchangePattern.class, value)); return true;
+ case "groupid":
+ case "groupId": target.setGroupId(property(camelContext,
java.lang.String.class, value)); return true;
+ case "ignoresslverification":
+ case "ignoreSslVerification":
target.setIgnoreSslVerification(property(camelContext, boolean.class, value));
return true;
+ case "lazystartproducer":
+ case "lazyStartProducer":
target.setLazyStartProducer(property(camelContext, boolean.class, value));
return true;
+ case "proxyhost":
+ case "proxyHost": target.setProxyHost(property(camelContext,
java.lang.String.class, value)); return true;
+ case "proxypassword":
+ case "proxyPassword": target.setProxyPassword(property(camelContext,
java.lang.String.class, value)); return true;
+ case "proxyport":
+ case "proxyPort": target.setProxyPort(property(camelContext,
int.class, value)); return true;
+ case "proxyuser":
+ case "proxyUser": target.setProxyUser(property(camelContext,
java.lang.String.class, value)); return true;
+ case "region": target.setRegion(property(camelContext,
java.lang.String.class, value)); return true;
+ case "secretkey":
+ case "secretKey": target.setSecretKey(property(camelContext,
java.lang.String.class, value)); return true;
+ case "servicekeys":
+ case "serviceKeys": target.setServiceKeys(property(camelContext,
org.apache.camel.component.huaweicloud.iam.models.ServiceKeys.class, value));
return true;
+ case "userid":
+ case "userId": target.setUserId(property(camelContext,
java.lang.String.class, value)); return true;
+ default: return false;
+ }
+ }
+
+ @Override
+ public Class<?> getOptionType(String name, boolean ignoreCase) {
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "authenticationkey":
+ case "authenticationKey": return java.lang.String.class;
+ case "bridgeerrorhandler":
+ case "bridgeErrorHandler": return boolean.class;
+ case "endpoint": return java.lang.String.class;
+ case "exceptionhandler":
+ case "exceptionHandler": return
org.apache.camel.spi.ExceptionHandler.class;
+ case "exchangepattern":
+ case "exchangePattern": return org.apache.camel.ExchangePattern.class;
+ case "groupid":
+ case "groupId": return java.lang.String.class;
+ case "ignoresslverification":
+ case "ignoreSslVerification": return boolean.class;
+ case "lazystartproducer":
+ case "lazyStartProducer": return boolean.class;
+ case "proxyhost":
+ case "proxyHost": return java.lang.String.class;
+ case "proxypassword":
+ case "proxyPassword": return java.lang.String.class;
+ case "proxyport":
+ case "proxyPort": return int.class;
+ case "proxyuser":
+ case "proxyUser": return java.lang.String.class;
+ case "region": return java.lang.String.class;
+ case "secretkey":
+ case "secretKey": return java.lang.String.class;
+ case "servicekeys":
+ case "serviceKeys": return
org.apache.camel.component.huaweicloud.iam.models.ServiceKeys.class;
+ case "userid":
+ case "userId": return java.lang.String.class;
+ default: return null;
+ }
+ }
+
+ @Override
+ public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
+ IAMEndpoint target = (IAMEndpoint) obj;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "authenticationkey":
+ case "authenticationKey": return target.getAuthenticationKey();
+ case "bridgeerrorhandler":
+ case "bridgeErrorHandler": return target.isBridgeErrorHandler();
+ case "endpoint": return target.getEndpoint();
+ case "exceptionhandler":
+ case "exceptionHandler": return target.getExceptionHandler();
+ case "exchangepattern":
+ case "exchangePattern": return target.getExchangePattern();
+ case "groupid":
+ case "groupId": return target.getGroupId();
+ case "ignoresslverification":
+ case "ignoreSslVerification": return target.isIgnoreSslVerification();
+ case "lazystartproducer":
+ case "lazyStartProducer": return target.isLazyStartProducer();
+ case "proxyhost":
+ case "proxyHost": return target.getProxyHost();
+ case "proxypassword":
+ case "proxyPassword": return target.getProxyPassword();
+ case "proxyport":
+ case "proxyPort": return target.getProxyPort();
+ case "proxyuser":
+ case "proxyUser": return target.getProxyUser();
+ case "region": return target.getRegion();
+ case "secretkey":
+ case "secretKey": return target.getSecretKey();
+ case "servicekeys":
+ case "serviceKeys": return target.getServiceKeys();
+ case "userid":
+ case "userId": return target.getUserId();
+ default: return null;
+ }
+ }
+}
+
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/generated/java/org/apache/camel/component/huaweicloud/iam/IAMEndpointUriFactory.java
b/components/camel-huawei/camel-huaweicloud-iam/src/generated/java/org/apache/camel/component/huaweicloud/iam/IAMEndpointUriFactory.java
new file mode 100644
index 0000000..fc79130
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/generated/java/org/apache/camel/component/huaweicloud/iam/IAMEndpointUriFactory.java
@@ -0,0 +1,85 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.component.huaweicloud.iam;
+
+import java.net.URISyntaxException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.camel.spi.EndpointUriFactory;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+public class IAMEndpointUriFactory extends
org.apache.camel.support.component.EndpointUriFactorySupport implements
EndpointUriFactory {
+
+ private static final String BASE = ":operation";
+
+ private static final Set<String> PROPERTY_NAMES;
+ private static final Set<String> SECRET_PROPERTY_NAMES;
+ static {
+ Set<String> props = new HashSet<>(17);
+ props.add("serviceKeys");
+ props.add("secretKey");
+ props.add("groupId");
+ props.add("proxyPassword");
+ props.add("exchangePattern");
+ props.add("ignoreSslVerification");
+ props.add("authenticationKey");
+ props.add("proxyHost");
+ props.add("userId");
+ props.add("proxyPort");
+ props.add("endpoint");
+ props.add("lazyStartProducer");
+ props.add("bridgeErrorHandler");
+ props.add("proxyUser");
+ props.add("region");
+ props.add("operation");
+ props.add("exceptionHandler");
+ PROPERTY_NAMES = Collections.unmodifiableSet(props);
+ Set<String> secretProps = new HashSet<>(7);
+ secretProps.add("serviceKeys");
+ secretProps.add("secretKey");
+ secretProps.add("groupId");
+ secretProps.add("proxyPassword");
+ secretProps.add("proxyUser");
+ secretProps.add("authenticationKey");
+ secretProps.add("userId");
+ SECRET_PROPERTY_NAMES = Collections.unmodifiableSet(secretProps);
+ }
+
+ @Override
+ public boolean isEnabled(String scheme) {
+ return "hwcloud-iam".equals(scheme);
+ }
+
+ @Override
+ public String buildUri(String scheme, Map<String, Object> properties,
boolean encode) throws URISyntaxException {
+ String syntax = scheme + BASE;
+ String uri = syntax;
+
+ Map<String, Object> copy = new HashMap<>(properties);
+
+ uri = buildPathParameter(syntax, uri, "operation", null, true, copy);
+ uri = buildQueryParameters(uri, copy, encode);
+ return uri;
+ }
+
+ @Override
+ public Set<String> propertyNames() {
+ return PROPERTY_NAMES;
+ }
+
+ @Override
+ public Set<String> secretPropertyNames() {
+ return SECRET_PROPERTY_NAMES;
+ }
+
+ @Override
+ public boolean isLenientProperties() {
+ return false;
+ }
+}
+
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/generated/resources/META-INF/services/org/apache/camel/configurer/hwcloud-iam-component
b/components/camel-huawei/camel-huaweicloud-iam/src/generated/resources/META-INF/services/org/apache/camel/configurer/hwcloud-iam-component
new file mode 100644
index 0000000..b6d1d77
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/generated/resources/META-INF/services/org/apache/camel/configurer/hwcloud-iam-component
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.huaweicloud.iam.IAMComponentConfigurer
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/generated/resources/META-INF/services/org/apache/camel/configurer/hwcloud-iam-endpoint
b/components/camel-huawei/camel-huaweicloud-iam/src/generated/resources/META-INF/services/org/apache/camel/configurer/hwcloud-iam-endpoint
new file mode 100644
index 0000000..e01ed78
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/generated/resources/META-INF/services/org/apache/camel/configurer/hwcloud-iam-endpoint
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.huaweicloud.iam.IAMEndpointConfigurer
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/generated/resources/META-INF/services/org/apache/camel/urifactory/hwcloud-iam-endpoint
b/components/camel-huawei/camel-huaweicloud-iam/src/generated/resources/META-INF/services/org/apache/camel/urifactory/hwcloud-iam-endpoint
new file mode 100644
index 0000000..9e52916
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/generated/resources/META-INF/services/org/apache/camel/urifactory/hwcloud-iam-endpoint
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.component.huaweicloud.iam.IAMEndpointUriFactory
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/generated/resources/org/apache/camel/component/huaweicloud/iam/hwcloud-iam.json
b/components/camel-huawei/camel-huaweicloud-iam/src/generated/resources/org/apache/camel/component/huaweicloud/iam/hwcloud-iam.json
new file mode 100644
index 0000000..e599f7a
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/generated/resources/org/apache/camel/component/huaweicloud/iam/hwcloud-iam.json
@@ -0,0 +1,48 @@
+{
+ "component": {
+ "kind": "component",
+ "name": "hwcloud-iam",
+ "title": "IAM",
+ "description": "To securely manage users on Huawei Cloud",
+ "deprecated": false,
+ "firstVersion": "3.11.0",
+ "label": "cloud",
+ "javaType": "org.apache.camel.component.huaweicloud.iam.IAMComponent",
+ "supportLevel": "Preview",
+ "groupId": "org.apache.camel",
+ "artifactId": "camel-huaweicloud-iam",
+ "version": "3.11.0-SNAPSHOT",
+ "scheme": "hwcloud-iam",
+ "extendsScheme": "",
+ "syntax": "hwcloud-iam:operation",
+ "async": false,
+ "api": false,
+ "consumerOnly": false,
+ "producerOnly": false,
+ "lenientProperties": false
+ },
+ "componentProperties": {
+ "bridgeErrorHandler": { "kind": "property", "displayName": "Bridge Error
Handler", "group": "consumer", "label": "consumer", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "description": "Allows for bridging the
consumer to the Camel routing Error Handler, which mean any exceptions occurred
while the consumer is trying to pickup incoming messages, or the likes, will
now be processed as a me [...]
+ "lazyStartProducer": { "kind": "property", "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 star [...]
+ "autowiredEnabled": { "kind": "property", "displayName": "Autowired
Enabled", "group": "advanced", "label": "advanced", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether autowiring is
enabled. This is used for automatic autowiring options (the option must be
marked as autowired) by looking up in the registry to find if there is a single
instance of matching type, which t [...]
+ },
+ "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": "common", "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": "common", "label": "", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "deprecationNote": "",
"autowired": false, "secret": false, "description": "IAM endpoint url. Carries
higher precedence than region parameter based client initialization" },
+ "groupId": { "kind": "parameter", "displayName": "Group ID", "group":
"common", "label": "", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": true, "description": "Group ID to perform operation with" },
+ "ignoreSslVerification": { "kind": "parameter", "displayName": "SSL
Verification Ignored", "group": "common", "label": "", "required": false,
"type": "boolean", "javaType": "boolean", "deprecated": false,
"deprecationNote": "", "autowired": false, "secret": false, "defaultValue":
false, "description": "Ignore SSL verification" },
+ "proxyHost": { "kind": "parameter", "displayName": "Proxy server host",
"group": "common", "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": "common", "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": "common", "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":
"common", "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":
"common", "label": "", "required": true, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": false, "description": "IAM service region. This is lower
precedence than endpoint based configuration" },
+ "secretKey": { "kind": "parameter", "displayName": "API secret key (SK)",
"group": "common", "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": "common", "label": "", "required": false, "type":
"object", "javaType":
"org.apache.camel.component.huaweicloud.iam.models.ServiceKeys", "deprecated":
false, "deprecationNote": "", "autowired": false, "secret": true,
"description": "Configuration object for cloud service authentication" },
+ "userId": { "kind": "parameter", "displayName": "User ID", "group":
"common", "label": "", "required": false, "type": "string", "javaType":
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired":
false, "secret": true, "description": "User ID to perform operation with" },
+ "bridgeErrorHandler": { "kind": "parameter", "displayName": "Bridge Error
Handler", "group": "consumer", "label": "consumer", "required": false, "type":
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": false, "description": "Allows for bridging the
consumer to the Camel routing Error Handler, which mean any exceptions occurred
while the consumer is trying to pickup incoming messages, or the likes, will
now be processed as a m [...]
+ "exceptionHandler": { "kind": "parameter", "displayName": "Exception
Handler", "group": "consumer (advanced)", "label": "consumer,advanced",
"required": false, "type": "object", "javaType":
"org.apache.camel.spi.ExceptionHandler", "optionalPrefix": "consumer.",
"deprecated": false, "autowired": false, "secret": false, "description": "To
let the consumer use a custom ExceptionHandler. Notice if the option
bridgeErrorHandler is enabled then this option is not in use. By default the
con [...]
+ "exchangePattern": { "kind": "parameter", "displayName": "Exchange
Pattern", "group": "consumer (advanced)", "label": "consumer,advanced",
"required": false, "type": "object", "javaType":
"org.apache.camel.ExchangePattern", "enum": [ "InOnly", "InOut",
"InOptionalOut" ], "deprecated": false, "autowired": false, "secret": false,
"description": "Sets the exchange pattern when the consumer creates an
exchange." },
+ "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 [...]
+ }
+}
diff --git
a/components/camel-huawei/camel-huaweicloud-functiongraph/src/main/docs/hwcloud-functiongraph-component.adoc
b/components/camel-huawei/camel-huaweicloud-iam/src/main/docs/hwcloud-iam-component.adoc
similarity index 60%
copy from
components/camel-huawei/camel-huaweicloud-functiongraph/src/main/docs/hwcloud-functiongraph-component.adoc
copy to
components/camel-huawei/camel-huaweicloud-iam/src/main/docs/hwcloud-iam-component.adoc
index 7b3fce9..ff8dd38 100644
---
a/components/camel-huawei/camel-huaweicloud-functiongraph/src/main/docs/hwcloud-functiongraph-component.adoc
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/main/docs/hwcloud-iam-component.adoc
@@ -1,12 +1,12 @@
-[[hwcloud-functiongraph-component]]
-= FunctionGraph Component
-:docTitle: FunctionGraph
-:artifactId: camel-huaweicloud-functiongraph
-:description: To call serverless functions on Huawei Cloud
+[[hwcloud-iam-component]]
+= Huawei Cloud Identity and Access Management (IAM) Component
+:docTitle: Huawei Cloud Identity and Access Management (IAM)
+:artifactId: camel-huaweicloud-iam
+:description: To securely manage users on Huawei Cloud
:since: 3.11
:supportLevel: Preview
:component-header: Only producer is supported
-include::{cq-version}@camel-quarkus:ROOT:partial$reference/components/hwcloud-functiongraph.adoc[opts=optional]
+include::{cq-version}@camel-quarkus:ROOT:partial$reference/components/hwcloud-iam.adoc[opts=optional]
//Manually maintained attributes
:group: Huawei Cloud
@@ -14,7 +14,7 @@
include::{cq-version}@camel-quarkus:ROOT:partial$reference/components/hwcloud-fu
*{component-header}*
-Huawei Cloud FunctionGraph component allows you to integrate with
https://www.huaweicloud.com/en-us/product/functiongraph.html[FunctionGraph]
services provided by Huawei Cloud.
+Huawei Cloud Identity and Access Management (IAM) component allows you to
integrate with https://www.huaweicloud.com/intl/en-us/product/iam.html[IAM]
provided by Huawei Cloud.
Maven users will need to add the following dependency to their `pom.xml` for
this component:
@@ -22,7 +22,7 @@ Maven users will need to add the following dependency to
their `pom.xml` for thi
----
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-huaweicloud-functiongraph</artifactId>
+ <artifactId>camel-huaweicloud-iam</artifactId>
<version>x.x.x</version>
<!-- use the same version as your Camel core version -->
</dependency>
@@ -32,13 +32,13 @@ Maven users will need to add the following dependency to
their `pom.xml` for thi
[source,text]
----
-hwcloud-functiongraph:operation[?options]
+hwcloud-iam:operation[?options]
----
== URI Options
// component options: START
-The FunctionGraph component supports 2 options, which are listed below.
+The IAM component supports 2 options, which are listed below.
@@ -50,12 +50,11 @@ The FunctionGraph component supports 2 options, which are
listed below.
|===
// component options: END
-
// endpoint options: START
-The FunctionGraph endpoint is configured using URI syntax:
+The HuaweiCloud IAM endpoint is configured using URI syntax:
----
-hwcloud-functiongraph:operation
+hwcloud-iam:operation
----
with the following path and query parameters:
@@ -76,12 +75,10 @@ with the following path and query parameters:
[width="100%",cols="2,5,^1,2",options="header"]
|===
| Name | Description | Default | Type
-| *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 | default | String
+| *endpoint* (producer) | IAM url. Carries higher precedence than region
parameter based client initialization | | String
+| *groupId* (producer) | Group ID to perform operation with | | String
| *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
-| *region* (producer) | *Required* FunctionGraph service region. This is lower
precedence than endpoint based configuration | | String
+| *region* (producer) | *Required* IAM service region. This is lower
precedence than endpoint based configuration | | String
| *serviceKeys* (producer) | Configuration object for cloud service
authentication | | ServiceKeys
| *proxyHost* (proxy) | Proxy server ip/hostname | | String
| *proxyPassword* (proxy) | Proxy authentication password | | String
@@ -90,56 +87,47 @@ with the following path and query parameters:
| *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
+| *userId* (producer) | User ID to perform operation with | | String
|===
// endpoint options: END
== Usage
-=== Message properties evaluated by the FunctionGraph producer
+=== Message properties evaluated by the IAM 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
-
-|=======================================================================
+|`CamelHwCloudIamOperation` |`String` | Name of operation to invoke
-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
+|`CamelHwCloudIamUserId` |`String` | User ID to invoke operation on
-|`CamelHwCloudFgXCffLogs` |`String` | Unique log returned by FunctionGraph
after processing the request if `CamelHwCloudFgXCffLogType` is set
+|`CamelHwCloudIamGroupId` |`String` | Group ID to invoke operation on
|=======================================================================
+If any of the above properties are set, they will override their corresponding
query parameter.
-== List of Supported FunctionGraph Operations
+== List of Supported IAM Operations
-- invokeFunction - to invoke a serverless function
+- listUsers
+- getUsers
+- listGroups
+- getGroupUsers
== Using ServiceKey Configuration Bean
-Authentication 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`.
+Authentication key and secret keys are required to authenticate against cloud
IAM 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.iam.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">
+<bean id="myServiceKeyConfig"
class="org.apache.camel.component.huaweicloud.iam.models.ServiceKeys">
<property name="authenticationKey" value="your_authentication_key" />
<property name="secretKey" value="your_secret_key" />
</bean>
@@ -147,8 +135,8 @@ Check the following code snippets:
[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")
+ .setProperty(IAMPropeties.OPERATION, constant("listUsers"))
+ .setProperty(IAMPropeties.USER_ID ,constant("your_user_id"))
+ .setProperty(IAMPropeties.GROUP_ID, constant("your_group_id))
+ .to("hwcloud-iam:listUsers?region=cn-north-4&serviceKeys=#myServiceKeyConfig")
----
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/main/java/org/apache/camel/component/huaweicloud/iam/IAMComponent.java
b/components/camel-huawei/camel-huaweicloud-iam/src/main/java/org/apache/camel/component/huaweicloud/iam/IAMComponent.java
new file mode 100644
index 0000000..24b3077
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/main/java/org/apache/camel/component/huaweicloud/iam/IAMComponent.java
@@ -0,0 +1,32 @@
+/*
+ * 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.component.huaweicloud.iam;
+
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.support.DefaultComponent;
+
[email protected]("hwcloud-iam")
+public class IAMComponent extends DefaultComponent {
+
+ protected Endpoint createEndpoint(String uri, String remaining,
Map<String, Object> parameters) throws Exception {
+ Endpoint endpoint = new IAMEndpoint(uri, remaining, this);
+ setProperties(endpoint, parameters);
+ return endpoint;
+ }
+}
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/main/java/org/apache/camel/component/huaweicloud/iam/IAMEndpoint.java
b/components/camel-huawei/camel-huaweicloud-iam/src/main/java/org/apache/camel/component/huaweicloud/iam/IAMEndpoint.java
new file mode 100644
index 0000000..82d391e
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/main/java/org/apache/camel/component/huaweicloud/iam/IAMEndpoint.java
@@ -0,0 +1,281 @@
+/*
+ * 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.component.huaweicloud.iam;
+
+import com.huaweicloud.sdk.core.auth.GlobalCredentials;
+import com.huaweicloud.sdk.core.http.HttpConfig;
+import com.huaweicloud.sdk.iam.v3.IamClient;
+import com.huaweicloud.sdk.iam.v3.region.IamRegion;
+import org.apache.camel.Category;
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.component.huaweicloud.iam.models.ServiceKeys;
+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 org.apache.camel.support.DefaultEndpoint;
+import org.apache.camel.util.ObjectHelper;
+
+/**
+ * To securely manage users on Huawei Cloud
+ */
+@UriEndpoint(firstVersion = "3.11.0", scheme = "hwcloud-iam", title = "IAM",
syntax = "hwcloud-iam:operation",
+ category = { Category.CLOUD })
+public class IAMEndpoint extends DefaultEndpoint {
+
+ @UriPath(description = "Operation to be performed", displayName =
"Operation", label = "producer", secret = false)
+ @Metadata(required = true)
+ private String operation;
+
+ @UriParam(description = "IAM service region. This is lower precedence than
endpoint based configuration",
+ displayName = "Service region", secret = false)
+ @Metadata(required = true)
+ private String region;
+
+ @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 = "IAM endpoint 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;
+
+ @UriParam(description = "User ID to perform operation with", displayName =
"User ID", secret = true)
+ @Metadata(required = false)
+ private String userId;
+
+ @UriParam(description = "Group ID to perform operation with", displayName
= "Group ID", secret = true)
+ @Metadata(required = false)
+ private String groupId;
+
+ private IamClient iamClient;
+
+ public IAMEndpoint() {
+ }
+
+ public IAMEndpoint(String uri, String operation, IAMComponent component) {
+ super(uri, component);
+ this.operation = operation;
+ }
+
+ @Override
+ public Producer createProducer() throws Exception {
+ return new IAMProducer(this);
+ }
+
+ @Override
+ public Consumer createConsumer(Processor processor) throws Exception {
+ throw new UnsupportedOperationException("You cannot receive messages
from this endpoint");
+ }
+
+ public String getOperation() {
+ return operation;
+ }
+
+ public void setOperation(String operation) {
+ this.operation = operation;
+ }
+
+ public String getRegion() {
+ return region;
+ }
+
+ public void setRegion(String region) {
+ this.region = region;
+ }
+
+ 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 String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public String getGroupId() {
+ return groupId;
+ }
+
+ public void setGroupId(String groupId) {
+ this.groupId = groupId;
+ }
+
+ public IamClient getIamClient() {
+ return iamClient;
+ }
+
+ public void setIamClient(IamClient iamClient) {
+ this.iamClient = iamClient;
+ }
+
+ public IamClient initClient() {
+ if (iamClient != null) {
+ return iamClient;
+ }
+
+ if (ObjectHelper.isEmpty(getServiceKeys()) &&
ObjectHelper.isEmpty(getAuthenticationKey())) {
+ throw new IllegalArgumentException("Authentication parameter
'authentication key (AK)' not found");
+ }
+ if (ObjectHelper.isEmpty(getServiceKeys()) &&
ObjectHelper.isEmpty(getSecretKey())) {
+ throw new IllegalArgumentException("Authentication parameter
'secret key (SK)' not found");
+ }
+
+ GlobalCredentials auth = new GlobalCredentials()
+ .withAk(getServiceKeys() != null
+ ? getServiceKeys().getAuthenticationKey()
+ : getAuthenticationKey())
+ .withSk(getServiceKeys() != null
+ ? getServiceKeys().getSecretKey()
+ : getSecretKey());
+
+ HttpConfig httpConfig = HttpConfig.getDefaultHttpConfig();
+ httpConfig.withIgnoreSSLVerification(isIgnoreSslVerification());
+ if (ObjectHelper.isNotEmpty(getProxyHost())
+ && ObjectHelper.isNotEmpty(getProxyPort())) {
+ httpConfig.withProxyHost(getProxyHost())
+ .withProxyPort(getProxyPort());
+
+ if (ObjectHelper.isNotEmpty(getProxyUser())) {
+ httpConfig.withProxyUsername(getProxyUser());
+ if (ObjectHelper.isNotEmpty(getProxyPassword())) {
+ httpConfig.withProxyPassword(getProxyPassword());
+ }
+ }
+ }
+
+ if (ObjectHelper.isNotEmpty(getEndpoint())) {
+ return IamClient.newBuilder()
+ .withCredential(auth)
+ .withHttpConfig(httpConfig)
+ .withEndpoint(getEndpoint())
+ .build();
+ } else if (ObjectHelper.isNotEmpty(getRegion())) {
+ return IamClient.newBuilder()
+ .withCredential(auth)
+ .withHttpConfig(httpConfig)
+ .withRegion(IamRegion.valueOf(getRegion()))
+ .build();
+ } else {
+ throw new IllegalArgumentException("Region/endpoint not found");
+ }
+ }
+}
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/main/java/org/apache/camel/component/huaweicloud/iam/IAMProducer.java
b/components/camel-huawei/camel-huaweicloud-iam/src/main/java/org/apache/camel/component/huaweicloud/iam/IAMProducer.java
new file mode 100644
index 0000000..60f9aad
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/main/java/org/apache/camel/component/huaweicloud/iam/IAMProducer.java
@@ -0,0 +1,161 @@
+/*
+ * 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.component.huaweicloud.iam;
+
+import com.google.gson.Gson;
+import com.huaweicloud.sdk.iam.v3.IamClient;
+import com.huaweicloud.sdk.iam.v3.model.KeystoneListGroupsRequest;
+import com.huaweicloud.sdk.iam.v3.model.KeystoneListGroupsResponse;
+import
com.huaweicloud.sdk.iam.v3.model.KeystoneListUsersForGroupByAdminRequest;
+import
com.huaweicloud.sdk.iam.v3.model.KeystoneListUsersForGroupByAdminResponse;
+import com.huaweicloud.sdk.iam.v3.model.KeystoneListUsersRequest;
+import com.huaweicloud.sdk.iam.v3.model.KeystoneListUsersResponse;
+import com.huaweicloud.sdk.iam.v3.model.ShowUserRequest;
+import com.huaweicloud.sdk.iam.v3.model.ShowUserResponse;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.huaweicloud.iam.constants.IAMOperations;
+import org.apache.camel.component.huaweicloud.iam.constants.IAMProperties;
+import org.apache.camel.component.huaweicloud.iam.models.ClientConfigurations;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class IAMProducer extends DefaultProducer {
+ private static final Logger LOG =
LoggerFactory.getLogger(IAMProducer.class);
+ private IAMEndpoint endpoint;
+ private ClientConfigurations clientConfigurations;
+ private IamClient iamClient;
+ private Gson gson;
+
+ public IAMProducer(IAMEndpoint endpoint) {
+ super(endpoint);
+ this.endpoint = endpoint;
+ }
+
+ @Override
+ protected void doStart() throws Exception {
+ super.doStart();
+ this.clientConfigurations = new ClientConfigurations();
+ this.iamClient = this.endpoint.initClient();
+ this.gson = new Gson();
+ }
+
+ public void process(Exchange exchange) throws Exception {
+ updateClientConfigs(exchange);
+
+ switch (clientConfigurations.getOperation()) {
+ case IAMOperations.LIST_USERS:
+ listUsers(exchange);
+ break;
+ case IAMOperations.GET_USER:
+ getUser(exchange);
+ break;
+ case IAMOperations.GET_GROUP_USERS:
+ getGroupUsers(exchange);
+ break;
+ case IAMOperations.LIST_GROUPS:
+ listGroups(exchange);
+ break;
+ default:
+ throw new UnsupportedOperationException(
+ String.format("%s is not a supported operation",
clientConfigurations.getOperation()));
+ }
+ }
+
+ private void listUsers(Exchange exchange) {
+ KeystoneListUsersRequest request = new KeystoneListUsersRequest();
+ KeystoneListUsersResponse response =
iamClient.keystoneListUsers(request);
+ exchange.getMessage().setBody(gson.toJson(response.getUsers()));
+ }
+
+ private void getUser(Exchange exchange) {
+ if (ObjectHelper.isEmpty(clientConfigurations.getUserId())) {
+ if (LOG.isErrorEnabled()) {
+ LOG.error("No user id given");
+ }
+ throw new IllegalArgumentException("User id is mandatory to get
user");
+ }
+
+ ShowUserRequest request = new ShowUserRequest()
+ .withUserId(clientConfigurations.getUserId());
+ ShowUserResponse response = iamClient.showUser(request);
+ exchange.getMessage().setBody(gson.toJson(response.getUser()));
+ }
+
+ private void getGroupUsers(Exchange exchange) {
+ if (ObjectHelper.isEmpty(clientConfigurations.getGroupId())) {
+ if (LOG.isErrorEnabled()) {
+ LOG.error("No group id given");
+ }
+ throw new IllegalArgumentException("Group id is mandatory to get
group users");
+ }
+
+ KeystoneListUsersForGroupByAdminRequest request = new
KeystoneListUsersForGroupByAdminRequest()
+ .withGroupId(clientConfigurations.getGroupId());
+ KeystoneListUsersForGroupByAdminResponse response =
iamClient.keystoneListUsersForGroupByAdmin(request);
+ exchange.getMessage().setBody(gson.toJson(response.getUsers()));
+ }
+
+ private void listGroups(Exchange exchange) {
+ KeystoneListGroupsRequest request = new KeystoneListGroupsRequest();
+ KeystoneListGroupsResponse response =
iamClient.keystoneListGroups(request);
+ exchange.getMessage().setBody(gson.toJson(response.getGroups()));
+ }
+
+ private void updateClientConfigs(Exchange exchange) {
+ resetDynamicConfigs();
+
+ // checking for required operation
+ if (ObjectHelper.isEmpty(exchange.getProperty(IAMProperties.OPERATION))
+ && ObjectHelper.isEmpty(endpoint.getOperation())) {
+ if (LOG.isErrorEnabled()) {
+ LOG.error("No operation name given. Cannot proceed with IAM
operations.");
+ }
+ throw new IllegalArgumentException("Operation name not found");
+ } else {
+ clientConfigurations.setOperation(
+
ObjectHelper.isNotEmpty(exchange.getProperty(IAMProperties.OPERATION))
+ ? (String)
exchange.getProperty(IAMProperties.OPERATION)
+ : endpoint.getOperation());
+ }
+
+ // checking for optional userId
+ if
(ObjectHelper.isNotEmpty(exchange.getProperty(IAMProperties.USER_ID))
+ || ObjectHelper.isNotEmpty(endpoint.getUserId())) {
+ clientConfigurations.setUserId(
+
ObjectHelper.isNotEmpty(exchange.getProperty(IAMProperties.USER_ID))
+ ? (String)
exchange.getProperty(IAMProperties.USER_ID)
+ : endpoint.getUserId());
+ }
+
+ // checking for optional groupId
+ if
(ObjectHelper.isNotEmpty(exchange.getProperty(IAMProperties.GROUP_ID))
+ || ObjectHelper.isNotEmpty(endpoint.getGroupId())) {
+ clientConfigurations.setGroupId(
+
ObjectHelper.isNotEmpty(exchange.getProperty(IAMProperties.GROUP_ID))
+ ? (String)
exchange.getProperty(IAMProperties.GROUP_ID)
+ : endpoint.getGroupId());
+ }
+ }
+
+ private void resetDynamicConfigs() {
+ clientConfigurations.setOperation(null);
+ clientConfigurations.setUserId(null);
+ clientConfigurations.setGroupId(null);
+ }
+}
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/main/java/org/apache/camel/component/huaweicloud/iam/constants/IAMOperations.java
b/components/camel-huawei/camel-huaweicloud-iam/src/main/java/org/apache/camel/component/huaweicloud/iam/constants/IAMOperations.java
new file mode 100644
index 0000000..c1c6dfd
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/main/java/org/apache/camel/component/huaweicloud/iam/constants/IAMOperations.java
@@ -0,0 +1,27 @@
+/*
+ * 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.component.huaweicloud.iam.constants;
+
+public final class IAMOperations {
+ public static final String LIST_USERS = "listUsers";
+ public static final String GET_USER = "getUser";
+ public static final String GET_GROUP_USERS = "getGroupUsers";
+ public static final String LIST_GROUPS = "listGroups";
+
+ private IAMOperations() {
+ }
+}
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/main/java/org/apache/camel/component/huaweicloud/iam/constants/IAMProperties.java
b/components/camel-huawei/camel-huaweicloud-iam/src/main/java/org/apache/camel/component/huaweicloud/iam/constants/IAMProperties.java
new file mode 100644
index 0000000..eda38de
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/main/java/org/apache/camel/component/huaweicloud/iam/constants/IAMProperties.java
@@ -0,0 +1,26 @@
+/*
+ * 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.component.huaweicloud.iam.constants;
+
+public final class IAMProperties {
+ public static final String OPERATION = "CamelHwCloudIamOperation";
+ public static final String USER_ID = "CamelHwCloudIamUserId";
+ public static final String GROUP_ID = "CamelHwCloudIamGroupId";
+
+ private IAMProperties() {
+ }
+}
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/main/java/org/apache/camel/component/huaweicloud/iam/models/ClientConfigurations.java
b/components/camel-huawei/camel-huaweicloud-iam/src/main/java/org/apache/camel/component/huaweicloud/iam/models/ClientConfigurations.java
new file mode 100644
index 0000000..ff50e5e
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/main/java/org/apache/camel/component/huaweicloud/iam/models/ClientConfigurations.java
@@ -0,0 +1,54 @@
+/*
+ * 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.component.huaweicloud.iam.models;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ClientConfigurations {
+ private static final Logger LOG =
LoggerFactory.getLogger(ClientConfigurations.class.getName());
+ private String operation;
+ private String userId;
+ private String groupId;
+
+ public ClientConfigurations() {
+ }
+
+ public String getOperation() {
+ return operation;
+ }
+
+ public void setOperation(String operation) {
+ this.operation = operation;
+ }
+
+ public String getUserId() {
+ return userId;
+ }
+
+ public void setUserId(String userId) {
+ this.userId = userId;
+ }
+
+ public String getGroupId() {
+ return groupId;
+ }
+
+ public void setGroupId(String groupId) {
+ this.groupId = groupId;
+ }
+}
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/main/java/org/apache/camel/component/huaweicloud/iam/models/ServiceKeys.java
b/components/camel-huawei/camel-huaweicloud-iam/src/main/java/org/apache/camel/component/huaweicloud/iam/models/ServiceKeys.java
new file mode 100644
index 0000000..4a9cb73
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/main/java/org/apache/camel/component/huaweicloud/iam/models/ServiceKeys.java
@@ -0,0 +1,51 @@
+/*
+ * 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.component.huaweicloud.iam.models;
+
+public class ServiceKeys {
+ private String authenticationKey;
+ private String secretKey;
+
+ public ServiceKeys() {
+ }
+
+ public ServiceKeys(String authenticationKey, String secretKey) {
+ this.authenticationKey = authenticationKey;
+ this.secretKey = secretKey;
+ }
+
+ public ServiceKeys(String authenticationKey, String secretKey, String
projectId) {
+ this.authenticationKey = authenticationKey;
+ this.secretKey = secretKey;
+ }
+
+ 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;
+ }
+}
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/main/resources/META-INF/services/org/apache/camel/component/hwcloud-iam
b/components/camel-huawei/camel-huaweicloud-iam/src/main/resources/META-INF/services/org/apache/camel/component/hwcloud-iam
new file mode 100644
index 0000000..72cfcc1
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/main/resources/META-INF/services/org/apache/camel/component/hwcloud-iam
@@ -0,0 +1 @@
+class=org.apache.camel.component.huaweicloud.iam.IAMComponent
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/GetGroupUsersTest.java
b/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/GetGroupUsersTest.java
new file mode 100644
index 0000000..5bbb538
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/GetGroupUsersTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.component.huaweicloud.iam;
+
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GetGroupUsersTest extends CamelTestSupport {
+ private static final Logger LOG =
LoggerFactory.getLogger(GetGroupUsersTest.class.getName());
+
+ TestConfiguration testConfiguration = new TestConfiguration();
+
+ @BindToRegistry("iamClient")
+ IAMMockClient mockClient = new IAMMockClient(null);
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:get_group_users")
+ .setProperty("CamelHwCloudIamOperation",
constant("getGroupUsers"))
+ .setProperty("CamelHwCloudIamGroupId",
constant(testConfiguration.getProperty("groupId")))
+ .to("hwcloud-iam:dummy?" +
+ "region=" +
testConfiguration.getProperty("region") +
+ "&ignoreSslVerification=true" +
+ "&iamClient=#iamClient")
+ .log("Get user successful")
+ .to("mock:get_group_users_result");
+ }
+ };
+ }
+
+ @Test
+ public void testGetGroupUsers() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:get_group_users_result");
+ mock.expectedMinimumMessageCount(1);
+ template.sendBody("direct:get_group_users", "sample_body");
+ Exchange responseExchange = mock.getExchanges().get(0);
+
+ mock.assertIsSatisfied();
+
+ assertEquals(
+ "[{\"name\":\"User 9\",\"id\":\"abc\"},{\"name\":\"User
10\",\"description\":\"Employee\",\"id\":\"def\"}]",
+ responseExchange.getIn().getBody(String.class));
+ }
+}
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/GetUserTest.java
b/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/GetUserTest.java
new file mode 100644
index 0000000..68581de
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/GetUserTest.java
@@ -0,0 +1,72 @@
+/*
+ * 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.component.huaweicloud.iam;
+
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.huaweicloud.iam.models.ServiceKeys;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GetUserTest extends CamelTestSupport {
+ private static final Logger LOG =
LoggerFactory.getLogger(GetUserTest.class.getName());
+
+ TestConfiguration testConfiguration = new TestConfiguration();
+
+ @BindToRegistry("iamClient")
+ IAMMockClient mockClient = new IAMMockClient(null);
+
+ @BindToRegistry("serviceKeys")
+ ServiceKeys serviceKeys = new ServiceKeys(
+ testConfiguration.getProperty("authenticationKey"),
+ testConfiguration.getProperty("secretKey"));
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:get_user")
+ .setProperty("CamelHwCloudIamOperation",
constant("getUser"))
+ .setProperty("CamelHwCloudIamUserId",
constant(testConfiguration.getProperty("userId")))
+ .to("hwcloud-iam:?" +
+ "region=" +
testConfiguration.getProperty("region") +
+ "&ignoreSslVerification=true" +
+ "&iamClient=#iamClient" +
+ "&serviceKeys=#serviceKeys")
+ .log("Get user successful")
+ .to("mock:get_user_result");
+ }
+ };
+ }
+
+ @Test
+ public void testGetUser() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:get_user_result");
+ mock.expectedMinimumMessageCount(1);
+ template.sendBody("direct:get_user", "sample_body");
+ Exchange responseExchange = mock.getExchanges().get(0);
+
+ mock.assertIsSatisfied();
+
+ assertEquals("{\"domainId\":\"138\",\"name\":\"User
15\",\"email\":\"[email protected]\"}",
+ responseExchange.getIn().getBody(String.class));
+ }
+}
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/IAMMockClient.java
b/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/IAMMockClient.java
new file mode 100644
index 0000000..9033c77
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/IAMMockClient.java
@@ -0,0 +1,95 @@
+/*
+ * 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.component.huaweicloud.iam;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.huaweicloud.sdk.core.HcClient;
+import com.huaweicloud.sdk.iam.v3.IamClient;
+import com.huaweicloud.sdk.iam.v3.model.KeystoneGroupResult;
+import com.huaweicloud.sdk.iam.v3.model.KeystoneListGroupsRequest;
+import com.huaweicloud.sdk.iam.v3.model.KeystoneListGroupsResponse;
+import
com.huaweicloud.sdk.iam.v3.model.KeystoneListUsersForGroupByAdminRequest;
+import
com.huaweicloud.sdk.iam.v3.model.KeystoneListUsersForGroupByAdminResponse;
+import com.huaweicloud.sdk.iam.v3.model.KeystoneListUsersRequest;
+import com.huaweicloud.sdk.iam.v3.model.KeystoneListUsersResponse;
+import com.huaweicloud.sdk.iam.v3.model.KeystoneListUsersResult;
+import com.huaweicloud.sdk.iam.v3.model.KeystoneUserResult;
+import com.huaweicloud.sdk.iam.v3.model.Links;
+import com.huaweicloud.sdk.iam.v3.model.ShowUserRequest;
+import com.huaweicloud.sdk.iam.v3.model.ShowUserResponse;
+import com.huaweicloud.sdk.iam.v3.model.ShowUserResult;
+
+public class IAMMockClient extends IamClient {
+ public IAMMockClient(HcClient hcClient) {
+ super(null);
+ }
+
+ @Override
+ public KeystoneListUsersResponse
keystoneListUsers(KeystoneListUsersRequest request) {
+ Links links = new Links()
+ .withSelf("sample_link");
+ List<KeystoneListUsersResult> users = new ArrayList<>();
+ KeystoneListUsersResult user1 = new
KeystoneListUsersResult().withName("User 1").withDomainId("123");
+ KeystoneListUsersResult user2 = new
KeystoneListUsersResult().withName("User 2").withDomainId("456");
+ users.add(user1);
+ users.add(user2);
+ KeystoneListUsersResponse response = new KeystoneListUsersResponse()
+ .withLinks(links)
+ .withUsers(users);
+ return response;
+ }
+
+ @Override
+ public ShowUserResponse showUser(ShowUserRequest request) {
+ ShowUserResult user = new ShowUserResult()
+ .withName("User 15")
+ .withDomainId("138")
+ .withEmail("[email protected]");
+ ShowUserResponse response = new ShowUserResponse()
+ .withUser(user);
+ return response;
+ }
+
+ @Override
+ public KeystoneListUsersForGroupByAdminResponse
keystoneListUsersForGroupByAdmin(
+ KeystoneListUsersForGroupByAdminRequest request) {
+ List<KeystoneUserResult> users = new ArrayList<>();
+ KeystoneUserResult user9 = new KeystoneUserResult().withName("User
9").withId("abc");
+ KeystoneUserResult user10 = new KeystoneUserResult().withName("User
10").withId("def").withDescription("Employee");
+ users.add(user9);
+ users.add(user10);
+ KeystoneListUsersForGroupByAdminResponse response = new
KeystoneListUsersForGroupByAdminResponse()
+ .withUsers(users);
+ return response;
+ }
+
+ @Override
+ public KeystoneListGroupsResponse
keystoneListGroups(KeystoneListGroupsRequest request) {
+ List<KeystoneGroupResult> groups = new ArrayList<>();
+ KeystoneGroupResult group1
+ = new KeystoneGroupResult().withName("Group
1").withId("group1_id").withDescription("First group");
+ KeystoneGroupResult group2
+ = new KeystoneGroupResult().withName("Group
2").withId("group2_id").withDescription("Second group");
+ groups.add(group1);
+ groups.add(group2);
+ KeystoneListGroupsResponse response = new KeystoneListGroupsResponse()
+ .withGroups(groups);
+ return response;
+ }
+}
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/ListGroupsTest.java
b/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/ListGroupsTest.java
new file mode 100644
index 0000000..9119518
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/ListGroupsTest.java
@@ -0,0 +1,66 @@
+/*
+ * 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.component.huaweicloud.iam;
+
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ListGroupsTest extends CamelTestSupport {
+ private static final Logger LOG =
LoggerFactory.getLogger(ListGroupsTest.class.getName());
+
+ TestConfiguration testConfiguration = new TestConfiguration();
+
+ @BindToRegistry("iamClient")
+ IAMMockClient mockClient = new IAMMockClient(null);
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:list_groups")
+ .to("hwcloud-iam:listGroups?" +
+ "authenticationKey=" +
testConfiguration.getProperty("authenticationKey") +
+ "&secretKey=" +
testConfiguration.getProperty("secretKey") +
+ "®ion=" +
testConfiguration.getProperty("region") +
+ "&ignoreSslVerification=true" +
+ "&iamClient=#iamClient")
+ .log("List groups successful")
+ .to("mock:list_groups_result");
+ }
+ };
+ }
+
+ @Test
+ public void testListGroups() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:list_groups_result");
+ mock.expectedMinimumMessageCount(1);
+ template.sendBody("direct:list_groups", "sample_body");
+ Exchange responseExchange = mock.getExchanges().get(0);
+
+ mock.assertIsSatisfied();
+
+ assertEquals("[{\"description\":\"First
group\",\"id\":\"group1_id\",\"name\":\"Group 1\"}," +
+ "{\"description\":\"Second
group\",\"id\":\"group2_id\",\"name\":\"Group 2\"}]",
+ responseExchange.getIn().getBody(String.class));
+ }
+}
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/ListUsersTest.java
b/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/ListUsersTest.java
new file mode 100644
index 0000000..5e6287b
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/ListUsersTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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.component.huaweicloud.iam;
+
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ListUsersTest extends CamelTestSupport {
+ private static final Logger LOG =
LoggerFactory.getLogger(ListUsersTest.class.getName());
+
+ TestConfiguration testConfiguration = new TestConfiguration();
+
+ @BindToRegistry("iamClient")
+ IAMMockClient mockClient = new IAMMockClient(null);
+
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+ @Override
+ public void configure() throws Exception {
+ from("direct:list_users")
+ .to("hwcloud-iam:listUsers?" +
+ "authenticationKey=" +
testConfiguration.getProperty("authenticationKey") +
+ "&secretKey=" +
testConfiguration.getProperty("secretKey") +
+ "®ion=" +
testConfiguration.getProperty("region") +
+ "&ignoreSslVerification=true" +
+ "&iamClient=#iamClient")
+ .log("List users successful")
+ .to("mock:list_users_result");
+ }
+ };
+ }
+
+ @Test
+ public void testListUsers() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:list_users_result");
+ mock.expectedMinimumMessageCount(1);
+ template.sendBody("direct:list_users", "sample_body");
+ Exchange responseExchange = mock.getExchanges().get(0);
+
+ mock.assertIsSatisfied();
+
+ assertEquals("[{\"domainId\":\"123\",\"name\":\"User
1\"},{\"domainId\":\"456\",\"name\":\"User 2\"}]",
+ responseExchange.getIn().getBody(String.class));
+ }
+}
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/TestConfiguration.java
b/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/TestConfiguration.java
new file mode 100644
index 0000000..2c162cd
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/TestConfiguration.java
@@ -0,0 +1,49 @@
+/*
+ * 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.component.huaweicloud.iam;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestConfiguration {
+ private static final Logger LOG =
LoggerFactory.getLogger(TestConfiguration.class.getName());
+ private static Map<String, String> propertyMap;
+
+ public TestConfiguration() {
+ initPropertyMap();
+ }
+
+ private void initPropertyMap() {
+ propertyMap = new HashMap<>();
+ propertyMap.put("authenticationKey", "dummy_authentication_key");
+ propertyMap.put("secretKey", "dummy_secret_key");
+ propertyMap.put("region", "dummy_region");
+ propertyMap.put("endpoint", "dummy_endpoint");
+ propertyMap.put("userId", "dummy_user_id");
+ propertyMap.put("groupId", "dummy_group_id");
+ }
+
+ public String getProperty(String key) {
+ if (propertyMap == null) {
+ initPropertyMap();
+ }
+ return propertyMap.get(key);
+ }
+}
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/constants/IAMOperationsTest.java
b/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/constants/IAMOperationsTest.java
new file mode 100644
index 0000000..e991806
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/constants/IAMOperationsTest.java
@@ -0,0 +1,31 @@
+/*
+ * 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.component.huaweicloud.iam.constants;
+
+import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class IAMOperationsTest {
+ @Test
+ public void testOperations() {
+ assertEquals("listUsers", IAMOperations.LIST_USERS);
+ assertEquals("getUser", IAMOperations.GET_USER);
+ assertEquals("getGroupUsers", IAMOperations.GET_GROUP_USERS);
+ assertEquals("listGroups", IAMOperations.LIST_GROUPS);
+ }
+}
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/constants/IAMPropertiesTest.java
b/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/constants/IAMPropertiesTest.java
new file mode 100644
index 0000000..9ca8f85
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/test/java/org/apache/camel/component/huaweicloud/iam/constants/IAMPropertiesTest.java
@@ -0,0 +1,30 @@
+/*
+ * 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.component.huaweicloud.iam.constants;
+
+import org.junit.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+public class IAMPropertiesTest {
+ @Test
+ public void testProperties() {
+ assertEquals("CamelHwCloudIamOperation", IAMProperties.OPERATION);
+ assertEquals("CamelHwCloudIamUserId", IAMProperties.USER_ID);
+ assertEquals("CamelHwCloudIamGroupId", IAMProperties.GROUP_ID);
+ }
+}
diff --git
a/components/camel-huawei/camel-huaweicloud-iam/src/test/resources/log4j2.properties
b/components/camel-huawei/camel-huaweicloud-iam/src/test/resources/log4j2.properties
new file mode 100644
index 0000000..d9f0508
--- /dev/null
+++
b/components/camel-huawei/camel-huaweicloud-iam/src/test/resources/log4j2.properties
@@ -0,0 +1,23 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+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
+rootLogger.level = INFO
+rootLogger.appenderRef.out.ref = out
diff --git
a/components/camel-huawei/camel-huaweicloud-smn/src/main/docs/hwcloud-smn-component.adoc
b/components/camel-huawei/camel-huaweicloud-smn/src/main/docs/hwcloud-smn-component.adoc
index 84ae573..512fb11 100644
---
a/components/camel-huawei/camel-huaweicloud-smn/src/main/docs/hwcloud-smn-component.adoc
+++
b/components/camel-huawei/camel-huaweicloud-smn/src/main/docs/hwcloud-smn-component.adoc
@@ -1,8 +1,8 @@
[[hwcloud-smn-component]]
-= SimpleNotification Component
-:docTitle: SimpleNotification
+= Huawei Cloud Simple Message Notification Component
+:docTitle: Huawei Cloud Simple Message Notification (SMN)
:artifactId: camel-huaweicloud-smn
-:description: Huawei Cloud component to integrate with SimpleNotification
services
+:description: Huawei Cloud component to integrate with Simple Message
Notification
:since: 3.8
:supportLevel: Stable
:component-header: Only producer is supported
@@ -14,7 +14,7 @@
include::{cq-version}@camel-quarkus:ROOT:partial$reference/components/hwcloud-sm
*{component-header}*
-Huawei Cloud SMN component allowes you to integrate with Simple notification
services[https://www.huaweicloud.com/en-us/product/smn.html] provided by Huawei
cloud.
+Huawei Cloud Simple Message Notification (SMN) component allows you to
integrate with https://www.huaweicloud.com/intl/en-us/product/smn.html[SMN]
provided by Huawei Cloud.
Maven users will need to add the following dependency to their `pom.xml`
for this component:
@@ -42,7 +42,7 @@ hwcloud-smn:service[?options]
== Options
// component options: START
-The SimpleNotification component supports 2 options, which are listed below.
+The SMN component supports 2 options, which are listed below.
@@ -55,7 +55,7 @@ The SimpleNotification component supports 2 options, which
are listed below.
// component options: END
// endpoint options: START
-The SimpleNotification endpoint is configured using URI syntax:
+The SMN endpoint is configured using URI syntax:
----
hwcloud-smn:smnService
@@ -123,9 +123,9 @@ with the following path and query parameters:
|=======================================================================
|Header |Type |Description
-|`CamelHwCloudSmnMesssageId` |`String` | Unique message id returned by simple
message notification server after processing the request
+|`CamelHwCloudSmnMesssageId` |`String` | Unique message id returned by Simple
Message Notification server after processing the request
-|`CamelHwCloudSmnRequestId` |`String` | Unique request id returned by simple
message notification server after processing the request
+|`CamelHwCloudSmnRequestId` |`String` | Unique request id returned by Simple
Message Notification server after processing the request
|=======================================================================
diff --git a/components/camel-huawei/pom.xml b/components/camel-huawei/pom.xml
index 84724ec..cf2c706 100644
--- a/components/camel-huawei/pom.xml
+++ b/components/camel-huawei/pom.xml
@@ -34,6 +34,7 @@
<modules>
<module>camel-huaweicloud-functiongraph</module>
+ <module>camel-huaweicloud-iam</module>
<module>camel-huaweicloud-smn</module>
</modules>
diff --git a/parent/pom.xml b/parent/pom.xml
index 3a56315..0b96107 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -1520,6 +1520,11 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
+ <artifactId>camel-huaweicloud-iam</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
<artifactId>camel-huaweicloud-smn</artifactId>
<version>${project.version}</version>
</dependency>