uc3-dmp-dynamo 0.0.18 → 0.0.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/uc3-dmp-dynamo/client.rb +37 -6
- data/lib/uc3-dmp-dynamo/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64f78e794c1060f22ab60bc6077221b7fd68ce9ed0467adbae750d0c2b7cf449
|
4
|
+
data.tar.gz: 66504b6a9b9069af77df7d4856903c1e9127b050575ed69db82d55df1e77a9a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0dc946f3f27b30540b5c4b5bd910565d13f64a9d75955897facf5dda44e9498719dfe0a2ac47f6ed8b5d24e74d3af32ab5522617701ae4e093328236dbe28a55
|
7
|
+
data.tar.gz: e0cb493bf071ad67f0a018d5fb9705e0b61c81882559686cc43e72a8cbe46560234a6dd5e95f8bb8a17b178d4c5b214a9eae4a5ad48fc592da1a38ee6f164b44
|
@@ -24,7 +24,7 @@ module Uc3DmpDynamo
|
|
24
24
|
def pk_exists?(key:, logger: nil)
|
25
25
|
return nil unless key.is_a?(Hash) && !key['PK'].nil?
|
26
26
|
|
27
|
-
resp = client.get_item(table_name: @table, key
|
27
|
+
resp = client.get_item(table_name: @table, key:, projection_expression: 'PK', logger:)
|
28
28
|
resp.item.is_a?(Hash) && resp.item['PK'] == key['PK']
|
29
29
|
end
|
30
30
|
|
@@ -35,7 +35,7 @@ module Uc3DmpDynamo
|
|
35
35
|
|
36
36
|
resp = @connection.get_item(
|
37
37
|
{ table_name: @table,
|
38
|
-
key
|
38
|
+
key:,
|
39
39
|
consistent_read: false,
|
40
40
|
return_consumed_capacity: logger&.level == 'debug' ? 'TOTAL' : 'NONE' }
|
41
41
|
)
|
@@ -53,7 +53,7 @@ module Uc3DmpDynamo
|
|
53
53
|
# projection_expression: 'title, dmp_id, modified'
|
54
54
|
#
|
55
55
|
# See the DynamoDB docs for examples of key_conditions and projection_expressions
|
56
|
-
# rubocop:disable Metrics/AbcSize
|
56
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
57
57
|
def query(args:, logger: nil)
|
58
58
|
raise ClientError, MSG_INVALID_KEY unless args.is_a?(Hash) && args.fetch(:key_conditions, {}).any?
|
59
59
|
|
@@ -64,7 +64,8 @@ module Uc3DmpDynamo
|
|
64
64
|
return_consumed_capacity: logger&.level == 'debug' ? 'TOTAL' : 'NONE'
|
65
65
|
}
|
66
66
|
# Look for and add any other filtering or projection args
|
67
|
-
%i[index_name filter_expression expression_attribute_values projection_expression
|
67
|
+
%i[index_name filter_expression expression_attribute_values projection_expression
|
68
|
+
scan_index_forward].each do |key|
|
68
69
|
next if args[key.to_sym].nil?
|
69
70
|
|
70
71
|
hash[key.to_sym] = args[key.to_sym]
|
@@ -79,14 +80,43 @@ module Uc3DmpDynamo
|
|
79
80
|
rescue Aws::Errors::ServiceError => e
|
80
81
|
raise ClientError, format(MSG_DYNAMO_ERROR, msg: e.message, trace: e.backtrace)
|
81
82
|
end
|
82
|
-
# rubocop:enable Metrics/AbcSize
|
83
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
84
|
+
|
85
|
+
# rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
86
|
+
def scan(args:, logger: nil)
|
87
|
+
raise ClientError, MSG_INVALID_KEY unless args.is_a?(Hash) && args.fetch(:key_conditions, {}).any?
|
88
|
+
|
89
|
+
hash = {
|
90
|
+
table_name: @table,
|
91
|
+
consistent_read: false,
|
92
|
+
return_consumed_capacity: logger&.level == 'debug' ? 'TOTAL' : 'NONE'
|
93
|
+
}
|
94
|
+
# Look for and add any other filtering or projection args
|
95
|
+
%i[filter_expression expression_attribute_values projection_expression expression_attribute_names].each do |key|
|
96
|
+
next if args[key.to_sym].nil?
|
97
|
+
|
98
|
+
hash[key.to_sym] = args[key.to_sym]
|
99
|
+
end
|
100
|
+
|
101
|
+
logger.debug(message: "#{SOURCE} queried for: #{hash}") if logger.respond_to?(:debug)
|
102
|
+
resp = @connection.scan(hash)
|
103
|
+
return [] unless resp.items.any?
|
104
|
+
return resp.items if resp.items.first.is_a?(Hash)
|
105
|
+
|
106
|
+
resp.items.first.respond_to?(:item) ? resp.items.map(&:item) : resp.items
|
107
|
+
rescue Aws::Errors::ServiceError => e
|
108
|
+
raise ClientError, format(MSG_DYNAMO_ERROR, msg: e.message, trace: e.backtrace)
|
109
|
+
end
|
110
|
+
# rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
83
111
|
|
84
112
|
# Create/Update an item
|
113
|
+
# rubocop:disable Metrics/AbcSize
|
85
114
|
def put_item(json:, logger: nil)
|
86
115
|
raise ClientError, MSG_INVALID_KEY unless json.is_a?(Hash) && !json['PK'].nil? && !json['SK'].nil?
|
87
116
|
|
88
117
|
resp = @connection.put_item(
|
89
|
-
{
|
118
|
+
{
|
119
|
+
table_name: @table,
|
90
120
|
item: json,
|
91
121
|
return_consumed_capacity: logger&.level == 'debug' ? 'TOTAL' : 'NONE'
|
92
122
|
}
|
@@ -97,6 +127,7 @@ module Uc3DmpDynamo
|
|
97
127
|
rescue Aws::Errors::ServiceError => e
|
98
128
|
raise ClientError, format(MSG_DYNAMO_ERROR, msg: e.message, trace: e.backtrace)
|
99
129
|
end
|
130
|
+
# rubocop:enable Metrics/AbcSize
|
100
131
|
|
101
132
|
# Delete an item
|
102
133
|
def delete_item(p_key:, s_key:, logger: nil)
|
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.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Riley
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -124,7 +124,7 @@ licenses:
|
|
124
124
|
- MIT
|
125
125
|
metadata:
|
126
126
|
rubygems_mfa_required: 'false'
|
127
|
-
post_install_message:
|
127
|
+
post_install_message:
|
128
128
|
rdoc_options: []
|
129
129
|
require_paths:
|
130
130
|
- lib
|
@@ -132,15 +132,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
132
132
|
requirements:
|
133
133
|
- - ">="
|
134
134
|
- !ruby/object:Gem::Version
|
135
|
-
version: '2
|
135
|
+
version: '3.2'
|
136
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
137
|
requirements:
|
138
138
|
- - ">="
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: '0'
|
141
141
|
requirements: []
|
142
|
-
rubygems_version: 3.
|
143
|
-
signing_key:
|
142
|
+
rubygems_version: 3.4.10
|
143
|
+
signing_key:
|
144
144
|
specification_version: 4
|
145
145
|
summary: DMPTool gem that provides support for Dynamo DB
|
146
146
|
test_files: []
|