Class: Visor::Auth::Client

Inherits:
Object
  • Object
show all
Includes:
Common::Exception
Defined in:
lib/auth/client.rb

Overview

The Client API for the VISoR Auth.

After Instantiate a Client object its possible to directly interact with the auth server and its database backend.

Constant Summary collapse

DEFAULT_HOST =
configs[:bind_host] || '0.0.0.0'
DEFAULT_PORT =
configs[:bind_port] || 4566

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Client

Returns a new instance of Client.



25
26
27
28
29
# File 'lib/auth/client.rb', line 25

def initialize(opts = {})
  @host       = opts[:host] || DEFAULT_HOST
  @port       = opts[:port] || DEFAULT_PORT
  @ssl        = opts[:ssl] || false
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



23
24
25
# File 'lib/auth/client.rb', line 23

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



23
24
25
# File 'lib/auth/client.rb', line 23

def port
  @port
end

#sslObject (readonly)

Returns the value of attribute ssl.



23
24
25
# File 'lib/auth/client.rb', line 23

def ssl
  @ssl
end

Instance Method Details

#delete_user(access_key) ⇒ Object



54
55
56
57
# File 'lib/auth/client.rb', line 54

def delete_user(access_key)
  request = Net::HTTP::Delete.new("/users/#{access_key}")
  do_request(request)
end

#get_user(access_key) ⇒ Object



37
38
39
40
# File 'lib/auth/client.rb', line 37

def get_user(access_key)
  request = Net::HTTP::Get.new("/users/#{access_key}")
  do_request(request)
end

#get_users(query = {}) ⇒ Object



31
32
33
34
35
# File 'lib/auth/client.rb', line 31

def get_users(query={})
  str     = build_query(query)
  request = Net::HTTP::Get.new("/users#{str}")
  do_request(request)
end

#post_user(info) ⇒ Object



42
43
44
45
46
# File 'lib/auth/client.rb', line 42

def post_user(info)
  request      = Net::HTTP::Post.new('/users')
  request.body = prepare_body(info)
  do_request(request)
end

#put_user(access_key, info) ⇒ Object



48
49
50
51
52
# File 'lib/auth/client.rb', line 48

def put_user(access_key, info)
  request      = Net::HTTP::Put.new("/users/#{access_key}")
  request.body = prepare_body(info)
  do_request(request)
end