Repository: nifi Updated Branches: refs/heads/master ba84ad1e3 -> 579078e35
NIFI-5129: AWS Processors now displays proper region names Signed-off-by: James Wing <[email protected]> This closes #2665. Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/579078e3 Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/579078e3 Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/579078e3 Branch: refs/heads/master Commit: 579078e3521040a6e37ce08cadf4c79942a4229e Parents: ba84ad1 Author: zenfenan <[email protected]> Authored: Sat Apr 28 21:36:37 2018 +0530 Committer: James Wing <[email protected]> Committed: Sun Apr 29 17:06:10 2018 -0700 ---------------------------------------------------------------------- .../processors/aws/AbstractAWSProcessor.java | 10 ++-- .../nifi/processors/aws/regions/AWSRegions.java | 58 ++++++++++++++++++++ 2 files changed, 63 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/579078e3/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/AbstractAWSProcessor.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/AbstractAWSProcessor.java b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/AbstractAWSProcessor.java index d066606..a091812 100644 --- a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/AbstractAWSProcessor.java +++ b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/AbstractAWSProcessor.java @@ -51,6 +51,7 @@ import org.apache.nifi.processor.Relationship; import org.apache.nifi.processor.exception.ProcessException; import org.apache.nifi.processor.util.StandardValidators; import org.apache.nifi.processors.aws.credentials.provider.factory.CredentialPropertyDescriptors; +import org.apache.nifi.processors.aws.regions.AWSRegions; import org.apache.nifi.ssl.SSLContextService; /** @@ -129,16 +130,15 @@ public abstract class AbstractAWSProcessor<ClientType extends AmazonWebServiceCl protected static final Protocol DEFAULT_PROTOCOL = Protocol.HTTPS; protected static final String DEFAULT_USER_AGENT = "NiFi"; - private static AllowableValue createAllowableValue(final Regions regions) { - return new AllowableValue(regions.getName(), regions.getName(), regions.getName()); + private static AllowableValue createAllowableValue(final Regions region) { + return new AllowableValue(region.getName(), AWSRegions.getRegionDisplayName(region.getName())); } private static AllowableValue[] getAvailableRegions() { final List<AllowableValue> values = new ArrayList<>(); - for (final Regions regions : Regions.values()) { - values.add(createAllowableValue(regions)); + for (final Regions region : Regions.values()) { + values.add(createAllowableValue(region)); } - return values.toArray(new AllowableValue[values.size()]); } http://git-wip-us.apache.org/repos/asf/nifi/blob/579078e3/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/regions/AWSRegions.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/regions/AWSRegions.java b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/regions/AWSRegions.java new file mode 100644 index 0000000..f2d01a8 --- /dev/null +++ b/nifi-nar-bundles/nifi-aws-bundle/nifi-aws-abstract-processors/src/main/java/org/apache/nifi/processors/aws/regions/AWSRegions.java @@ -0,0 +1,58 @@ +/* + * 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.nifi.processors.aws.regions; + +public enum AWSRegions { + + GovCloud("us-gov-west-1", "AWS GovCloud (US)"), + US_EAST_1("us-east-1", "US East (N. Virginia)"), + US_EAST_2("us-east-2", "US East (Ohio)"), + US_WEST_1("us-west-1", "US West (N. California)"), + US_WEST_2("us-west-2", "US West (Oregon)"), + EU_WEST_1("eu-west-1", "EU (Ireland)"), + EU_WEST_2("eu-west-2", "EU (London)"), + EU_WEST_3("eu-west-3", "EU (Paris)"), + EU_CENTRAL_1("eu-central-1", "EU (Frankfurt)"), + AP_SOUTH_1("ap-south-1", "Asia Pacific (Mumbai)"), + AP_SOUTHEAST_1("ap-southeast-1", "Asia Pacific (Singapore)"), + AP_SOUTHEAST_2("ap-southeast-2", "Asia Pacific (Sydney)"), + AP_NORTHEAST_1("ap-northeast-1", "Asia Pacific (Tokyo)"), + AP_NORTHEAST_2("ap-northeast-2", "Asia Pacific (Seoul)"), + SA_EAST_1("sa-east-1", "South America (Sao Paulo)"), + CN_NORTH_1("cn-north-1", "China (Beijing)"), + CN_NORTHWEST_1("cn-northwest-1", "China (Ningxia)"), + CA_CENTRAL_1("ca-central-1", "Canada (Central)"); + + private final String regionCode; + private final String regionDisplayName; + + AWSRegions(String regionCode, String regionDisplayName) { + this.regionCode = regionCode; + this.regionDisplayName = regionDisplayName; + } + + public static String getRegionDisplayName(String regionCode) { + for (AWSRegions regions : AWSRegions.values()) { + if (regions.regionCode.equalsIgnoreCase(regionCode)) { + return regions.regionDisplayName; + } + } + + return regionCode; + } + +}
