Class: RightScaleCLI::Dashboard

Inherits:
Thor
  • Object
show all
Defined in:
lib/rightscale_cli/dashboard.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Dashboard

Returns a new instance of Dashboard.



27
28
29
30
31
# File 'lib/rightscale_cli/dashboard.rb', line 27

def initialize(*args)
  super
  @client = RightScaleCLI::Client.new(options)
  @logger = RightScaleCLI::Logger.new()
end

Class Method Details



73
74
75
# File 'lib/rightscale_cli/dashboard.rb', line 73

def self.banner(task, namespace = true, subcommand = false)
  "#{basename} #{task.formatted_usage(self, true, subcommand)}"
end

Instance Method Details

#ajax(href) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/rightscale_cli/dashboard.rb', line 60

def ajax(href)
  uri = URI.parse("#{@client.client.api_url}#{href}")
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  request = Net::HTTP::Get.new(uri.request_uri)
  request.add_field("Cookie", @client.client.last_request[:request].headers[:cookie])
  request.add_field("X-Requested-With", "XMLHttpRequest")

  response = http.request(request)
  puts response.body
end

#overviewObject



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/rightscale_cli/dashboard.rb', line 34

def overview()
  uri = URI.parse("#{@client.client.api_url}/acct/#{@client.client.}/dashboard;overview")
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  request = Net::HTTP::Get.new(uri.request_uri)
  request.add_field("Cookie", @client.client.last_request[:request].headers[:cookie])

  response = http.request(request)
  puts response.body
end

#scrape(href) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/rightscale_cli/dashboard.rb', line 47

def scrape(href)
  uri = URI.parse("#{@client.client.api_url}#{href}")
  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  request = Net::HTTP::Get.new(uri.request_uri)
  request.add_field("Cookie", @client.client.last_request[:request].headers[:cookie])

  response = http.request(request)
  puts response.body
end