Class: Dyna::Client

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

Instance Method Summary collapse

Methods included from Filterable

#should_skip

Methods included from Logger::ClientHelper

#log

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/dyna/client.rb', line 6

def initialize(options = {})
  @options = OpenStruct.new(options)
  @options_hash = options
  if @options.use_local
    @options.ddb = Aws::DynamoDB::Client.new(
      endpoint: @options.dynamo_endpoint || 'http://127.0.0.1:8000',
      region: @options.region || 'ap-northeast-1',
      access_key_id: @options.access_key_id || 'dummy',
      secret_access_key: @options.secret_access_key || 'dummy',
    )
  else
    @options.ddb = Aws::DynamoDB::Client.new
    @options.aas = Aws::ApplicationAutoScaling::Client.new
    Exporter.aas(@options.aas)
  end
end

Instance Method Details

#apply(file) ⇒ Object



23
24
25
# File 'lib/dyna/client.rb', line 23

def apply(file)
  walk(file)
end

#export(options = {}) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/dyna/client.rb', line 27

def export(options = {})
  exported = Exporter.export(@options.ddb, @options)

  converter = proc do |src|
    DSL.convert(@options.ddb.config.region, src)
  end

  if block_given?
    yield(exported, converter)
  else
    converter.call(exported)
  end
end