From ce395f47a8caed6e63e9e7bee38d006f3f8fdd44 Mon Sep 17 00:00:00 2001 From: Anton Kukushkin <3997468+kukushking@users.noreply.github.com> Date: Fri, 29 Jul 2022 09:32:01 -0400 Subject: [PATCH] add timestream endpoint config prop --- awswrangler/_config.py | 11 +++++++++++ awswrangler/_utils.py | 2 ++ tests/test_config.py | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/awswrangler/_config.py b/awswrangler/_config.py index bb9203fe9..b1d024b5c 100644 --- a/awswrangler/_config.py +++ b/awswrangler/_config.py @@ -46,6 +46,7 @@ class _ConfigArg(NamedTuple): "lakeformation_endpoint_url": _ConfigArg(dtype=str, nullable=True, enforced=True), "dynamodb_endpoint_url": _ConfigArg(dtype=str, nullable=True, enforced=True), "secretsmanager_endpoint_url": _ConfigArg(dtype=str, nullable=True, enforced=True), + "timestream_endpoint_url": _ConfigArg(dtype=str, nullable=True, enforced=True), # Botocore config "botocore_config": _ConfigArg(dtype=botocore.config.Config, nullable=True), "verify": _ConfigArg(dtype=str, nullable=True), @@ -68,6 +69,7 @@ def __init__(self) -> None: self.lakeformation_endpoint_url = None self.dynamodb_endpoint_url = None self.secretsmanager_endpoint_url = None + self.timestream_endpoint_url = None self.botocore_config = None self.verify = None for name in _CONFIG_ARGS: @@ -387,6 +389,15 @@ def secretsmanager_endpoint_url(self) -> Optional[str]: def secretsmanager_endpoint_url(self, value: Optional[str]) -> None: self._set_config_value(key="secretsmanager_endpoint_url", value=value) + @property + def timestream_endpoint_url(self) -> Optional[str]: + """Property timestream_endpoint_url.""" + return cast(Optional[str], self["timestream_endpoint_url"]) + + @timestream_endpoint_url.setter + def timestream_endpoint_url(self, value: Optional[str]) -> None: + self._set_config_value(key="timestream_endpoint_url", value=value) + @property def botocore_config(self) -> botocore.config.Config: """Property botocore_config.""" diff --git a/awswrangler/_utils.py b/awswrangler/_utils.py index deb979dd6..8e6e36947 100644 --- a/awswrangler/_utils.py +++ b/awswrangler/_utils.py @@ -99,6 +99,8 @@ def _get_endpoint_url(service_name: str) -> Optional[str]: endpoint_url = _config.config.dynamodb_endpoint_url elif service_name == "secretsmanager" and _config.config.secretsmanager_endpoint_url is not None: endpoint_url = _config.config.secretsmanager_endpoint_url + elif service_name == "timestream" and _config.config.timestream_endpoint_url is not None: + endpoint_url = _config.config.timestream_endpoint_url return endpoint_url diff --git a/tests/test_config.py b/tests/test_config.py index a10fa292b..0e9b82a1e 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -31,6 +31,8 @@ def wrapper(self, **kwarg): assert url == wr.config.glue_endpoint_url elif name == "secretsmanager": assert url == wr.config.secretsmanager_endpoint_url + elif name == "timestream": + assert url == wr.config.timestream_endpoint_url return original(self, **kwarg) with patch("botocore.client.ClientCreator.create_client", new=wrapper): @@ -115,12 +117,14 @@ def test_basics(path, glue_database, glue_table, workgroup0, workgroup1): wr.config.athena_endpoint_url = f"https://athena.{region}.amazonaws.com" wr.config.glue_endpoint_url = f"https://glue.{region}.amazonaws.com" wr.config.secretsmanager_endpoint_url = f"https://secretsmanager.{region}.amazonaws.com" + wr.config.timestream_endpoint_url = f"https://timestream.{region}.amazonaws.com" _urls_test(glue_database) os.environ["WR_STS_ENDPOINT_URL"] = f"https://sts.{region}.amazonaws.com" os.environ["WR_S3_ENDPOINT_URL"] = f"https://s3.{region}.amazonaws.com" os.environ["WR_ATHENA_ENDPOINT_URL"] = f"https://athena.{region}.amazonaws.com" os.environ["WR_GLUE_ENDPOINT_URL"] = f"https://glue.{region}.amazonaws.com" os.environ["WR_SECRETSMANAGER_ENDPOINT_URL"] = f"https://secretsmanager.{region}.amazonaws.com" + os.environ["WR_TIMESTREAM_ENDPOINT_URL"] = f"https://timestream.{region}.amazonaws.com" wr.config.reset() _urls_test(glue_database)