/*
 * © 2021 Thoughtworks, Inc.
 */

import { mappedRegionsToElectricityMapZones } from '@cloud-carbon-footprint/common'

export enum AWS_REGIONS {
  US_EAST_1 = 'us-east-1',
  US_EAST_2 = 'us-east-2',
  US_WEST_1 = 'us-west-1',
  US_WEST_2 = 'us-west-2',
  AF_SOUTH_1 = 'af-south-1',
  AP_EAST_1 = 'ap-east-1',
  AP_SOUTH_1 = 'ap-south-1',
  AP_NORTHEAST_3 = 'ap-northeast-3',
  AP_NORTHEAST_2 = 'ap-northeast-2',
  AP_SOUTHEAST_1 = 'ap-southeast-1',
  AP_SOUTHEAST_2 = 'ap-southeast-2',
  AP_NORTHEAST_1 = 'ap-northeast-1',
  AP_SOUTHEAST_3 = 'ap-southeast-3',
  CA_CENTRAL_1 = 'ca-central-1',
  CN_NORTH_1 = 'cn-north-1',
  CN_NORTHWEST_1 = 'cn-northwest-1',
  EU_CENTRAL_1 = 'eu-central-1',
  EU_WEST_1 = 'eu-west-1',
  EU_WEST_2 = 'eu-west-2',
  EU_SOUTH_1 = 'eu-south-1',
  EU_WEST_3 = 'eu-west-3',
  EU_NORTH_1 = 'eu-north-1',
  ME_SOUTH_1 = 'me-south-1',
  ME_CENTRAL_1 = 'me-central-1',
  SA_EAST_1 = 'sa-east-1',
  US_GOV_EAST_1 = 'us-gov-east-1',
  US_GOV_WEST_1 = 'us-gov-west-1',
  UNKNOWN = 'Unknown',
}

export const AWS_MAPPED_REGION_NAMES_TO_CODES: { [key: string]: string } = {
  'US East (Ohio)': AWS_REGIONS.US_EAST_2,
  'US East (N. Virginia)': AWS_REGIONS.US_EAST_1,
  'US West (N. California)': AWS_REGIONS.US_WEST_1,
  'US West (Oregon)': AWS_REGIONS.US_WEST_2,
  'Africa (Cape Town)': AWS_REGIONS.AF_SOUTH_1,
  'Asia Pacific (Hong Kong)': AWS_REGIONS.AP_EAST_1,
  'Asia Pacific (Mumbai)': AWS_REGIONS.AP_SOUTH_1,
  'Asia Pacific (Osaka)': AWS_REGIONS.AP_NORTHEAST_3,
  'Asia Pacific (Seoul)': AWS_REGIONS.AP_NORTHEAST_2,
  'Asia Pacific (Singapore)': AWS_REGIONS.AP_SOUTHEAST_1,
  'Asia Pacific (Sydney)': AWS_REGIONS.AP_SOUTHEAST_2,
  'Asia Pacific (Tokyo)': AWS_REGIONS.AP_NORTHEAST_1,
  'Asia Pacific (Jakarta)': AWS_REGIONS.AP_SOUTHEAST_3,
  'Canada (Central)': AWS_REGIONS.CA_CENTRAL_1,
  'EU (Frankfurt)': AWS_REGIONS.EU_CENTRAL_1,
  'EU (Ireland)': AWS_REGIONS.EU_WEST_1,
  'EU (London)': AWS_REGIONS.EU_WEST_2,
  'EU (Milan)': AWS_REGIONS.EU_SOUTH_1,
  'EU (Paris)': AWS_REGIONS.EU_WEST_3,
  'EU (Stockholm)': AWS_REGIONS.EU_NORTH_1,
  'Middle East (Bahrain)': AWS_REGIONS.ME_SOUTH_1,
  'Middle East (UAE)': AWS_REGIONS.ME_CENTRAL_1,
  'South America (Sao Paulo)': AWS_REGIONS.SA_EAST_1,
  'AWS GovCloud (US-East)': AWS_REGIONS.US_GOV_EAST_1,
  'AWS GovCloud (US-West)': AWS_REGIONS.US_GOV_WEST_1,
  'China (Beijing)': AWS_REGIONS.CN_NORTH_1,
  'China (Ningxia)': AWS_REGIONS.CN_NORTHWEST_1,
}

export const AWS_MAPPED_REGIONS_TO_ELECTRICITY_MAPS_ZONES: mappedRegionsToElectricityMapZones =
  {
    [AWS_REGIONS.US_EAST_1]: 'US-MIDA-PJM',
    [AWS_REGIONS.US_EAST_2]: 'US-MIDA-PJM',
    [AWS_REGIONS.US_WEST_1]: 'US-CAL-CISO',
    [AWS_REGIONS.US_WEST_2]: 'US-NW-PACW',
    [AWS_REGIONS.AF_SOUTH_1]: 'ZA',
    [AWS_REGIONS.AP_EAST_1]: null,
    [AWS_REGIONS.AP_SOUTH_1]: 'IN-WE',
    [AWS_REGIONS.AP_NORTHEAST_3]: 'JP-KN',
    [AWS_REGIONS.AP_NORTHEAST_2]: 'KR',
    [AWS_REGIONS.AP_SOUTHEAST_1]: 'SG',
    [AWS_REGIONS.AP_SOUTHEAST_2]: 'AU-NSW',
    [AWS_REGIONS.AP_NORTHEAST_1]: 'JP-TK',
    [AWS_REGIONS.AP_SOUTHEAST_3]: 'ID',
    [AWS_REGIONS.CA_CENTRAL_1]: 'CA-QC',
    [AWS_REGIONS.CN_NORTH_1]: null,
    [AWS_REGIONS.CN_NORTHWEST_1]: null,
    [AWS_REGIONS.EU_CENTRAL_1]: 'DE',
    [AWS_REGIONS.EU_WEST_1]: 'IE',
    [AWS_REGIONS.EU_WEST_2]: 'GB',
    [AWS_REGIONS.EU_SOUTH_1]: 'IT-NO',
    [AWS_REGIONS.EU_WEST_3]: 'FR',
    [AWS_REGIONS.EU_NORTH_1]: 'SE-SE3',
    [AWS_REGIONS.ME_SOUTH_1]: null,
    [AWS_REGIONS.ME_CENTRAL_1]: null,
    [AWS_REGIONS.SA_EAST_1]: 'BR-CS',
    [AWS_REGIONS.US_GOV_EAST_1]: 'US-MIDA-PJM',
    [AWS_REGIONS.US_GOV_WEST_1]: 'US-NW-PACW',
    [AWS_REGIONS.UNKNOWN]: null,
  }
