Class: Mamba::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/mamba/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server, user = nil, password = nil, accounting = false, timeout = 30) ⇒ Client



7
8
9
10
11
12
13
14
15
16
# File 'lib/mamba/client.rb', line 7

def initialize(server,user=nil,password=nil,accounting=false,timeout=30)
  @client = XMLRPC::Client.new2("https://#{server}/rpc/api",nil,timeout)

  if accounting
    @accounting = true
    @calls = Hash.new(0)
  end

  (user,password) if ! (user.nil? or password.nil?)
end

Instance Attribute Details

#accountingObject (readonly)

Returns the value of attribute accounting.



5
6
7
# File 'lib/mamba/client.rb', line 5

def accounting
  @accounting
end

#callsObject (readonly)

Returns the value of attribute calls.



5
6
7
# File 'lib/mamba/client.rb', line 5

def calls
  @calls
end

Instance Method Details

#call(method, *params) ⇒ Object



26
27
28
# File 'lib/mamba/client.rb', line 26

def call(method,*params)
  _call(method,@key,*params)
end

#login(user, password) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/mamba/client.rb', line 18

def (user,password)
  @key = @client.call('auth.login',user,password)
  ('auth.login')

  # return true if we were successful
  true
end

#logoutObject



30
31
32
# File 'lib/mamba/client.rb', line 30

def logout
  _call('auth.logout',@key)
end