1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/openstack/models/identity/users.rb

42 lines
1 KiB
Ruby
Raw Normal View History

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
attribute :tenant_id
2012-02-22 09:40:32 -05:00
def all
load(service.list_users(tenant_id).body['users'])
2012-02-22 09:40:32 -05:00
end
def find_by_id(id)
self.find {|user| user.id == id} ||
Fog::Identity::OpenStack::User.new(
service.get_user_by_id(id).body['user'].merge(
'service' => service
)
)
end
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
def destroy(id)
user = self.find_by_id(id)
user.destroy
end
end # class Users
2012-02-22 09:40:32 -05:00
end # class OpenStack
end # module Identity
2012-02-22 09:40:32 -05:00
end # module Fog