Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# CHANGELOG

## Version 4.1.0

### Date: 15-Sept-2025

- Added support for Australian (AU) region and GCP-EU region

## Version 4.0.1

### Date: 06-June-2024
### Date: 06-June-2025

- Integration tests added
- Global fields support added
Expand Down
2 changes: 1 addition & 1 deletion contentstack/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ android.buildFeatures.buildConfig true
mavenPublishing {
publishToMavenCentral(SonatypeHost.DEFAULT)
signAllPublications()
coordinates("com.contentstack.sdk", "android", "4.0.1")
coordinates("com.contentstack.sdk", "android", "4.1.0")

pom {
name = "contentstack-android"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertNotNull;

import static java.lang.String.*;

import androidx.test.InstrumentationRegistry;
import androidx.test.core.app.ApplicationProvider;

Expand Down Expand Up @@ -149,6 +151,20 @@ public void test_AZURE_NA() throws Exception {
config.setRegion(Config.ContentstackRegion.AZURE_NA);
Context appContext = InstrumentationRegistry.getTargetContext();
stack = Contentstack.stack(appContext, DEFAULT_API_KEY, DEFAULT_DELIVERY_TOKEN, DEFAULT_ENV, config);
assertEquals("azure-na-cdn.contentstack.com", config.getHost());
}

@Test
public void test_AU() throws Exception {
Config config = new Config();
String DEFAULT_API_KEY = BuildConfig.APIKey;
String DEFAULT_DELIVERY_TOKEN = BuildConfig.deliveryToken;
String DEFAULT_ENV = BuildConfig.environment;
config.setRegion(Config.ContentstackRegion.AU);
// Host will be set based on region
Context appContext = InstrumentationRegistry.getTargetContext();
stack = Contentstack.stack(appContext, DEFAULT_API_KEY, DEFAULT_DELIVERY_TOKEN, DEFAULT_ENV, config);
assertEquals("au-cdn.contentstack.com", config.getHost());
}

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

@Test
Expand Down
12 changes: 11 additions & 1 deletion contentstack/src/main/java/com/contentstack/sdk/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,17 @@ public Config earlyAccess(String[] earlyAccess) {
return this;
}

public enum ContentstackRegion {US, EU, AZURE_NA, AZURE_EU, GCP_NA}
/**
* Represents the available Contentstack regions.
* US: United States region (default)
* EU: European region
* AU: Australian region
* AZURE_NA: Azure North America region
* AZURE_EU: Azure European region
* GCP_NA: Google Cloud Platform North America region
* GCP_EU: Google Cloud Platform European region
*/
public enum ContentstackRegion {US, EU, AU, AZURE_NA, AZURE_EU, GCP_NA, GCP_EU}

/**
* Config constructor
Expand Down
18 changes: 11 additions & 7 deletions contentstack/src/main/java/com/contentstack/sdk/Stack.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,27 +78,31 @@ protected void setConfig(Config config) {
if (!TextUtils.isEmpty(config.environment)) {
setHeader("environment", config.environment);
}
// Handle region setting first before any host overrides
if (!config.region.name().isEmpty()) {
String region = config.region.name().toLowerCase();
if (!region.equalsIgnoreCase("us")) {
if (URL.equalsIgnoreCase("cdn.contentstack.io")) {
URL = "cdn.contentstack.com";
}
if (region.equalsIgnoreCase("azure_na")) {
URL = "azure-na-cdn.contentstack.com";
config.setHost("azure-na-cdn.contentstack.com");
} else if (region.equalsIgnoreCase("azure_eu")) {
URL = "azure-eu-cdn.contentstack.com";
config.setHost("azure-eu-cdn.contentstack.com");
} else if (region.equalsIgnoreCase("gcp_na")) {
URL = "gcp-na-cdn.contentstack.com";
config.setHost("gcp-na-cdn.contentstack.com");
} else if (region.equalsIgnoreCase("gcp_eu")) {
config.setHost("gcp-eu-cdn.contentstack.com");
} else if (region.equalsIgnoreCase("au")) {
config.setHost("au-cdn.contentstack.com");
} else {
URL = region + "-" + URL;
config.setHost(region + "-cdn.contentstack.io");
}
}
}
String endpoint = config.PROTOCOL + config.URL;
this.config.setEndpoint(endpoint);
System.out.println("Endpoint:" + endpoint);
client(endpoint);


}

private void client(String endpoint) {
Expand Down
Loading