Class: Fog::Identity::OpenStack::V2::User
Instance Attribute Summary collapse
#project
Instance Method Summary
collapse
#create, #initialize
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
16
17
18
|
# File 'lib/fog/identity/openstack/v2/models/user.rb', line 16
def email
@email
end
|
#enabled ⇒ Object
Returns the value of attribute enabled.
16
17
18
|
# File 'lib/fog/identity/openstack/v2/models/user.rb', line 16
def enabled
@enabled
end
|
#name ⇒ Object
Returns the value of attribute name.
16
17
18
|
# File 'lib/fog/identity/openstack/v2/models/user.rb', line 16
def name
@name
end
|
#password ⇒ Object
Returns the value of attribute password.
16
17
18
|
# File 'lib/fog/identity/openstack/v2/models/user.rb', line 16
def password
@password
end
|
#tenant_id ⇒ Object
Returns the value of attribute tenant_id.
16
17
18
|
# File 'lib/fog/identity/openstack/v2/models/user.rb', line 16
def tenant_id
@tenant_id
end
|
Instance Method Details
#destroy ⇒ Object
52
53
54
55
56
|
# File 'lib/fog/identity/openstack/v2/models/user.rb', line 52
def destroy
requires :id
service.delete_user(id)
true
end
|
#ec2_credentials ⇒ Object
18
19
20
21
|
# File 'lib/fog/identity/openstack/v2/models/user.rb', line 18
def ec2_credentials
requires :id
service.ec2_credentials(:user => self)
end
|
#roles(tenant_id = self.tenant_id) ⇒ Object
58
59
60
61
62
63
64
|
# File 'lib/fog/identity/openstack/v2/models/user.rb', line 58
def roles(tenant_id = self.tenant_id)
if tenant_id
service.list_roles_for_user_on_tenant(tenant_id, id).body['roles']
else
[]
end
end
|
#save ⇒ Object
23
24
25
26
27
28
29
30
|
# File 'lib/fog/identity/openstack/v2/models/user.rb', line 23
def save
raise Fog::Errors::Error, 'Resaving an existing object may create a duplicate' if persisted?
requires :name
enabled = true if enabled.nil?
data = service.create_user(name, password, email, tenant_id, enabled)
merge_attributes(data.body['user'])
true
end
|
#update(options = {}) ⇒ Object
32
33
34
35
36
37
|
# File 'lib/fog/identity/openstack/v2/models/user.rb', line 32
def update(options = {})
requires :id
options.merge('id' => id)
service.update_user(id, options)
true
end
|
#update_enabled(enabled) ⇒ Object
48
49
50
|
# File 'lib/fog/identity/openstack/v2/models/user.rb', line 48
def update_enabled(enabled)
update(:enabled => enabled, 'url' => "/users/#{id}/OS-KSADM/enabled")
end
|
#update_password(password) ⇒ Object
39
40
41
|
# File 'lib/fog/identity/openstack/v2/models/user.rb', line 39
def update_password(password)
update('password' => password, 'url' => "/users/#{id}/OS-KSADM/password")
end
|
#update_tenant(tenant) ⇒ Object
43
44
45
46
|
# File 'lib/fog/identity/openstack/v2/models/user.rb', line 43
def update_tenant(tenant)
tenant = tenant.id if tenant.class != String
update(:tenantId => tenant, 'url' => "/users/#{id}/OS-KSADM/tenant")
end
|