Class: ChefAPI::Resource::User
- Defined in:
- lib/chef-api/resources/user.rb
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
-
.authenticate(options = {}) ⇒ Hash
Authenticate a user with the given
username
andpassword
. - .each(prefix = {}, &block) ⇒ Object
Methods inherited from Base
#_attributes, #_prefix, all, #attribute?, build, classname, collection, collection_path, connection, count, create, delete, #destroy, destroy, destroy_all, #diff, #dirty?, #errors, exists?, expanded_collection_path, fetch, from_file, from_json, from_url, has_many, #id, #ignore_attribute?, #initialize, inspect, #inspect, list, #new_resource?, post, #primary_key, protect, #protected?, protected_resources, put, #reload!, resource_path, #resource_path, #save, #save!, schema, #to_hash, #to_json, to_s, #to_s, type, update, #update, #update_attribute, #valid?, #validate!, #validators
Constructor Details
This class inherits a constructor from ChefAPI::Resource::Base
Class Method Details
.authenticate(options = {}) ⇒ Hash
Requires Enterprise Chef
Authenticate a user with the given username
and password
.
77 78 79 |
# File 'lib/chef-api/resources/user.rb', line 77 def authenticate( = {}) connection.post('/authenticate_user', .to_json) end |
.each(prefix = {}, &block) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/chef-api/resources/user.rb', line 35 def each(prefix = {}, &block) users = collection(prefix) # HEC/EC returns a slightly different response than OSC/CZ if users.is_a?(Array) users.each do |info| name = URI.escape(info['user']['username']) response = connection.get("/users/#{name}") result = from_json(response, prefix) block.call(result) if block end else users.each do |_, path| response = connection.get(path) result = from_json(response, prefix) block.call(result) if block end end end |