boto3-assist 0.22.0__py3-none-any.whl → 0.24.0__py3-none-any.whl
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/dynamodb/dynamodb.py +3 -1
- boto3_assist/dynamodb/dynamodb_index.py +30 -13
- boto3_assist/dynamodb/dynamodb_model_base.py +9 -1
- boto3_assist/version.py +1 -1
- {boto3_assist-0.22.0.dist-info → boto3_assist-0.24.0.dist-info}/METADATA +5 -5
- {boto3_assist-0.22.0.dist-info → boto3_assist-0.24.0.dist-info}/RECORD +9 -9
- {boto3_assist-0.22.0.dist-info → boto3_assist-0.24.0.dist-info}/WHEEL +0 -0
- {boto3_assist-0.22.0.dist-info → boto3_assist-0.24.0.dist-info}/licenses/LICENSE-EXPLAINED.txt +0 -0
- {boto3_assist-0.22.0.dist-info → boto3_assist-0.24.0.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -355,7 +355,9 @@ class DynamoDB(DynamoDBConnection):
|
|
|
355
355
|
key = key.key()
|
|
356
356
|
|
|
357
357
|
kwargs: dict = {}
|
|
358
|
-
|
|
358
|
+
|
|
359
|
+
if index_name and index_name != "primary":
|
|
360
|
+
# only include the index_name if we are not using our "primary" pk/sk
|
|
359
361
|
kwargs["IndexName"] = f"{index_name}"
|
|
360
362
|
kwargs["TableName"] = f"{table_name}"
|
|
361
363
|
kwargs["KeyConditionExpression"] = key
|
|
@@ -37,7 +37,7 @@ class DynamoDBIndexes:
|
|
|
37
37
|
if index.name in self.__indexes:
|
|
38
38
|
raise ValueError(
|
|
39
39
|
f"The index {index.name} is already defined in your model somewhere. "
|
|
40
|
-
"This error is generated to protect you from
|
|
40
|
+
"This error is generated to protect you from unforeseen issues. "
|
|
41
41
|
"If you models are inheriting from other models, you may have the primary defined twice."
|
|
42
42
|
)
|
|
43
43
|
|
|
@@ -64,7 +64,7 @@ class DynamoDBIndexes:
|
|
|
64
64
|
for _, v in self.__indexes.items():
|
|
65
65
|
if v.partition_key.attribute_name == index.partition_key.attribute_name:
|
|
66
66
|
raise ValueError(
|
|
67
|
-
f"The
|
|
67
|
+
f"The attribute {index.partition_key.attribute_name} is already being used by index "
|
|
68
68
|
f"{v.name}. "
|
|
69
69
|
f"Reusing this attribute would over write the value on index {v.name}"
|
|
70
70
|
)
|
|
@@ -73,7 +73,7 @@ class DynamoDBIndexes:
|
|
|
73
73
|
for _, v in self.__indexes.items():
|
|
74
74
|
if v.sort_key.attribute_name == index.sort_key.attribute_name:
|
|
75
75
|
raise ValueError(
|
|
76
|
-
f"The
|
|
76
|
+
f"The attribute {index.sort_key.attribute_name} is already being used by index "
|
|
77
77
|
f"{v.name}. "
|
|
78
78
|
f"Reusing this attribute would over write the value on index {v.name}"
|
|
79
79
|
)
|
|
@@ -156,21 +156,13 @@ class DynamoDBIndex:
|
|
|
156
156
|
condition: str = "begins_with",
|
|
157
157
|
low_value: Any = None,
|
|
158
158
|
high_value: Any = None,
|
|
159
|
+
query_key: bool = False,
|
|
159
160
|
# sk_value_2: Optional[str | int | float] = None,
|
|
160
161
|
) -> dict | Key | ConditionBase | ComparisonCondition | Equals:
|
|
161
162
|
"""Get the key for a given index"""
|
|
162
163
|
key: dict | Key | ConditionBase | ComparisonCondition | Equals
|
|
163
|
-
if self.name == DynamoDBIndexes.PRIMARY_INDEX and include_sort_key:
|
|
164
|
-
# this is a direct primary key which is used in a get call
|
|
165
|
-
# this is differenet than query keys
|
|
166
|
-
key = {}
|
|
167
|
-
key[self.partition_key.attribute_name] = self.partition_key.value
|
|
168
164
|
|
|
169
|
-
|
|
170
|
-
key[self.sort_key.attribute_name] = self.sort_key.value
|
|
171
|
-
|
|
172
|
-
return key
|
|
173
|
-
else:
|
|
165
|
+
if query_key:
|
|
174
166
|
key = self._build_query_key(
|
|
175
167
|
include_sort_key=include_sort_key,
|
|
176
168
|
condition=condition,
|
|
@@ -179,6 +171,31 @@ class DynamoDBIndex:
|
|
|
179
171
|
)
|
|
180
172
|
return key
|
|
181
173
|
|
|
174
|
+
elif (
|
|
175
|
+
self.name == DynamoDBIndexes.PRIMARY_INDEX
|
|
176
|
+
and include_sort_key
|
|
177
|
+
# if it ends with a # we are assuming that we are doing a wild card mapping
|
|
178
|
+
and not str(self.sort_key.value).endswith("#")
|
|
179
|
+
):
|
|
180
|
+
# this is a direct primary key which is used in a get call
|
|
181
|
+
# this is different than query keys
|
|
182
|
+
key = {}
|
|
183
|
+
key[self.partition_key.attribute_name] = self.partition_key.value
|
|
184
|
+
|
|
185
|
+
if self.sort_key and self.sort_key.attribute_name:
|
|
186
|
+
key[self.sort_key.attribute_name] = self.sort_key.value
|
|
187
|
+
|
|
188
|
+
return key
|
|
189
|
+
|
|
190
|
+
# catch all (TODO: decide if this is the best pattern or should we raise an error)
|
|
191
|
+
key = self._build_query_key(
|
|
192
|
+
include_sort_key=include_sort_key,
|
|
193
|
+
condition=condition,
|
|
194
|
+
low_value=low_value,
|
|
195
|
+
high_value=high_value,
|
|
196
|
+
)
|
|
197
|
+
return key
|
|
198
|
+
|
|
182
199
|
def _build_query_key(
|
|
183
200
|
self,
|
|
184
201
|
*,
|
|
@@ -21,6 +21,7 @@ from boto3_assist.dynamodb.dynamodb_index import (
|
|
|
21
21
|
from boto3_assist.dynamodb.dynamodb_reserved_words import DynamoDBReservedWords
|
|
22
22
|
from boto3_assist.utilities.datetime_utility import DatetimeUtility
|
|
23
23
|
from boto3_assist.models.serializable_model import SerializableModel
|
|
24
|
+
from boto3_assist.utilities.string_utility import StringUtility
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
def exclude_from_serialization(method):
|
|
@@ -190,7 +191,7 @@ class DynamoDBModelBase(SerializableModel):
|
|
|
190
191
|
def to_dictionary(self, include_none: bool = True):
|
|
191
192
|
"""
|
|
192
193
|
Convert the instance to a dictionary without an indexes/keys.
|
|
193
|
-
|
|
194
|
+
Useful for turning an object into a dictionary for serialization.
|
|
194
195
|
This is the same as to_resource_dictionary(include_indexes=False)
|
|
195
196
|
"""
|
|
196
197
|
return DynamoDBSerializer.to_resource_dictionary(
|
|
@@ -205,6 +206,13 @@ class DynamoDBModelBase(SerializableModel):
|
|
|
205
206
|
|
|
206
207
|
return self.indexes.get(index_name)
|
|
207
208
|
|
|
209
|
+
@staticmethod
|
|
210
|
+
def generate_uuid(sortable: bool = True) -> str:
|
|
211
|
+
if sortable:
|
|
212
|
+
return StringUtility.generate_sortable_uuid()
|
|
213
|
+
|
|
214
|
+
return StringUtility.generate_uuid()
|
|
215
|
+
|
|
208
216
|
@property
|
|
209
217
|
@exclude_from_serialization
|
|
210
218
|
def helpers(self) -> DynamoDBHelpers:
|
boto3_assist/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = '0.
|
|
1
|
+
__version__ = '0.24.0'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: boto3_assist
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.24.0
|
|
4
4
|
Summary: Additional boto3 wrappers to make your life a little easier
|
|
5
5
|
Author-email: Eric Wilson <boto3-assist@geekcafe.com>
|
|
6
6
|
License-File: LICENSE-EXPLAINED.txt
|
|
@@ -32,7 +32,7 @@ Description-Content-Type: text/markdown
|
|
|
32
32
|
|
|
33
33
|
This is in beta and subject to changes before it's initial 1.0.0 release
|
|
34
34
|
|
|
35
|
-
This
|
|
35
|
+
This library was created to make life a little easier when using boto3.
|
|
36
36
|
|
|
37
37
|
Currently it supports:
|
|
38
38
|
- User Authentication / Session Mapping
|
|
@@ -40,11 +40,11 @@ Currently it supports:
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
## User Authentication / Session Mapping
|
|
43
|
-
Have you ever needed an easy way to load your sessions for a local, dev or production
|
|
43
|
+
Have you ever needed an easy way to load your sessions for a local, dev or production environment? Well this library
|
|
44
44
|
makes it a little easier by lazy loading your boto3 session so that tools like `python-dotenv` can be used to load your
|
|
45
45
|
environment vars first and then load your session.
|
|
46
46
|
|
|
47
|
-
##
|
|
47
|
+
## DynamoDB model mapping and Key Generation
|
|
48
48
|
It's a light weight mapping tool to turn your python classes / object models to DynamoDB items that are ready
|
|
49
49
|
for saving. See the [examples](https://github.com/geekcafe/boto3-assist/tree/main/examples) directory in the repo for more information.
|
|
50
50
|
|
|
@@ -61,7 +61,7 @@ pip install boto3-assist
|
|
|
61
61
|
## Running Unit Tests
|
|
62
62
|
Several of our tests use a mocking library to simulate connections to S3, DynamoDB, etc. In order to use those tests, you will need to have a `.env.unittest` file at the root of this project (which our tests will attempt to locate and load).
|
|
63
63
|
|
|
64
|
-
For your
|
|
64
|
+
For your convenience the `.evn.unittest` file has been added to this project. The values should not point to live AWS profiles, instead it should use the values added.
|
|
65
65
|
|
|
66
66
|
Since we also point to a profile, you should create the profile in the `~/.aws/config` file. The entry should look like the following:
|
|
67
67
|
|
|
@@ -6,7 +6,7 @@ boto3_assist/connection_tracker.py,sha256=UgfR9RlvXf3A4ssMr3gDMpw89ka8mSRvJn4M34
|
|
|
6
6
|
boto3_assist/http_status_codes.py,sha256=G0zRSWenwavYKETvDF9tNVUXQz3Ae2gXdBETYbjvJe8,3284
|
|
7
7
|
boto3_assist/role_assumption_mixin.py,sha256=PMUU5yC2FUBjFD1UokVkRY3CPB5zTw85AhIB5BMtbc8,1031
|
|
8
8
|
boto3_assist/session_setup_mixin.py,sha256=X-JQKyyaWNA8Z8kKgf2V2I5vsiLAH8udLTX_xepnsdQ,3140
|
|
9
|
-
boto3_assist/version.py,sha256=
|
|
9
|
+
boto3_assist/version.py,sha256=lbgaUA9yL_X3wnFgvRc5nIlmJ4gFm6Ala6TbPHN-5aY,23
|
|
10
10
|
boto3_assist/aws_lambda/event_info.py,sha256=OkZ4WzuGaHEu_T8sB188KBgShAJhZpWASALKRGBOhMg,14648
|
|
11
11
|
boto3_assist/aws_lambda/mock_context.py,sha256=LPjHP-3YSoY6iPl1kPqJDwSVf1zLNTcukUunDtYcbK0,116
|
|
12
12
|
boto3_assist/cloudwatch/cloudwatch_connection.py,sha256=mnGWaLSQpHh5EeY7Ek_2o9JKHJxOELIYtQVMX1IaHn4,2480
|
|
@@ -19,14 +19,14 @@ boto3_assist/cognito/cognito_connection.py,sha256=deuXR3cNHz0mCYff2k0LfAvK--9Okq
|
|
|
19
19
|
boto3_assist/cognito/cognito_utility.py,sha256=IVZAg58nHG1U7uxe7FsTYpqwwZiwwdIBGiVTZuLCFqg,18417
|
|
20
20
|
boto3_assist/cognito/jwks_cache.py,sha256=1Y9r-YfQ8qrgZN5xYPvjUEEV0vthbdcPdAIaPbZP7kU,373
|
|
21
21
|
boto3_assist/cognito/user.py,sha256=qc44qLx3gwq6q2zMxcPQze1EjeZwy5Kuav93vbe-4WU,820
|
|
22
|
-
boto3_assist/dynamodb/dynamodb.py,sha256=
|
|
22
|
+
boto3_assist/dynamodb/dynamodb.py,sha256=aW6kWq-Hcc6idmuFygdpUyPusPHsIvVGq2hiG8n8gBo,18481
|
|
23
23
|
boto3_assist/dynamodb/dynamodb_connection.py,sha256=D4KmVpMpE0OuVOwW5g4JBWllUNkwy0hMXEGUiToAMBc,3608
|
|
24
24
|
boto3_assist/dynamodb/dynamodb_helpers.py,sha256=RoRRqKjdwfC-2-gvlkLvCoNWhIoMrHm-68dkyhXI_Xk,12080
|
|
25
25
|
boto3_assist/dynamodb/dynamodb_importer.py,sha256=nCKsyRQeMqDSf0Q5mQ_X_oVIg4PRnu0hcUzZnBli610,3471
|
|
26
|
-
boto3_assist/dynamodb/dynamodb_index.py,sha256=
|
|
26
|
+
boto3_assist/dynamodb/dynamodb_index.py,sha256=EhLvaLQznrsbP1b8LRHDnPSUxou_JYn0fYYRLhvH26U,9085
|
|
27
27
|
boto3_assist/dynamodb/dynamodb_iservice.py,sha256=O9Aj0PFEvcuk2vhARifWTFnUwcQW5EXzwZS478Hm-N0,796
|
|
28
28
|
boto3_assist/dynamodb/dynamodb_key.py,sha256=4IYnG4a99AjdOKUcDaWhNF_lvZJRZcKOIPzBQQzVdB0,3294
|
|
29
|
-
boto3_assist/dynamodb/dynamodb_model_base.py,sha256=
|
|
29
|
+
boto3_assist/dynamodb/dynamodb_model_base.py,sha256=Bgnjs62lHTqqJ2nZbPV1JHvcK6d2-aaRsJtcc8DEqKk,12291
|
|
30
30
|
boto3_assist/dynamodb/dynamodb_model_base_interfaces.py,sha256=SFw-yK7TDPL4cK52bpn2zMm5G4mX7eYNU7eFytEw0-A,749
|
|
31
31
|
boto3_assist/dynamodb/dynamodb_re_indexer.py,sha256=Y0qRrvpmjS68w8ci6Au7Hg02W_ktqhUGGALeN-9XTls,6164
|
|
32
32
|
boto3_assist/dynamodb/dynamodb_reindexer.py,sha256=bCj6KIU0fQOgjkkiq9yF51PFZZr4Y9Lu3-hPlmsPG0Y,6164
|
|
@@ -57,8 +57,8 @@ boto3_assist/utilities/logging_utility.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5N
|
|
|
57
57
|
boto3_assist/utilities/numbers_utility.py,sha256=wzv9d0uXT_2_ZHHio7LBzibwxPqhGpvbq9HinrVn_4A,10160
|
|
58
58
|
boto3_assist/utilities/serialization_utility.py,sha256=Jc6H0cpcZjLO7tdyUZdBWHzItduLkw6sh2YQh8Hc8D8,21647
|
|
59
59
|
boto3_assist/utilities/string_utility.py,sha256=XxUIz19L2LFFTRDAAmdPa8Qhn40u9yO7g4nULFuvg0M,11033
|
|
60
|
-
boto3_assist-0.
|
|
61
|
-
boto3_assist-0.
|
|
62
|
-
boto3_assist-0.
|
|
63
|
-
boto3_assist-0.
|
|
64
|
-
boto3_assist-0.
|
|
60
|
+
boto3_assist-0.24.0.dist-info/METADATA,sha256=yWQTff8EmXgeFxcFGHTq1DbzD-bhAUArD3CCOjz3BYk,2879
|
|
61
|
+
boto3_assist-0.24.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
62
|
+
boto3_assist-0.24.0.dist-info/licenses/LICENSE-EXPLAINED.txt,sha256=WFREvTpfTjPjDHpOLADxJpCKpIla3Ht87RUUGii4ODU,606
|
|
63
|
+
boto3_assist-0.24.0.dist-info/licenses/LICENSE.txt,sha256=PXDhFWS5L5aOTkVhNvoitHKbAkgxqMI2uUPQyrnXGiI,1105
|
|
64
|
+
boto3_assist-0.24.0.dist-info/RECORD,,
|
|
File without changes
|
{boto3_assist-0.22.0.dist-info → boto3_assist-0.24.0.dist-info}/licenses/LICENSE-EXPLAINED.txt
RENAMED
|
File without changes
|
|
File without changes
|