Class: Fog::Identity::OpenStack::User
- Defined in:
- lib/rackspace-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
-
#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 Attributes::InstanceMethods
#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #requires, #requires_one
Constructor Details
#initialize(attributes) ⇒ User
Returns a new instance of User.
17 18 19 20 |
# File 'lib/rackspace-fog/openstack/models/identity/user.rb', line 17 def initialize(attributes) @connection = attributes[:connection] super end |
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email.
15 16 17 |
# File 'lib/rackspace-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/rackspace-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/rackspace-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/rackspace-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/rackspace-fog/openstack/models/identity/user.rb', line 15 def tenant_id @tenant_id end |
Instance Method Details
#destroy ⇒ Object
51 52 53 54 55 |
# File 'lib/rackspace-fog/openstack/models/identity/user.rb', line 51 def destroy requires :id connection.delete_user(id) true end |
#roles(tenant_id = self.tenant_id) ⇒ Object
57 58 59 |
# File 'lib/rackspace-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 ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/rackspace-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 = {}) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/rackspace-fog/openstack/models/identity/user.rb', line 31 def update( = {}) requires :id .merge('id' => id) response = connection.update_user(id, ) true end |
#update_enabled(enabled) ⇒ Object
47 48 49 |
# File 'lib/rackspace-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) ⇒ Object
38 39 40 |
# File 'lib/rackspace-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) ⇒ Object
42 43 44 45 |
# File 'lib/rackspace-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 |