Class: Dyna::Exporter

Inherits:
Object
  • Object
show all
Includes:
Filterable, Logger::ClientHelper
Defined in:
lib/dyna/exporter.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Filterable

#should_skip

Methods included from Logger::ClientHelper

#log

Constructor Details

#initialize(ddb, options = {}) ⇒ Exporter

Returns a new instance of Exporter.



12
13
14
15
# File 'lib/dyna/exporter.rb', line 12

def initialize(ddb, options = {})
  @ddb = ddb
  @options = options
end

Class Method Details

.aas(aas) ⇒ Object



48
49
50
# File 'lib/dyna/exporter.rb', line 48

def self.aas(aas)
  @aas = aas
end

.export(ddb, options = {}) ⇒ Object



7
8
9
# File 'lib/dyna/exporter.rb', line 7

def export(ddb, options = {})
  self.new(ddb, options).export
end

.table_definition(describe_table) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/dyna/exporter.rb', line 30

def self.table_definition(describe_table)
  {
    table_name:               describe_table.table_name,
    key_schema:               key_schema(describe_table),
    attribute_definitions:    attribute_definitions(describe_table),
    billing_mode:             describe_table.billing_mode_summary&.billing_mode,
    provisioned_throughput:   {
      read_capacity_units:    describe_table.provisioned_throughput.read_capacity_units,
      write_capacity_units:   describe_table.provisioned_throughput.write_capacity_units,
    },
    local_secondary_indexes:  local_secondary_indexes(describe_table),
    global_secondary_indexes: global_secondary_indexes(describe_table),
    stream_specification:     stream_specification(describe_table),
    scalable_targets:         scalable_targets(describe_table),
    scaling_policies:         scaling_policies(describe_table),
  }
end

Instance Method Details

#exportObject



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/dyna/exporter.rb', line 17

def export
  result = {}
  @ddb.list_tables.map do |tables|
    tables.table_names
      .reject { |name| should_skip(name) }
      .sort
      .each do |table_name|
      result[table_name] = self.class.export_table(@ddb, table_name)
    end
  end
  result
end