Sha256: 1482de055edd0e7d61a359a588c82a5ed29b750c36698d360cf6f6da81a63d21

Contents?: true

Size: 971 Bytes

Versions: 5

Compression:

Stored size: 971 Bytes

Contents

require 'fog/openstack/models/collection'
require 'fog/openstack/models/identity_v3/domain'

module Fog
  module Identity
    class OpenStack
      class V3
        class Users < Fog::OpenStack::Collection
          model Fog::Identity::OpenStack::V3::User

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

          def find_by_id(id)
            cached_user = self.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

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

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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fog-openstack-0.1.10 lib/fog/openstack/models/identity_v3/users.rb
fog-openstack-0.1.9 lib/fog/openstack/models/identity_v3/users.rb
fog-openstack-0.1.8 lib/fog/openstack/models/identity_v3/users.rb
fog-openstack-0.1.7 lib/fog/openstack/models/identity_v3/users.rb
fog-openstack-0.1.6 lib/fog/openstack/models/identity_v3/users.rb