Sha256: e7192804c1fefc9b873fd009050133567f180c277a95b000353eea55dc4f2c9a

Contents?: true

Size: 1.13 KB

Versions: 25

Compression:

Stored size: 1.13 KB

Contents

require 'fog/openstack/models/collection'
require 'fog/identity/openstack/v2/models/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)
            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)
            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 = find_by_id(id)
            user.destroy
          end
        end
      end
    end
  end
end

Version data entries

25 entries across 23 versions & 3 rubygems

Version Path
fog-openstack-0.1.31 lib/fog/identity/openstack/v2/models/users.rb
fog-openstack-0.3.10 lib/fog/identity/openstack/v2/models/users.rb
fog-openstack-0.1.30 lib/fog/identity/openstack/v2/models/users.rb
fog-openstack-0.1.29 lib/fog/identity/openstack/v2/models/users.rb
fog-openstack-0.3.9 lib/fog/identity/openstack/v2/models/users.rb
fog-openstack-0.1.28 lib/fog/identity/openstack/v2/models/users.rb
fog-openstack-0.3.8 lib/fog/identity/openstack/v2/models/users.rb
fog-openstack-0.3.7 lib/fog/identity/openstack/v2/models/users.rb
fog-openstack-0.3.6 lib/fog/identity/openstack/v2/models/users.rb
fog-openstack-0.3.5 lib/fog/identity/openstack/v2/models/users.rb
fog-openstack-0.3.4 lib/fog/identity/openstack/v2/models/users.rb
fog-openstack-0.3.3 lib/fog/identity/openstack/v2/models/users.rb
fog-openstack-0.3.2 lib/fog/identity/openstack/v2/models/users.rb
fog-openstack-0.3.0 lib/fog/identity/openstack/v2/models/users.rb
fog-openstack-0.2.4 lib/fog/identity/openstack/v2/models/users.rb
fog-openstack-0.2.3 lib/fog/identity/openstack/v2/models/users.rb
fog-openstack-0.2.2 lib/fog/identity/openstack/v2/models/users.rb
fog-openstack-0.2.1 lib/fog/identity/openstack/v2/models/users.rb
fog-openstack-0.2.0 lib/fog/identity/openstack/v2/models/users.rb
fog-zj-0.1.28 lib/fog/identity/openstack/v2/models/users.rb