Class: CloudstackClient::Cli

Inherits:
Thor
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/cloudstack_client/cli.rb

Instance Method Summary collapse

Instance Method Details

#consoleObject



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/cloudstack_client/cli.rb', line 77

def console
  cs_client = client(options)

  print "cloudstack_client version #{CloudstackClient::VERSION}"
  puts " (CloudStack API version #{cs_client.api.api_version})"
  puts '  try: list_virtual_machines state: "Started"'

  ARGV.clear
  env = options[:env] ? options[:env] : load_configuration.last
  Ripl.config[:prompt] = "#{env} >> "
  Ripl.start binding: cs_client.instance_eval('binding')
end

#list_apisObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/cloudstack_client/cli.rb', line 51

def list_apis
  apis = client(no_api_methods: true).send_request('command' => 'listApis')
  apis.each do |command|
    command.delete("response") if options[:remove_response]
    if options[:remove_description]
      command.delete("description")
      command["params"].each {|param| param.delete("description")}
    end
  end

  print case options[:format]
  when "json"
    options[:pretty_print] ? JSON.pretty_generate(apis) : apis.to_json
  when "yaml"
    apis.to_yaml
  else
    apis.to_msgpack
  end
end

#versionObject



37
38
39
# File 'lib/cloudstack_client/cli.rb', line 37

def version
  say "cloudstack_client version #{CloudstackClient::VERSION}"
end