dynamocli 0.1.4 → 0.1.5
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/CHANGELOG.md +7 -0
- data/Gemfile.lock +3 -3
- data/lib/dynamocli/erase.rb +12 -6
- data/lib/dynamocli/import.rb +18 -4
- data/lib/dynamocli/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: ff41269be712ae8e16cab262ee39da16da6eba5adc8efaa2d6316a357133bc91
|
4
|
+
data.tar.gz: 94f3af39b5c2a3373a7adb4fae76967302170a3a74b01068184671896dbb9f0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4040a8df21120f3b5e41baf4a3d5b50afe8f95983fc35fcad3f468afc4142ecebff8629e6478d53dc9c7fd420b222fd5531eeb664b3ca7b1e931cd31adbf382
|
7
|
+
data.tar.gz: 1ab22e6e4abc793cfdfc25dcee422530e13209f6b9de8dbca5118d35c09842876f26da1b05eddd75cf90f995924d668f34479e74a2ad93865ec62e15c36ee5d0
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
+
## [0.1.5] - 2019-08-08
|
6
|
+
### Fixed
|
7
|
+
- Fix erase table without GSIs.
|
8
|
+
- Fix erase table with LCIs.
|
9
|
+
- Fix import data to a table with attributes types other than String.
|
10
|
+
|
5
11
|
## [0.1.4] - 2019-07-29
|
6
12
|
### Fixed
|
7
13
|
- Fix erase table with indexes.
|
@@ -23,6 +29,7 @@ All notable changes to this project will be documented in this file.
|
|
23
29
|
### Added
|
24
30
|
- Command to import data from a CSV file to a DynamoDB table.
|
25
31
|
|
32
|
+
[0.1.5]: https://github.com/matheussilvasantos/dynamocli/compare/v0.1.4...v0.1.5
|
26
33
|
[0.1.4]: https://github.com/matheussilvasantos/dynamocli/compare/v0.1.3...v0.1.4
|
27
34
|
[0.1.3]: https://github.com/matheussilvasantos/dynamocli/compare/v0.1.2...v0.1.3
|
28
35
|
[0.1.2]: https://github.com/matheussilvasantos/dynamocli/commit/6fd76a06819ff32464eeeae1f097bccd33f21387
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dynamocli (0.1.
|
4
|
+
dynamocli (0.1.5)
|
5
5
|
aws-sdk-cloudformation (~> 1.23)
|
6
6
|
aws-sdk-dynamodb (~> 1.28)
|
7
7
|
thor (~> 0.20)
|
@@ -11,11 +11,11 @@ GEM
|
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
13
|
aws-eventstream (1.0.3)
|
14
|
-
aws-partitions (1.
|
14
|
+
aws-partitions (1.197.0)
|
15
15
|
aws-sdk-cloudformation (1.25.0)
|
16
16
|
aws-sdk-core (~> 3, >= 3.61.1)
|
17
17
|
aws-sigv4 (~> 1.1)
|
18
|
-
aws-sdk-core (3.
|
18
|
+
aws-sdk-core (3.62.0)
|
19
19
|
aws-eventstream (~> 1.0, >= 1.0.2)
|
20
20
|
aws-partitions (~> 1.0)
|
21
21
|
aws-sigv4 (~> 1.1)
|
data/lib/dynamocli/erase.rb
CHANGED
@@ -47,12 +47,18 @@ class Dynamocli::Erase
|
|
47
47
|
schema.delete(:table_arn)
|
48
48
|
schema.delete(:table_id)
|
49
49
|
schema[:provisioned_throughput].delete(:number_of_decreases_today)
|
50
|
-
schema[:
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
50
|
+
schema[:local_secondary_indexes]&.each do |lsi|
|
51
|
+
lsi.delete(:index_status)
|
52
|
+
lsi.delete(:index_size_bytes)
|
53
|
+
lsi.delete(:item_count)
|
54
|
+
lsi.delete(:index_arn)
|
55
|
+
end
|
56
|
+
schema[:global_secondary_indexes]&.each do |gsi|
|
57
|
+
gsi.delete(:index_status)
|
58
|
+
gsi.delete(:index_size_bytes)
|
59
|
+
gsi.delete(:item_count)
|
60
|
+
gsi.delete(:index_arn)
|
61
|
+
gsi[:provisioned_throughput].delete(:number_of_decreases_today)
|
56
62
|
end
|
57
63
|
end
|
58
64
|
end
|
data/lib/dynamocli/import.rb
CHANGED
@@ -11,6 +11,7 @@ class Dynamocli::Import
|
|
11
11
|
def initialize(file:, table:)
|
12
12
|
@file = file
|
13
13
|
@table = table
|
14
|
+
@dynamodb = Aws::DynamoDB::Client.new
|
14
15
|
end
|
15
16
|
|
16
17
|
def start
|
@@ -33,16 +34,29 @@ class Dynamocli::Import
|
|
33
34
|
end
|
34
35
|
|
35
36
|
def records_from_csv(csv)
|
36
|
-
|
37
|
+
set_custom_converter_for_csv
|
38
|
+
csv_options = { encoding: "UTF-8", headers: true, converters: :attribute_definitions }
|
37
39
|
records_csv = CSV.read(csv, csv_options)
|
38
40
|
records_csv.map(&:to_hash)
|
39
41
|
end
|
40
42
|
|
41
|
-
|
42
|
-
|
43
|
+
ATTRIBUTE_TYPES_CONVERTERS = {
|
44
|
+
"S" => :to_s.to_proc,
|
45
|
+
"N" => :to_i.to_proc,
|
46
|
+
"B" => Proc.new(&StringIO.method(:new))
|
47
|
+
}
|
48
|
+
def set_custom_converter_for_csv
|
49
|
+
attribute_definitions = @dynamodb.describe_table(table_name: @table).table.attribute_definitions
|
50
|
+
CSV::Converters[:attribute_definitions] = lambda do |value, info|
|
51
|
+
attribute_definition = attribute_definitions.find { |it| it.attribute_name == info.header }
|
52
|
+
return value if attribute_definition.nil?
|
53
|
+
ATTRIBUTE_TYPES_CONVERTERS[attribute_definition.attribute_type].call(value)
|
54
|
+
end
|
55
|
+
end
|
43
56
|
|
57
|
+
def write_records_to_dynamodb_table(records)
|
44
58
|
slice_items_to_attend_batch_write_limit(records).each do |items|
|
45
|
-
dynamodb.batch_write_item(request_items: format_request_items(items))
|
59
|
+
@dynamodb.batch_write_item(request_items: format_request_items(items))
|
46
60
|
end
|
47
61
|
end
|
48
62
|
|
data/lib/dynamocli/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamocli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matheus Silva Santos de Oliveira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|