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

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

Instance Attribute Summary

Attributes inherited from Model

#project

Instance Method Summary collapse

Methods inherited from Model

#initialize, #save

Constructor Details

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

Instance Method Details

#createObject



44
45
46
47
48
49
50
# File 'lib/fog/openstack/identity/v2/models/tenant.rb', line 44

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

#destroyObject



30
31
32
33
34
# File 'lib/fog/openstack/identity/v2/models/tenant.rb', line 30

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

#grant_user_role(user_id, role_id) ⇒ Object



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

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

#revoke_user_role(user_id, role_id) ⇒ Object



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

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

#roles_for(user) ⇒ Object



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

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

#to_sObject



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

def to_s
  name
end

#update(attr = nil) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/fog/openstack/identity/v2/models/tenant.rb', line 36

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

#usersObject



25
26
27
28
# File 'lib/fog/openstack/identity/v2/models/tenant.rb', line 25

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