class OpenStack::Keystone::Admin::User

An OpenStack User (“admin view”)

Attributes

Public Class Methods

all_by_tenant(tenant) click to toggle source

List of users in a given tenant

Attributes

# File lib/open_stack/keystone/admin/user.rb, line 88
def self.all_by_tenant(tenant)
  tenant_id = tenant.is_a?(OpenStack::Keystone::Admin::Tenant) ? tenant.id : tenant

  all.select { |user| user.tenant_id == tenant_id }
end
find_by_name(name) click to toggle source

List of user with a given name

Attributes

  • name - A string

# File lib/open_stack/keystone/admin/user.rb, line 110
def self.find_by_name(name)
  all.detect { |user| user.name == name }
end
find_by_tenant(id, tenant) click to toggle source

Find a user in a given tenant

Attributes

# File lib/open_stack/keystone/admin/user.rb, line 99
def self.find_by_tenant(id, tenant)
  tenant_id = tenant.is_a?(OpenStack::Keystone::Admin::Tenant) ? tenant.id : tenant

  user = self.find(id)
  user.tenant_id == tenant_id ? user : nil
end

Public Instance Methods

roles(scope = :all, tenant = nil) click to toggle source

File role(s) (i.e. instances of OpenStack::Keystone::Admin::UserRole) for this user in a given tenant

Attributes

# File lib/open_stack/keystone/admin/user.rb, line 132
def roles(scope = :all, tenant = nil)
  tenant_id = tenant.is_a?(OpenStack::Keystone::Admin::Tenant) ? tenant.id : (tenant || self.tenant_id)

  UserRole.find(scope, :params => {:tenant_id => tenant_id, :user_id => self.id})
end
tenant() click to toggle source

The primary (default) tenant (i.e. an instance of OpenStack::Keystone::Admin::Tenant) associated with this user

# File lib/open_stack/keystone/admin/user.rb, line 115
def tenant
  OpenStack::Keystone::Admin::Tenant.find tenant_id
end
tenant=(primary_tenant) click to toggle source

Set the primary (default) tenant associated with this user

Attributes

  • primary_tenant - A valid tenant or a tenant_id

# File lib/open_stack/keystone/admin/user.rb, line 123
def tenant=(primary_tenant)
  self.tenant_id = primary_tenant.is_a?(OpenStack::Keystone::Admin::Tenant) ? primary_tenant.id : primary_tenant
end

Protected Instance Methods

initialize(attributes = {}, persisted = false) click to toggle source
Calls superclass method
# File lib/open_stack/keystone/admin/user.rb, line 54
def initialize(attributes = {}, persisted = false) # :notnew:
  attributes = attributes.with_indifferent_access

  if attributes[:tenant].present?
    attributes[:tenant_id] = attributes.delete(:tenant).id
  end

  if attributes[:tenantId].present?
    attributes[:tenant_id] = attributes.delete(:tenantId)
  end

  super(attributes, persisted)
end