Sha256: fb5bd8f52bcb64fbe2da4c3c1c3cb1e6ded763bba7d6a0a953cbc34fe264383d

Contents?: true

Size: 1.25 KB

Versions: 17

Compression:

Stored size: 1.25 KB

Contents

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

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
fog-openstack-0.1.10 lib/fog/openstack/models/identity_v2/users.rb
fog-openstack-0.1.9 lib/fog/openstack/models/identity_v2/users.rb
fog-openstack-0.1.8 lib/fog/openstack/models/identity_v2/users.rb
fog-openstack-0.1.7 lib/fog/openstack/models/identity_v2/users.rb
fog-openstack-0.1.6 lib/fog/openstack/models/identity_v2/users.rb
fog-openstack-0.1.5 lib/fog/openstack/models/identity_v2/users.rb
fog-openstack-0.1.4 lib/fog/openstack/models/identity_v2/users.rb
fog-openstack-0.1.3 lib/fog/openstack/models/identity_v2/users.rb
fog-openstack-0.1.2 lib/fog/openstack/models/identity_v2/users.rb
fog-openstack-0.1.1 lib/fog/openstack/models/identity_v2/users.rb
fog-openstack-0.1.0 lib/fog/openstack/models/identity_v2/users.rb
fog-1.37.0 lib/fog/openstack/models/identity_v2/users.rb
fog-1.36.0 lib/fog/openstack/models/identity_v2/users.rb
fog-1.35.0 lib/fog/openstack/models/identity_v2/users.rb
fog-2.0.0.pre.0 lib/fog/openstack/models/identity_v2/users.rb
fog-1.34.0 lib/fog/openstack/models/identity_v2/users.rb
fog-1.33.0 lib/fog/openstack/models/identity_v2/users.rb