uc3-dmp-dynamo 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b054d85d718d47e62a50c5f227d5442a4467d235da417491d05e2100c4750eb
4
- data.tar.gz: 90e7d99d66f4bf219089c508b42cb7813d13f2d16cc8fd0fdb7662519234701f
3
+ metadata.gz: aa0cf659b6f3edcd00daa7ab6d65317f4cd985f9142437d62811716843c31b4f
4
+ data.tar.gz: 7decab5a151bded9ad6de31591cbc225754384a699241f1ebc314c026c484b72
5
5
  SHA512:
6
- metadata.gz: 7f1aaa39b77ec58b14b7c0b395bf19a11719afb08a12e42d7cf1358143206aad955cf78694033511d6ea810e0b738179415e1cd3f6c5b52dd59e0f964904c5aa
7
- data.tar.gz: f16bba459f0226371303fb86132836c9576ad9af0b6224ecd18c19148b20cc301c9313f5a805d4674abc44f9de74e6f8dd1f8bb4f9dfd7340d4bb04304697cbe
6
+ metadata.gz: caca36dbadabe3ab58928d443c12d180149b9fd00a6fe711d54d4d2260be72f2adb87770231973bde79d63c766bf457147f9224a38153f385767145856419ee6
7
+ data.tar.gz: b4a3c40de41da8bfcad5342f64ac6cbc3b5794864543a0adcac1eaba0f78aca749277d7201bc2c2e20a15ddf90f7e89c8c50fd6f3f3d38493f3a025cae469aee
@@ -83,5 +83,52 @@ module Uc3DmpDynamo
83
83
  raise ClientError, format(MSG_DYNAMO_ERROR, msg: e.message, trace: e.backtrace)
84
84
  end
85
85
  # rubocop:enable Metrics/AbcSize
86
+
87
+ # Create/Update an item
88
+ def put_item(json:, debug: false)
89
+ json = Helper.parse_json(json: json)
90
+ raise ClientError, MSG_INVALID_KEY unless json.is_a?(Hash) && !json['PK'].nil? && !json['SK'].nil?
91
+
92
+ resp = @connection.put_item(
93
+ { table_name: @table,
94
+ item: json,
95
+ consistent_read: false,
96
+ return_consumed_capacity: debug ? 'TOTAL' : 'NONE'
97
+ }
98
+ )
99
+
100
+ # If debug is enabled then write the response to the LogWriter
101
+ if debug
102
+ puts "#{SOURCE} => put_item -"
103
+ puts json
104
+ puts resp.inspect
105
+ end
106
+ resp
107
+ rescue Aws::Errors::ServiceError => e
108
+ raise ClientError, format(MSG_DYNAMO_ERROR, msg: e.message, trace: e.backtrace)
109
+ end
110
+
111
+ # Delete an item
112
+ def delete_item(p_key:, s_key:, debug: false)
113
+ json = Helper.parse_json(json: json)
114
+ raise ClientError, MSG_INVALID_KEY unless json.is_a?(Hash) && !json['PK'].nil? && !json['SK'].nil?
115
+
116
+ resp = @connection.delete_item(
117
+ {
118
+ table_name: @table,
119
+ key: {
120
+ PK: p_key,
121
+ SK: s_key
122
+ }
123
+ }
124
+ )
125
+ # If debug is enabled then write the response to the LogWriter
126
+ if debug
127
+ puts "#{SOURCE} => delete_item -"
128
+ puts json
129
+ puts resp.inspect
130
+ end
131
+ resp
132
+ end
86
133
  end
87
134
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpDynamo
4
- VERSION = '0.0.9'
4
+ VERSION = '0.0.10'
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.9
4
+ version: 0.0.10
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-06 00:00:00.000000000 Z
11
+ date: 2023-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json