class Fog::Identity::OpenStack::User

Attributes

email[RW]
enabled[RW]
name[RW]
password[RW]
tenant_id[RW]

Public Class Methods

new(attributes) click to toggle source
Calls superclass method Fog::Model.new
# File lib/fog/openstack/models/identity/user.rb, line 17
def initialize(attributes)
  @connection = attributes[:connection]
  super
end

Public Instance Methods

destroy() click to toggle source
# File lib/fog/openstack/models/identity/user.rb, line 51
def destroy
  requires :id
  connection.delete_user(id)
  true
end
roles(tenant_id = self.tenant_id) click to toggle source
# File lib/fog/openstack/models/identity/user.rb, line 57
def roles(tenant_id = self.tenant_id)
  connection.list_roles_for_user_on_tenant(tenant_id, self.id).body['roles']
end
save() click to toggle source
# File lib/fog/openstack/models/identity/user.rb, line 22
def save
  raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
  requires :name, :tenant_id, :password
  enabled = true if enabled.nil?
  data = connection.create_user(name, password, email, tenant_id, enabled)
  merge_attributes(data.body['user'])
  true
end
update(options = {}) click to toggle source
# File lib/fog/openstack/models/identity/user.rb, line 31
def update(options = {})
  requires :id
  options.merge('id' => id)
  response = connection.update_user(id, options)
  true
end
update_enabled(enabled) click to toggle source
# File lib/fog/openstack/models/identity/user.rb, line 47
def update_enabled(enabled)
  update({:enabled => enabled, 'url' => "/users/#{id}/OS-KSADM/enabled"})
end
update_password(password) click to toggle source
# File lib/fog/openstack/models/identity/user.rb, line 38
def update_password(password)
  update({'password' => password, 'url' => "/users/#{id}/OS-KSADM/password"})
end
update_tenant(tenant) click to toggle source
# File lib/fog/openstack/models/identity/user.rb, line 42
def update_tenant(tenant)
  tenant = tenant.id if tenant.class != String
  update({:tenantId => tenant, 'url' => "/users/#{id}/OS-KSADM/tenant"})
end