mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00

Fog::OpenStack::Collection base class for all openstack collections, also replacing load method with load_response method, which stores the whole response on Collection object, in the case that we need other medata e.g. for pagination. Also removing :summary and :find_by_id aliases, since they are defined in base method.
45 lines
1.2 KiB
Ruby
45 lines
1.2 KiB
Ruby
require 'fog/openstack/models/collection'
|
|
require 'fog/openstack/models/identity_v2/user'
|
|
|
|
module Fog
|
|
module Identity
|
|
class OpenStack
|
|
class V2
|
|
class Users < Fog::OpenStack::Collection
|
|
model Fog::Identity::OpenStack::V2::User
|
|
|
|
attribute :tenant_id
|
|
|
|
def all(options = {})
|
|
options[:tenant_id] = tenant_id
|
|
|
|
load_response(service.list_users(options), 'users')
|
|
end
|
|
|
|
def find_by_id(id)
|
|
self.find { |user| user.id == id } ||
|
|
Fog::Identity::OpenStack::V2::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::V2::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
|
|
end # class V2
|
|
end # class OpenStack
|
|
end # module Identity
|
|
end # module Fog
|