Class: RightScale::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/rightscale-api/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(account, email, password) ⇒ Client

Returns a new instance of Client.



5
6
7
8
# File 'lib/rightscale-api/client.rb', line 5

def initialize(, email, password)
  @account, @email, @password = , email, password
  self.class.base_uri "https://my.rightscale.com/api/acct/#{@account}"
end

Instance Method Details

#deploymentsObject



29
30
31
# File 'lib/rightscale-api/client.rb', line 29

def deployments  
  @deployments ||= Deployments.new(self)
end

#get(path, options = {}) ⇒ Object



10
11
12
# File 'lib/rightscale-api/client.rb', line 10

def get(path, options={})
  request :get, path, options
end

#post(path, options = {}) ⇒ Object



14
15
16
# File 'lib/rightscale-api/client.rb', line 14

def post(path, options={})
  request :post, path, options
end

#request(method, path, options = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/rightscale-api/client.rb', line 18

def request(method, path, options={})
  options.merge!({
    :basic_auth => {:username => @email, :password => @password},
    :headers    => {'X-API-VERSION' => '1.0'}
  })

  response = self.class.send(method, "#{path}", options)
  # puts response.inspect
  return response
end

#right_scriptsObject



41
42
43
# File 'lib/rightscale-api/client.rb', line 41

def right_scripts
  @right_scripts ||= RightScripts.new(self, :resource => 'right_scripts')
end

#serversObject



33
34
35
# File 'lib/rightscale-api/client.rb', line 33

def servers
  @servers ||= Servers.new(self)
end

#statusesObject



37
38
39
# File 'lib/rightscale-api/client.rb', line 37

def statuses
  @statuses ||= Statuses.new(self)
end