Skip to content

Commit db8c33c

Browse files
authored
Add Azure static regions list (#2157)
Fixes OPS-3951. ## Additional Notes 1. Regions list is taken from [Microsoft Learn](https://learn.microsoft.com/en-us/azure/reliability/regions-list?tabs=all) 2. Not including `Denmark East` in the list because it is marked as `coming soon` in the website. 3. Not including Sovereign cloud regions (US Govt and China)(Checked with Marco)
1 parent eed9074 commit db8c33c

5 files changed

Lines changed: 107 additions & 5 deletions

File tree

packages/openops/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export * from './lib/aws/sts-common';
3131
export * from './lib/aws/tags/tag-resources';
3232
export * from './lib/aws/tags/tags';
3333

34+
export * from './lib/region-list-item';
35+
3436
export * from './lib/condition-watcher';
3537

3638
export * from './lib/aws/pricing';
@@ -60,6 +62,7 @@ export * from './lib/iac/rds-properties';
6062
export * from './lib/openops-analytics/requests-helpers';
6163

6264
export * from './lib/azure/auth';
65+
export * from './lib/azure/regions';
6366
export * from './lib/azure/subscription/get-subscription-dropdown';
6467

6568
export * from './lib/axios-wrapper';

packages/openops/src/lib/aws/regions.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { DropdownState, Property } from '@openops/blocks-framework';
22
import { convertToStringArrayWithValidation } from '@openops/shared';
3+
import type { RegionListItem } from '../region-list-item';
34
import { parseArn } from './arn-handler';
45

56
const staticRegions = {
@@ -37,11 +38,6 @@ const staticRegions = {
3738
'sa-east-1 (South America (São Paulo))': 'sa-east-1',
3839
};
3940

40-
export type RegionListItem = {
41-
id: string;
42-
displayName: string;
43-
};
44-
4541
export function getRegionsList(): RegionListItem[] {
4642
return Object.entries(staticRegions).map(([displayName, id]) => ({
4743
id,
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import type { RegionListItem } from '../region-list-item';
2+
3+
const staticAzureRegions: Record<string, string> = {
4+
australiacentral: 'Australia Central',
5+
australiacentral2: 'Australia Central 2',
6+
australiaeast: 'Australia East',
7+
australiasoutheast: 'Australia Southeast',
8+
austriaeast: 'Austria East',
9+
belgiumcentral: 'Belgium Central',
10+
brazilsouth: 'Brazil South',
11+
brazilsoutheast: 'Brazil Southeast',
12+
canadacentral: 'Canada Central',
13+
canadaeast: 'Canada East',
14+
centralindia: 'Central India',
15+
centralus: 'Central US',
16+
chilecentral: 'Chile Central',
17+
eastasia: 'East Asia',
18+
eastus: 'East US',
19+
eastus2: 'East US 2',
20+
francecentral: 'France Central',
21+
francesouth: 'France South',
22+
germanynorth: 'Germany North',
23+
germanywestcentral: 'Germany West Central',
24+
indonesiacentral: 'Indonesia Central',
25+
israelcentral: 'Israel Central',
26+
italynorth: 'Italy North',
27+
japaneast: 'Japan East',
28+
japanwest: 'Japan West',
29+
koreacentral: 'Korea Central',
30+
koreasouth: 'Korea South',
31+
malaysiawest: 'Malaysia West',
32+
mexicocentral: 'Mexico Central',
33+
newzealandnorth: 'New Zealand North',
34+
northcentralus: 'North Central US',
35+
northeurope: 'North Europe',
36+
norwayeast: 'Norway East',
37+
norwaywest: 'Norway West',
38+
polandcentral: 'Poland Central',
39+
qatarcentral: 'Qatar Central',
40+
southafricanorth: 'South Africa North',
41+
southafricawest: 'South Africa West',
42+
southcentralus: 'South Central US',
43+
southindia: 'South India',
44+
southeastasia: 'Southeast Asia',
45+
spaincentral: 'Spain Central',
46+
swedencentral: 'Sweden Central',
47+
switzerlandnorth: 'Switzerland North',
48+
switzerlandwest: 'Switzerland West',
49+
uaecentral: 'UAE Central',
50+
uaenorth: 'UAE North',
51+
uksouth: 'UK South',
52+
ukwest: 'UK West',
53+
westcentralus: 'West Central US',
54+
westeurope: 'West Europe',
55+
westindia: 'West India',
56+
westus: 'West US',
57+
westus2: 'West US 2',
58+
westus3: 'West US 3',
59+
};
60+
61+
export function getAzureRegionsList(): RegionListItem[] {
62+
return Object.entries(staticAzureRegions).map(([id, displayName]) => ({
63+
id,
64+
displayName,
65+
}));
66+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export type RegionListItem = {
2+
id: string;
3+
displayName: string;
4+
};
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { getAzureRegionsList } from '../src/lib/azure/regions';
2+
3+
describe('getAzureRegionsList', () => {
4+
it('returns non-empty array of region items', () => {
5+
const result = getAzureRegionsList();
6+
expect(Array.isArray(result)).toBe(true);
7+
expect(result.length).toBeGreaterThan(0);
8+
});
9+
10+
it('returns items with id and displayName', () => {
11+
const result = getAzureRegionsList();
12+
for (const item of result) {
13+
expect(item).toHaveProperty('id');
14+
expect(item).toHaveProperty('displayName');
15+
expect(typeof item.id).toBe('string');
16+
expect(typeof item.displayName).toBe('string');
17+
}
18+
});
19+
20+
it('includes known regions with correct display names', () => {
21+
const result = getAzureRegionsList();
22+
const eastUs = result.find((r) => r.id === 'eastus');
23+
const westEurope = result.find((r) => r.id === 'westeurope');
24+
expect(eastUs).toEqual({
25+
id: 'eastus',
26+
displayName: 'East US',
27+
});
28+
expect(westEurope).toEqual({
29+
id: 'westeurope',
30+
displayName: 'West Europe',
31+
});
32+
});
33+
});

0 commit comments

Comments
 (0)