Class: Fog::Identity::OpenStack::Tenant
- Inherits:
-
Model
- Object
- Model
- Fog::Identity::OpenStack::Tenant
show all
- Defined in:
- lib/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
#_load, #aliases, #attribute, #attributes, #identity, #ignore_attributes, #ignored_attributes
#_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
#create ⇒ Object
46
47
48
49
50
|
# File 'lib/fog/openstack/models/identity/tenant.rb', line 46
def create
merge_attributes(
connection.create_tenant(attributes).body['tenant'])
self
end
|
#destroy ⇒ Object
28
29
30
31
32
|
# File 'lib/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/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/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/fog/openstack/models/identity/tenant.rb', line 17
def roles_for(user)
connection.roles(
:tenant => self,
:user => user)
end
|
#save ⇒ Object
41
42
43
44
|
# File 'lib/fog/openstack/models/identity/tenant.rb', line 41
def save
requires :name
identity ? update : create
end
|
#to_s ⇒ Object
13
14
15
|
# File 'lib/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/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
|
#users ⇒ Object
23
24
25
26
|
# File 'lib/fog/openstack/models/identity/tenant.rb', line 23
def users
requires :id
connection.users(:tenant => self)
end
|