Class: Visor::Auth::Client
- Inherits:
-
Object
- Object
- Visor::Auth::Client
- 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
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#ssl ⇒ Object
readonly
Returns the value of attribute ssl.
Instance Method Summary collapse
- #delete_user(access_key) ⇒ Object
- #get_user(access_key) ⇒ Object
- #get_users(query = {}) ⇒ Object
-
#initialize(opts = {}) ⇒ Client
constructor
A new instance of Client.
- #post_user(info) ⇒ Object
- #put_user(access_key, info) ⇒ Object
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
#host ⇒ Object (readonly)
Returns the value of attribute host.
23 24 25 |
# File 'lib/auth/client.rb', line 23 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
23 24 25 |
# File 'lib/auth/client.rb', line 23 def port @port end |
#ssl ⇒ Object (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 |