Class: Visor::Image::Auth
- Inherits:
-
Object
- Object
- Visor::Image::Auth
- Includes:
- Common::Exception
- Defined in:
- lib/image/auth.rb
Overview
The API for the VISOR Auth System (VAS) server. This class supports all user’s manipulation operations.
After Instantiate a VAS API client object its possible to directly interact with the VAS server and its database backend.
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#delete_user(access_key) ⇒ Hash
Delete an user and returns its information.
-
#get_user(access_key) ⇒ Hash
Get information about a specific user.
-
#get_users(query = {}) ⇒ Array
Get information about all registered users.
-
#initialize(opts = {}) ⇒ Auth
constructor
A new instance of Auth.
-
#post_user(info) ⇒ Hash
Register a new user account on VAS and return its data.
-
#put_user(access_key, info) ⇒ Hash
Update an existing user information and return it.
Constructor Details
#initialize(opts = {}) ⇒ Auth
Returns a new instance of Auth.
19 20 21 22 |
# File 'lib/image/auth.rb', line 19 def initialize(opts = {}) @host = opts[:host] @port = opts[:port] end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
17 18 19 |
# File 'lib/image/auth.rb', line 17 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
17 18 19 |
# File 'lib/image/auth.rb', line 17 def port @port end |
Instance Method Details
#delete_user(access_key) ⇒ Hash
Delete an user and returns its information.
94 95 96 97 |
# File 'lib/image/auth.rb', line 94 def delete_user(access_key) http = request.delete path: "/users/#{access_key}", access_key: delete_headers return_response(http) end |
#get_user(access_key) ⇒ Hash
Get information about a specific user.
49 50 51 52 |
# File 'lib/image/auth.rb', line 49 def get_user(access_key) http = request.get path: "/users/#{access_key}", head: get_headers return_response(http) end |
#get_users(query = {}) ⇒ Array
Get information about all registered users.
Options for filtering the returned results can be passed in.
36 37 38 39 |
# File 'lib/image/auth.rb', line 36 def get_users(query = {}) http = request.get path: '/users', query: query, head: get_headers return_response(http) end |
#post_user(info) ⇒ Hash
Register a new user account on VAS and return its data.
64 65 66 67 68 |
# File 'lib/image/auth.rb', line 64 def post_user(info) body = prepare_body(info) http = request.post path: '/users', body: body, head: post_headers return_response(http) end |
#put_user(access_key, info) ⇒ Hash
Update an existing user information and return it.
80 81 82 83 84 |
# File 'lib/image/auth.rb', line 80 def put_user(access_key, info) body = prepare_body(info) http = request.put path: "/users/#{access_key}", body: body, head: put_headers return_response(http) end |