uc3-dmp-dynamo 0.0.9 → 0.0.10
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 +4 -4
- data/lib/uc3-dmp-dynamo/client.rb +47 -0
- data/lib/uc3-dmp-dynamo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa0cf659b6f3edcd00daa7ab6d65317f4cd985f9142437d62811716843c31b4f
|
4
|
+
data.tar.gz: 7decab5a151bded9ad6de31591cbc225754384a699241f1ebc314c026c484b72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
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-
|
11
|
+
date: 2023-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|