boto3-assist 0.2.1__tar.gz → 0.2.2__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 (98) hide show
  1. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/PKG-INFO +1 -1
  2. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/pyproject.toml +1 -1
  3. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/s3/s3.py +51 -22
  4. boto3_assist-0.2.2/src/boto3_assist/version.py +1 -0
  5. boto3_assist-0.2.1/src/boto3_assist/version.py +0 -1
  6. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/.env.docker +0 -0
  7. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/.env.docker.001 +0 -0
  8. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/.env.docker.nosql.workbench +0 -0
  9. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/.env.unittest +0 -0
  10. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/.gitignore +0 -0
  11. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/.vscode/launch.json +0 -0
  12. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/.vscode/settings.json +0 -0
  13. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/.vscode/tasks.json +0 -0
  14. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/LICENSE-EXPLAINED.txt +0 -0
  15. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/LICENSE.txt +0 -0
  16. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/README.md +0 -0
  17. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/aws_regions_with_status.csv +0 -0
  18. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/aws_regions_with_status.json +0 -0
  19. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/devops/build.py +0 -0
  20. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/devops/readme.md +0 -0
  21. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/examples/__init__.py +0 -0
  22. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/examples/cloudwatch/log_report.py +0 -0
  23. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/examples/dynamodb/models/order_item_model.py +0 -0
  24. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/examples/dynamodb/models/order_model.py +0 -0
  25. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/examples/dynamodb/models/product_model.py +0 -0
  26. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/examples/dynamodb/models/user_model.py +0 -0
  27. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/examples/dynamodb/models/user_post_model.py +0 -0
  28. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/examples/dynamodb/order_example/main.py +0 -0
  29. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/examples/dynamodb/order_example/products.json +0 -0
  30. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/examples/dynamodb/services/order_item_service.py +0 -0
  31. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/examples/dynamodb/services/order_service.py +0 -0
  32. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/examples/dynamodb/services/product_service.py +0 -0
  33. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/examples/dynamodb/services/table_service.py +0 -0
  34. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/examples/dynamodb/services/user_post_service.py +0 -0
  35. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/examples/dynamodb/services/user_service.py +0 -0
  36. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/examples/dynamodb/services/user_service_client_example.py +0 -0
  37. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/examples/dynamodb/services/user_service_resource_example.py +0 -0
  38. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/examples/dynamodb/user_post_example/main.py +0 -0
  39. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/examples/ec2/regions_report.py +0 -0
  40. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/module-headers.txt +0 -0
  41. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/mypy.ini +0 -0
  42. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/requirements-dev.txt +0 -0
  43. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/requirements.txt +0 -0
  44. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/run-checks.sh +0 -0
  45. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/__init__.py +0 -0
  46. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/boto3session.py +0 -0
  47. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/cloudwatch/cloudwatch_connection.py +0 -0
  48. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/cloudwatch/cloudwatch_connection_tracker.py +0 -0
  49. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/cloudwatch/cloudwatch_log_connection.py +0 -0
  50. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/cloudwatch/cloudwatch_logs.py +0 -0
  51. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/cloudwatch/cloudwatch_query.py +0 -0
  52. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/connection.py +0 -0
  53. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/connection_tracker.py +0 -0
  54. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/dynamodb/dynamodb.py +0 -0
  55. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/dynamodb/dynamodb_connection.py +0 -0
  56. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/dynamodb/dynamodb_connection_tracker.py +0 -0
  57. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/dynamodb/dynamodb_helpers.py +0 -0
  58. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/dynamodb/dynamodb_importer.py +0 -0
  59. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/dynamodb/dynamodb_index.py +0 -0
  60. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/dynamodb/dynamodb_iservice.py +0 -0
  61. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/dynamodb/dynamodb_key.py +0 -0
  62. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/dynamodb/dynamodb_model_base.py +0 -0
  63. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/dynamodb/dynamodb_model_base_interfaces.py +0 -0
  64. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/dynamodb/dynamodb_reindexer.py +0 -0
  65. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/dynamodb/dynamodb_reserved_words.py +0 -0
  66. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/dynamodb/dynamodb_reserved_words.txt +0 -0
  67. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/dynamodb/readme.md +0 -0
  68. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/dynamodb/troubleshooting.md +0 -0
  69. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/ec2/ec2_connection.py +0 -0
  70. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/environment_services/__init__.py +0 -0
  71. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/environment_services/environment_loader.py +0 -0
  72. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/environment_services/environment_variables.py +0 -0
  73. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/errors/custom_exceptions.py +0 -0
  74. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/s3/s3_connection.py +0 -0
  75. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/utilities/datetime_utility.py +0 -0
  76. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/utilities/file_operations.py +0 -0
  77. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/utilities/http_utility.py +0 -0
  78. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/utilities/logging_utility.py +0 -0
  79. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/utilities/serialization_utility.py +0 -0
  80. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/src/boto3_assist/utilities/string_utility.py +0 -0
  81. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/tests/__init__.py +0 -0
  82. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/tests/__top/__init__.py +0 -0
  83. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/tests/dynamodb/__init__.py +0 -0
  84. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/tests/dynamodb/dynamodb_model_base_test.py +0 -0
  85. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/tests/dynamodb/dynamodb_model_projections_test.py +0 -0
  86. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/tests/dynamodb/dynamodb_model_serializtion_test.py +0 -0
  87. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/tests/dynamodb/dynamodb_moto_sorting_test.py +0 -0
  88. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/tests/dynamodb/dynamodb_reindex_test.py +0 -0
  89. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/tests/dynamodb/models/cms/base.py +0 -0
  90. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/tests/dynamodb/models/cms/content_block.py +0 -0
  91. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/tests/dynamodb/models/cms/page.py +0 -0
  92. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/tests/dynamodb/models/cms/template.py +0 -0
  93. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/tests/dynamodb/models/simple_model.py +0 -0
  94. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/tests/dynamodb/models/user_model.py +0 -0
  95. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/tests/examples_test/__init__.py +0 -0
  96. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/tests/examples_test/user_service_test.py +0 -0
  97. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/tests/utilities/__init__.py +0 -0
  98. {boto3_assist-0.2.1 → boto3_assist-0.2.2}/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.2.1
