Skip to content

Commit 1b30b54

Browse files
Merge pull request #90 from contentstack/development
Staging PR
2 parents 5731bfa + 16fa5cd commit 1b30b54

File tree

5 files changed

+46
-10
lines changed

5 files changed

+46
-10
lines changed

CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
# CHANGELOG
22

3+
## Version 4.1.0
4+
5+
### Date: 15-Sept-2025
6+
7+
- Added support for Australian (AU) region and GCP-EU region
8+
39
## Version 4.0.1
410

5-
### Date: 06-June-2024
11+
### Date: 06-June-2025
612

713
- Integration tests added
814
- Global fields support added

contentstack/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ android.buildFeatures.buildConfig true
1010
mavenPublishing {
1111
publishToMavenCentral(SonatypeHost.DEFAULT)
1212
signAllPublications()
13-
coordinates("com.contentstack.sdk", "android", "4.0.1")
13+
coordinates("com.contentstack.sdk", "android", "4.1.0")
1414

1515
pom {
1616
name = "contentstack-android"

contentstack/src/androidTest/java/com/contentstack/sdk/AssetTestCase.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import static junit.framework.TestCase.assertEquals;
1717
import static junit.framework.TestCase.assertNotNull;
1818

19+
import static java.lang.String.*;
20+
1921
import androidx.test.InstrumentationRegistry;
2022
import androidx.test.core.app.ApplicationProvider;
2123

@@ -149,6 +151,20 @@ public void test_AZURE_NA() throws Exception {
149151
config.setRegion(Config.ContentstackRegion.AZURE_NA);
150152
Context appContext = InstrumentationRegistry.getTargetContext();
151153
stack = Contentstack.stack(appContext, DEFAULT_API_KEY, DEFAULT_DELIVERY_TOKEN, DEFAULT_ENV, config);
154+
assertEquals("azure-na-cdn.contentstack.com", config.getHost());
155+
}
156+
157+
@Test
158+
public void test_AU() throws Exception {
159+
Config config = new Config();
160+
String DEFAULT_API_KEY = BuildConfig.APIKey;
161+
String DEFAULT_DELIVERY_TOKEN = BuildConfig.deliveryToken;
162+
String DEFAULT_ENV = BuildConfig.environment;
163+
config.setRegion(Config.ContentstackRegion.AU);
164+
// Host will be set based on region
165+
Context appContext = InstrumentationRegistry.getTargetContext();
166+
stack = Contentstack.stack(appContext, DEFAULT_API_KEY, DEFAULT_DELIVERY_TOKEN, DEFAULT_ENV, config);
167+
assertEquals("au-cdn.contentstack.com", config.getHost());
152168
}
153169

154170
@Test
@@ -162,6 +178,7 @@ public void test_GCP_NA() throws Exception {
162178
config.setRegion(Config.ContentstackRegion.GCP_NA);
163179
Context appContext = InstrumentationRegistry.getTargetContext();
164180
stack = Contentstack.stack(appContext, DEFAULT_API_KEY, DEFAULT_DELIVERY_TOKEN, DEFAULT_ENV, config);
181+
assertEquals("gcp-na-cdn.contentstack.com", config.getHost());
165182
}
166183

167184
@Test

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,17 @@ public Config earlyAccess(String[] earlyAccess) {
8686
return this;
8787
}
8888

89-
public enum ContentstackRegion {US, EU, AZURE_NA, AZURE_EU, GCP_NA}
89+
/**
90+
* Represents the available Contentstack regions.
91+
* US: United States region (default)
92+
* EU: European region
93+
* AU: Australian region
94+
* AZURE_NA: Azure North America region
95+
* AZURE_EU: Azure European region
96+
* GCP_NA: Google Cloud Platform North America region
97+
* GCP_EU: Google Cloud Platform European region
98+
*/
99+
public enum ContentstackRegion {US, EU, AU, AZURE_NA, AZURE_EU, GCP_NA, GCP_EU}
90100

91101
/**
92102
* Config constructor

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,27 +78,30 @@ protected void setConfig(Config config) {
7878
if (!TextUtils.isEmpty(config.environment)) {
7979
setHeader("environment", config.environment);
8080
}
81+
// Handle region setting first before any host overrides
8182
if (!config.region.name().isEmpty()) {
8283
String region = config.region.name().toLowerCase();
8384
if (!region.equalsIgnoreCase("us")) {
84-
if (URL.equalsIgnoreCase("cdn.contentstack.io")) {
85-
URL = "cdn.contentstack.com";
86-
}
8785
if (region.equalsIgnoreCase("azure_na")) {
88-
URL = "azure-na-cdn.contentstack.com";
86+
config.setHost("azure-na-cdn.contentstack.com");
8987
} else if (region.equalsIgnoreCase("azure_eu")) {
90-
URL = "azure-eu-cdn.contentstack.com";
88+
config.setHost("azure-eu-cdn.contentstack.com");
9189
} else if (region.equalsIgnoreCase("gcp_na")) {
92-
URL = "gcp-na-cdn.contentstack.com";
90+
config.setHost("gcp-na-cdn.contentstack.com");
91+
} else if (region.equalsIgnoreCase("gcp_eu")) {
92+
config.setHost("gcp-eu-cdn.contentstack.com");
93+
} else if (region.equalsIgnoreCase("au")) {
94+
config.setHost("au-cdn.contentstack.com");
9395
} else {
94-
URL = region + "-" + URL;
96+
config.setHost(region + "-cdn.contentstack.io");
9597
}
9698
}
9799
}
98100
String endpoint = config.PROTOCOL + config.URL;
99101
this.config.setEndpoint(endpoint);
100102
client(endpoint);
101103

104+
102105
}
103106

104107
private void client(String endpoint) {

0 commit comments

Comments
 (0)