Class: Fog::Identity::OpenStack::V3::Users

Inherits:
OpenStack::Collection show all
Defined in:
lib/fog/identity/openstack/v3/models/users.rb

Instance Attribute Summary

Attributes inherited from OpenStack::Collection

#response

Instance Method Summary collapse

Methods inherited from OpenStack::Collection

#get, #load_response, #summary

Instance Method Details

#all(options = {}) ⇒ Object


11
12
13
# File 'lib/fog/identity/openstack/v3/models/users.rb', line 11

def all(options = {})
  load_response(service.list_users(options), 'users')
end

#destroy(id) ⇒ Object


28
29
30
31
# File 'lib/fog/identity/openstack/v3/models/users.rb', line 28

def destroy(id)
  user = find_by_id(id)
  user.destroy
end

#find_by_id(id) ⇒ Object


15
16
17
18
19
20
21
22
# File 'lib/fog/identity/openstack/v3/models/users.rb', line 15

def find_by_id(id)
  cached_user = find { |user| user.id == id }
  return cached_user if cached_user
  user_hash = service.get_user(id).body['user']
  Fog::Identity::OpenStack::V3::User.new(
    user_hash.merge(:service => service)
  )
end

#find_by_name(name, options = {}) ⇒ Object


24
25
26
# File 'lib/fog/identity/openstack/v3/models/users.rb', line 24

def find_by_name(name, options = {})
  load(service.list_users(options.merge(:name => name)).body["users"])
end