2012-02-22 09:40:32 -05:00
|
|
|
require 'fog/core/collection'
|
|
|
|
require 'fog/openstack/models/identity/user'
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Identity
|
|
|
|
class OpenStack
|
|
|
|
class Users < Fog::Collection
|
|
|
|
model Fog::Identity::OpenStack::User
|
|
|
|
|
2012-11-08 02:02:27 -05:00
|
|
|
attribute :tenant_id
|
2012-04-02 03:26:45 -04:00
|
|
|
|
2012-02-22 09:40:32 -05:00
|
|
|
def all
|
2012-12-22 18:24:36 -05:00
|
|
|
load(service.list_users(tenant_id).body['users'])
|
2012-02-22 09:40:32 -05:00
|
|
|
end
|
2012-03-09 04:28:32 -05:00
|
|
|
|
|
|
|
def find_by_id(id)
|
|
|
|
self.find {|user| user.id == id} ||
|
|
|
|
Fog::Identity::OpenStack::User.new(
|
2012-12-22 18:24:36 -05:00
|
|
|
service.get_user_by_id(id).body['user'].merge(
|
|
|
|
'service' => service
|
2012-09-06 21:37:52 -04:00
|
|
|
)
|
|
|
|
)
|
2012-03-09 04:28:32 -05:00
|
|
|
end
|
|
|
|
|
2014-02-12 06:56:29 -05:00
|
|
|
def find_by_name(name)
|
|
|
|
self.find {|user| user.name == name} ||
|
|
|
|
Fog::Identity::OpenStack::User.new(
|
|
|
|
service.get_user_by_name(name).body['user'].merge(
|
|
|
|
'service' => service
|
|
|
|
)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2012-03-09 04:28:32 -05:00
|
|
|
def destroy(id)
|
|
|
|
user = self.find_by_id(id)
|
|
|
|
user.destroy
|
|
|
|
end
|
2012-02-26 21:43:42 -05:00
|
|
|
end # class Users
|
2012-02-22 09:40:32 -05:00
|
|
|
end # class OpenStack
|
2012-02-26 21:43:42 -05:00
|
|
|
end # module Identity
|
2012-02-22 09:40:32 -05:00
|
|
|
end # module Fog
|