diff --git a/src/tiledb/cloud/__init__.py b/src/tiledb/cloud/__init__.py index 2344b43c5..112a20d78 100644 --- a/src/tiledb/cloud/__init__.py +++ b/src/tiledb/cloud/__init__.py @@ -17,6 +17,7 @@ from .array import register_array from .array import share_array from .array import unshare_array +from .client import AwsRegion from .client import Config from .client import Ctx from .client import list_arrays @@ -89,4 +90,5 @@ "last_udf_task", "task", "TileDBCloudError", + "AwsRegion", ) diff --git a/src/tiledb/cloud/client.py b/src/tiledb/cloud/client.py index c8384d948..5b91600cc 100644 --- a/src/tiledb/cloud/client.py +++ b/src/tiledb/cloud/client.py @@ -63,6 +63,24 @@ def Ctx(config=None): return tiledb.Ctx(Config(config)) +class AwsRegion(enum.Enum): + """ + The AWS cloud regions that are currently supported. + + US_EAST_1 = North America, United States (Virginia) + US_WEST_1 = North America, United States (California) + EU_WEST_1 = Europe, Ireland + EU_WEST_2 = Europe, London + AP_SOUTHEAST_1 = Asia, Singapore + """ + + US_EAST_1 = "us-east-1.aws." + US_WEST_1 = "us-west-1.aws." + EU_WEST_1 = "eu-west-1.aws." + EU_WEST_2 = "eu-west-2.aws." + AP_SOUTHEAST_1 = "ap-southeast-1.aws." + + def login( token=None, username=None, @@ -71,6 +89,7 @@ def login( verify_ssl=None, no_session=False, threads=None, + region=None, ): """ Login to cloud service @@ -83,10 +102,21 @@ def login( :param no_session: don't create a session token on login, store instead username/password :param threads: number of threads to enable for concurrent requests + :param region: the AWS region to run code in :return: """ if host is None: host = config.default_host + if region is not None: + if region not in AwsRegion: + raise Exception("Invalid cloud region provided") + # Overwrite the host using the given region. + orig_url = urllib3.util.parse_url(host) + region_url = urllib3.util.Url( + scheme=orig_url.scheme, + host=region.value + orig_url.host, + ) + host = region_url.url if (token is None or token == "") and ( (username is None or username == "") and (password is None or password == "")