3
+ Version: 0.2.2
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
  Classifier: License :: Other/Proprietary License
@@ -7,7 +7,7 @@ packages = ["src/boto3_assist"]
7
7
 
8
8
  [project]
9
9
  name = "boto3_assist"
10
- version = "0.2.1"
10
+ version = "0.2.2"
11
11
  authors = [
12
12
  { name="Eric Wilson", email="boto3-assist@geekcafe.com" }
13
13
  ]
@@ -89,7 +89,7 @@ class S3(S3Connection):
89
89
  else:
90
90
  meta_data.update(local_meta)
91
91
 
92
- object_key = key_path
92
+ key = key_path
93
93
  method_type = method_type.upper()
94
94
 
95
95
  signed_url: str | Dict[str, Any]
@@ -98,7 +98,7 @@ class S3(S3Connection):
98
98
  "put_object",
99
99
  Params={
100
100
  "Bucket": f"{bucket_name}",
101
- "Key": f"{object_key}",
101
+ "Key": f"{key}",
102
102
  # NOTE: if you include the ContentType or Metadata then its required in the when they upload the file
103
103
  # Otherwise you will get a `SignatureDoesNotMatch` error
104
104
  # for now I'm commenting it out.
@@ -111,7 +111,7 @@ class S3(S3Connection):
111
111
  elif method_type == "POST":
112
112
  signed_url = self.client.generate_presigned_post(
113
113
  bucket_name,
114
- object_key,
114
+ key,
115
115
  ExpiresIn=expiration, # URL is valid for x seconds
116
116
  )
117
117
  elif method_type == "GET":
@@ -119,7 +119,7 @@ class S3(S3Connection):
119
119
  "get_object",
120
120
  Params={
121
121
  "Bucket": f"{bucket_name}",
122
- "Key": f"{object_key}",
122
+ "Key": f"{key}",
123
123
  },
124
124
  ExpiresIn=expiration, # URL is valid for x seconds
125
125
  )
@@ -133,12 +133,43 @@ class S3(S3Connection):
133
133
 
134
134
  response = {
135
135
  "signed_url": signed_url,
136
- "object_key": object_key,
136
+ "key": key,
137
137
  "meta_data": meta_data,
138
138
  }
139
139
 
140
140
  return response
141
141
 
