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

Inherits:
OpenStack::Model show all
Defined in:
lib/fog/openstack/models/identity_v2/tenant.rb

Instance Attribute Summary

Attributes inherited from OpenStack::Model

#project

Instance Method Summary collapse

Methods inherited from OpenStack::Model

#initialize, #save

Constructor Details

This class inherits a constructor from Fog::OpenStack::Model

Instance Method Details

#createObject


42
43
44
45
46
47
# File 'lib/fog/openstack/models/identity_v2/tenant.rb', line 42

def create
  requires :name
  merge_attributes(
      service.create_tenant(attributes).body['tenant'])
  self
end

#destroyObject


29
30
31
32
33
# File 'lib/fog/openstack/models/identity_v2/tenant.rb', line 29

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

#grant_user_role(user_id, role_id) ⇒ Object


49
50
51
# File 'lib/fog/openstack/models/identity_v2/tenant.rb', line 49

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

#revoke_user_role(user_id, role_id) ⇒ Object


53
54
55
# File 'lib/fog/openstack/models/identity_v2/tenant.rb', line 53

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

#roles_for(user) ⇒ Object


18
19
20
21
22
# File 'lib/fog/openstack/models/identity_v2/tenant.rb', line 18

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

#to_sObject


14
15
16
# File 'lib/fog/openstack/models/identity_v2/tenant.rb', line 14

def to_s
  self.name
end

#update(attr = nil) ⇒ Object


35
36
37
38
39
40
# File 'lib/fog/openstack/models/identity_v2/tenant.rb', line 35

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

#usersObject


24
25
26
27
# File 'lib/fog/openstack/models/identity_v2/tenant.rb', line 24

def users
  requires :id
  service.users(:tenant_id => self.id)
end