Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enabling DynamoDB endpoint URL #887

Merged
merged 2 commits into from
Sep 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions awswrangler/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class _ConfigArg(NamedTuple):
"redshift_endpoint_url": _ConfigArg(dtype=str, nullable=True, enforced=True),
"kms_endpoint_url": _ConfigArg(dtype=str, nullable=True, enforced=True),
"emr_endpoint_url": _ConfigArg(dtype=str, nullable=True, enforced=True),
"dynamodb_endpoint_url": _ConfigArg(dtype=str, nullable=True, enforced=True),
# Botocore config
"botocore_config": _ConfigArg(dtype=botocore.config.Config, nullable=True),
}
Expand All @@ -61,6 +62,7 @@ def __init__(self) -> None:
self.redshift_endpoint_url = None
self.kms_endpoint_url = None
self.emr_endpoint_url = None
self.dynamodb_endpoint_url = None
self.botocore_config = None
for name in _CONFIG_ARGS:
self._load_config(name=name)
Expand Down Expand Up @@ -352,6 +354,15 @@ def emr_endpoint_url(self) -> Optional[str]:
def emr_endpoint_url(self, value: Optional[str]) -> None:
self._set_config_value(key="emr_endpoint_url", value=value)

@property
def dynamodb_endpoint_url(self) -> Optional[str]:
"""Property dynamodb_endpoint_url."""
return cast(Optional[str], self["dynamodb_endpoint_url"])

@dynamodb_endpoint_url.setter
def dynamodb_endpoint_url(self, value: Optional[str]) -> None:
self._set_config_value(key="dynamodb_endpoint_url", value=value)

@property
def botocore_config(self) -> botocore.config.Config:
"""Property botocore_config."""
Expand Down
2 changes: 2 additions & 0 deletions awswrangler/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ def _get_endpoint_url(service_name: str) -> Optional[str]:
endpoint_url = _config.config.kms_endpoint_url
elif service_name == "emr" and _config.config.emr_endpoint_url is not None:
endpoint_url = _config.config.emr_endpoint_url
elif service_name == "dynamodb" and _config.config.dynamodb_endpoint_url is not None:
endpoint_url = _config.config.dynamodb_endpoint_url
return endpoint_url


Expand Down
3 changes: 3 additions & 0 deletions awswrangler/dynamodb/_delete.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@

import boto3

from awswrangler._config import apply_configs

from ._utils import _validate_items, get_table

_logger: logging.Logger = logging.getLogger(__name__)


@apply_configs
def delete_items(
items: List[Dict[str, Any]],
table_name: str,
Expand Down
2 changes: 2 additions & 0 deletions awswrangler/dynamodb/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
import boto3

from awswrangler import _utils, exceptions
from awswrangler._config import apply_configs


@apply_configs
def get_table(
table_name: str,
boto3_session: Optional[boto3.Session] = None,
Expand Down
6 changes: 6 additions & 0 deletions awswrangler/dynamodb/_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
import boto3
import pandas as pd

from awswrangler._config import apply_configs

from ._utils import _validate_items, get_table

_logger: logging.Logger = logging.getLogger(__name__)


@apply_configs
def put_json(
path: Union[str, Path],
table_name: str,
Expand Down Expand Up @@ -56,6 +59,7 @@ def put_json(
put_items(items=items, table_name=table_name, boto3_session=boto3_session)


@apply_configs
def put_csv(
path: Union[str, Path],
table_name: str,
Expand Down Expand Up @@ -109,6 +113,7 @@ def put_csv(
put_df(df=df, table_name=table_name, boto3_session=boto3_session)


@apply_configs
def put_df(
df: pd.DataFrame,
table_name: str,
Expand Down Expand Up @@ -146,6 +151,7 @@ def put_df(
put_items(items=items, table_name=table_name, boto3_session=boto3_session)


@apply_configs
def put_items(
items: Union[List[Dict[str, Any]], List[Mapping[str, Any]]],
table_name: str,
Expand Down