Skip to content

carboncue_sdk.region_mapper

region_mapper

Region mapping utilities for cloud providers to Electricity Maps zones.

RegionMapper

Maps cloud provider regions to Electricity Maps zone identifiers.

get_zone_id staticmethod

get_zone_id(region: str, provider: str = 'aws') -> str

Get Electricity Maps zone ID for a cloud region.

Parameters:

Name Type Description Default
region str

Cloud provider region code (e.g., us-west-2, eastus)

required
provider str

Cloud provider name (aws, azure, gcp, digitalocean)

'aws'

Returns:

Type Description
str

Electricity Maps zone ID (e.g., US-CAL-CISO)

Raises:

Type Description
ValueError

If region or provider is not supported

Source code in packages/sdk/src/carboncue_sdk/region_mapper.py
@staticmethod
def get_zone_id(region: str, provider: str = "aws") -> str:
    """Get Electricity Maps zone ID for a cloud region.

    Args:
        region: Cloud provider region code (e.g., us-west-2, eastus)
        provider: Cloud provider name (aws, azure, gcp, digitalocean)

    Returns:
        Electricity Maps zone ID (e.g., US-CAL-CISO)

    Raises:
        ValueError: If region or provider is not supported
    """
    provider_lower = provider.lower()

    if provider_lower not in REGION_TO_ZONE_MAP:
        raise ValueError(
            f"Unsupported cloud provider: {provider}. "
            f"Supported: {', '.join(REGION_TO_ZONE_MAP.keys())}"
        )

    region_map = REGION_TO_ZONE_MAP[provider_lower]

    if region not in region_map:
        raise ValueError(
            f"Unsupported region '{region}' for provider '{provider}'. "
            f"Supported regions: {', '.join(region_map.keys())}"
        )

    return region_map[region]

get_supported_regions staticmethod

get_supported_regions(provider: str = 'aws') -> list[str]

Get list of supported regions for a cloud provider.

Parameters:

Name Type Description Default
provider str

Cloud provider name

'aws'

Returns:

Type Description
list[str]

List of supported region codes

Raises:

Type Description
ValueError

If provider is not supported

Source code in packages/sdk/src/carboncue_sdk/region_mapper.py
@staticmethod
def get_supported_regions(provider: str = "aws") -> list[str]:
    """Get list of supported regions for a cloud provider.

    Args:
        provider: Cloud provider name

    Returns:
        List of supported region codes

    Raises:
        ValueError: If provider is not supported
    """
    provider_lower = provider.lower()

    if provider_lower not in REGION_TO_ZONE_MAP:
        raise ValueError(f"Unsupported cloud provider: {provider}")

    return list(REGION_TO_ZONE_MAP[provider_lower].keys())

get_supported_providers staticmethod

get_supported_providers() -> list[str]

Get list of all supported cloud providers.

Returns:

Type Description
list[str]

List of supported provider names

Source code in packages/sdk/src/carboncue_sdk/region_mapper.py
@staticmethod
def get_supported_providers() -> list[str]:
    """Get list of all supported cloud providers.

    Returns:
        List of supported provider names
    """
    return list(REGION_TO_ZONE_MAP.keys())