Class: Fog::Identity::OpenStack::Role

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

Instance Attribute Summary

Attributes inherited from Model

#collection, #service

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 Core::DeprecatedConnectionAccessors

#connection, #connection=, #prepare_service_value

Methods included from Attributes::InstanceMethods

#_dump, #attributes, #dup, #identity, #identity=, #merge_attributes, #new_record?, #persisted?, #requires, #requires_one

Constructor Details

This class inherits a constructor from Fog::Model

Instance Method Details

#add_to_user(user, tenant) ⇒ Object



23
24
25
# File 'lib/fog/openstack/models/identity/role.rb', line 23

def add_to_user(user, tenant)
  add_remove_to_user(user, tenant, :add)
end

#destroyObject



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

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

#remove_to_user(user, tenant) ⇒ Object



27
28
29
# File 'lib/fog/openstack/models/identity/role.rb', line 27

def remove_to_user(user, tenant)
  add_remove_to_user(user, tenant, :remove)
end

#saveObject



10
11
12
13
14
15
# File 'lib/fog/openstack/models/identity/role.rb', line 10

def save
  requires :name
  data = service.create_role(name)
  merge_attributes(data.body['role'])
  true
end