uc3-dmp-dynamo 0.0.10 → 0.0.12

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa0cf659b6f3edcd00daa7ab6d65317f4cd985f9142437d62811716843c31b4f
4
- data.tar.gz: 7decab5a151bded9ad6de31591cbc225754384a699241f1ebc314c026c484b72
3
+ metadata.gz: 5f56e8305a7c18d00f32d82320410ee3541d192cb8316387520905b157ef2722
4
+ data.tar.gz: 62a8052686169fd3a52d8109df505a4a5121d02cf46dad79c654cd1ab04ae001
5
5
  SHA512:
6
- metadata.gz: caca36dbadabe3ab58928d443c12d180149b9fd00a6fe711d54d4d2260be72f2adb87770231973bde79d63c766bf457147f9224a38153f385767145856419ee6
7
- data.tar.gz: b4a3c40de41da8bfcad5342f64ac6cbc3b5794864543a0adcac1eaba0f78aca749277d7201bc2c2e20a15ddf90f7e89c8c50fd6f3f3d38493f3a025cae469aee
6
+ metadata.gz: 51379653dd5cefcc664257775443fea34108378596dd40d43ae4e1ef58b1195557fc5ea548159364e88794836ecaa68a03871c2508e14265f03a240295794689
7
+ data.tar.gz: 80e910684933726b0009f498f525d7053255221031f74fe7fe7421dc3fe5e41989ff14da3f72095f20cb93979b75cfb609b9c224b96c847b8cdf6c2d8648fc61
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # TODO: Be sure to update the API functions so that they call cleanse_dmp_json before
4
- # calling Uc3DmpApiCore::Responder.respond !!!!!!!!!!
5
-
6
3
  module Uc3DmpDynamo
7
4
  class ClientError < StandardError; end
8
5
 
@@ -23,6 +20,14 @@ module Uc3DmpDynamo
23
20
  @connection = Aws::DynamoDB::Client.new(region: ENV.fetch('AWS_REGION', 'us-west-2'))
24
21
  end
25
22
 
23
+ # Quick get_item that only returns the PK to validate that the item exists
24
+ def pk_exists?(key:)
25
+ return nil unless key.is_a?(Hash) && !key['PK'].nil?
26
+
27
+ resp = client.get_item(table_name: @table, key: key, projection_expression: 'PK')
28
+ resp.item.is_a?(Hash) && resp.item['PK'] == key['PK']
29
+ end
30
+
26
31
  # Fetch a single item
27
32
  # rubocop:disable Metrics/AbcSize
28
33
  def get_item(key:, debug: false)
@@ -86,7 +91,6 @@ module Uc3DmpDynamo
86
91
 
87
92
  # Create/Update an item
88
93
  def put_item(json:, debug: false)
89
- json = Helper.parse_json(json: json)
90
94
  raise ClientError, MSG_INVALID_KEY unless json.is_a?(Hash) && !json['PK'].nil? && !json['SK'].nil?
91
95
 
92
96
  resp = @connection.put_item(
@@ -110,7 +114,6 @@ module Uc3DmpDynamo
110
114
 
111
115
  # Delete an item
112
116
  def delete_item(p_key:, s_key:, debug: false)
113
- json = Helper.parse_json(json: json)
114
117
  raise ClientError, MSG_INVALID_KEY unless json.is_a?(Hash) && !json['PK'].nil? && !json['SK'].nil?
115
118
 
116
119
  resp = @connection.delete_item(
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpDynamo
4
- VERSION = '0.0.10'
4
+ VERSION = '0.0.12'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uc3-dmp-dynamo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Riley
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-07 00:00:00.000000000 Z
11
+ date: 2023-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json