class RdsConcerto::CLI

Public Instance Methods

create() click to toggle source
# File lib/rds_concerto/cli.rb, line 26
def create
  concerto = RdsConcerto::Aurora.new(config_path: options[:config])
  concerto.clone!(klass: options[:type], dry_run: options[:pretend])
end
destroy(name=nil) click to toggle source
# File lib/rds_concerto/cli.rb, line 34
def destroy(name=nil)
  concerto = RdsConcerto::Aurora.new(config_path: options[:config])
  concerto.destroy!(name: name || options[:name], dry_run: options[:pretend])
end
list(stdout=true) click to toggle source
# File lib/rds_concerto/cli.rb, line 10
def list(stdout=true)
  out = ''
  out += show_replica
  out << "\n"
  out += show_clones
  out << "\n"
  if stdout
    puts out
  else
    out
  end
end
start(name=nil) click to toggle source
# File lib/rds_concerto/cli.rb, line 47
def start(name=nil)
  concerto = RdsConcerto::Aurora.new(config_path: options[:config])
  concerto.start_from_stopping(name || options[:name], dry_run: options[:pretend])
end
stop(name=nil) click to toggle source
# File lib/rds_concerto/cli.rb, line 53
def stop(name=nil)
  concerto = RdsConcerto::Aurora.new(config_path: options[:config])
  concerto.stop_from_available(name || options[:name], dry_run: options[:pretend])
end
url(name=nil) click to toggle source
# File lib/rds_concerto/cli.rb, line 40
def url(name=nil)
  concerto = RdsConcerto::Aurora.new(config_path: options[:config])
  puts concerto.url(name)
end

Private Instance Methods

show_clones() click to toggle source
# File lib/rds_concerto/cli.rb, line 80
  def show_clones
    concerto = RdsConcerto::Aurora.new(config_path: options[:config])
    out = "-clone db instances-"
    row = <<~EOH
      -------
      name: %{name}
      size: %{size}
      engine: %{engine}
      version: %{version}
      endpoint: %{endpoint}
      status: %{status}
      created_at: %{created_at}
      tags: %{tag}
    EOH
    concerto.cloned_instances.each do |hash|
      out << row % hash
    end
    out
  end
show_replica() click to toggle source
# File lib/rds_concerto/cli.rb, line 60
  def show_replica
    concerto = RdsConcerto::Aurora.new(config_path: options[:config])
    out = "-source db instance-"
    row = <<~EOH
      -------
      name: %{name}
      size: %{size}
      engine: %{engine}
      version: %{version}
      endpoint: %{endpoint}
      status: %{status}
      created_at: %{created_at}
    EOH

    if concerto.source_db_instance
      out << row % concerto.source_db_instance
    end
    out
  end