boto3-assist 0.1.8__tar.gz → 0.1.10__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.
Files changed (80) hide show
  1. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/PKG-INFO +1 -1
  2. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/pyproject.toml +1 -1
  3. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/dynamodb/dynamodb_model_base.py +46 -13
  4. boto3_assist-0.1.10/src/boto3_assist/version.py +1 -0
  5. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/tests/dynamodb/dynamodb_model_projections_test.py +27 -0
  6. boto3_assist-0.1.8/src/boto3_assist/version.py +0 -1
  7. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/.env.development +0 -0
  8. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/.env.docker +0 -0
  9. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/.env.docker.001 +0 -0
  10. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/.env.docker.nosql.workbench +0 -0
  11. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/.gitignore +0 -0
  12. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/.vscode/launch.json +0 -0
  13. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/.vscode/settings.json +0 -0
  14. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/.vscode/tasks.json +0 -0
  15. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/LICENSE-EXPLAINED.txt +0 -0
  16. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/LICENSE.txt +0 -0
  17. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/README.md +0 -0
  18. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/aws_regions_with_status.csv +0 -0
  19. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/aws_regions_with_status.json +0 -0
  20. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/devops/build.py +0 -0
  21. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/devops/readme.md +0 -0
  22. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/examples/__init__.py +0 -0
  23. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/examples/dynamodb/models/order_item_model.py +0 -0
  24. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/examples/dynamodb/models/order_model.py +0 -0
  25. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/examples/dynamodb/models/product_model.py +0 -0
  26. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/examples/dynamodb/models/user_model.py +0 -0
  27. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/examples/dynamodb/models/user_post_model.py +0 -0
  28. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/examples/dynamodb/order_example/main.py +0 -0
  29. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/examples/dynamodb/order_example/products.json +0 -0
  30. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/examples/dynamodb/services/order_item_service.py +0 -0
  31. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/examples/dynamodb/services/order_service.py +0 -0
  32. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/examples/dynamodb/services/product_service.py +0 -0
  33. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/examples/dynamodb/services/table_service.py +0 -0
  34. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/examples/dynamodb/services/user_post_service.py +0 -0
  35. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/examples/dynamodb/services/user_service.py +0 -0
  36. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/examples/dynamodb/services/user_service_client_example.py +0 -0
  37. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/examples/dynamodb/services/user_service_resource_example.py +0 -0
  38. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/examples/dynamodb/user_post_example/main.py +0 -0
  39. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/examples/ec2/regions_report.py +0 -0
  40. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/module-headers.txt +0 -0
  41. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/mypy.ini +0 -0
  42. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/requirements-dev.txt +0 -0
  43. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/requirements.txt +0 -0
  44. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/run-checks.sh +0 -0
  45. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/__init__.py +0 -0
  46. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/boto3session.py +0 -0
  47. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/connection_tracker.py +0 -0
  48. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/dynamodb/dynamodb.py +0 -0
  49. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/dynamodb/dynamodb_connection.py +0 -0
  50. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/dynamodb/dynamodb_connection_tracker.py +0 -0
  51. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/dynamodb/dynamodb_helpers.py +0 -0
  52. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/dynamodb/dynamodb_importer.py +0 -0
  53. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/dynamodb/dynamodb_index.py +0 -0
  54. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/dynamodb/dynamodb_iservice.py +0 -0
  55. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/dynamodb/dynamodb_key.py +0 -0
  56. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/dynamodb/dynamodb_model_base_interfaces.py +0 -0
  57. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/dynamodb/dynamodb_reindexer.py +0 -0
  58. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/dynamodb/dynamodb_reserved_words.py +0 -0
  59. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/dynamodb/dynamodb_reserved_words.txt +0 -0
  60. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/dynamodb/readme.md +0 -0
  61. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/dynamodb/troubleshooting.md +0 -0
  62. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/ec2/ec2_connection.py +0 -0
  63. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/environment_services/__init__.py +0 -0
  64. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/environment_services/environment_loader.py +0 -0
  65. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/environment_services/environment_variables.py +0 -0
  66. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/utilities/datetime_utility.py +0 -0
  67. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/utilities/logging_utility.py +0 -0
  68. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/utilities/serialization_utility.py +0 -0
  69. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/src/boto3_assist/utilities/string_utility.py +0 -0
  70. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/tests/__init__.py +0 -0
  71. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/tests/__top/__init__.py +0 -0
  72. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/tests/dynamodb/__init__.py +0 -0
  73. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/tests/dynamodb/dynamodb_model_base_test.py +0 -0
  74. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/tests/dynamodb/dynamodb_reindex_test.py +0 -0
  75. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/tests/dynamodb/models/simple_model.py +0 -0
  76. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/tests/dynamodb/models/user_model.py +0 -0
  77. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/tests/examples_test/__init__.py +0 -0
  78. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/tests/examples_test/user_service_test.py +0 -0
  79. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/tests/utilities/__init__.py +0 -0
  80. {boto3_assist-0.1.8 → boto3_assist-0.1.10}/tests/utilities/serialization_utility_test.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: boto3_assist