142
+ def upload_file_obj(self, bucket: str, key: str, file_obj: bytes) -> str:
143
+ """
144
+ Uploads a file object to s3. Returns the full s3 path s3://<bucket>/<key>
145
+ """
146
+
147
+ if key.startswith("/"):
148
+ # remove the first slash
149
+ key = key[1:]
150
+
151
+ logger.debug(
152
+ {
153
+ "metric_filter": "upload_file_to_s3",
154
+ "bucket": bucket,
155
+ "key": key,
156
+ }
157
+ )
158
+ try:
159
+ self.client.upload_fileobj(Fileobj=file_obj, Bucket=bucket, Key=key)
160
+
161
+ except ClientError as ce:
162
+ error = {
163
+ "metric_filter": "upload_file_to_s3_failure",
164
+ "s3 upload": "failure",
165
+ "bucket": bucket,
166
+ "key": key,
167
+ }
168
+ logger.error(error)
169
+ raise RuntimeError(error) from ce
170
+
171
+ return f"s3://{bucket}/{key}"
172
+
142
173
  def upload_file(
143
174
  self,
144
175
  bucket: str,
@@ -188,7 +219,7 @@ class S3(S3Connection):
188
219
  def download_file(
189
220
  self,
190
221
  bucket: str,
191
- object_key: str,
222
+ key: str,
192
223
  local_directory: str | None = None,
193
224
  local_file_path: str | None = None,
194
225
  retry_attempts: int = 3,
@@ -205,7 +236,7 @@ class S3(S3Connection):
205
236
  try:
206
237
  path = self.download_file_no_retries(
207
238
  bucket=bucket,
208
- object_key=object_key,
239
+ key=key,
209
240
  local_directory=local_directory,
210
241
  local_file_path=local_file_path,
211
242
  )
@@ -246,7 +277,7 @@ class S3(S3Connection):
246
277
  def download_file_no_retries(
247
278
  self,
248
279
  bucket: str,
249
- object_key: str,
280
+ key: str,
250
281
  local_directory: str | None = None,
251
282
  local_file_path: str | None = None,
252
283
  ) -> str:
@@ -255,7 +286,7 @@ class S3(S3Connection):
255
286
 
256
287
  Args:
257
288
  bucket (str): s3 bucket
258
- object_key (str): the s3 object key
289
+ key (str): the s3 object key
259
290
  local_directory (str, optional): Local directory to download to. Defaults to None.
260
291
  If None, we'll use a local tmp directory.
261
292
 
@@ -272,13 +303,11 @@ class S3(S3Connection):
272
303
  {
273
304
  "action": "downloading file",
274
305
  "bucket": bucket,
275
- "object_key": object_key,
306
+ "key": key,
276
307
  "local_directory": local_directory,
277
308
  }
278
309
  )
279
- return self.__download_file(
280
- bucket, object_key, local_directory, local_file_path
281
- )
310
+ return self.__download_file(bucket, key, local_directory, local_file_path)
282
311
  except FileNotFoundError:
283
312
  logger.warning(
284
313
  {
@@ -286,12 +315,12 @@ class S3(S3Connection):
286
315
  "error": "FileNotFoundError",
287
316
  "message": "attempting to find it decoded",
288
317
  "bucket": bucket,
289
- "object_key": object_key,
318
+ "key": key,
290
319
  }
291
320
  )
292
321
 
293
- # attempt to decode the object_key
294
- decoded_object_key = HttpUtility.decode_url(object_key)
322
+ # attempt to decode the key
323
+ decoded_object_key = HttpUtility.decode_url(key)
295
324
 
296
325
  logger.error(
297
326
  {
@@ -299,7 +328,7 @@ class S3(S3Connection):
299
328
  "error": "FileNotFoundError",
300
329
  "message": "attempting to find it decoded",
301
330
  "bucket": bucket,
302
- "object_key": object_key,
331
+ "key": key,
303
332
  "decoded_object_key": decoded_object_key,
304
333
  }
305
334
  )
@@ -317,7 +346,7 @@ class S3(S3Connection):
317
346
  )
318
347
  raise e
319
348
 
320
- def stream_file(self, bucket_name: str, object_key: str) -> Dict[str, Any]:
349
+ def stream_file(self, bucket_name: str, key: str) -> Dict[str, Any]:
321
350
  """
322
351
  Gets a file from s3 and returns the response.
323
352
  The "Body" is a streaming body object. You can read it like a file.
@@ -334,7 +363,7 @@ class S3(S3Connection):
334
363
  "source": "download_file",
335
364
  "action": "downloading a file from s3",
336
365
  "bucket": bucket_name,
337
- "key": object_key,
366
+ "key": key,
338
367
  }
339
368
  )
340
369
 
@@ -342,7 +371,7 @@ class S3(S3Connection):
342
371
  error = None
343
372
 
344
373
  try:
345
- response = dict(self.client.get_object(Bucket=bucket_name, Key=object_key))
374
+ response = dict(self.client.get_object(Bucket=bucket_name, Key=key))
346
375
 
347
376
  logger.debug(
348
377
  {"metric_filter": "s3_download_response", "response": str(response)}
@@ -356,7 +385,7 @@ class S3(S3Connection):
356
385
  "metric_filter": "s3_download_error",
357
386
  "error": str(e),
358
387
  "bucket": bucket_name,
359
- "key": object_key,
388
+ "key": key,
360
389
  }
361
390
  ) from e
362
391
 
@@ -366,7 +395,7 @@ class S3(S3Connection):
366
395
  "source": "download_file",
367
396
  "action": "downloading a file from s3",
368
397
  "bucket": bucket_name,
369
- "key": object_key,
398
+ "key": key,
370
399
  "response": response,
371
400
  "errors": error,
372
401
  }
@@ -0,0 +1 @@
1
+ __version__ = '0.2.2'
@@ -1 +0,0 @@
1
- __version__ = '0.2.1'
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes