Skip to content

Commit f8283ff

Browse files
charlesliqlogicandreamlin
authored andcommitted
---
yaml --- r: 14009 b: refs/heads/autosynth-container c: 28a85a7 h: refs/heads/master i: 14007: fae60e0
1 parent 5370270 commit f8283ff

3 files changed

Lines changed: 139 additions & 1 deletion

File tree

  • branches/autosynth-container/google-cloud-clients/google-cloud-compute/src

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ refs/tags/v0.65.0: 10939381ffe0b8da32db4fe3087c86e3aa7f3e55
113113
refs/tags/v0.66.0: ed6a3f57cbdaa20339a1995f7d7d53b172a5b8ef
114114
refs/tags/v0.67.0: 30b56f02092efc6f3c3667650ea8b8825003e0b7
115115
refs/heads/autosynth-compute: 8e86445e504cea6f99b9fb237bfd7f0e5ef8b3ce
116-
refs/heads/autosynth-container: 8463514b02972e29ad1193e93e73d223bf7f6f38
116+
refs/heads/autosynth-container: 28a85a77883ccf5d48f297fd0ef3b3dca6ce01f0
117117
refs/heads/autosynth-dataproc: bc74a8841bc1693d7945d991d15979df550b1fd1
118118
refs/heads/autosynth-monitoring: 120f508e0065f4ce39cf0e6a69a08138773f2cfb
119119
refs/heads/autosynth-pubsub: ed3340e32d13bb1a42ca4431cb1ad9bdaf550aa4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
/*
2+
* Copyright 2019 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.google.cloud.compute;
17+
18+
import java.util.HashMap;
19+
import java.util.Map;
20+
21+
/**
22+
* Enumeration of Regions.
23+
*
24+
* @see <a href="https://cloud.google.com/compute/docs/regions-zones/">Regions and Zones</a>
25+
*/
26+
public enum Regions {
27+
ASIA_EAST1("asia-east1", new String[] {"asia-east1-a", "asia-east1-b", "asia-east1-c"}),
28+
ASIA_EAST2("asia-east2", new String[] {"asia-east2-a", "asia-east2-b", "asia-east2-c"}),
29+
ASIA_NORTHEAST1(
30+
"asia-northeast1",
31+
new String[] {"asia-northeast1-a", "asia-northeast1-b", "asia-northeast1-c"}),
32+
ASIA_SOUTH1("asia-south1", new String[] {"asia-south1-a", "asia-south1-b", "asia-south1-c"}),
33+
ASIA_SOUTHEAST1(
34+
"asia-southeast1",
35+
new String[] {"asia-southeast1-a", "asia-southeast1-b", "asia-southeast1-c"}),
36+
AUSTRALIA_SOUTHEAST1(
37+
"australia-southeast1",
38+
new String[] {"australia-southeast1-a", "australia-southeast1-b", "australia-southeast1-c"}),
39+
EUROPE_NORTH1(
40+
"europe-north1", new String[] {"europe-north1-a", "europe-north1-b", "europe-north1-c"}),
41+
EUROPE_WEST1("europe-west1", new String[] {"europe-west1-b", "europe-west1-c", "europe-west1-d"}),
42+
EUROPE_WEST2("europe-west2", new String[] {"europe-west2-a", "europe-west2-b", "europe-west2-c"}),
43+
EUROPE_WEST3("europe-west3", new String[] {"europe-west3-a", "europe-west3-b", "europe-west3-c"}),
44+
EUROPE_WEST4("europe-west4", new String[] {"europe-west4-a", "europe-west4-b", "europe-west4-c"}),
45+
NORTHAMERICA_NORTHEAST1(
46+
"northamerica-northeast1",
47+
new String[] {
48+
"northamerica-northeast1-a", "northamerica-northeast1-b", "northamerica-northeast1-c"
49+
}),
50+
SOUTHAMERICA_EAST1(
51+
"southamerica-east1",
52+
new String[] {"southamerica-east1-a", "southamerica-east1-b", "southamerica-east1-c"}),
53+
US_CENTRAL1(
54+
"us-central1",
55+
new String[] {"us-central1-a", "us-central1-b", "us-central1-c", "us-central1-f"}),
56+
US_EAST1("us-east1", new String[] {"us-east1-b", "us-east1-c", "us-east1-d"}),
57+
US_EAST4("us-east4", new String[] {"us-east4-a", "us-east4-b", "us-east4-c"}),
58+
US_WEST1("us-west1", new String[] {"us-west1-a", "us-west1-b", "us-west1-c"}),
59+
US_WEST2("us-west2", new String[] {"us-west2-a", "us-west2-b", "us-west2-c"});
60+
61+
private static final Map<String, Regions> REGIONS = new HashMap<>();
62+
63+
static {
64+
for (Regions region : Regions.values()) {
65+
REGIONS.put(region.name, region);
66+
}
67+
}
68+
69+
private final String name;
70+
private final String[] zones;
71+
72+
private Regions(String name, String[] zones) {
73+
this.name = name;
74+
this.zones = zones;
75+
}
76+
77+
/** The name of this region. */
78+
public String getName() {
79+
return name;
80+
}
81+
82+
/** The zones of this region. */
83+
public String[] getZones() {
84+
return zones;
85+
}
86+
87+
/**
88+
* Returns a Regions enum corresponding to the given region name.
89+
*
90+
* @param regionName The name of the region.
91+
* @return Regions enum representing the given region name, or a null if there is no Regions enum
92+
* that is representing the given region name.
93+
*/
94+
public static Regions fromName(String regionName) {
95+
return REGIONS.get(regionName);
96+
}
97+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2019 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.google.cloud.compute;
17+
18+
import org.junit.Assert;
19+
import org.junit.Test;
20+
21+
public class RegionsTest {
22+
@Test
23+
public void fromNameWhenNullReturnNull() {
24+
Assert.assertNull(Regions.fromName(null));
25+
}
26+
27+
@Test
28+
public void fromNameWhenEmptyReturnNull() {
29+
Assert.assertNull(Regions.fromName(""));
30+
}
31+
32+
@Test
33+
public void fromNameWhenInvalidReturnNull() {
34+
Assert.assertNull(Regions.fromName("mars"));
35+
}
36+
37+
@Test
38+
public void fromNameWhenValidReturnRegion() {
39+
Assert.assertEquals(Regions.ASIA_EAST1, Regions.fromName("asia-east1"));
40+
}
41+
}

0 commit comments

Comments
 (0)