3
- Version: 0.1.8
3
+ Version: 0.1.10
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
@@ -7,7 +7,7 @@ packages = ["src/boto3_assist"]
7
7
 
8
8
  [project]
9
9
  name = "boto3_assist"
10
- version = "0.1.8"
10
+ version = "0.1.10"
11
11
  authors = [
12
12
  { name="Eric Wilson", email="boto3-assist@geekcafe.com" }
13
13
  ]
@@ -80,6 +80,10 @@ class DynamoDBModelBase:
80
80
  """Gets the auto generate projections"""
81
81
  return self.__auto_generate_projections
82
82
 
83
+ @auto_generate_projections.setter
84
+ def auto_generate_projections(self, value: bool):
85
+ self.__auto_generate_projections = value
86
+
83
87
  @projection_expression.setter
84
88
  def projection_expression(self, value: str | None):
85
89
  self.__projection_expression = value
@@ -153,21 +157,25 @@ class DynamoDBModelBase:
153
157
  self, include_indexes=include_indexes
154
158
  )
155
159
 
156
- def to_resource_dictionary(self, include_indexes: bool = True):
160
+ def to_resource_dictionary(
161
+ self, include_indexes: bool = True, include_none: bool = False
162
+ ):
157
163
  """
158
164
  Convert the instance to a dictionary suitable for DynamoDB resource.
159
165
  """
160
166
  return DynamoDBSerializer.to_resource_dictionary(
161
- self, include_indexes=include_indexes
167
+ self, include_indexes=include_indexes, include_none=include_none
162
168
  )
163
169
 
164
- def to_dictionary(self):
170
+ def to_dictionary(self, include_none: bool = True):
165
171
  """
166
172
  Convert the instance to a dictionary without an indexes/keys.
167
173
  Usefull for turning an object into a dictionary for serialization.
168
174
  This is the same as to_resource_dictionary(include_indexes=False)
169
175
  """
170
- return DynamoDBSerializer.to_resource_dictionary(self, include_indexes=False)
176
+ return DynamoDBSerializer.to_resource_dictionary(
177
+ self, include_indexes=False, include_none=include_none
178
+ )
171
179
 
172
180
  def get_key(self, index_name: str) -> DynamoDBIndex:
173
181
  """Get the index name and key"""
@@ -232,7 +240,9 @@ class DynamoDBSerializer:
232
240
 
233
241
  @staticmethod
234
242
  def to_resource_dictionary(
235
- instance: DynamoDBModelBase, include_indexes: bool = True
243
+ instance: DynamoDBModelBase,
244
+ include_indexes: bool = True,
245
+ include_none: bool = False,
236
246
  ):
237
247
  """
238
248
  Convert a Python class instance to a dictionary suitable for DynamoDB resource.
@@ -244,12 +254,18 @@ class DynamoDBSerializer:
244
254
  - dict: A dictionary representation of the class instance suitable for DynamoDB resource.
245
255
  """
246
256
  return DynamoDBSerializer._serialize(
247
- instance, lambda x: x, include_indexes=include_indexes
257
+ instance,
258
+ lambda x: x,
259
+ include_indexes=include_indexes,
260
+ include_none=include_none,
248
261
  )
249
262
 
250
263
  @staticmethod
251
264
  def _serialize(
252
- instance: DynamoDBModelBase, serialize_fn, include_indexes: bool = True
265
+ instance: DynamoDBModelBase,
266
+ serialize_fn,
267
+ include_indexes: bool = True,
268
+ include_none: bool = True,
253
269
  ):
