Module: VagrantPlugins::OneAndOne::Command::Utils

Included in:
ListAppliances, ListDatacenters, ListFirewalls, ListIPs, ListLoadBalancers, ListMonitorPolicies, ListServers, ListSizes
Defined in:
lib/vagrant-oneandone/command/utils.rb

Instance Method Summary collapse

Instance Method Details

#display_table(env, headers, rows) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/vagrant-oneandone/command/utils.rb', line 20

def display_table(env, headers, rows)
  table = Terminal::Table.new headings: headers, rows: rows
  if env.respond_to?('ui')
    env.ui.info(table.to_s)
  else
    env[:ui].info(table.to_s)
  end
end

#fog_oneandone(token) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/vagrant-oneandone/command/utils.rb', line 8

def fog_oneandone(token)
  api_key = token ? token : ENV['ONEANDONE_API_KEY']

  raise Errors::NoApiKeyError unless api_key

  params = {
    oneandone_api_key: api_key
  }

  Fog::Compute::OneAndOne.new params
end