Skip to content

Commit eaadece

Browse files
Merge pull request #229 from contentstack/feat/DX-3359-AU-support
Add support for GCP_EU and AU regions in Config and Stack classes
2 parents e21a58a + 20d23a9 commit eaadece

File tree

6 files changed

+51
-2
lines changed

6 files changed

+51
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# CHANGELOG
22

3+
## v2.3.0
4+
5+
### Date: 29-Sep-2025
6+
7+
- GCP-EU and AU region support
8+
39
## v2.2.0
410

511
### Date: 25-Aug-2025

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.contentstack.sdk</groupId>
77
<artifactId>java</artifactId>
8-
<version>2.2.0</version>
8+
<version>2.3.0</version>
99
<packaging>jar</packaging>
1010
<name>contentstack-java</name>
1111
<description>Java SDK for Contentstack Content Delivery API</description>

src/main/java/com/contentstack/sdk/Config.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ public Config setManagementToken(@NotNull String managementToken) {
211211
* The enum Contentstack region. for now contentstack supports [US, EU, AZURE_NA]
212212
*/
213213
public enum ContentstackRegion {
214-
US, EU, AZURE_NA, AZURE_EU, GCP_NA
214+
US, EU, AZURE_NA, AZURE_EU, GCP_NA, GCP_EU, AU
215215
}
216216

217217
}

src/main/java/com/contentstack/sdk/Stack.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ protected void setConfig(Config config) {
7373
urlDomain = "cdn.contentstack.com";
7474
}
7575
config.host = "gcp-na" + "-" + urlDomain;
76+
} else if (region.equalsIgnoreCase("gcp_eu")) {
77+
if (urlDomain.equalsIgnoreCase("cdn.contentstack.io")) {
78+
urlDomain = "cdn.contentstack.com";
79+
}
80+
config.host = "gcp-eu" + "-" + urlDomain;
81+
} else if (region.equalsIgnoreCase("au")) {
82+
if (urlDomain.equalsIgnoreCase("cdn.contentstack.io")) {
83+
urlDomain = "cdn.contentstack.com";
84+
}
85+
config.host = region + "-" + urlDomain;
7686
}
7787
}
7888

src/test/java/com/contentstack/sdk/TestGcpRegion.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,15 @@ void testGcpNARegionBehaviourGcpStackHost() throws IllegalAccessException {
3333
Assertions.assertEquals("gcp-na-cdn.contentstack.com", stack.config.host);
3434

3535
}
36+
37+
@Test
38+
void testGcpEURegionBehaviourGcpStack() throws IllegalAccessException {
39+
Config config = new Config();
40+
Config.ContentstackRegion region = Config.ContentstackRegion.GCP_EU;
41+
config.setRegion(region);
42+
Stack stack = Contentstack.stack("fakeApiKey", "fakeDeliveryToken", "fakeEnvironment", config);
43+
Assertions.assertFalse(config.region.name().isEmpty());
44+
Assertions.assertEquals("GCP_EU", stack.config.region.name());
45+
Assertions.assertEquals("gcp-eu-cdn.contentstack.com", stack.config.host);
46+
}
3647
}

src/test/java/com/contentstack/sdk/TestStack.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,4 +400,26 @@ public void onCompletion(ResponseType responseType, Error error) {
400400
});
401401
}
402402

403+
@Test
404+
@Order(44)
405+
void testAURegionSupport() throws IllegalAccessException {
406+
Config config = new Config();
407+
Config.ContentstackRegion region = Config.ContentstackRegion.AU;
408+
config.setRegion(region);
409+
Assertions.assertFalse(config.region.name().isEmpty());
410+
Assertions.assertEquals("AU", config.region.name());
411+
}
412+
413+
@Test
414+
@Order(45)
415+
void testAURegionBehaviourStackHost() throws IllegalAccessException {
416+
Config config = new Config();
417+
Config.ContentstackRegion region = Config.ContentstackRegion.AU;
418+
config.setRegion(region);
419+
Stack stack = Contentstack.stack("fakeApiKey", "fakeDeliveryToken", "fakeEnvironment", config);
420+
Assertions.assertFalse(config.region.name().isEmpty());
421+
Assertions.assertEquals("au-cdn.contentstack.com", stack.config.host);
422+
423+
}
424+
403425
}

0 commit comments

Comments
 (0)