254
270
  def is_primitive(value):
255
271
  """Check if the value is a primitive data type."""
@@ -259,7 +275,11 @@ class DynamoDBSerializer:
259
275
  """Serialize the value using the provided function."""
260
276
 
261
277
  if isinstance(value, DynamoDBModelBase):
262
- return serialize_fn(value.to_resource_dictionary(False))
278
+ return serialize_fn(
279
+ value.to_resource_dictionary(
280
+ include_indexes=False, include_none=include_none
281
+ )
282
+ )
263
283
  if isinstance(value, dt.datetime):
264
284
  return serialize_fn(value.isoformat())
265
285
  elif isinstance(value, float):
@@ -278,23 +298,36 @@ class DynamoDBSerializer:
278
298
  elif isinstance(value, dict):
279
299
  return serialize_fn({k: serialize_value(v) for k, v in value.items()})
280
300
  else:
281
- return serialize_fn(DynamoDBSerializer._serialize(value, serialize_fn))
301
+ return serialize_fn(
302
+ DynamoDBSerializer._serialize(
303
+ value,
304
+ serialize_fn,
305
+ include_indexes=include_indexes,
306
+ include_none=include_none,
307
+ )
308
+ )
282
309
 
283
- instance_dict = DynamoDBSerializer._add_properties(instance, serialize_value)
310
+ instance_dict = DynamoDBSerializer._add_properties(
311
+ instance, serialize_value, include_none=include_none
312
+ )
284
313
 
285
314
  if include_indexes:
286
315
  instance_dict = DynamoDBSerializer._add_indexes(instance, instance_dict)
287
316
  return instance_dict
288
317
 
289
318
  @staticmethod
290
- def _add_properties(instance: DynamoDBModelBase, serialize_value) -> dict:
319
+ def _add_properties(
320
+ instance: DynamoDBModelBase,
321
+ serialize_value,
322
+ include_none: bool = True,
323
+ ) -> dict:
291
324
  instance_dict = {}
292
325
 
293
326
  # Add instance variables
294
327
  for attr, value in instance.__dict__.items():
295
328
  # don't get the private properties
296
329
  if not str(attr).startswith("_"):
297
- if value is not None:
330
+ if value is not None or include_none:
298
331
  instance_dict[attr] = serialize_value(value)
299
332
 
300
333
  # Add properties
@@ -316,7 +349,7 @@ class DynamoDBSerializer:
316
349
  # don't get the private properties
317
350
  if not str(name).startswith("_"):
318
351
  value = getattr(instance, name)
319
- if value is not None:
352
+ if value is not None or include_none:
320
353
  instance_dict[name] = serialize_value(value)
321
354
 
322
355
  return instance_dict
@@ -0,0 +1 @@
1
+ __version__ = '0.1.10'
@@ -80,3 +80,30 @@ class DynamoDBModeProjectionlUnitTest(unittest.TestCase):
80
80
 
81
81
  attribute_names = model.projection_expression_attribute_names
82
82
  self.assertIsNone(attribute_names)
83
+
84
+ def test_user_model_and_nulls(self):
85
+ model: User = User()
86
+ model.first_name = "John"
87
+
88
+ expressions = model.projection_expression
89
+ self.assertIsInstance(expressions, str)
90
+
91
+ self.assertIn("id", expressions)
92
+
93
+ def test_user_limited_projections(self):
94
+ model: User = User()
95
+ model.first_name = "John"
96
+
97
+ model.projection_expression = "id"
98
+ model.projection_expression_attribute_names = None
99
+ model.auto_generate_projections = False
100
+ expressions = model.projection_expression
101
+ attributes = model.projection_expression_attribute_names
102
+ self.assertIsInstance(expressions, str)
103
+
104
+ self.assertIn("id", expressions)
105
+ self.assertNotIn("first_name", expressions)
106
+ self.assertNotIn("age", expressions)
107
+ self.assertNotIn("email", expressions)
108
+ self.assertNotIn("status", expressions)
109
+ self.assertIsNone(attributes)
@@ -1 +0,0 @@
1
- __version__ = '0.1.8'
File without changes
File without changes
File without changes
File without changes
File without changes