Class: Rhc::Rest::User
- Inherits:
-
Object
- Object
- Rhc::Rest::User
- Includes:
- Rhc::Rest
- Defined in:
- lib/rhc-rest/user.rb
Constant Summary
Constants included from Rhc::Rest
Instance Attribute Summary collapse
-
#login ⇒ Object
readonly
Returns the value of attribute login.
Instance Method Summary collapse
-
#add_key(name, content, type) ⇒ Object
Add Key for this user.
-
#find_key(name) ⇒ Object
Find Key by name.
-
#initialize(args) ⇒ User
constructor
A new instance of User.
-
#keys ⇒ Object
Get all Key for this user.
Methods included from Rhc::Rest
#logger, #parse_response, #process_error_response, #send
Constructor Details
#initialize(args) ⇒ User
Returns a new instance of User.
6 7 8 9 |
# File 'lib/rhc-rest/user.rb', line 6 def initialize(args) @login = args[:login] || args["login"] @links = args[:links] || args["links"] end |
Instance Attribute Details
#login ⇒ Object (readonly)
Returns the value of attribute login.
5 6 7 |
# File 'lib/rhc-rest/user.rb', line 5 def login @login end |
Instance Method Details
#add_key(name, content, type) ⇒ Object
Add Key for this user
12 13 14 15 16 17 18 |
# File 'lib/rhc-rest/user.rb', line 12 def add_key(name, content, type) url = @links['ADD_KEY']['href'] method = @links['ADD_KEY']['method'] payload = {:name => name, :type => type, :content => content} request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers, :payload => payload) return send(request) end |
#find_key(name) ⇒ Object
Find Key by name
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/rhc-rest/user.rb', line 29 def find_key(name) filtered = Array.new keys.each do |key| #TODO do a regex caomparison if key.name == name filtered.push(key) end end return filtered end |
#keys ⇒ Object
Get all Key for this user
21 22 23 24 25 26 |
# File 'lib/rhc-rest/user.rb', line 21 def keys url = @links['LIST_KEYS']['href'] method = @links['LIST_KEYS']['method'] request = RestClient::Request.new(:url => url, :method => method, :headers => @@headers) return send(request) end |