Class: Fog::Identity::OpenStack::User
- Defined in:
- lib/fog/openstack/models/identity/user.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#name ⇒ Object
Returns the value of attribute name.
-
#password ⇒ Object
Returns the value of attribute password.
-
#tenant_id ⇒ Object
Returns the value of attribute tenant_id.
Attributes inherited from Model
Instance Method Summary collapse
- #destroy ⇒ Object
- #ec2_credentials ⇒ Object
-
#initialize(attributes) ⇒ User
constructor
A new instance of User.
- #roles(tenant_id = self.tenant_id) ⇒ Object
- #save ⇒ Object
- #update(options = {}) ⇒ Object
- #update_enabled(enabled) ⇒ Object
- #update_password(password) ⇒ Object
- #update_tenant(tenant) ⇒ Object
Methods inherited from Model
#inspect, #reload, #symbolize_keys, #to_json, #wait_for
Methods included from Attributes::ClassMethods
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
Methods included from Core::DeprecatedConnectionAccessors
#connection, #connection=, #prepare_service_value
Methods included from Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one
Constructor Details
#initialize(attributes) ⇒ User
Returns a new instance of User.
17 18 19 20 21 |
# File 'lib/fog/openstack/models/identity/user.rb', line 17 def initialize(attributes) # Old 'connection' is renamed as service and should be used instead prepare_service_value(attributes) super end |
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
15 16 17 |
# File 'lib/fog/openstack/models/identity/user.rb', line 15 def email @email end |
#enabled ⇒ Object
Returns the value of attribute enabled.
15 16 17 |
# File 'lib/fog/openstack/models/identity/user.rb', line 15 def enabled @enabled end |
#name ⇒ Object
Returns the value of attribute name.
15 16 17 |
# File 'lib/fog/openstack/models/identity/user.rb', line 15 def name @name end |
#password ⇒ Object
Returns the value of attribute password.
15 16 17 |
# File 'lib/fog/openstack/models/identity/user.rb', line 15 def password @password end |
#tenant_id ⇒ Object
Returns the value of attribute tenant_id.
15 16 17 |
# File 'lib/fog/openstack/models/identity/user.rb', line 15 def tenant_id @tenant_id end |
Instance Method Details
#destroy ⇒ Object
57 58 59 60 61 |
# File 'lib/fog/openstack/models/identity/user.rb', line 57 def destroy requires :id service.delete_user(id) true end |
#ec2_credentials ⇒ Object
23 24 25 26 |
# File 'lib/fog/openstack/models/identity/user.rb', line 23 def ec2_credentials requires :id service.ec2_credentials(:user => self) end |
#roles(tenant_id = self.tenant_id) ⇒ Object
63 64 65 |
# File 'lib/fog/openstack/models/identity/user.rb', line 63 def roles(tenant_id = self.tenant_id) service.list_roles_for_user_on_tenant(tenant_id, self.id).body['roles'] end |
#save ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/fog/openstack/models/identity/user.rb', line 28 def save raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if persisted? requires :name, :tenant_id, :password 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
37 38 39 40 41 42 |
# File 'lib/fog/openstack/models/identity/user.rb', line 37 def update( = {}) requires :id .merge('id' => id) response = service.update_user(id, ) true end |
#update_enabled(enabled) ⇒ Object
53 54 55 |
# File 'lib/fog/openstack/models/identity/user.rb', line 53 def update_enabled(enabled) update({:enabled => enabled, 'url' => "/users/#{id}/OS-KSADM/enabled"}) end |
#update_password(password) ⇒ Object
44 45 46 |
# File 'lib/fog/openstack/models/identity/user.rb', line 44 def update_password(password) update({'password' => password, 'url' => "/users/#{id}/OS-KSADM/password"}) end |
#update_tenant(tenant) ⇒ Object
48 49 50 51 |
# File 'lib/fog/openstack/models/identity/user.rb', line 48 def update_tenant(tenant) tenant = tenant.id if tenant.class != String update({:tenantId => tenant, 'url' => "/users/#{id}/OS-KSADM/tenant"}) end |