Skip to content

Commit 13ab5eb

Browse files
authored
added new OCI regions (BOG, OZZ, DRS)
also removed obsolete region codes test.
1 parent c944ede commit 13ab5eb

File tree

4 files changed

+61
-217
lines changed

4 files changed

+61
-217
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
2323
- isReplicated()
2424
- isLocalReplicaInitialized()
2525
- getReplicas()
26+
- Cloud only: added new OCI regions (BOG, OZZ, DRS)
2627

2728
## [5.4.12] 2023-07-28
2829

driver/src/main/java/oracle/nosql/driver/Region.java

Lines changed: 43 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public class Region {
6161
private static final Map<String, Region> OC20_REGIONS = new HashMap<>();
6262
private static final Map<String, Region> OC22_REGIONS = new HashMap<>();
6363
private static final Map<String, Region> OC24_REGIONS = new HashMap<>();
64+
private static final Map<String, Region> OC27_REGIONS = new HashMap<>();
65+
private static final Map<String, Region> OC28_REGIONS = new HashMap<>();
6466

6567
/* OC1 */
6668
/** JNB */
@@ -137,6 +139,8 @@ public class Region {
137139
/** YYZ */
138140
public static final Region CA_TORONTO_1 = new Region("ca-toronto-1");
139141

142+
/** BOG */
143+
public static final Region SA_BOGOTA_1 = new Region("sa-bogota-1");
140144
/** GRU */
141145
public static final Region SA_SAOPAULO_1 = new Region("sa-saopaulo-1");
142146
/** SCL */
@@ -228,6 +232,14 @@ public class Region {
228232
/** AVZ */
229233
public static final Region EU_DCC_ZURICH_1 = new Region("eu-dcc-zurich-1");
230234

235+
/* OC27 */
236+
/** OZZ */
237+
public static final Region US_DCC_SWJORDAN_1 = new Region("us-dcc-swjordan-1");
238+
239+
/* OC28 */
240+
/** DRS */
241+
public static final Region US_DCC_SWJORDAN_2 = new Region("us-dcc-swjordan-2");
242+
231243
static {
232244
/* OC1 */
233245
/* AF */
@@ -267,6 +279,7 @@ public class Region {
267279
OC1_REGIONS.put(IL_JERUSALEM_1.getRegionId(), IL_JERUSALEM_1);
268280

269281
/* LAD */
282+
OC1_REGIONS.put(SA_BOGOTA_1.getRegionId(), SA_BOGOTA_1);
270283
OC1_REGIONS.put(SA_SAOPAULO_1.getRegionId(), SA_SAOPAULO_1);
271284
OC1_REGIONS.put(SA_SANTIAGO_1.getRegionId(), SA_SANTIAGO_1);
272285
OC1_REGIONS.put(SA_VALPARAISO_1.getRegionId(), SA_VALPARAISO_1);
@@ -336,6 +349,12 @@ public class Region {
336349

337350
/* OC24 */
338351
OC24_REGIONS.put(EU_DCC_ZURICH_1.getRegionId(), EU_DCC_ZURICH_1);
352+
353+
/* OC27 */
354+
OC27_REGIONS.put(US_DCC_SWJORDAN_1.getRegionId(), US_DCC_SWJORDAN_1);
355+
356+
/* OC28 */
357+
OC28_REGIONS.put(US_DCC_SWJORDAN_2.getRegionId(), US_DCC_SWJORDAN_2);
339358
}
340359

341360
private final static MessageFormat OC1_EP_BASE = new MessageFormat(
@@ -366,6 +385,10 @@ public class Region {
366385
"https://nosql.{0}.oci.oraclecloud22.com");
367386
private final static MessageFormat OC24_EP_BASE = new MessageFormat(
368387
"https://nosql.{0}.oci.oraclecloud24.com");
388+
private final static MessageFormat OC27_EP_BASE = new MessageFormat(
389+
"https://nosql.{0}.oci.oraclecloud27.com");
390+
private final static MessageFormat OC28_EP_BASE = new MessageFormat(
391+
"https://nosql.{0}.oci.oraclecloud28.com");
369392

370393
private String regionId;
371394

@@ -420,6 +443,12 @@ public String endpoint() {
420443
if (isOC24Region(regionId)) {
421444
return OC24_EP_BASE.format(new Object[] { regionId });
422445
}
446+
if (isOC27Region(regionId)) {
447+
return OC27_EP_BASE.format(new Object[] { regionId });
448+
}
449+
if (isOC28Region(regionId)) {
450+
return OC28_EP_BASE.format(new Object[] { regionId });
451+
}
423452
throw new IllegalArgumentException(
424453
"Unable to find endpoint for unknown region" + regionId);
425454
}
@@ -477,6 +506,12 @@ public static Region fromRegionId(String regionId) {
477506
if (region == null) {
478507
region = OC24_REGIONS.get(regionId);
479508
}
509+
if (region == null) {
510+
region = OC27_REGIONS.get(regionId);
511+
}
512+
if (region == null) {
513+
region = OC28_REGIONS.get(regionId);
514+
}
480515

481516
return region;
482517
}
@@ -633,109 +668,21 @@ public static boolean isOC24Region(String regionId) {
633668
/**
634669
* @hidden
635670
* Internal use only
636-
* @return the regions
637-
*/
638-
public static Collection<Region> getOC1Regions() {
639-
return OC1_REGIONS.values();
640-
}
641-
642-
/**
643-
* @hidden
644-
* Internal use only
645-
* @return the regions
646-
*/
647-
public static Collection<Region> getGovRegions() {
648-
return GOV_REGIONS.values();
649-
}
650-
651-
/**
652-
* @hidden
653-
* Internal use only
654-
* @return the regions
655-
*/
656-
public static Collection<Region> getOC4Regions() {
657-
return OC4_REGIONS.values();
658-
}
659-
660-
/**
661-
* @hidden
662-
* Internal use only
663-
* @return the regions
664-
*/
665-
public static Collection<Region> getOC5Regions() {
666-
return OC5_REGIONS.values();
667-
}
668-
669-
/**
670-
* @hidden
671-
* Internal use only
672-
* @return the regions
673-
*/
674-
public static Collection<Region> getOC8Regions() {
675-
return OC8_REGIONS.values();
676-
}
677-
678-
/**
679-
* @hidden
680-
* Internal use only
681-
* @return the regions
682-
*/
683-
public static Collection<Region> getOC9Regions() {
684-
return OC9_REGIONS.values();
685-
}
686-
687-
/**
688-
* @hidden
689-
* Internal use only
690-
* @return the regions
691-
*/
692-
public static Collection<Region> getOC10Regions() {
693-
return OC10_REGIONS.values();
694-
}
695-
696-
/**
697-
* @hidden
698-
* Internal use only
699-
* @return the regions
700-
*/
701-
public static Collection<Region> getOC14Regions() {
702-
return OC14_REGIONS.values();
703-
}
704-
705-
/**
706-
* @hidden
707-
* Internal use only
708-
* @return the regions
709-
*/
710-
public static Collection<Region> getOC16Regions() {
711-
return OC16_REGIONS.values();
712-
}
713-
714-
/**
715-
* @hidden
716-
* Internal use only
717-
* @return the regions
718-
*/
719-
public static Collection<Region> getOC17Regions() {
720-
return OC17_REGIONS.values();
721-
}
722-
723-
/**
724-
* @hidden
725-
* Internal use only
726-
* @return the regions
671+
* @param regionId the region id
672+
* @return the value
727673
*/
728-
public static Collection<Region> getOC19Regions() {
729-
return OC19_REGIONS.values();
674+
public static boolean isOC27Region(String regionId) {
675+
return (OC27_REGIONS.get(regionId) != null);
730676
}
731677

732678
/**
733679
* @hidden
734680
* Internal use only
735-
* @return the regions
681+
* @param regionId the region id
682+
* @return the value
736683
*/
737-
public static Collection<Region> getOC20Regions() {
738-
return OC20_REGIONS.values();
684+
public static boolean isOC28Region(String regionId) {
685+
return (OC28_REGIONS.get(regionId) != null);
739686
}
740687

741688
/**

driver/src/main/java/oracle/nosql/driver/iam/Utils.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ class Utils {
119119
"https://auth.{0}.oraclecloud22.com");
120120
private final static MessageFormat OC24_EP_BASE = new MessageFormat(
121121
"https://auth.{0}.oraclecloud24.com");
122+
private final static MessageFormat OC27_EP_BASE = new MessageFormat(
123+
"https://auth.{0}.oraclecloud27.com");
124+
private final static MessageFormat OC28_EP_BASE = new MessageFormat(
125+
"https://auth.{0}.oraclecloud28.com");
122126

123127
static {
124128
/* OC1 */
@@ -155,6 +159,7 @@ class Utils {
155159

156160
IAM_URI.put("mtz", OC1_EP_BASE.format(new Object[] {"il-jerusalem-1"}));
157161

162+
IAM_URI.put("bog", OC1_EP_BASE.format(new Object[] {"sa-bogota-1"}));
158163
IAM_URI.put("gru", OC1_EP_BASE.format(new Object[] {"sa-saopaulo-1"}));
159164
IAM_URI.put("scl", OC1_EP_BASE.format(new Object[] {"sa-santiago-1"}));
160165
IAM_URI.put("vcp", OC1_EP_BASE.format(new Object[] {"sa-vinhedo-1"}));
@@ -223,6 +228,12 @@ class Utils {
223228

224229
/* OC24 */
225230
IAM_URI.put("avz", OC24_EP_BASE.format(new Object[] {"eu-dcc-zurich-1"}));
231+
232+
/* OC27 */
233+
IAM_URI.put("ozz", OC27_EP_BASE.format(new Object[] {"us-dcc-swjordan-1"}));
234+
235+
/* OC28 */
236+
IAM_URI.put("drs", OC28_EP_BASE.format(new Object[] {"us-dcc-swjordan-2"}));
226237
}
227238

228239
static String getIAMURL(String regionIdOrCode) {
@@ -270,6 +281,12 @@ static String getIAMURL(String regionIdOrCode) {
270281
if (Region.isOC24Region(regionIdOrCode)) {
271282
return OC24_EP_BASE.format(new Object[] {regionIdOrCode});
272283
}
284+
if (Region.isOC27Region(regionIdOrCode)) {
285+
return OC27_EP_BASE.format(new Object[] {regionIdOrCode});
286+
}
287+
if (Region.isOC28Region(regionIdOrCode)) {
288+
return OC28_EP_BASE.format(new Object[] {regionIdOrCode});
289+
}
273290
}
274291

275292
return uri;

driver/src/test/java/oracle/nosql/driver/iam/InstancePrincipalsProviderTest.java

Lines changed: 0 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -394,127 +394,6 @@ public void testGetTokenError()
394394
}
395395
}
396396

397-
@Test
398-
public void testRegionURI() {
399-
for (Region r : Region.getOC1Regions()) {
400-
assertEquals(r.endpoint(),
401-
"https://nosql." + r.getRegionId() +
402-
".oci.oraclecloud.com");
403-
assertEquals(Utils.getIAMURL(r.getRegionId()),
404-
"https://auth." + r.getRegionId() + ".oraclecloud.com");
405-
}
406-
for (Region r : Region.getGovRegions()) {
407-
assertEquals(r.endpoint(),
408-
"https://nosql." + r.getRegionId() +
409-
".oci.oraclegovcloud.com");
410-
assertEquals(Utils.getIAMURL(r.getRegionId()),
411-
"https://auth." + r.getRegionId() +
412-
".oraclegovcloud.com");
413-
}
414-
for (Region r : Region.getOC4Regions()) {
415-
assertEquals(r.endpoint(),
416-
"https://nosql." + r.getRegionId() +
417-
".oci.oraclegovcloud.uk");
418-
assertEquals(Utils.getIAMURL(r.getRegionId()),
419-
"https://auth." + r.getRegionId() +
420-
".oraclegovcloud.uk");
421-
}
422-
for (Region r : Region.getOC8Regions()) {
423-
assertEquals(r.endpoint(),
424-
"https://nosql." + r.getRegionId() +
425-
".oci.oraclecloud8.com");
426-
assertEquals(Utils.getIAMURL(r.getRegionId()),
427-
"https://auth." + r.getRegionId() +
428-
".oraclecloud8.com");
429-
}
430-
431-
/* test IAM URI by airport code */
432-
assertEquals(Utils.getIAMURL("jnb"),
433-
"https://auth.af-johannesburg-1.oraclecloud.com");
434-
435-
assertEquals(Utils.getIAMURL("bom"),
436-
"https://auth.ap-mumbai-1.oraclecloud.com");
437-
assertEquals(Utils.getIAMURL("sin"),
438-
"https://auth.ap-singapore-1.oraclecloud.com");
439-
assertEquals(Utils.getIAMURL("icn"),
440-
"https://auth.ap-seoul-1.oraclecloud.com");
441-
assertEquals(Utils.getIAMURL("syd"),
442-
"https://auth.ap-sydney-1.oraclecloud.com");
443-
assertEquals(Utils.getIAMURL("nrt"),
444-
"https://auth.ap-tokyo-1.oraclecloud.com");
445-
assertEquals(Utils.getIAMURL("mel"),
446-
"https://auth.ap-melbourne-1.oraclecloud.com");
447-
assertEquals(Utils.getIAMURL("kix"),
448-
"https://auth.ap-osaka-1.oraclecloud.com");
449-
assertEquals(Utils.getIAMURL("hyd"),
450-
"https://auth.ap-hyderabad-1.oraclecloud.com");
451-
assertEquals(Utils.getIAMURL("yny"),
452-
"https://auth.ap-chuncheon-1.oraclecloud.com");
453-
454-
assertEquals(Utils.getIAMURL("mrs"),
455-
"https://auth.eu-marseille-1.oraclecloud.com");
456-
assertEquals(Utils.getIAMURL("arn"),
457-
"https://auth.eu-stockholm-1.oraclecloud.com");
458-
assertEquals(Utils.getIAMURL("fra"),
459-
"https://auth.eu-frankfurt-1.oraclecloud.com");
460-
assertEquals(Utils.getIAMURL("zrh"),
461-
"https://auth.eu-zurich-1.oraclecloud.com");
462-
assertEquals(Utils.getIAMURL("lhr"),
463-
"https://auth.uk-london-1.oraclecloud.com");
464-
assertEquals(Utils.getIAMURL("ams"),
465-
"https://auth.eu-amsterdam-1.oraclecloud.com");
466-
467-
assertEquals(Utils.getIAMURL("auh"),
468-
"https://auth.me-abudhabi-1.oraclecloud.com");
469-
assertEquals(Utils.getIAMURL("jed"),
470-
"https://auth.me-jeddah-1.oraclecloud.com");
471-
assertEquals(Utils.getIAMURL("dxb"),
472-
"https://auth.me-dubai-1.oraclecloud.com");
473-
474-
assertEquals(Utils.getIAMURL("cwl"),
475-
"https://auth.uk-cardiff-1.oraclecloud.com");
476-
477-
assertEquals(Utils.getIAMURL("iad"),
478-
"https://auth.us-ashburn-1.oraclecloud.com");
479-
assertEquals(Utils.getIAMURL("phx"),
480-
"https://auth.us-phoenix-1.oraclecloud.com");
481-
assertEquals(Utils.getIAMURL("sjc"),
482-
"https://auth.us-sanjose-1.oraclecloud.com");
483-
assertEquals(Utils.getIAMURL("yyz"),
484-
"https://auth.ca-toronto-1.oraclecloud.com");
485-
assertEquals(Utils.getIAMURL("yul"),
486-
"https://auth.ca-montreal-1.oraclecloud.com");
487-
488-
assertEquals(Utils.getIAMURL("gru"),
489-
"https://auth.sa-saopaulo-1.oraclecloud.com");
490-
assertEquals(Utils.getIAMURL("scl"),
491-
"https://auth.sa-santiago-1.oraclecloud.com");
492-
493-
assertEquals(Utils.getIAMURL("lfi"),
494-
"https://auth.us-langley-1.oraclegovcloud.com");
495-
assertEquals(Utils.getIAMURL("luf"),
496-
"https://auth.us-luke-1.oraclegovcloud.com");
497-
498-
assertEquals(Utils.getIAMURL("ric"),
499-
"https://auth.us-gov-ashburn-1.oraclegovcloud.com");
500-
assertEquals(Utils.getIAMURL("pia"),
501-
"https://auth.us-gov-chicago-1.oraclegovcloud.com");
502-
assertEquals(Utils.getIAMURL("tus"),
503-
"https://auth.us-gov-phoenix-1.oraclegovcloud.com");
504-
505-
assertEquals(Utils.getIAMURL("ltn"),
506-
"https://auth.uk-gov-london-1.oraclegovcloud.uk");
507-
508-
assertEquals(Utils.getIAMURL("nja"),
509-
"https://auth.ap-chiyoda-1.oraclecloud8.com");
510-
511-
assertEquals(Utils.getIAMURL("mct"),
512-
"https://auth.me-dcc-muscat-1.oraclecloud9.com");
513-
514-
assertEquals(Utils.getIAMURL("wga"),
515-
"https://auth.ap-dcc-canberra-1.oraclecloud10.com");
516-
}
517-
518397
private static class TestSupplier implements SessionKeyPairSupplier {
519398
final private KeyPair keyPair;
520399

0 commit comments

Comments
 (0)