Skip to content

Commit 6259848

Browse files
feat: ✨ gcp support implementation
1 parent 949ac27 commit 6259848

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public Config setManagementToken(@NotNull String managementToken) {
196196
* The enum Contentstack region. for now contentstack supports [US, EU, AZURE_NA]
197197
*/
198198
public enum ContentstackRegion {
199-
US, EU, AZURE_NA, AZURE_EU
199+
US, EU, AZURE_NA, AZURE_EU, GCP_NA
200200
}
201201

202202
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ protected void setConfig(Config config) {
6363
urlDomain = "cdn.contentstack.com";
6464
}
6565
config.host = "azure-eu" + "-" + urlDomain;
66+
} else if (region.equalsIgnoreCase("gcp_na")) {
67+
if (urlDomain.equalsIgnoreCase("cdn.contentstack.io")) {
68+
urlDomain = "cdn.contentstack.com";
69+
}
70+
config.host = "gcp-na" + "-" + urlDomain;
6671
}
6772
}
6873

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.contentstack.sdk;
2+
3+
import org.junit.jupiter.api.Assertions;
4+
import org.junit.jupiter.api.Test;
5+
6+
public class TestGcpRegion {
7+
@Test
8+
void testGcpRegionBehaviourGcpNA() {
9+
Config config = new Config();
10+
Config.ContentstackRegion region = Config.ContentstackRegion.GCP_NA;
11+
config.setRegion(region);
12+
Assertions.assertFalse(config.region.name().isEmpty());
13+
Assertions.assertEquals("GCP_NA", config.region.name());
14+
}
15+
16+
@Test
17+
void testGcpNaRegionBehaviourGcpStack() throws IllegalAccessException {
18+
Config config = new Config();
19+
Config.ContentstackRegion region = Config.ContentstackRegion.GCP_NA;
20+
config.setRegion(region);
21+
Stack stack = Contentstack.stack("fakeApiKey", "fakeDeliveryToken", "fakeEnvironment", config);
22+
Assertions.assertFalse(config.region.name().isEmpty());
23+
Assertions.assertEquals("GCP_NA", stack.config.region.name());
24+
}
25+
26+
@Test
27+
void testGcpNARegionBehaviourGcpStackHost() throws IllegalAccessException {
28+
Config config = new Config();
29+
Config.ContentstackRegion region = Config.ContentstackRegion.GCP_NA;
30+
config.setRegion(region);
31+
Stack stack = Contentstack.stack("fakeApiKey", "fakeDeliveryToken", "fakeEnvironment", config);
32+
Assertions.assertFalse(config.region.name().isEmpty());
33+
Assertions.assertEquals("gcp-na-cdn.contentstack.com", stack.config.host);
34+
35+
}
36+
}

0 commit comments

Comments
 (0)