Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions azure-mgmt-redis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

<artifactId>azure-mgmt-redis</artifactId>
<packaging>jar</packaging>
<version>1.0.0-SNAPSHOT</version>

<name>Microsoft Azure SDK for Redis Cache Management</name>
<description>This package contains Microsoft Azure Redis Cache SDK.</description>
Expand Down Expand Up @@ -132,4 +131,4 @@
</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -6,81 +6,128 @@

package com.microsoft.azure.management.resources.fluentcore.arm;

import com.fasterxml.jackson.annotation.JsonValue;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
* Enumeration of the Azure datacenter regions. See https://azure.microsoft.com/regions/
*/
public enum Region {
public class Region {
// CHECKSTYLE IGNORE Javadoc FOR NEXT 48 LINES
/**************************************************
* Azure Cloud - Americas
**************************************************/
US_WEST("westus", "West US"),
US_WEST2("westus2", "West US 2"),
US_CENTRAL("centralus", "Central US"),
US_EAST("eastus", "East US"),
US_EAST2("eastus2", "East US 2"),
US_NORTH_CENTRAL("northcentralus", "North Central US"),
US_SOUTH_CENTRAL("southcentralus", "South Central US"),
US_WEST_CENTRAL("westcentralus", "West Central US"),
CANADA_CENTRAL("canadacentral", "Canada Central"),
CANADA_EAST("canadaeast", "Canada East"),
BRAZIL_SOUTH("brazilsouth", "Brazil South"),
public static final Region US_WEST = new Region("westus", "West US");
public static final Region US_WEST2 = new Region("westus2", "West US 2");
public static final Region US_CENTRAL = new Region("centralus", "Central US");
public static final Region US_EAST = new Region("eastus", "East US");
public static final Region US_EAST2 = new Region("eastus2", "East US 2");
public static final Region US_NORTH_CENTRAL = new Region("northcentralus", "North Central US");
public static final Region US_SOUTH_CENTRAL = new Region("southcentralus", "South Central US");
public static final Region US_WEST_CENTRAL = new Region("westcentralus", "West Central US");
public static final Region CANADA_CENTRAL = new Region("canadacentral", "Canada Central");
public static final Region CANADA_EAST = new Region("canadaeast", "Canada East");
public static final Region BRAZIL_SOUTH = new Region("brazilsouth", "Brazil South");
/**************************************************
* Azure Cloud - Europe
**************************************************/
EUROPE_NORTH("northeurope", "North Europe"),
EUROPE_WEST("westeurope", "West Europe"),
UK_SOUTH("uksouth", "UK South"),
UK_WEST("ukwest", "UK West"),
public static final Region EUROPE_NORTH = new Region("northeurope", "North Europe");
public static final Region EUROPE_WEST = new Region("westeurope", "West Europe");
public static final Region UK_SOUTH = new Region("uksouth", "UK South");
public static final Region UK_WEST = new Region("ukwest", "UK West");
/**************************************************
* Azure Cloud - Asia
**************************************************/
ASIA_EAST("eastasia", "East Asia"),
ASIA_SOUTHEAST("southeastasia", "South East Asia"),
JAPAN_EAST("japaneast", "Japan East"),
JAPAN_WEST("japanwest", "Japan West"),
AUSTRALIA_EAST("australiaeast", "Australia East"),
AUSTRALIA_SOUTHEAST("australiasoutheast", "Australia Southeast"),
INDIA_CENTRAL("centralindia", "Central India"),
INDIA_SOUTH("southindia", "South India"),
INDIA_WEST("westindia", "West India"),
public static final Region ASIA_EAST = new Region("eastasia", "East Asia");
public static final Region ASIA_SOUTHEAST = new Region("southeastasia", "South East Asia");
public static final Region JAPAN_EAST = new Region("japaneast", "Japan East");
public static final Region JAPAN_WEST = new Region("japanwest", "Japan West");
public static final Region AUSTRALIA_EAST = new Region("australiaeast", "Australia East");
public static final Region AUSTRALIA_SOUTHEAST = new Region("australiasoutheast", "Australia Southeast");
public static final Region INDIA_CENTRAL = new Region("centralindia", "Central India");
public static final Region INDIA_SOUTH = new Region("southindia", "South India");
public static final Region INDIA_WEST = new Region("westindia", "West India");
/**************************************************
* Azure China Cloud
**************************************************/
CHINA_NORTH("chinanorth", "China North"),
CHINA_EAST("chinaeast", "China East"),
public static final Region CHINA_NORTH = new Region("chinanorth", "China North");
public static final Region CHINA_EAST = new Region("chinaeast", "China East");
/**************************************************
* Azure German Cloud
**************************************************/
GERMANY_CENTRAL("germanycentral", "Germany Central"),
GERMANY_NORTHEAST("germanynortheast", "Germany Northeast"),
public static final Region GERMANY_CENTRAL = new Region("germanycentral", "Germany Central");
public static final Region GERMANY_NORTHEAST = new Region("germanynortheast", "Germany Northeast");
/**************************************************
* Azure Government Cloud
**************************************************/
GOV_US_VIRGINIA("usgoveast", "US Gov Virginia"),
GOV_US_IOWA("usgovcentral", "US Gov Iowa");
public static final Region GOV_US_VIRGINIA = new Region("usgovvirginia", "US Gov Virginia");
public static final Region GOV_US_IOWA = new Region("usgoviowa", "US Gov Iowa");

private static final List<Region> VALUES;

private final String name;
private final String label;

Region(String name, String label) {
static {
Field[] declaredFields = Region.class.getDeclaredFields();
List<Region> values = new ArrayList<>();
for (Field field : declaredFields) {
if (Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers())) {
field.setAccessible(true);
try {
values.add((Region) field.get(null));
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
}
VALUES = Collections.unmodifiableList(values);
}

/**
* Create a region from a name and a label.
*
* @param name the uniquely identifiable name of the region
* @param label the label of the region
*/
public Region(String name, String label) {
this.name = name;
this.label = label;
}

@JsonValue
@Override
public String toString() {
return name();
}

/**
* @return the name of the region
*/
public String name() {
return this.name;
}

/**
* @return the label of the region
*/
public String label() {
return this.label;
}

/**
* Parses a label into a Region object.
*
* @param label the region label
* @return the parsed region or null if there's no such region
*/
public static Region fromLabel(String label) {
for (Region region : Region.values()) {
for (Region region : Region.VALUES) {
if (region.label.equalsIgnoreCase(label)) {
return region;
}
Expand All @@ -95,11 +142,28 @@ public static Region fromLabel(String label) {
* @return the parsed region or null if there's no such region
*/
public static Region fromName(String name) {
for (Region region : Region.values()) {
for (Region region : Region.VALUES) {
if (region.name.equalsIgnoreCase(name)) {
return region;
}
}
return null;
}

@Override
public int hashCode() {
return name.hashCode();
}

@Override
public boolean equals(Object obj) {
if (!(obj instanceof Region)) {
return false;
}
if (obj == this) {
return true;
}
Region rhs = (Region) obj;
return name.equalsIgnoreCase(rhs.name);
}
}
10 changes: 5 additions & 5 deletions azure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@
<artifactId>azure-mgmt-dns</artifactId>
<version>1.0.0-beta4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-mgmt-redis</artifactId>
<version>1.0.0-beta4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand All @@ -121,11 +126,6 @@
<artifactId>api-annotations</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-mgmt-redis</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>

</dependencies>
<build>
Expand Down