You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/04/08 08:39:09 UTC

[camel] 01/02: CAMEL-14850 - Camel-AWS2-*: Improve the verifiers to check if a particular service works on a specified region, Translate

This is an automated email from the ASF dual-hosted git repository.

acosentino pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 889236e1dea8205ffaa6892e6d3d708e58c5dc8a
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Wed Apr 8 10:17:55 2020 +0200

    CAMEL-14850 - Camel-AWS2-*: Improve the verifiers to check if a particular service works on a specified region, Translate
---
 .../aws2/translate/Translate2ComponentVerifierExtension.java         | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/components/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2ComponentVerifierExtension.java b/components/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2ComponentVerifierExtension.java
index b3872f2..cebb2be 100644
--- a/components/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2ComponentVerifierExtension.java
+++ b/components/camel-aws2-translate/src/main/java/org/apache/camel/component/aws2/translate/Translate2ComponentVerifierExtension.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.aws2.translate;
 
 import java.util.Map;
 
+import org.apache.camel.component.extension.ComponentVerifierExtension.VerificationError;
 import org.apache.camel.component.extension.verifier.DefaultComponentVerifierExtension;
 import org.apache.camel.component.extension.verifier.ResultBuilder;
 import org.apache.camel.component.extension.verifier.ResultErrorBuilder;
@@ -67,6 +68,10 @@ public class Translate2ComponentVerifierExtension extends DefaultComponentVerifi
 
         try {
             Translate2Configuration configuration = setProperties(new Translate2Configuration(), parameters);
+            if (!TranslateClient.serviceMetadata().regions().contains(Region.of(configuration.getRegion()))) {
+                ResultErrorBuilder errorBuilder = ResultErrorBuilder.withCodeAndDescription(VerificationError.StandardCode.ILLEGAL_PARAMETER, "The service is not supported in this region");
+                return builder.error(errorBuilder.build()).build();
+            }
             AwsBasicCredentials cred = AwsBasicCredentials.create(configuration.getAccessKey(), configuration.getSecretKey());
             TranslateClientBuilder clientBuilder = TranslateClient.builder();
             TranslateClient client = clientBuilder.credentialsProvider(StaticCredentialsProvider.create(cred)).region(Region.of(configuration.getRegion())).build();