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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf0b1bae3beebc279a5eaabd92a509ed1b814c2127d69b1b7fa97773406b09dd
4
- data.tar.gz: 99cf915195d3465fafca5be50bd99657b750cfb8feda6a83dc64b663a8710f19
3
+ metadata.gz: ff41269be712ae8e16cab262ee39da16da6eba5adc8efaa2d6316a357133bc91
4
+ data.tar.gz: 94f3af39b5c2a3373a7adb4fae76967302170a3a74b01068184671896dbb9f0b
5
5
  SHA512:
6
- metadata.gz: 693f43bdd1424c8ad114830cef71b3871db841f7bf3ae5a1d143d1fe70ff82d35105f9ada9482e4607ac85cb53fb960c8ffe81b61ef37f585f35d1fd9c22af93
7
- data.tar.gz: 63957579490f76bb7444b005a5b75686662cd26c27b432c671be1f20eb5726f78c53accaf7dbf302b8f486f96ee99ccdac4ff5ca8767716d79767303db396f10
6
+ metadata.gz: a4040a8df21120f3b5e41baf4a3d5b50afe8f95983fc35fcad3f468afc4142ecebff8629e6478d53dc9c7fd420b222fd5531eeb664b3ca7b1e931cd31adbf382
7
+ data.tar.gz: 1ab22e6e4abc793cfdfc25dcee422530e13209f6b9de8dbca5118d35c09842876f26da1b05eddd75cf90f995924d668f34479e74a2ad93865ec62e15c36ee5d0
@@ -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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dynamocli (0.1.4)
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.193.0)
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.61.1)
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)
@@ -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[:global_secondary_indexes].each do |gsis|
51
- gsis.delete(:index_status)
52
- gsis.delete(:index_size_bytes)
53
- gsis.delete(:item_count)
54
- gsis.delete(:index_arn)
55
- gsis[:provisioned_throughput].delete(:number_of_decreases_today)
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
@@ -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
- csv_options = { encoding: "UTF-8", headers: true, header_converters: :symbol, converters: :all }
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
- def write_records_to_dynamodb_table(records)
42
- dynamodb = Aws::DynamoDB::Client.new
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
 
@@ -1,3 +1,3 @@
1
1
  module Dynamocli
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
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
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-07-29 00:00:00.000000000 Z
11
+ date: 2019-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor