uc3-dmp-dynamo 0.0.8 → 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: ee2c663d3ea38fa977b1da431a056b6978efb1ec45c6c2449ff549a961bb08e3
4
- data.tar.gz: b6b94f7caea0f1967a215b4dd8284fefa45ea6c906d3c0cb597247d217aeae53
3
+ metadata.gz: aa0cf659b6f3edcd00daa7ab6d65317f4cd985f9142437d62811716843c31b4f
4
+ data.tar.gz: 7decab5a151bded9ad6de31591cbc225754384a699241f1ebc314c026c484b72
5
5
  SHA512:
6
- metadata.gz: 7e0c5b2af7500be27fc66ea6a15f3296d3c116ac025a58e668be7d7687248c4fcf174f11705ac3faa6d338594f48f563e7cfef93cf1feb8851bbb34f279c4d7a
7
- data.tar.gz: e8fa984ec6a3e325b517634dd7b771a31a03b7a11df3394f6fa47effecbaf8fc0fc23783f67b391934c7c9d969450ebe84a181f70d7f9eefff998d682964a767
6
+ metadata.gz: caca36dbadabe3ab58928d443c12d180149b9fd00a6fe711d54d4d2260be72f2adb87770231973bde79d63c766bf457147f9224a38153f385767145856419ee6
7
+ data.tar.gz: b4a3c40de41da8bfcad5342f64ac6cbc3b5794864543a0adcac1eaba0f78aca749277d7201bc2c2e20a15ddf90f7e89c8c50fd6f3f3d38493f3a025cae469aee
@@ -75,10 +75,6 @@ module Uc3DmpDynamo
75
75
  puts "#{SOURCE} => query - args: #{hash.inspect}"
76
76
  puts resp.items.inspect
77
77
  end
78
-
79
- puts "QUERY RESULT:"
80
- puts resp.items.first.inspect
81
-
82
78
  return [] unless resp.items.any?
83
79
  return resp.items if resp.items.first.is_a?(Hash)
84
80
 
@@ -87,5 +83,52 @@ puts resp.items.first.inspect
87
83
  raise ClientError, format(MSG_DYNAMO_ERROR, msg: e.message, trace: e.backtrace)
88
84
  end
89
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
90
133
  end
91
134
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Uc3DmpDynamo
4
- VERSION = '0.0.8'
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.8
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