Class: Chef::Knife::OneandoneMpList

Inherits:
Chef::Knife show all
Includes:
OneandoneBase
Defined in:
lib/chef/knife/oneandone_mp_list.rb

Instance Method Summary collapse

Methods included from OneandoneBase

#formated_output, included, #init_client

Instance Method Details

#runObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/chef/knife/oneandone_mp_list.rb', line 10

def run
  $stdout.sync = true

  init_client

  response = OneAndOne::MonitoringPolicy.new.list
  formated_output(response, true)

  mp_list = [
    ui.color('ID', :bold),
    ui.color('Name', :bold),
    ui.color('Email', :bold),
    ui.color('State', :bold),
    ui.color('Agent', :bold)
  ]
  response.each do |mp|
    mp_list << mp['id']
    mp_list << mp['name']
    mp_list << mp['email']
    mp_list << mp['state']
    mp_list << mp['agent'].to_s
  end

  puts ui.list(mp_list, :uneven_columns_across, 5)
end