boto3-assist 0.19.0__tar.gz → 0.21.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/PKG-INFO +1 -1
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/pyproject.toml +1 -1
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/dynamodb/dynamodb_key.py +48 -1
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/dynamodb/dynamodb_model_base.py +4 -1
- boto3_assist-0.21.0/src/boto3_assist/dynamodb/dynamodb_reindexer.py +165 -0
- boto3_assist-0.21.0/src/boto3_assist/version.py +1 -0
- boto3_assist-0.19.0/src/boto3_assist/version.py +0 -1
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/.env.docker +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/.env.docker.001 +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/.env.docker.nosql.workbench +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/.env.unittest +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/.gitignore +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/.vscode/launch.json +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/.vscode/settings.json +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/.vscode/tasks.json +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/LICENSE-EXPLAINED.txt +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/LICENSE.txt +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/README.md +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/aws_regions_with_status.csv +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/aws_regions_with_status.json +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/devops/build.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/devops/readme.md +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/examples/__init__.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/examples/cloudwatch/log_report.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/examples/dynamodb/models/order_item_model.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/examples/dynamodb/models/order_model.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/examples/dynamodb/models/product_model.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/examples/dynamodb/models/user_model.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/examples/dynamodb/models/user_post_model.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/examples/dynamodb/order_example/main.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/examples/dynamodb/order_example/products.json +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/examples/dynamodb/services/order_item_service.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/examples/dynamodb/services/order_service.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/examples/dynamodb/services/product_service.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/examples/dynamodb/services/table_service.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/examples/dynamodb/services/user_post_service.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/examples/dynamodb/services/user_service.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/examples/dynamodb/services/user_service_client_example.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/examples/dynamodb/services/user_service_resource_example.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/examples/dynamodb/user_post_example/main.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/examples/ec2/regions_report.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/module-headers.txt +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/mypy.ini +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/requirements-dev.txt +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/requirements.txt +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/run-checks.sh +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/run_unit_tests.sh +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/__init__.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/aws_config.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/aws_lambda/event_info.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/aws_lambda/mock_context.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/boto3session.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/cloudwatch/cloudwatch_connection.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/cloudwatch/cloudwatch_connection_tracker.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/cloudwatch/cloudwatch_log_connection.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/cloudwatch/cloudwatch_logs.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/cloudwatch/cloudwatch_query.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/cognito/cognito_authorizer.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/cognito/cognito_connection.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/cognito/cognito_utility.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/cognito/jwks_cache.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/cognito/user.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/connection.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/connection_tracker.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/dynamodb/dynamodb.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/dynamodb/dynamodb_connection.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/dynamodb/dynamodb_helpers.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/dynamodb/dynamodb_importer.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/dynamodb/dynamodb_index.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/dynamodb/dynamodb_iservice.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/dynamodb/dynamodb_model_base_interfaces.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/dynamodb/dynamodb_re_indexer.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/dynamodb/dynamodb_reserved_words.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/dynamodb/dynamodb_reserved_words.txt +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/dynamodb/readme.md +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/dynamodb/troubleshooting.md +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/ec2/ec2_connection.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/environment_services/__init__.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/environment_services/environment_loader.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/environment_services/environment_variables.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/errors/custom_exceptions.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/http_status_codes.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/models/serializable_model.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/role_assumption_mixin.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/s3/s3.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/s3/s3_bucket.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/s3/s3_connection.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/s3/s3_event_data.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/s3/s3_object.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/securityhub/securityhub.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/securityhub/securityhub_connection.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/session_setup_mixin.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/ssm/connection.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/ssm/parameter_store/parameter_store.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/utilities/datetime_utility.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/utilities/dictionary_utility.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/utilities/file_operations.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/utilities/http_utility.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/utilities/logging_utility.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/utilities/numbers_utility.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/utilities/serialization_utility.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/utilities/string_utility.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/__init__.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/integration/cross_account_connection_test.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/integration/tenant.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/integration/tenant_services.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/aws_config_test.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/common/db_test_helpers.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/__init__.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/db_models/cms/base.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/db_models/cms/content_block.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/db_models/cms/page.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/db_models/cms/template.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/db_models/simple_model.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/db_models/user_model.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/db_models/user_required_fields_model.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/dynamodb_model_base_test.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/dynamodb_model_projections_test.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/dynamodb_model_serializtion_test.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/dynamodb_moto_sorting_test.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/dynamodb_query_test.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/dynamodb_reindex_test.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/examples_test/__init__.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/examples_test/user_service_test.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/lambda_tests/__init__.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/lambda_tests/event_info_test.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/models_tests/__init__.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/models_tests/models/person.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/models_tests/models/user.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/models_tests/serializable_model_person_test.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/models_tests/serializable_model_user_test.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/models_tests/serializable_model_wide_test.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/parameter_store/__init__.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/parameter_store/parameter_store_test.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/s3/__init__.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/s3/files/test.txt +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/s3/s3_event_data_test.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/s3/s3_file_delete_test.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/s3/s3_file_upload_test.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/session_tests/test_boto3_session_manager.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/utilities/__init__.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/utilities/serialization_utility_test.py +0 -0
- {boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/utilities/string_utility_test.py +0 -0
|
@@ -49,7 +49,52 @@ class DynamoDBKey:
|
|
|
49
49
|
def build_key(*key_value_pairs) -> str:
|
|
50
50
|
"""
|
|
51
51
|
Static method to build a key based on provided key-value pairs.
|
|
52
|
-
Stops appending if any value is None.
|
|
52
|
+
- Stops appending if any value is None.
|
|
53
|
+
- However a value of "" (empty string) will continue the chain.
|
|
54
|
+
|
|
55
|
+
Example:
|
|
56
|
+
gsi.partition_key.value = lambda: DynamoDBKey.build_key(
|
|
57
|
+
("user",self.model.user_id)
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
pk: user#<user-id>
|
|
61
|
+
pk: user#123456789
|
|
62
|
+
|
|
63
|
+
gsi.sort_key.value = lambda: DynamoDBKey.build_key(
|
|
64
|
+
("xref", self.model.xref_type),
|
|
65
|
+
("id", self.model.xref_pk),
|
|
66
|
+
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
sk: xref#<xref-type>#id#<some-id>
|
|
70
|
+
sk: xref#task#id#123456789
|
|
71
|
+
|
|
72
|
+
# example two has a leading "domain" (crm)
|
|
73
|
+
gsi.sort_key.value = lambda: DynamoDBKey.build_key(
|
|
74
|
+
("crm", "")
|
|
75
|
+
("xref", self.model.xref_type),
|
|
76
|
+
("id", self.model.xref_pk),
|
|
77
|
+
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
sk: crm#xref#<xref-type>#id#<some-id>
|
|
81
|
+
sk: crm#xref#task#id#123456789
|
|
82
|
+
|
|
83
|
+
# using None stops the key build
|
|
84
|
+
# useful when doing begins with
|
|
85
|
+
|
|
86
|
+
# assume self.model.xref_pk is None
|
|
87
|
+
gsi.sort_key.value = lambda: DynamoDBKey.build_key(
|
|
88
|
+
("xref", self.model.xref_type),
|
|
89
|
+
("id", self.model.xref_pk),
|
|
90
|
+
|
|
91
|
+
)
|
|
92
|
+
# results with a key of
|
|
93
|
+
# which would get all of the users tasks assuming the pk was still
|
|
94
|
+
# the same
|
|
95
|
+
sk: xref#<xref-type>#id#
|
|
96
|
+
sk: xref#task#id#
|
|
97
|
+
|
|
53
98
|
"""
|
|
54
99
|
parts = []
|
|
55
100
|
for key, value in key_value_pairs:
|
|
@@ -57,6 +102,8 @@ class DynamoDBKey:
|
|
|
57
102
|
if value is None:
|
|
58
103
|
parts.append(f"{prefix}")
|
|
59
104
|
break
|
|
105
|
+
elif len(str(value).strip()) == 0:
|
|
106
|
+
parts.append(f"{key}")
|
|
60
107
|
else:
|
|
61
108
|
parts.append(f"{prefix}{value}")
|
|
62
109
|
key_str = "#".join(parts)
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/dynamodb/dynamodb_model_base.py
RENAMED
|
@@ -40,7 +40,7 @@ def exclude_indexes_from_serialization(method):
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
class DynamoDBModelBase(SerializableModel):
|
|
43
|
-
"""
|
|
43
|
+
"""DynamoDb Model Base"""
|
|
44
44
|
|
|
45
45
|
T = TypeVar("T", bound="DynamoDBModelBase")
|
|
46
46
|
|
|
@@ -53,6 +53,9 @@ class DynamoDBModelBase(SerializableModel):
|
|
|
53
53
|
self.__auto_generate_projections: bool = auto_generate_projections
|
|
54
54
|
self.__actively_serializing_data__: bool = False
|
|
55
55
|
|
|
56
|
+
def serialization_in_progress(self) -> bool:
|
|
57
|
+
return self.__actively_serializing_data__
|
|
58
|
+
|
|
56
59
|
@property
|
|
57
60
|
@exclude_from_serialization
|
|
58
61
|
def indexes(self) -> DynamoDBIndexes:
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Geek Cafe, LLC
|
|
3
|
+
Maintainers: Eric Wilson
|
|
4
|
+
MIT License. See Project Root for the license information.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import json
|
|
8
|
+
from typing import Any, Dict, Optional, List, Type
|
|
9
|
+
from aws_lambda_powertools import Logger
|
|
10
|
+
from boto3_assist.dynamodb.dynamodb import DynamoDB
|
|
11
|
+
from boto3_assist.dynamodb.dynamodb_model_base import DynamoDBModelBase
|
|
12
|
+
from boto3_assist.utilities.serialization_utility import Serialization
|
|
13
|
+
from boto3_assist.dynamodb.dynamodb_index import DynamoDBIndex
|
|
14
|
+
from boto3_assist.dynamodb.dynamodb_iservice import IDynamoDBService
|
|
15
|
+
|
|
16
|
+
logger = Logger()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class DynamoDBReindexer:
|
|
20
|
+
"""Reindexing your database"""
|
|
21
|
+
|
|
22
|
+
def __init__(
|
|
23
|
+
self,
|
|
24
|
+
table_name: str,
|
|
25
|
+
*,
|
|
26
|
+
db: Optional[DynamoDB] = None,
|
|
27
|
+
aws_profile: Optional[str] = None,
|
|
28
|
+
aws_region: Optional[str] = None,
|
|
29
|
+
aws_end_point_url: Optional[str] = None,
|
|
30
|
+
aws_access_key_id: Optional[str] = None,
|
|
31
|
+
aws_secret_access_key: Optional[str] = None,
|
|
32
|
+
):
|
|
33
|
+
self.table_name = table_name
|
|
34
|
+
self.db: DynamoDB = db or DynamoDB(
|
|
35
|
+
aws_profile=aws_profile,
|
|
36
|
+
aws_region=aws_region,
|
|
37
|
+
aws_end_point_url=aws_end_point_url,
|
|
38
|
+
aws_access_key_id=aws_access_key_id,
|
|
39
|
+
aws_secret_access_key=aws_secret_access_key,
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
def reindex_item(
|
|
43
|
+
self,
|
|
44
|
+
original_primary_key: dict,
|
|
45
|
+
model: DynamoDBModelBase,
|
|
46
|
+
*,
|
|
47
|
+
dry_run: bool = False,
|
|
48
|
+
inplace: bool = True,
|
|
49
|
+
leave_original_record: bool = False,
|
|
50
|
+
service_cls: Type[IDynamoDBService] | None,
|
|
51
|
+
):
|
|
52
|
+
"""
|
|
53
|
+
Reindex the record
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
original_primary_key (dict): The original primary key of the record to be reindexed.
|
|
57
|
+
This is either the partition_key or a composite key (partition_key, sort_key)
|
|
58
|
+
model (DynamoDBModelBase): A model instance that will be used to serialize the new keys
|
|
59
|
+
into a dictionary. It must inherit from DynamoDBModelBase
|
|
60
|
+
|
|
61
|
+
dry_run (bool, optional): Ability to log the actions without executing them. Defaults to False.
|
|
62
|
+
inplace (bool, optional): Ability to just update the indexes only.
|
|
63
|
+
No other fields will be updated, however you can't update the primary_key (partition/sort key)
|
|
64
|
+
with this action since they are immutable.
|
|
65
|
+
Defaults to True.
|
|
66
|
+
leave_original_record (bool, optional): _description_. Defaults to False.
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
if inplace:
|
|
70
|
+
keys: List[DynamoDBIndex] = model.list_keys()
|
|
71
|
+
# Update the item in DynamoDB with new keys
|
|
72
|
+
self.update_item_in_dynamodb(
|
|
73
|
+
original_primary_key=original_primary_key, keys=keys, dry_run=dry_run
|
|
74
|
+
)
|
|
75
|
+
# todo: add some additional error handling here and throw a more
|
|
76
|
+
# descriptive error if they try to use a different primary
|
|
77
|
+
# pk or sk, which you can't do. If that's the case
|
|
78
|
+
else:
|
|
79
|
+
# add the new one first and optionally delete the older one
|
|
80
|
+
# once we are succesfull
|
|
81
|
+
try:
|
|
82
|
+
# save the new one first
|
|
83
|
+
service_instance: Optional[IDynamoDBService] = (
|
|
84
|
+
service_cls(db=self.db) if callable(service_cls) else None
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
if service_instance:
|
|
88
|
+
service_instance.save(model=model)
|
|
89
|
+
else:
|
|
90
|
+
self.db.save(
|
|
91
|
+
item=model, table_name=self.table_name, source="reindex"
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
# then delete the old on
|
|
95
|
+
if not leave_original_record:
|
|
96
|
+
self.db.delete(
|
|
97
|
+
table_name=self.table_name, primary_key=original_primary_key
|
|
98
|
+
)
|
|
99
|
+
except Exception as e: # pylint: disable=broad-except
|
|
100
|
+
logger.error(str(e))
|
|
101
|
+
raise RuntimeError(str(e)) from e
|
|
102
|
+
# this gets a little more trick as we need to delete the item
|
|
103
|
+
|
|
104
|
+
def load_model(
|
|
105
|
+
self, db_item: dict, db_model: DynamoDBModelBase
|
|
106
|
+
) -> DynamoDBModelBase | None:
|
|
107
|
+
"""load the model which will serialze the dynamodb dictionary to an instance of an object"""
|
|
108
|
+
|
|
109
|
+
base_model = Serialization.map(db_item, db_model)
|
|
110
|
+
return base_model
|
|
111
|
+
|
|
112
|
+
def update_item_in_dynamodb(
|
|
113
|
+
self,
|
|
114
|
+
original_primary_key: dict,
|
|
115
|
+
keys: List[DynamoDBIndex],
|
|
116
|
+
dry_run: bool = False,
|
|
117
|
+
):
|
|
118
|
+
"""Update the dynamodb item"""
|
|
119
|
+
dictionary = self.db.helpers.keys_to_dictionary(keys=keys)
|
|
120
|
+
|
|
121
|
+
update_expression = self.build_update_expression(dictionary)
|
|
122
|
+
expression_attribute_values = self.build_expression_attribute_values(dictionary)
|
|
123
|
+
|
|
124
|
+
if not dry_run:
|
|
125
|
+
self.db.update_item(
|
|
126
|
+
table_name=self.table_name,
|
|
127
|
+
key=original_primary_key,
|
|
128
|
+
update_expression=update_expression,
|
|
129
|
+
expression_attribute_values=expression_attribute_values,
|
|
130
|
+
)
|
|
131
|
+
else:
|
|
132
|
+
print("Dry run: Skipping Update item")
|
|
133
|
+
print(f"{json.dumps(original_primary_key, indent=4)}")
|
|
134
|
+
print(f"{update_expression}")
|
|
135
|
+
print(f"{json.dumps(expression_attribute_values, indent=4)}")
|
|
136
|
+
|
|
137
|
+
def build_update_expression(self, updated_keys: Dict[str, Any]) -> str:
|
|
138
|
+
"""
|
|
139
|
+
Build the expression for updating the item
|
|
140
|
+
|
|
141
|
+
Args:
|
|
142
|
+
updated_keys (Dict[str, Any]): _description_
|
|
143
|
+
|
|
144
|
+
Returns:
|
|
145
|
+
str: _description_
|
|
146
|
+
"""
|
|
147
|
+
update_expression = "SET " + ", ".join(
|
|
148
|
+
f"{k} = :{k}" for k in updated_keys.keys()
|
|
149
|
+
)
|
|
150
|
+
return update_expression
|
|
151
|
+
|
|
152
|
+
def build_expression_attribute_values(
|
|
153
|
+
self, updated_keys: Dict[str, Any]
|
|
154
|
+
) -> Dict[str, Any]:
|
|
155
|
+
"""
|
|
156
|
+
Build the expression attribute values for the update expression
|
|
157
|
+
|
|
158
|
+
Args:
|
|
159
|
+
updated_keys (Dict[str, Any]): _description_
|
|
160
|
+
|
|
161
|
+
Returns:
|
|
162
|
+
Dict[str, Any]: _description_
|
|
163
|
+
"""
|
|
164
|
+
expression_attribute_values = {f":{k}": v for k, v in updated_keys.items()}
|
|
165
|
+
return expression_attribute_values
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.21.0'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = '0.19.0'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/examples/dynamodb/services/order_item_service.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/cloudwatch/cloudwatch_connection.py
RENAMED
|
File without changes
|
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/cloudwatch/cloudwatch_log_connection.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/dynamodb/dynamodb_connection.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/dynamodb/dynamodb_re_indexer.py
RENAMED
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/dynamodb/dynamodb_reserved_words.py
RENAMED
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/dynamodb/dynamodb_reserved_words.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/environment_services/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/securityhub/securityhub_connection.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/ssm/parameter_store/parameter_store.py
RENAMED
|
File without changes
|
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/utilities/dictionary_utility.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/src/boto3_assist/utilities/serialization_utility.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/integration/cross_account_connection_test.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/db_models/cms/content_block.py
RENAMED
|
File without changes
|
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/db_models/cms/template.py
RENAMED
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/db_models/simple_model.py
RENAMED
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/db_models/user_model.py
RENAMED
|
File without changes
|
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/dynamodb_model_base_test.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/dynamodb_moto_sorting_test.py
RENAMED
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/dynamodb_query_test.py
RENAMED
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/dynamodb_tests/dynamodb_reindex_test.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/models_tests/serializable_model_user_test.py
RENAMED
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/models_tests/serializable_model_wide_test.py
RENAMED
|
File without changes
|
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/parameter_store/parameter_store_test.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/session_tests/test_boto3_session_manager.py
RENAMED
|
File without changes
|
|
File without changes
|
{boto3_assist-0.19.0 → boto3_assist-0.21.0}/tests/unit/utilities/serialization_utility_test.py
RENAMED
|
File without changes
|
|
File without changes
|