Class: Fog::Identity::OpenStack::Tenant

Inherits:
Model
  • Object
show all
Defined in:
lib/rackspace-fog/openstack/models/identity/tenant.rb

Instance Attribute Summary

Attributes inherited from Model

#collection, #connection

Instance Method Summary collapse

Methods inherited from Model

#initialize, #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

This class inherits a constructor from Fog::Model

Instance Method Details

#createObject



46
47
48
49
50
# File 'lib/rackspace-fog/openstack/models/identity/tenant.rb', line 46

def create
  merge_attributes(
    connection.create_tenant(attributes).body['tenant'])
  self
end

#destroyObject



28
29
30
31
32
# File 'lib/rackspace-fog/openstack/models/identity/tenant.rb', line 28

def destroy
  requires :id
  connection.delete_tenant(self.id)
  true
end

#grant_user_role(user_id, role_id) ⇒ Object



52
53
54
# File 'lib/rackspace-fog/openstack/models/identity/tenant.rb', line 52

def grant_user_role(user_id, role_id)
  connection.add_user_to_tenant(self.id, user_id, role_id)
end

#revoke_user_role(user_id, role_id) ⇒ Object



56
57
58
# File 'lib/rackspace-fog/openstack/models/identity/tenant.rb', line 56

def revoke_user_role(user_id, role_id)
  connection.remove_user_from_tenant(self.id, user_id, role_id)
end

#roles_for(user) ⇒ Object



17
18
19
20
21
# File 'lib/rackspace-fog/openstack/models/identity/tenant.rb', line 17

def roles_for(user)
  connection.roles(
    :tenant => self,
    :user   => user)
end

#saveObject



41
42
43
44
# File 'lib/rackspace-fog/openstack/models/identity/tenant.rb', line 41

def save
  requires :name
  identity ? update : create
end

#to_sObject



13
14
15
# File 'lib/rackspace-fog/openstack/models/identity/tenant.rb', line 13

def to_s
  self.name
end

#update(attr = nil) ⇒ Object



34
35
36
37
38
39
# File 'lib/rackspace-fog/openstack/models/identity/tenant.rb', line 34

def update(attr = nil)
  requires :id
  merge_attributes(
    connection.update_tenant(self.id, attr || attributes).body['tenant'])
  self
end

#usersObject



23
24
25
26
# File 'lib/rackspace-fog/openstack/models/identity/tenant.rb', line 23

def users
  requires :id
  connection.users(:tenant => self)
end