Class: RightScaleSelfService::Cli::Execution

Inherits:
Base
  • Object
show all
Defined in:
lib/rightscale_selfservice/cli/execution.rb

Instance Method Summary collapse

Instance Method Details

#listObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rightscale_selfservice/cli/execution.rb', line 28

def list
  client = get_api_client()

  begin
    response = client.manager.execution.index
    executions = JSON.parse(response.body)
    if @options["property"]
      executions.each do |execution|
        execution.delete_if{|k,v| !(@options["property"].include?(k))}
      end
    end
    puts JSON.pretty_generate(executions)
  rescue RestClient::ExceptionWithResponse => e
    shell = Thor::Shell::Color.new
    message = "Failed to list executions\n\n#{RightScaleSelfService::Api::Client.format_error(e)}"
    logger.error(shell.set_color message, :red)
  end
end

#show(id_or_href) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/rightscale_selfservice/cli/execution.rb', line 50

def show(id_or_href)
  client = get_api_client()
  id = RightScaleSelfService::Api::Client.get_resource_id_from_href(id_or_href)

  begin
    response = client.manager.execution.show(:id => id, :view => @options["view"])
    execution = JSON.parse(response.body)
    if @options["property"] && @options["view"] != "source"
      execution.delete_if{|k,v| !(@options["property"].include?(k))}
    end
    puts JSON.pretty_generate(execution)
  rescue RestClient::ExceptionWithResponse => e
    shell = Thor::Shell::Color.new
    message = "Failed to show execution id #{id}\n\n#{RightScaleSelfService::Api::Client.format_error(e)}"
    logger.error(shell.set_color message, :red)
  end
end