Class: Fog::Identity::OpenStack::V3::Roles

Inherits:
OpenStack::Collection show all
Defined in:
lib/fog/identity/openstack/v3/models/roles.rb

Instance Attribute Summary

Attributes inherited from OpenStack::Collection

#response

Instance Method Summary collapse

Methods inherited from OpenStack::Collection

#get, #load_response, #summary

Instance Method Details

#all(options = {}) ⇒ Object



11
12
13
# File 'lib/fog/identity/openstack/v3/models/roles.rb', line 11

def all(options = {})
  load_response(service.list_roles(options), 'roles')
end

#assignments(options = {}) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/fog/identity/openstack/v3/models/roles.rb', line 15

def assignments(options = {})
  # TODO(lsmola) this method doesn't make much sense, it should be moved to role.rb and automatically add
  # role.id filter. Otherwise it's just duplication.
  Fog::Logger.deprecation("Calling OpenStack[:keystone].roles.assignments(options) method which"\
                          " deprecated, call OpenStack[:keystone].role_assignments.all(options) instead")
  load(service.list_role_assignments(options).body['role_assignments'])
end

#destroy(id) ⇒ Object



32
33
34
35
# File 'lib/fog/identity/openstack/v3/models/roles.rb', line 32

def destroy(id)
  role = find_by_id(id)
  role.destroy
end

#find_by_id(id) ⇒ Object



23
24
25
26
27
28
29
30
# File 'lib/fog/identity/openstack/v3/models/roles.rb', line 23

def find_by_id(id)
  cached_role = find { |role| role.id == id }
  return cached_role if cached_role
  role_hash = service.get_role(id).body['role']
  Fog::Identity::OpenStack::V3.role.new(
    role_hash.merge(:service => service)
  )
end